In this exercise you will build a ball shape, then animate its position to cause the shape to bounce up and down, as if under the effect of gravity. Next, you will expand on the exercise and add nodes to sense the viewer's touch and start and stop the animation.
In visualization, animations are often based upon data computed by simulation applications. This example uses a simple gravity simulation program to generate a series of 3D positions. Your task will be to incorporate these positions into your animation to cause a shape to bounce.
This exercise focuses upon use of TimeSensor, PositionInterpolator, and TouchSensor nodes.
You will need to use this data for subsequent tasks.
SOLUTION: gravity.dat
Your task is to make ball and ground shapes, then make the ball bounce up and down forever. You'll need a TimeSensor node and a PositionInterpolator node. Use the data from the "gravity.dat" file for the key fractional times and key positions for the interpolator.
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.
SOLUTION: gravity1.wrl
The animation from task 1 runs forever. Your task is to modify gravity2.wrl to make the ball bounce just once each time the ball is touched. You'll need a TouchSensor node.
HINT: The start time of a TimeSensor node can be set by another node.
SOLUTION: gravity2.wrl
The animation from task 2 bounces the ball once, then stops. Your task is to modify gravity3.wrl to make the ball start bouncing when the viewer touches a button, and stop bouncing when the viewer touches another button.
HINT: The stop time of a TimeSensor node can be set by another node.
SOLUTION: gravity3.wrl
Extra credit: The previous tasks enabled you to make the ball bounce forever, just once, or between a starting and stopping time. Another common animation need is to cause an animation to play back for a specific number of cycles, then stop. Your task is to modify gravity4.wrl to make the ball bounce exactly twice each time the viewer touches the start button. Pressing the stop button stops the animation prematurely.
HINT: A TimeSensor node can be enabled and disabled using output from another node.
HINT: A TimeSensor node outputs TRUE when the sensor becomes active, and FALSE when it's done.
SOLUTION: gravity4.wrl