|
Keyframe animation
Most animation systems are based on a technique called keyframe animation, which was developed by the likes of Walt Disney when animation was a young art form. A master animator would draw the important images (the keyframes) and a junior animator would draw the images that fill the gaps between the key images. Transform groups in a scene graph can be rotated, positioned, and scaled (as discussed earlier in the course) and we use this ability to animate the scene graph. For each keyframe, we store the values of the transform group's position, orientation, or (sometimes and) scale properties. Each keyframe occurs at a user-defined time after the animation starts, so, using a technique called interpolation, the computer can calculate the in-between transformation values required so that the transformation group (and it's children) can be moved smoothly between keyframes. VRML97's built-in interpolators perform linear interpolation, which interpolates between two values in a linear fashion (ie following a straight line). Using Scripts and PROTOtypes, you can create your own interpolators that implement other methods of calculating the in-between values. Alternatives to simple linear interpolation include Bezier, B-spine, and cardinal curves which can give smooth interpolation with fewer keyframes than linear intepolation. Also, interpolators do not necessarily need to create in-between values between two keyframes at a linear speed. Sometimes it is desirable for the speed to vary, accelerating or decelerating towards a keyframe, for example. In VRML97, animation is controlled by a time sensor, which routes fraction times to an interpolator, which uses those times to calculate an interpolated value, which is then routed to a transform mode. To start an animation by clicking on an object, a time sensor can be activated by routing the touch time from a touch sensor (in the same group as the object) to the time sensor. The key of a VRML interpolator is a fraction value between 0 and 1, and for each key there is a key value. The time that the interpolator takes to interpolate between 0 and 1 is the cycle time of the time sensor. VRML Example where a box rotates using three key rotation values, taking five seconds to complete a rotation. Note that the time sensor is enabled and loops, so it does not need to be started 'manually' and repeats the animation sequence 'forever': #VRML V2.0 utf8 Group { children [ DEF GreenBox Transform { children [ Shape { appearance Appearance { material Material { diffuseColor 0.0 1.0 0.0 } } geometry Box { size 2.0 2.0 2.0 } } ] } DEF Clock TimeSensor { enabled TRUE cycleInterval 5.0 loop TRUE }, DEF Path OrientationInterpolator { key [ 0.0 0.5 1.0 ] keyValue [ 0.0 1.0 1.0 0.0, 0.0 1.0 1.0 3.14, 0.0 1.0 1.0 6.28 ] } ] } ROUTE Clock.fraction_changed TO Path.set_fraction ROUTE Path.value_changed TO GreenBox.set_rotation VRML97 has the following built-in interpolators, that can be used to animate different properties of transform groups or shapes (geometry and appearance) using keyframe animation:
There is also a simple ScalarInterpolator that simply interpolates between float values. As mentioned above, additional interpolators can easily be implemented using a Script, which accept fraction times as events in and uses user-defined keys and key values as input to a function that outputs a value (event out) for the fraction time that comes in. See, for example, the helical and sine-wave interpolator examples in chapter 30 of the VRML 2.0 Sourcbook. |
Michael Louka, December 15,
2000 |