3
\$\begingroup\$

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.

\$\endgroup\$
2

3 Answers 3

4
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for this answer. I know few on the subject, and I believed there would be some standard formats/way to do it, given all the 3D applications out there. \$\endgroup\$
    – BiAiB
    Commented Mar 27, 2011 at 16:20
  • \$\begingroup\$ There are lots of formats but none of them are (or should) be tied to the android operating system - just as no image formats or document formats should be tied to an operating system. In the end, it's all just bits and bytes and it's up to you to interpret those or to get a library that does that job for you. I use my own proprietary 3d file format that I output from a home grown 3d modelling program - that's a bit of an extreme example of D.I.Y. though. You could probably write a plugin for Blender that would output in whatever format is convenient for you - even as Java code. \$\endgroup\$
    – Luther
    Commented Mar 27, 2011 at 18:14
3
\$\begingroup\$

For converting animated models from Blender to M3G you can use Liquidiser (http://code.google.com/p/liquidiser/). As for reading -- I'm not aware of any publicly available library that would allow you to import .m3g files but I do have a library which can do that.

I wouldn't mind making it public as it does what it's supposed to do (read, process and render models, including tweened animations) but at the moment it's not optimised as I'm still developing the game that uses it and performance hasn't been a priority yet. If you're interested in cooperation please get in touch at max.<my-stackexchange-nick>@gmail.com

\$\endgroup\$
1
  • \$\begingroup\$ I'm currently at a very early stage: for now I'm only gathering information and I expected importation to be a simplier work. I know too few to cooperate I think, but I'll keep that in mind :) \$\endgroup\$
    – BiAiB
    Commented Mar 27, 2011 at 22:02
1
\$\begingroup\$

Just for the record, in case someone else wants to import/play skeletal animation with skinning using Blender:

There is the open source AnimKit that can play skeletal animation straight from a .blend file. It includes some basic samples using OpenGL/glut. THe code is portable, works under Windows, Linux, OSX, and a sample using Android is planned.

http://code.google.com/p/gamekit/downloads/detail?name=animkit_src_r1020.zip And also some info related to this here http://opengles20study.blogspot.com/

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .