Eng 591 - VR Programming - Class Outline 3

General Topics: Lab Exercises regarding position and orientation; Addition of geometry nodes into a scene graph ( continued. )

Homework / Lab Exercises ( Continued / Modified )

  • Make the following modifications to your project program ( bareVR.c or other program(s) as appropriate. ):
    1. Change the clown, snail, and lunchbox to moveable nodes. Set their positions and orientations when they are loaded, so that they are not all located at the same spot. ( Experiment with a variety of methods for doing this. For example, what is the difference between WTnode_translate and WTnode_settranslation? )
    2. Modify the action function so that when the user types either upper or lower case "I" it provides them with useful Information. At this point it should report the user's viewpoint position and orientation. As your project progresses, you will probably want to add additional information items.
    3. Set up a global variable of type WTpq, called InitialView, which will hold the initial user viewpoint position and orientation when the program starts. Modify the action function so that typing either upper or lower case "R" will Reset the view to the initial view. ( This can be done either by initializing InitialView and replacing Wtwindow_zoomviewpoint with code to set the viewpoint to the initial view, or by getting the initial viewpoint coordinates after the call to Wtwindow_zoomviewpoint. )
    4. Change the direction of the directed light.

    Adding Content ( Geometry Nodes ) to a Scene Graph

    Nodes in a scene graph can be categorized into three basic types: Content nodes, state nodes, and procedural nodes. Today's topic is the content category, which consists essentially of geometry nodes. There are three basic methods for adding geometry nodes to a scene graph: load the geometry from a file, build the geometry on the fly, or "instance" (reference) an existing geometry.
    Loading Geometry From a File

    WorldToolKit can load geometry information from files using three primary functions:

    • WTnode_load
    • WTmovnode_load
    • WTgeometrynode_load

    All three take the same type of arguments, read the same types of files, and return the same type of result. All three add a geometry node to the scene graph, ( unless the parent is specified as NULL. )

    The distinction is that WTgeometry node_load always creates a single non-movable geometry node regardless of the data in the file; WTnode_load creates one or more non-movable geometry nodes, depending upon the data in the file, and WTmovnode_load creates a movable node, consisting of a separator node, a transform node, and a geometry node. See pages 6-2 and following for information regarding the file types supported by WorldToolKit, and the limitations thereof.

    Building Geometry on the Fly

    WorldToolKit can build geometry on the fly using two different methods. Note, however, that neither method adds a node to the scene graph. These methods only produce a geometry, which must then be added to the scene graph with WTgeometrynode_new.

    The easiest and most straightforward method is the set of routines for creating standard shapes ( aka predefined geometries ). See pages 6-14 to 6-21 for more information.

    • WTgeometry_newblock
    • WTgeometry_newcylinder
    • WTgeometry_newcone
    • WTgeometry_newsphere
    • WTgeometry_newhemisphere
    • WTgeometry_newrectangle
    • WTgeometry_newtruncone
    • WTgeometry_newextrusion
    • WTgeometry_newtext3d

    The other method for creating geometries on the fly is to create custom geometries, as described on page 6-21 and following. We will not concern ourselves with this method at this time.

    Instancing ( Referencing ) an Existing Movable Node

    There are many cases in which it is desirable to have multiple copies of a single geometry - trees in a forest, books on a bookshelf, wheels on a car. In each of these cases the original geometry may be large and complex, and there is no good reason to store multiple copies in memory. However it is important that each instance of the object have its own transformation information, since the objects must be in different locations. WorldToolKit therefore has a mechanism whereby multiple movable nodes can share pointers to a common geometry. This is arranged using the function

    • WTmovnode_instance

    This function will effectively "copy" a movable node, creating new separator and transform nodes. However instead of creating a copy of the geometry, the new node will contain a link (pointer) to the existing geometry from the original source node.

    Lab Exercises

  • Practice adding geometry to your scene graph, using each of the three methods discussed above.