3D Animation Workshop: Lesson 31: VRML 97--Magical Mystery Tour | WebReference

# 3D Animation Workshop: Lesson 31: VRML 97--Magical Mystery Tour

## Lesson 31 - VRML 97--Magical Mystery Tour - Part 1

A VRML world is a space. Among Albert Einstein's most brilliant insights was the notion that space without matter is meaningless, and may be said not to even exist. This ends up being true of VRML worlds in the most evident way. The entire sense of 3D space conveyed by navigation in a VRML world is attributable to the placement of virtual objects at locations in coordinate space. The viewer's perception that this a navigable navigable is due to the organized placement of objects, creating a coherent sense of distance relationships. A coherent space is fun and inviting to the user, and navigating it with a VRML browser is exciting and pleasurable.

The following is about the simplest coherent space imaginable. Cubes of different colors are arranged at poles around a central white sphere. The sphere is located at the center of world space, being at the center of the Transform node that holds all the objects. A yellow and a blue cube are 10 meters above and below it. A green and red cube are ten meters to the right and left. A magenta cube is ten meters in front of center and a cyan cube is 10 meters behind.

See if you can read the following code.

#VRML V2.0 utf8 Viewpoint { position 0, 0, 30 } DEF World Transform { Â Â translation 0 0 0 Â Â childrenÂ Â [ Â Â Â Â DEF Center Transform { Â Â Â Â Â Â translation 0 0 0 Â Â Â Â Â Â childrenÂ Â [ Â Â Â Â Â Â Â Â ShapeÂ Â { Â Â Â Â Â Â Â Â Â Â geometry Sphere {} Â Â Â Â Â Â Â Â Â Â appearance Appearance { Â Â Â Â Â Â Â Â Â Â Â Â material Material { diffuseColor 1 1 1 } Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â } Â Â Â Â Â Â ] Â Â Â Â }# end of Center transform--white Â Â Â Â DEF Right Transform { Â Â Â Â Â Â translation 10 0 0 Â Â Â Â Â Â childrenÂ Â [ Â Â Â Â Â Â Â Â ShapeÂ Â { Â Â Â Â Â Â Â Â Â Â geometry Box {} Â Â Â Â Â Â Â Â Â Â appearance Appearance { Â Â Â Â Â Â Â Â Â Â Â Â material Material { diffuseColor 0 1 0 } Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â } Â Â Â Â Â Â ] Â Â Â Â }# end of Right transform--green Â Â Â Â DEF Left Transform { Â Â Â Â Â Â translation -10 0 0 Â Â Â Â Â Â childrenÂ Â [ Â Â Â Â Â Â Â Â ShapeÂ Â { Â Â Â Â Â Â Â Â Â Â geometry Box {} Â Â Â Â Â Â Â Â Â Â appearance Appearance { Â Â Â Â Â Â Â Â Â Â Â Â material Material { diffuseColor 1 0 0 } Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â } Â Â Â Â Â Â ] Â Â Â Â }# end of Left transform--red Â Â Â Â DEF Front Transform { Â Â Â Â Â Â translation 0 0 10 Â Â Â Â Â Â childrenÂ Â [ Â Â Â Â Â Â Â Â ShapeÂ Â { Â Â Â Â Â Â Â Â Â Â geometry Box {} Â Â Â Â Â Â Â Â Â Â appearance Appearance { Â Â Â Â Â Â Â Â Â Â Â Â material Material { diffuseColor 1 0 1 } Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â } Â Â Â Â Â Â ] Â Â Â Â }# end of Front transform--magenta Â Â Â Â DEF Back Transform { Â Â Â Â Â Â translation 0 0 -10 Â Â Â Â Â Â childrenÂ Â [ Â Â Â Â Â Â Â Â ShapeÂ Â { Â Â Â Â Â Â Â Â Â Â geometry Box {} Â Â Â Â Â Â Â Â Â Â appearance Appearance { Â Â Â Â Â Â Â Â Â Â Â Â material Material { diffuseColor 0 1 1 } Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â } Â Â Â Â Â Â ] Â Â Â Â }# end of Back transform--cyan Â Â Â Â DEF Top Transform { Â Â Â Â Â Â translation 0 10 0 Â Â Â Â Â Â childrenÂ Â [ Â Â Â Â Â Â Â Â ShapeÂ Â { Â Â Â Â Â Â Â Â Â Â geometry Box {} Â Â Â Â Â Â Â Â Â Â appearance Appearance { Â Â Â Â Â Â Â Â Â Â Â Â material Material { diffuseColor 1 1 0 } Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â } Â Â Â Â Â Â ] Â Â Â Â }# end of Top transform--yellow Â Â Â Â DEF Bottom Transform { Â Â Â Â Â Â translation 0 -10 0 Â Â Â Â Â Â childrenÂ Â [ Â Â Â Â Â Â Â Â ShapeÂ Â { Â Â Â Â Â Â Â Â Â Â geometry Box {} Â Â Â Â Â Â Â Â Â Â appearance Appearance { Â Â Â Â Â Â Â Â Â Â Â Â material Material { diffuseColor 0 0 1 } Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â } Â Â Â Â Â Â ] Â Â Â Â }# end of Bottom transform--blue Â Â ] }# end of World Transform

This code has one element we haven't seen before. The Viewpoint node contains information about the viewer's location and orientation in the scene. The concept of a viewpoint is pretty much the same as that of a camera in a 3D rendering application, but the word "viewpoint" is suggestive and appropriate. The viewer of a VRML world is virtually "in" the world, not merely observing it. It's this very sense of immersion that makes VRML attractive and exciting. If the author fails to create a Viewpoint, one is created by the browser at the default location of 0, 0, 10, and facing directly toward the origin. Thus a default Viewpoint is ten meters in front of the origin.

This won't work for our scene because we have an object (the magenta cube) at 0, 0, 10. To see the whole scene we have to move back another 20 meters to 0, 0, 30. Thirty meters in front is far enough out to frame the entire world. Adding a Viewpoint node allows us to override the default values.

CLICK HERE to view example if you have a VRML browser.

Well, this view isn't very interesting! In fact, there's so clue at all that it's even three-dimensional. No one would be very likely to begin exploring a such flat, dead image. What can we do about this?

 To Continue to Parts 2 and 3, Use Arrow Buttons

Created: January 5, 1998
Revised: January 5, 1998

URL: http://webreference.com/3d/lesson31/