HW030 3D Hello World – Part 3

The Part 3 appliaction is same doing as Part 2. But this is different structure from Part 2 application to prepare for extending it to Block Buster Application.

The part 3 appliaction have the original scene named “AppMain” for displaying green 3D text “Hello world” in front of blue cube as the main scene of this application. VPGL Application can have arbitrary number of scenes and switching their displaying in VPGL “code” by SETSCN and UPDATE method of 3D class.

STEP 3-1 From scratch

Get the default scratch application, reloading your working browser if needed.

STEP 3-2 Create “AppMain”.

Create “AppMain” scene by copying from “Running” scene as follows.

(1) Choose “Running” scene from SCENE menu. (2) Choose “Copy this scene” from “select op” menu. This operation will prompt inputting copied scene name. Then Input “AppMain”:

(You can also make new scene from scratch by “Add New Scene” op.)

STEP 3-3 Build Up AppMain scene

Rename “TextRun” geometry to “TextHW”. (1) Choose AppMain Scene, choose “TextRun” item, then “Rename this item” from select op.

“Rename this item” prompts inputting new item name. Then input “TextHW”:

Finally, Set its text to “Hello World” and placement X to -175 both same as Part 2 app:

(It is better to save your work now before get ahead to next step.)

STEP 3-4 Redefine Mainline method of App Class

Modify the Mainline method of the App class of this application is as follows:

The option of D2 tile is the string literal “AppMain”. 3D is defined in T class as always providing the instance of 3D Class to output 0. SETSCN(SET SCeNe) method is defined in 3D class. If it has 1 input (like this case), the option in string is a scene name defined in this application, then switch this scene to be displayed after next UPDATE invocation. If SETSCN has 2 input, input1(the second input) shall be a scene name, and option is ignored.SETSCN always passes through the input 0 to output 0.

UPDATE is defined in 3D, its invocation reflects all changes, modifications on the 3D world to UI. In other words, no display change will be on 3D pane until UPDATE invoation.

Thus Mainline code steps (1) Get the instance of 3D class, (2) Set the scene “AppMain” to be displayed on next UPDATE, (3) Reflects chaging scene to display by UPDATE, then (4) release the 3D token by discarding and keep application alive by END.

STEP 3-5 Save your work.

Currently all works you needed is all set. Save your work.

STEP 3-6 Try your application.

If something wrong, chek your work carefully. Especially, Input-output direction in diagram should be checked.

STEP 3-5 Spinning The Back Ground Blue Cube.

The application built in Next Step will spin the Blue cube in AppMain scene. This is the first application you make has motion.