05: complex models

more geometry nodes

PointSet{} : pixel-sized points [»]
IndexedLineSet{} : pixel-thin lines [»]
IndexedFaceSet{} : polygon(s) [»]
ElevationGrid{} : a special IndexedFaceSet for height fields, essentially a patch [»]
Extrusion{}: high-level definition of a spine-based shape loft [»]
Text {} : polygonal rendering of installed fonts [»]

indexed face sets in more detail

whenever you need more control over the form of a shape than you can get from basic primitives, it's time for an IndexedFaceset (IFS). Kind of like a 3d connect-the-dots, you specify a series of points in space, and tell the vrml browser how you want them connected into polygons. Implicit in the order of connections is the polygon normal, which defines the inside and outside faces of the polygons.

polygons

a polygon is at least three points and the planar region the contain. Normals are lines that run perpendicular to the face of a polygon. Normals are very important to lighting calculations, but are also fairly easy for the vrml browser to compute. The vrml browser is happy to do this, so there is no need to spend file size declaring normals, unless you want to define unusual normals for a surface.

defining a polygon

supply a Coordinate{} node for the coord field of the IFS, and specify vertices in its point field. Define polygon face loops in the coordIndex field of the IFS, referring by index numbers to the vertices in the Coordinate node. Close the loop with a -1.

example:
IndexedFaceSet {
   coord Coordinate {
      point [
         -1.73 -1 0 # index 0
          1.73 -1 0 # index 1
          0     2 0 # index 2
      ]
   }
   coordIndex [ 0 1 2 -1 ]
}
coordIndex

if you want the surface normal of the poly to point towards you, then define the vertices in counter-clockwise order (remember the right hand rule). Some modelers specify their polygon vertices in the opposite order; the ccw flag allows you to flip the normals for an entire IFS. Using the default ccw TRUE saves the browser some effort by delivering vertices in the expected order.

single-sided polys

using the default solid TRUE lets browser take a short cut and only render one side of the poly. Viewed from the back, the poly is invisible.
example : walls you wouldn't normally walk through [»]

smooth shading

use the creaseAngle field of geometry nodes to control the 'facetedness' of the geometry. It doesn't change the geometry, just the threshold for making sharp distinctions between faces. The vrml browser compares the normals of two adjacent faces, and if the angle between them is less than the value specified for creaseAngle, then they are shaded together in a continuous tone. Otherwise, there is a shading change at the edge between them. Crease angles are specified in radians.
example : two different creaseAngle values [»]

vertex coloring

via the color field, you can specify per face or per vertex colors without using a texture map.
example : coloring an IFS [»]

elevation grids

because terrain is a common element in virtual environments, vrml provides an IFS optimized for terrain. Elevation grids are simple to define— just specify xDimension x zDimension height values:
ElevationGrid {
   xDimension 5
   zDimension 6
   height [
      .0 .2 .4 .2 .0
      .0 .2 .4 .2 .1
      .1 .4 .5 .2 .2
      .2 .3 .5 .3 .1
      .1 .2 .3 .1 .0
      .0 .1 .2 .1 .0 ]
}
For complex terrain, sometimes it's easier to draw a height field as an image and convert it to an elevation grid. [»]

extrusions

extrusions are lightweight, but not used a lot since modelers are generally easier to use and more robust, and give control over texture coordinates.

text

Text{} : the copy itself
FontStyle{} : the formatting characteristics
the Text node is useful for adding dynamic text to the scene. However, text is rendered as polygons rather than to the image buffer. The downside is that it impacts your poly count and frame rate, the upside is that you can texture, transform and animate text just like any other geometry. Fonts are not embedded in the vrml file, so in order to display text in a specific face, it must be installed on the user's machine.

more examples

task03 [»]