13

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).
Kromster
  • 7,181
  • 7
  • 63
  • 111
Martin Konecny
  • 57,827
  • 19
  • 139
  • 159
  • Generally the imported model contains the animation. Why do you need to animate it in OpenGL? Shouldn't this be handled by an artist? – Daniel Rodriguez Nov 20 '10 at 09:16
  • @Seth, I'm doing this as a personal project. So if the model contains the animation, I just need to interpolate between the different key frames it gives me? – Martin Konecny Nov 20 '10 at 09:23
  • Yes, exactly. There are a lot of resources about this. http://gpwiki.org/index.php/OpenGL:Tutorials:Basic_Bones_System – Daniel Rodriguez Nov 27 '10 at 02:24

2 Answers2

14

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.

Bojan
  • 736
  • 8
  • 18
  • +1 for good post. Personally, I'd recommend .3DS files as the animation keyframes, skeletal data and model is contained within one file. – Bojangles Nov 20 '10 at 12:41
2

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.

Stuart Golodetz
  • 20,238
  • 4
  • 51
  • 80
  • I should add that it required a bit of care and fiddling to get everything to work when I did it, but it can be done :) – Stuart Golodetz Nov 20 '10 at 12:47
  • thanks, I had already gone through the tutorial you mention, I will take a look into the ogre exporter. – Martin Konecny Nov 21 '10 at 00:44
  • @tom_mai78101: See https://github.com/sgolodetz/hesperus2/blob/master/source/engine/core/hesp/io/files/ModelFiles.cpp and https://github.com/sgolodetz/hesperus2/tree/master/source/engine/core/hesp/models - hope it helps. – Stuart Golodetz Jan 28 '14 at 13:20