Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL animation

If I have a human body 3d model, that I want to animate walking, what is the best way to achieve this? Here are the possible ways I see this being implemented:

  • Create several models with the legs in different positions and then interpolate between these models.
  • Load the model into openGL, and somehow figure which vertices correspond to the legs and perform the appropriate transformations.
  • Implement a skeleton or armature (similar to this: blender animation wiki).
like image 691
14 revs, 12 users 16% Avatar asked Nov 20 '10 09:11

14 revs, 12 users 16%


2 Answers

Technique that you described in the first option is called morph target animation and often used for some detailes of animation like facial animation or maybe opening and closing of hands.

Second option is procedural or physical animation which works something like robotics where you give the body of your character some velocity to move forward and calculate what legs need to do for it to avoid falling. But you wouldn't do it directly on vertices, but on skeleton. See next one.

Third option is skeletal animation which animates skeleton and the vertices follow it by the set of rules. Attaching vertices to skeleton is called skinning.

I suggest that, after getting hang of opengl stuff (viewing and positioning models in space, camera, etc), you start with skeletal animation.

You will need a rigged and animated model for your 3d app of choice. Then you can write an exporter to your custom format or choose a format that you want to read from your app. That file format should contain description of the model, skeleton, skinning and key frames. Than you read and use that data from your code to build the mesh, skeleton and animate over key frames.

like image 179
Bojan Avatar answered Oct 21 '22 01:10

Bojan


If I were you, I'd download Blender from http://www.blender.org and work through some animation tutorials. For example, this one:

http://wiki.blender.org/index.php/Doc:Tutorials/Animation/BSoD/Character_Animation

Having done that, you can then export your model and animations using e.g. the Ogre exporter. I think this is the latest version, but check to make sure:

http://www.ogre3d.org/tikiwiki/Blender+Exporter&structure=Tools

From there, you just need to write the C++ code to load everything in, interpolate between keyframes, etc. I have code I can show you for this if you're interested.

like image 41
Stuart Golodetz Avatar answered Oct 21 '22 00:10

Stuart Golodetz