Video gives the illusion of motion by displaying a sequence of still images fast enough to fool the eye.
A movie could be generated from a 3d model by rendering an image, making a small movement in the 3d model, rendering the next image, and so on.
These movements between frames, could be done automatically by making generating the movements from the laws of physics, for example.
In other cases it may be necessary to build up the animation manually, for example, by dragging the position of the objects in a 3d editor. In the case of a complex animation, such as a person walking, this can be difficult, and the animation may need to modified many times. This means that the state of the 3d world (such as the position of all the objects in it) needs to be stored for each frame, or at least, the editor program needs some way of recreating the position of everything for each frame.
The above is a frame capture from mjbWorld (see Users Guide keyframing)
Storing the 3d position of every object in every frame might require a lot of data. However there are ways to cut this down, for example we store the position of everything in the first frame, and then just the changes for subsequent frames. i.e. lift left foot 3 cm, move it forward 10 cm, etc. The position of the leg may not need to be explicitly specified as it could be calculated using IK. However this does mean extra calculations every time the animation is run, to recalculate all the transform matrix values.
To give the illusion of smooth motion probably needs at least 50 to 60 frames per second are needed. This not only requires a lot of data but would be very time consuming to make all these small changes manually in each frame.
On way to reduce the work, would be to generate keyframes less frequently than this, but to allow the program to generate the frames in-between by interpolation. The simplest way to do this is 'linear interpolation'. The positions of objects in an interpolated frame are taken from the keyframes before and after it using a weighting function.
Linear interpolation would cause very rapid changes of velocities. If you want changes of movements to be more gradual and natural looking then B-spline interpolation could be used. Even more complex methods can use quaternions to interpolate between the actual R-matrices.
If values are constrained, for example, if two items are connected by a joint, then the position of the joint needs to be calculated using IK instead of just interpolating its position.
Screenshot from Vistapro, showing a program where you can define a camera path and then generate a video as the camera flies through the scene.
Keyframing in Java3D
There are interpolators built into Java3D. also the Java3D utils package has additional interpolators for SplinePath Interpolation.
To use these classes you need to do the following:
- create a TransformGroup or other node in the scene graph which will be modified
- Create an Alpha object
- Create an Interpolator (which references both the Alpha and target object)
- add scheduling bounds to the interpolator object
- add the interpolator to the scene graph.
However there are some issues with these classes:
- I'm not sure how these classes could be sub-classed to provide IK capability?
- These classes modify the scene graph directly, I want to modify my parallel structure first?
- As well as playing forward, I want to be able to step though frame by frame. Not sure how to subclass Alpha to do this?