A quick question in animation using openGL

Alright… I converted a model into raw numbers (heh… its all layed out correctly… in fact I can display the model just fine), containing all of the information on it (colors, textures, vertex locations…etc).

The real question is, wouldn’t an animation of a model say… containing 100 frames or so… use a LOT of lines? I mean, the single frame of my model takes up 600 lines by itself. However, I am new to C++ and OpenGL/GLUT programming, and maybe 600 lines isnt a lot.

Eh anyways, not to get off track, if I develope my own file format for the model file, and store all of the model/animation info in there, would I be able to call that file from another program?

EX: I have my model file… we will call it ‘model.wth’… In this file, I have a separate display list for each animation “phase.” (ie Idle, walk, jump, etc). In the ‘other program,’ would I be able to reference model.wth and call a display list from it just as if it had been in the ‘other program’ source?

Or should I try to think of a more efficiente way of animating it in OpenGL?

there are a few basic ways to do character animation…

Going from the easiest to impliment up to the best looking…

No1. Swap The Models

load up each frame of each animation cycle and swap the models each time you get to the next keyframe. The problem with this is that it is inefficient to store 100+ copies of the same data in different locations. It will also give very jerky animation (only swapping models…)

If you think about it though (presuming you dont use display lists for animating objects - YOU SHOULDN’T BE!!!) the only thing that changes between poses is the vertex and normal data. For each keyframe, load up only vertices and normals, You can then simply replace the data in your model with these positions…

No2. Shape interpolation (blendshaping or morphing )

Load up one copy of the texturing coords, colours, and face info. Calculate the vertices and normals by blending between those held in the various animation frames.

ie, to move from frame 1 to frame 2, for each x,y,&z coord of each normal & vertex, perform the following calculation

VertexFinal.x = (1-t)Frame1.x + tFrame2.x
VertexFinal.y = (1-t)Frame1.y + tFrame2.y
VertexFinal.z = (1-t)Frame1.z + tFrame2.z

where t is a time value that varies from 0 to 1. You’d have to work out a relative time value between each frame.

Basically the effect will be morphing between keyframes, it does however still require a hell of a lot of memory, and at certain points the model may go out of shape and look wrong.

No3. Hierarchy of geometry

set up a hierarchy and transform solid geometry by the rotations of the parent geometry, think Quake 2 and older 3D games.

With this, you need only store the geometry once , a bunch of rotation values and the hierarchy itself . There are no unwanted ‘odd’ deforming effects, and memory requirements are low. It is also very fast.

No4. Skinned animation

Create a skeleton, load a mesh, load some vertex weights and set up a skinned animation model.

The visual quality of this is very high, the mesh appears to deform realistically, and the processing is a little bit faster than method No2.

This is not however, the easiest thing to impliment because you need to load a mesh, load up all the joint weighting, and then sort out all the processing that deforms each vertex.

Your best bet is No3, moving on to 4 in my opinion…

[This message has been edited by Rob The Bloke (edited 03-22-2001).]