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

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


Lesson 31 - VRML 97--Magical Mystery Tour - Part 3

Here's the next step, and it's an exciting one.

Thus far we've had a world we can navigate using the browser controls, and added some limited "animation" of the Viewpoint by creating a list for selection in the VRML browser. What about really animating the Viewpoint, creating a simple tour of our world?

We can do this by creating a Viewpoint node that we place in a Transform node. Check out the code.

Sure there's a lot here, but it's well worth our attention. An unnamed Viewpoint node, set to 0, 0, 30 starts the file. Thus the browser will first bind to this node, and the viewer will begin from the same front view we've already been using. But we can change this with a click of the mouse.

A second viewpoint named Viewer is set in a Transform named Tour. In effect, the Viewpoint has been turned into a camera that can be transformed in space just like any other object. Translating Tour moves the Viewpoint. Rotating Tour rotates the Viewpoint.

A TouchSensor named StartTour is included in the Transform that contains the magenta cube. Thus clicking on the magenta cube will trigger the sensor. Following the ROUTE statements at the bottom of the code, we find that clicking on that cube will bind the Viewer Viewpoint. This binding triggers the TimeSensor, which in turn starts the animation. The animation contains both a translation and a rotation. The first half of the animation moves the viewer to a position in front of the red cube, but does so without turning. Then the cube stops moving and starts turning toward the center of the space. This animation requires three keys for both the position and rotation interpolators.

Give it a try.

CLICK HERE to view this example if you have a VRML browser. If you don't yet have a VRML browser, hurry up and download the new Cosmo Player for free from Cosmo Software.

In this file, the tour begins when you click and can't be stopped until it's done, when the TimeSensor deactivates. The deactivation of Timer generates a FALSE isActive message that is sent to Viewer to unbind it. Another approach would replace the routing statements as follows:

In this case, the TouchSensor triggers the binding directly, and the binding triggers Timer. This is the opposite of the previous example. But the difference is interesting. A TouchSensor is activated when the user presses down on the mouse button, but is deactivated when the button is released. Thus letting up on the mouse button switches the user back to the original Viewport. This puts the tour under the user's control. If you want to stop, just let up on the button!

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

To Return to Parts 1 and 2, Use Arrow Buttons

Previous Lesson / Table of Contents / Next Lesson

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

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