In this exercise you will build an extrusion shape, then animate a ball sliding up the extrusion. Next, for extra credit, you will reverse the direction of the animation so that the ball slides down the extrusion instead of up!
In visualization, shapes and animations are often created by using data generated by programs. This example uses an extrusion path generator program. Your task will be to take the output of this program and build VRML nodes around it to make the extrusion shape and ball animation.
This exercise focuses upon use of Extrusion, TimeSensor, PositionInterpolator, and ScalarInterpolator nodes.
You will need to use this data for subsequent tasks.
Your task is to create an extrusion shape using the cross-section and extrusion spine values output by the extrude program and saved in extrude.dat. You will need to create a Shape, set it's Appearance and Material, then build the Extrusion geometry. In addition to the cross-section and spine for the extrusion, set these fields:
You'll need to read the extrusion data into your VRML file. In vi you can do this by typing, in command mode:
This will read the extrude.dat file contents into your VRML file starting on the line right after the line the cursor is on.
Then go to the end of the cross-section data and add this after it, and before the extrusion spine data:
Then scroll down the page a bit to the end of the spine data and add this:
Then delete the rest of the data in the file and finish the Extrusion node (closing curly-braces).
Your task is to add a ball that slides up the extrusion path. You'll need a TimeSensor node and a PositionInterpolator node. Use the data from the "extrude.dat" file for the key fractional times and key positions for the interpolator.
HINT: To turn the data into a PositionInterpolator node, add this just before the key times:
Add this after the times and before the positions:
And add this to the end of the positions:
HINT: You will need to create a ball shape within a Transform node that you can animate.
HINT: When a TimeSensor node's start time is later than its stop time, the sensor never stops.
HINT: You will need to route the fractional times out of the timer into the interpolator.
HINT: You will need to route the position values from the position interpolator into a Transform node.
Extra credit: The animation from the previous task slides the ball up the slide. Your task is to make it slide down the slide instead! There are at least two ways to do this:
The first method above is easy. Your task is to do the second method: reverse time!
HINT: Use a ScalarInterpolator node. Use two just two key times and values: