How to do 3D Animation

I’ve been working on a 3D Game engine for a short while now, but this is a question I’ve had for a very long time that relates to any time I am dealing with 3D. I am currently loading all of my game models by using Blender .obj files. However, these files don’t have animation capabilities. So I have a few questions…

First Question:
What file-type should I use for loading models and animations?

Second question is a bit longer:
How do I manage these animations in terms of the game-loop? Since games don’t always run at a constant rate, I need to find a way to loop through animations to ensure that they do happen at a constant rate independent of the FPS. Unfortunately, I’m not entirely sure how to do this. Any ideas?. What have you guys done, or recommend?

Any help if appreciated, thank you so much!

I would recommend the COLLADA format. It is an open-source, xml based format which supports pretty much anything you can think of. Can be a bit of a complex thing to parse but you can ignore most of it so it is OK.

As for consistent rate of animation, you need to use a time step. You calculate the time difference between the last loop and the current loop and use that as a parameter for how far the animation should move on.

If you’re not looking for anything too advanced, you can try the MD2 or even MD3 model formats. They are very simple frame-based animated model formats.

If you’re looking for something more up-to-date it might be worth your time to learn MD5, or some other bone-based animation :slight_smile:

Actually animating with a frame-based animation system is quite easy. If you have an array containing each frame, you could do something like…


int frame;
float frameActual;
Model[] frames;

public void update(float delta) {
    float frameSpeed = 0.3;

    frameActual += frameSpeed * delta;
    frame = (int)frameActual;
}

public void draw() {
    frames[frame].draw(x, y, z);
}

There are 3 ways that I know of:

-Frame animation: Interpolate between different meshes
-CPU skinning: each vertex has a weight that bones influence and is processed on the CPU
-GPU skinning: Same as CPU but on GPU

Heres a great tut:
for CPU: http://3dgep.com/loading-and-animating-md5-models-with-opengl/
for GPU(recommended): http://3dgep.com/gpu-skinning-of-md5-models-in-opengl-and-cg/

Hi

Yet another 3D engine… :expressionless:

Actually, the WaveFront OBJ format can be used for animations even though it isn’t designed for that purpose. For example, you can store all key frames into a single .obj file. The Quake formats (MD2, MD3 and MD5) are designed to support animations but they aren’t well supported by Blender since its version 2.50. The Collada exporter of Blender only exports the first frame :frowning: However, Collada is capable of storing animations. Instead of reinventing the Wheel, take a look at existing importers. JogAmp’s Ardor3D Continuation supports Collada (import only).

Skinning can be used for skeletal animations.

I really advise you to look at how JMonkeyEngine and JogAmp’s Ardor3D Continuation manage the animations, they are open source. quew8 is right, Collada is complicated, don’t start an importer from scratch.