Loading keyframes and animations from 3DS files?

Hi,

So I’ve made a 3DS model loader from the various tutorials on the web, and it seems to work well. It can handle texturing and materials and all, so I’m pretty happy, but how can I support keyframes and animations done in 3DS MAX?

Right now I’m loading each independently moving part of my object from separate 3DS files, and drawing them using glTranslate and glRotate in between subsequent object calls. This works fine, but I would like to be able to animate different parts of the object from the same file. So even if I don’t load keyframes, I want to be able to render different objects separately from the same file.

I know gametutorials.com has a keyframe tutorial, but it must be purchased. Has anyone else done this before, or are there any good places to start? The 3DS file format spec is fairly cryptic…

Thanks.

lib3ds ( http://sourceforge.net/projects/lib3ds/ ) extracts IMO all you can squeeze out of a 3ds file.

Just a small question while we’re talking about file formats: Why does everyone feel such a strong urge to develop his (or her) own 3ds, obj and tga loader? Is it a sign for the lack of knowledge where to get good loaders, a sign for the poor quality of the available loaders or the pure fun of programming a file loader?

Well, truth be told, 90% of the loader that I use is the one from gametutorials.com. I took out some stuff that I didn’t need, and rewrote the drawing routine, but I didn’t touch most of the loader code.

I did have an issue with a memory leak in it, but I patched that up.

So to answer your question, I think it is all three

Thanks!

Originally posted by stefan:
Just a small question while we’re talking about file formats: Why does everyone feel such a strong urge to develop his (or her) own 3ds, obj and tga loader? Is it a sign for the lack of knowledge where to get good loaders, a sign for the poor quality of the available loaders or the pure fun of programming a file loader?

I wrote my 3ds loader when there was no public 3ds loader available, a few years ago (at the great time of the software demoscene). So that was a bit of the 3 anwsers you gave : none available & fun

To anwser the original post:
First find a doc about how to read the object matrices, the animation hierarchy, the keyframes etc…
Then (from memory, I don’t have my code under my eyes), at the loading time:

  • back transform your vertices by the proper object matrice (one inversed translation + one transposed rotation matrix multiplication).
  • sub the object pivot from all your vertices

Then while rendering recursively (following the animation hierarchy) :

  • interpolate the rotation quaternion, and the scaling/translation vectors
  • do your classic glmatrix computation
  • render

www.wotsit.org has some great descriptions of the 3ds-format.
in the file of Jochen Wilhelmy (aka Digisnap/Haujobb) you find an explanation of spline-animation out of 3ds-files. should help you a lot

Greetings, bastian