Import a 3D animation into an android game

I want to import a skinned and animated character model built with bender into an android game. The animations can be: idle, walk, run …etc

I’ve seen a related question but it’s only about importing a static model: https://stackoverflow.com/questions/204363/is-there-a-way-to-import-a-3d-model-into-android

But I don’t see how to import a set of animation with tweened frames.

Any ideas, resources or tutorials about how this can be achieved ?


Edit:
After some further searching I’ve found this library that claim to provide model loaders for md5 files.
http://code.google.com/p/libgdx/

Edit2 (2011 12 16):
I tested libgdx mentionned above And it actually works well for now, I can render a walking animation from md5 models with a good framerate, but the model loading time is quite long. For a large amount of models and frames, I think switching to binary formats will become necessary.

Answer

You need to look up the file format for your animated mesh and decipher it. So, you’ll need a framework capable of rendering a skinned mesh; you may have to do weighted mesh transformations in software, yourself, unless you’re able to use vertex shaders in your version of OpenGL ES.

Next, you’ll need to be able to load the mesh, the skeleton and the animation. This is probably a binary file format so you’ll need:

  1. The file format(s) in question, showing you the byte offsets of all data members and other relevant information.
  2. You’ll need to load your files, possibly using ‘DataInputStream’ if they’re binary. Make sure the ‘endianness’ of the data matches your system, you may have to swap bytes around if the data has a different order to the platform you’re working on.
  3. Skin your weighted mesh – i.e. either in a vertex shader or on the CPU, go through each vertex and blend the position according to the vertex weights and the matrices that they refer to.
  4. Profit!

I’m not sure how much of that made sense because I don’t know what you don’t know. You could try giving a bit more information such as the file formats for your data and if you’re using a 3rd party 3D engine or writing your own.

HTH.

Attribution
Source : Link , Question Author : BiAiB , Answer Author : Luther

Leave a Comment