Gravity simulation
Exercise


Description


VRML Concepts

Files

Tasks


  1. Create and edit a new file in "gravity1.wrl":

    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.

    SOLUTION: gravity1.wrl


  2. Make a copy of the "gravity1.wrl" world:

    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.

    SOLUTION: gravity2.wrl


  3. Make a copy of the "gravity2.wrl" world:

    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.

    SOLUTION: gravity3.wrl


  4. Make a copy of the "gravity3.wrl" world:

    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.

    SOLUTION: gravity4.wrl