HW050 3D Spin Cube – part 2

At this step, we will spin the background cube . This application is implemented by modifying the result of previous step. This page introduces the periodic timer geometry in secnes to add motions in 3D applications.

Following is the result of this step. Try “RUN”. You can see spinning cube at the background of the green “HELLO WOLRD” text. Break button stops this application. The difference of 0040 application is the spinning axis is the vartical, not tilted.

STEP 1. Loading previous application.

Load the result of Page 0040 thru LOAD/SAVE tab.

STEP 2. Add New Scene of a blue cube to be spinned.

Selecting “GEO EDITOR” tab on the top of VPGL UI displays 3D Geometry Editor, then “Add New Scene” menu from “Select Ops”

Choosing “Add New Scene” displays a modal dialog to specify the name of the new scene. We will name it to “SpinCube”, then touch OK button.

Now the new Scene “SpinCube” is created which has a 45 dgrees tilted blue cube. This is the just same cube as previous application to be spinned. Therefore no more modification of this scene is needed.

STEP 3 Import SpinCube scene into AppMain scene.

Now we will change the BlueBox item to Import geometry of SpinCube. To do this, In GEO EDITOR, (1) Choose “AppMain” scene, (2) Choose “BlueBox” item, then (3) Change TYPE from Box to Import, (4) finally, choose Import item menu to “SpinCube”, and rotx=roty=rotz=0.

This diagram set application so that the ‘OnTick’ method to this application (the instance of App class) is invoked when ‘OnTick’ event (timer ticks) from Tact in the AppMain scene.

It can be change the increment value of x, y, z independently. The new method DEG+ on Number class keep the value in range [0..2*PI] or [-2*PI..0]. You must add the method DEG+ on Number class as follows. You can also add new methods on the system defined class such as Number by NEW METHOD button with the dispalying the class to be added.

STEP 4 Try Application

Try “RUN” button. You’ve got a success if you can see the same result as the example at the top of this page.

You can try some modification of how to spin by changing optoins of 3 “DEG+”es OnTick method.

STEP 5 Go to Part 3

Currently stopping this application is “aborting” by press Break bottun.

Next Step intoduces 2D UI button to terminate normally.