Eng 591 - VR Programming - Class Outline 4

General Topics: "State" Nodes - Lights, Fog, Transforms, Separators

State Nodes

State nodes do not contain any "content" in the form of geometrical objects. Rather they affect the "state" of the scene as WTK traverses the scene graph. Note carefully that state nodes only affect the nodes that WTK traverses after having traversed the state node, and that state nodes are generally cumulative. The two most obvious and prominent types of state nodes are lighting nodes and fog nodes. Others include transform nodes and separator nodes ( including transform separators. )

Lighting Nodes

This discussion is limited to scene graph construction, and how to attach lights to the scene graph. A full discussion of lighting issues is reserved for later in the course.

Lighting nodes are normally placed on the scene graph first, because they only light objects that are placed after them. However you could place them on the scene graph later, if you only want to light part of the scene. ( You could also use a separator to restrict light to a portion of a scene. )

The following WTK function calls place lights on the scene graph. They are listed in order from simplest ( fastest to calculate ) to more complex ( much slower to calculate. ) The more complex lights you add to a scene, the slower your simulation will run.

WTlightnode_newambient creates a new ambient light. Ambient light is general "background" illumination that lights all surfaces equally. By default all simulations have an ambient light present with white color and 40% intensity. The default light is inaccessible, but ambient lights are exceptional in that they are not cumulative - any new ambient light replaces the existing ambient light. Note that ambient light alone will not yield any three-dimensionality to objects, since all polygons are equally lighted.

WTlightnode_newdirected creates a new directed light. Directed light is like sunlight, that comes from a particular direction at an infinite distance, such that all light rays are parallel. This is the simplest light source that will generate three-dimensionality.

WTlightnode_newpoint creates a new point light. A point light emanates from a particular point in space, with a "direction" that changes depending upon the relative location of the light and the object being lit. Point lights attenuate ( fade ) with increasing distance from the source.

WTlightnode_newspot creates a new spot light. A spot light is like a point light, except the rays are restricted to a cone, such as a flashlight or automobile headlight.

WTlightnode_load loads lighting information from a file.

Fog Nodes

Fog nodes are normally used to increase a sense of depth, by causing objects that are farther away to fade away. Objects can fade to black, fade to white, or fade to any other color one chooses. Adjustable parameters for fog nodes include the nearest location at which an object begins to fade, the farthest point at which an object is completely faded away, and whether the attenuation is linear, exponential, or exponentially squared. The following WTK functions pertain to fog nodes:
  • WTfognode_new
  • WTfognode_setcolor, WTfognode_getcolor
  • WTfognode_setrange, WTfognode_getrange
  • WTfognode_setmode, WTfognode_getmode
  • WTfognode_setlinearstart, WTfognode_getlinearstart

Transform Nodes

Transform nodes contain positional and rotational transformation information, stored as a 4 x 4 matrix, ( the upper left 3 x 3 of which is a rotational matrix, and the last column of which contains the positional transformation. WTK normally ignores any scaling information that may be present. )

Transform nodes are created automatically when a movable node is created, or they can be created and added to the scene graph manually. Note that transformation normally propagates cumulatively to all nodes that follow it in the scene graph traversal, unless that propogation is blocked by a separator node. The following WTK functions pertain to transform nodes:

  • WTxformnode_new
  • WTnode_settranslation, WTnode_gettranslation
  • WTnode_setorientation, WTnode_getorientation
  • WTnode_setrotation, WTnode_getrotation
  • WTnode_settransform, WTnode_gettransform
  • WTnode_translate
  • WTnode_rotation
  • WTnode_rotateq, WTnode_rotatem3, Wtnode_rotatem4
  • WTnode_axisrotation

Note that some of the above functions cause incremental changes, and others determine an absolute position or orientation. Functions dealing with "rotations" use 3 x 3 matrices, and those dealing with "orientations" use quaternions.

Separator Nodes

Separator nodes prevent state information ( lights, transformations, fog, etc. ) from propagating from the separator node's children up to nodes higher up the scene graph. Separator nodes are created automatically when movable nodes are created, or they can be created manually using WTsepnode_new.

Transform Separator Nodes

Transform separators are similar to regular separators, except that only transformation information is blocked. Other state information ( light, fog ) are allowed to propogate up the scene graph. The classic example of the use of a transform separator is when placing a movable light - It is desired to let the light propogate up the tree, but not the transformation that places the light in a particular spot. Transform separators are created using WTxformsep_new.