Subscribe to VRMLSite -- Free
V-Realm  3D Browser,  Builder,  Server Read the Fun
Stuff Yet?

Using Live3D's SpinGroup Node

by Dennis McKenzie

Although the VRML 1.0 specification offers no means of animating virtual worlds, Netscape's VRML browser, considered by many to be the fastest and best available for the PC and Mac, has come up with a solution to the static nature of VRML1.0 by adding the SpinGroup extension to the Live3D plugin.

SpinGroup is a grouping node recognized by Live3D and a few other browsers that allows world builders to add movement to their virtual worlds with only slight modifications to the VRML 1.0 language. SpinGroup works in one of two ways; an object can be spun around either its own and/or its parent's center or around the origin point of the world.



The Syntax
 SpinGroup {
        rotation 0 0 1  0   # SFRotation
        local    TRUE       # SFBool
        --place nodes defining the object here--
    }
The first line takes the place of the grouping node
  Separator {
that is used in static VRML. As it is always a good idea to name your objects with DEF, the line should usually look like this:
  DEF objectname SpinGroup {
Line 2 defines the axis the object will rotate about and the speed it will rotate at. It is possible to make the object rotate around more than one axis at a time.

Some possible combinations are:
  rotation 0 1 0  .1
example 1 (these examples will appear in new windows)
which would rotate the object around the y axis.

Or
   rotation 1 1 1  .1
example 2
which would rotate the object around all three axes.

Another variation would-be:
   rotation .5 1  0  .1 
example 3
which would rotate the object around the x axis at half the speed it rotates around the y axis.

Line 3 defines whether the object will rotate around the world origin or its own or its parent's center. The value of the field can be either TRUE or FALSE.

The value:
   local FALSE
would cause the object to circle around the origin point ( 0 0 0 ) of the world. This is called spinning globally.

The value:
   local TRUE
causes the object to rotate around its bounding box's center, or locally.

It is important to remember that the object does not rotate around it's origin point. (More on this later.) If the object's center and the origin point of the world are the same, there will be no difference in the effect of using a TRUE or FALSE value.

After these three lines, the object's material, translation, geometry, etc. are specified in the normal manner and a curly bracket } is included at the end of the object description to close the SpinGroup node, just as it was with the Separator node.

All in all, SpinGroup is a simple, easy to use node that adds movement to a static VRML world and requires only a bit of hand-scripting. Used with node nesting, it can be a powerful tool to add realism to a world.


A step by step example

Here is a step by step example that can be used to add life to a world that would otherwise be static:

The static world:
  DEF point1 Separator {
     Cube { }
  }
example 4
Pretty boring!

Let's add some movement:
  DEF point1 SpinGroup {
     rotation 0 1 0  .1
     local    TRUE
        Cube { }
  }
example 5
Well, it's something anyway. Not very interesting after a few seconds, though.

Now a nested node. We'll add another cube, move it out from the center, and rotate it around a different axis.
 DEF point1 SpinGroup {
     rotation 0 1 0  .1
     local    TRUE
        Cube { }
    DEF point2 SpinGroup {
       rotation 1 0 0  .1
       local    TRUE
       Translation { translation 20 0 0 }
          Cube { }
     }
  }
example 6
Note how the curly bracket that would have closed the first SpinGroup has been moved behind the second group. This "nests" the second node, making the first one its parent. It inherits the spin from its parent, as well as using its own. Also, note how the cubes circle around each other in the world rather than the second around the first as might be expected. That is because their geometry is shared, and SpinGroup takes the central point between them as it's center of rotation.

Let's add another nested node and move the viewpoint out so everything can be seen. The third node will inherit the spins of both of its parents. Note that it inherits the translations also.
  DEF point1 SpinGroup {
     rotation 0 1 0  .5
     local    TRUE
        Cube { }
    DEF point2 SpinGroup {
       rotation 0 1 0  .5
       local    TRUE
       Translation { translation 3 0 0 }
          Cube { }
      DEF point3 Separator {
         rotation 0 0 1  .5
         local    TRUE
         Translation { translation 0 2 0 }
            Cube { }
        }
     }
  }
example 7
Things are starting to move.

And finally, lets add some life to it by adding a pool of water and some simple scenery:
  DEF point1 SpinGroup {
     rotation 0 1 0  .5
     local    TRUE
        Cube { }
    DEF point2 SpinGroup {
       rotation 0 1 0  .5
       local    TRUE
       Translation { translation 3 0 0 }
          Cube { }
      DEF fish Separator {
         rotation 0 1 0  .5
         local    TRUE
         Translation { translation 0 2 0 }
            fish { descriptive geometry }
      }
    }
  }
  DEF scenery Separator {
     scenery { descriptive geometry  }
  }
example 8

Live3D's SpinGroup can make your worlds come alive with just a little hand editing. However, there is one important thing to take into consideration:

Center of Rotation

The choice of which point the object rotates about can make a huge difference in how a world looks and operates, especially in complex nested figures, so let's spin a few other objects to see how it works.

example 9

The following example shows three cylinders (not predefined VRML cylinder nodes) that are spinning around the x axis. Cylinder 1 is built with its base setting on the 0 point of the y axis. Cylinder 2 is built with its center at the 0 point of the y axis. Cylinder 3 is the same as cylinder 1, but has a FALSE value for the local field. Copy the code for these three cylinders and change the value of the local field( TRUE or FALSE), and translations for each. You will be surprised by some of the results!
example 10

Here is a figure of a simple robot arm using the SpinGroup node and nested objects.
example 11
Whoops! There is something wrong here. Remember that each nested node inherits the geometry of its parent(s) to determine SpinGroup's center of rotation.

Several techniques can be used to correct this.
example 12
The initial cylinder is simply spun around the world's origin, that is, globally ( local FALSE ). The second cylinder is nested in a "counterweight" that is spun locally. A counterweight or pivot can be made fully transparent so the viewer of the world doesn't know it exists. The third cylinder really consists of three nested objects. A pivot point that is spun globally, a counterweight that is spun locally, and the actual cylinder.

Have fun adding movement and life to your worlds with Live3D's SpinGroup. With a little imagination, experimentation, and this extension to VRML1.0 all sorts of things are possible!!

Happy Building!


Related URLs


Dennis McKenzie is a VR and VRML enthusiast who does the popular Proteinman's Top Ten site for Aereal, and has done such interesting worlds as Above and Below and Proteinman's Playground. He is currently actively building worlds with VRML2.0 and says
"Now is when the REAL fun starts".


#VRML V2.0 utf8 | WorldInfo | ViewPoint | Shape
NavigationInfo | Java Chat | Subscribe | Tell Friends

© 1996 Aereal, Inc. Please send suggestions to suggest@vrmlsite.com.