Building Virtual Worlds

Moshell - Fall 98

Lecture 5B: VRML Timers, Interpolators and SOURCE CODE

Today we're moving through Chapter 5 of the CPC Tutorial. Lecture. These notes extend Lecture 5. These queries were not provided far enough in advance of class time to be homework assignments, but they are very important ones for quiz preparation!

Let's begin by considering the following code, which is VRML source for the example you construct in Chapter 5 of the Tutorial. You can get this code (or something very similar to it) by simply opening the world which you build, using your favorite word processor. VRML files are just text files, after all.


#VRML V2.0 utf8 

# 
# This file was generated by Community Place Conductor Version 2.0 Preview Release 1a 
# Date : Wed Sep 09 03:58:51 1998
# Moshell - CAP4021 - 9 Sept. 98 - Query 5.5+ Stage 1

WorldInfo {}

NavigationInfo {
  type [
    "WALK",
    "EXAMINE"
  ]
}
# Obviously these things with pound signs are comments.
Transform {
  translation 0 1.6 -1.43051e-005 # Numbers like these are nearly-zeroes.
  rotation 0 1 0 0                # They constantly emerge from mouse operations
  children [
    DEF TimeSensor_00 TimeSensor {
      loop TRUE
      cycleInterval 3
    }
    DEF Transform_00 Transform {
      translation 0.0349399 -0.0597043 0             # Some more nearly-zeroes
      rotation 0.770597 0.437147 -0.463771 1.65083   # A wonky rotation axis
      children [                                    # Query: What's the angle
        Shape {                                     # in degrees?
          geometry Cone {}
          appearance Appearance {
            material Material {}
          }
        }
      ]
    }
  ]
}

DEF PositionInterp_00 PositionInterpolator {
  keyValue [
    -1.53325 1.46658 0,    # Or, we might say, -1.5 1.5 0,
    1.3777 -1.36659 0      #                     1.5 -1.5 0
  ]
  key [
    0, 0.99                # Or, we might say 0.0, 1.0
  ]
}

DEF OrientationInterp_00 OrientationInterpolator {
  keyValue [
    0.997805 -0.0130391 -0.0649269 1.18812, # Or, 1 0 0 1.2
    0.521574 0.605935 -0.600669 2.25967     # Or, nothing particularly neat
  ]
  key [
    0, 0.99
  ]
}

ROUTE TimeSensor_00.fraction_changed TO PositionInterp_00.set_fraction
ROUTE PositionInterp_00.value_changed TO Transform_00.translation
ROUTE TimeSensor_00.fraction_changed TO OrientationInterp_00.set_fraction
ROUTE OrientationInterp_00.value_changed TO Transform_00.rotation


In the above example you can see many of the elements of VRML in action. We've previously seen them through the eyes of a tool-user (the tool is of course Community Place Conductor.) Now we see them through programmer's eyes.

Query 5.5: There are a couple of things here that weren't mentioned in the CPC user interface. Explain the meaning of DEF, and of 'children'.

Query 5.6: We see that some of the events flowing through our network (represented by the ROUTE commands, and visualized with the ROUTE window) have values which are simple scalars. (Name one such instance.) Others have values which are vectors of 3 floating numbers (name one such instance.)

Look at the ROUTE window. Highlight the route that is called

"PositionInterp_00.value_changed TO Transform_00.translation"

Off to the right appears the expression "SFVec3f". What does it mean? What other expressions are attached to the various routes, and what do they mean?

Query 5.7: Modify the above source code, using your text editor, so that there are now THREE keyframes. The third keyframe is at time value 0.5, and is located in the upper right corner of the screen.

Save the file. Use Windows Explorer to change its extension back to .wrl (MS Word will force a .txt extension, and maybe other tools will too.) Now use CPC to open this file again, and run the interpolation.

VRML Specifications

Along about now, you're wondering when I'm going to reveal to you the location of the actual specifications for this wierd VRML 2.0 we've been talking about. www.vrml.org is  the place to go. In the upper right corner of that page is a link to VRML97's specification.

Using this specification, CPC and your own curiosity, you can now do pretty much anything with the VRML language. For instance, you can even go do Lab 1!

I recommend working through the rest of the CPC Tutorial, to get concepts such as PROTO in Chapter 6. Without PROTO you would have a great deal of redundant code in your VRML, as you replicated substructures all over the place. PROTO is a kind of "geometry subroutine".

Back to the course index
Back to the course syllabus
Back to the previous lecture
Onward to the next lecture