Eng 591 - VR Programming - Class Outline 13

General Topics: Geometries ( WTK chapter 6 )

Today's Demo: ColrCube.c

Distinction Between Geometries and Geometry Nodes

There are two quantities in WTK that seem very similar, and can easily be confused.

A geometry node is a data structure that can be attached to a scene graph, and which normally contains a geometry ( or more likely a pointer to a geometry. )

A geometry is a collection of geometrical information about vertex locations, polygons, materials, surface normals, etc. It cannot be attached to a scene graph without being contained within a geometry node.

Methods of Accessing or Creating Geometries

The following functions can be useful for getting access to pre-existing geometries, or for creating new original geometries.
  • WTnode_getgeometry returns a pointer to the geometry contained within a geometry node.
     
  • WTgeometry_newcylinder - Self evident.
  • WTgeometry_newblock
  • WTgeometry_newcone
  • WTgeometry_newsphere
  • WTgeometry_newrectangle
  • WTgeometry_newtruncone
  • WTgeometry_newextrusion
  • WTgeometry_newtext3d
     
  • WTgeometry_copy
  • WTgeometry_merge
     
  • WTgeometry_begin - This set of calls is used to create a geometry vertex by vertex. This is most effective if there is suitable code to calculate the vertex positions, but the data can also be entered manually for small geometries. ( See the buildMarker function in the looploop demo program. )
  • WTgeometry_newvertex
  • WTgeometry_beginpoly
  • WTgeometry_close - Ends the geometry building process begun with WTgeometry_begin.
  • WTgeometry_closesmooth - Similar to WTgeometry_close, except that vertex normals are automatically calculated to generate a smooth surface.

Accessing and Modifying Geometry Properties

The following functions are useful for querying and changing geometry properties.

Note: There is an important distinction between translating a geometry and translating a geometry node. The former modifies all the vertex coordinates of the geometry data, and saves the new positions in RAM. The latter only updates the transform matrix associated with the movable node, and then this transformation is employed each time the geometry is rendered. ( A transform node can also conceivably affect more than one type of node, but only those that follow it in the rendering sequence and are not protected by separator nodes. Modifying a geometry will affect any other instances of that geometry. )

  • WTgeometry_getmidpoint
  • WTgeometry_getradius
  • WTgeometry_getextents - Gets the X, Y, and Z extents of the orthogonal bounding box that circumscribes the geometry.
  • WTgeometry_getname, WTgeometry_setname
     
  • WTgeometry_scale - stretches the geometry by a uniform amount in all directions.
  • WTgeometry_stretch - stretches the geometry by different amounts in each direction.
  • WTgeometry_translate - Modifies the geometry, changing the X, Y, and Z coordinates of every vertex in the geometry.
  • WTgeometry_transform- As above, modifying orientations as well as translations.
  • WTgeometry_setrgb
  • WTgeometry_getmtable, WTgeometry_setmtable
  • WTgeometry_setmatid
  • WTgeometry_setrenderingstyle, WTgeometry_getrenderingstyle - Determines whether a geometry is wire-frame, smooth shaded, texture-lit, etc.

Accessing and Modifying Geometry's Vertices ( and Polygons )

See Today's Demo, ColrCube.c, for examples of these functions.
  • WTgeometry_getvertices
  • WTvertex_next
     
  • WTgeometry_beginedit
    • WTgeometry_recomputestats
    • WTgeometry_getvertexposition, WTgeometry_setvertexposition
    • WTgeometry_getvertexnormal, WTgeometry_setvertexnormal
    • WTgeometry_computevertexnormal
    • WTgeometry_getvertexrgb, WTgeometry_setvertexrgb
    • WTgeometry_getvertexmatid, WTgeometry_setvertexmatid
  • WTgeometry_endedit
     
  • WTgeometry_getpolys
  • WTgeometry_numpolys
  • WTgeometry_id2poly
  • ( Polygon modification is covered in the next handout. )

Miscellaneous Geometry Functions

  • WTgeometry_delete
  • WTgeometry_save
  • WTgeometry_prebuild
  • WTgeometry_deleteprebuild
  • WTgeometry_prebuildreflectmap