3D Animation Workshop: Lesson 29: VRML 97--On the Move | WebReference

3D Animation Workshop: Lesson 29: VRML 97--On the Move

Lesson 29 - VRML 97--On the Move - Part 2

A timing device is so inherent in displaying animation that we rarely even think of it. The speed of a film projector or a video tape player must be reliable and clock-like. Rendered digital animation displayed on a computer screen (such as .avi files) is controlled by the microprocessor's internal clock. However, in VRML, we do not have an existing sequence of rendered images for display. The VRML browser must create the rendered sequence on the fly, using the information in the VRML file and the tools provided by the browser itself. Thus we must first create a clock to run the animation.

A clock is created by adding a TimeSensor node to the file. The basic decisions to be made when creating a TimeSensor are the length of cycleInterval (the value in the cycleInterval field of the node) and whether the cycle will loop, or simply stop after completing a cycle. The default values of these fields create a one-second cycle without looping. If we wish to create a ten-second cycle, with looping, the node must be written as:

TimeSensor {
   cycleInterval 10
   loop  TRUE

This timer will begin to run when the file is read, and requires no user interaction to start. But what is it doing? Thus far it is only defining a time cycle, without any resulting animation. The next step, therefore, is to animate some object using the timer.

You may remember from the previous lesson how even a single geometric object (like a sphere or box) was contained in a Transform node to permit that object to be positioned and oriented in the scene. If these transformation values can be changed over time (under the control of a reliable clock), we can animate the associated geometric object. To understand how they can be changed, we must be introduced to a major new VRML concept.

Thus far we have been treating VRML nodes as static blocks of code containing values (and sometimes even other nodes). The values must necessarily be of defined data types. For example, a diffuseColor field can only understand a color value. A distance or angular rotation value wouldn't make any sense to define a color. VRML 2 permits transactions between nodes, or more specifically, between the fields of different nodes that have the same data type. This transaction is called "routing," but is actually no more than copying a value from a field in one node to a corresponding field in another node. Thus one node can change as another does, and we can begin to imagine how the changing state of a clock (a TimeSensor node) could trigger periodic changes in other nodes to create animation.

Even the simplest animation requires two steps in VRML, and to understand this is to go right to the center of the problem. The TimeSensor changes its current time value. That value is then copied (routed) to an interpolator node. The job of the interpolator node is to determine the consequence of the change in time. The change in time produces a change in value in the controlling field of the interpolator node. That value is then copied (routed) to a corresponding value in the object to be animated. These ideas are undoubtedly subtle, so let's put them right into practice.

To Continue to Part 3, or Return to Part 1, Use Arrow Buttons

Created: December 8, 1997
Revised: December 8, 1997

URL: http://webreference.com/3d/lesson29/part2.html