3D Theory - Keyframe animation

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.

Keyframes

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.

Keyframe interpolation

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.

Timeline

 

Flythroughs

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:

  1. create a TransformGroup or other node in the scene graph which will be modified
  2. Create an Alpha object
  3. Create an Interpolator (which references both the Alpha and target object)
  4. add scheduling bounds to the interpolator object
  5. add the interpolator to the scene graph.

However there are some issues with these classes:

see:

 

 


metadata block
see also:

Cubic curves - mjbWorld Users Guide keyframing

Correspondence about this page Open Forum Discussion

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover If you are interested in 3D games, this looks like a good book to have on the shelf. If, like me, you want to have know the theory and how it is derived then there is a lot for you here. Including - Graphics pipeline, scenegraph, picking, collision detection, bezier curves, surfaces, key frame animation, level of detail, terrain, quadtrees & octtrees, special effects, numerical methods. Includes CDROM with code.

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

 

cover Dark Basic Professional Edition - It is better to get this professional edition

cover This is a version of basic designed for building games, for example to rotate a cube you might do the following:
make object cube 1,100
for x=1 to 360
rotate object 1,x,x,0
next x

cover Game Programming with Darkbasic - book for above software

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2017 Martin John Baker - All rights reserved - privacy policy.