Jump to content
  • Advertisement
Sign in to follow this  
battergow

OpenGL How to animate a 3ds Max model in my OpenGL program?

This topic is 2435 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, as you see I'm new here and I'm learning OpenGL and 3ds Max. I already know how to load a OBJ file exported by 3ds Max.
Let's say I created a model in 3ds Max, which is a man formed by bones. I load it into my OpenGL program and now I want to animate its face, legs, arms etc. I have no idea how to do such thing, since (not sure about this) the model itself is static. How could I play with only the legs, or face, or a single arm of that model? Please, I need to know the theory behind this.

Share this post


Link to post
Share on other sites
Advertisement
with Wavefront OBJ you can save only static scene (vertices of this scene are absolute, no matrix transformations). You can only to build an animation by saving #n frames in #n .obj files, load them into your application and finally render by frames. Try to use another one (for example, COLLADA or ID SOFTWARE's MD5 (importer/exporter scripts and usage examples are on internet).

also you need a reference to Making Skeletal Animation which would help you in future (tutorial using COLLADA).

Best wishes, FXACE.

Share this post


Link to post
Share on other sites

Hey guys, as you see I'm new here and I'm learning OpenGL and 3ds Max. I already know how to load a OBJ file exported by 3ds Max.
Let's say I created a model in 3ds Max, which is a man formed by bones. I load it into my OpenGL program and now I want to animate its face, legs, arms etc. I have no idea how to do such thing, since (not sure about this) the model itself is static. How could I play with only the legs, or face, or a single arm of that model? Please, I need to know the theory behind this.


First of all, you need to export to a format that supports bones, OBJ doesn't do that.

Normally the way its then done is as follows:

Each vertex is attached to one or more bones and has "weights" for those bones.
Each bone is represented by a matrix(4x4 matrix for rotation and offset or you can use a 3x3 matrix + a 1x3 vector for offset, or a quaternion + offset). (when the bones move the matrices change)

You then translate each vertex based on the weights and the bones matrices. so finalVertexposition = ((originalposition*boneMatrix1)*boneWeight1) + ((originalposition*boneMatrix2)*boneWeight2) etc.

This whole process is best done using the vertex shader (as it lets you store the entire mesh on the GPU and only upload the matrices for the bones each frame) but you can also do it on the CPU by manually translating the vertices before sending the mesh to the GPU (This however eats up alot more CPU resources and requires that you send more data to the GPU each frame)

Share this post


Link to post
Share on other sites
If you export as .3ds, you can load it back in, including bones, with the AssImp library. Although AssImp is really slow reading models in debug mode, so I tend to only use it in the tool chain to transform the model into my own, quick loading format, you can use it when you're developing algorithms to do these things fairly quickly and easily. Anyway once you've done that Simon's explanation about how bones work is a good one. There are tutorials around as well. It's a non-trivial, but tractable engine feature to implement.

Share this post


Link to post
Share on other sites
If you don't need boned animation and you are using the fixed function pipeline in OpenGL, you might want to give the following free and open-source Obj Wavefront model library a try.

http://public.sangui...id=libwavefront

It can read in basic animation files and simply transforms and rotates the parts making up the model (if it has been exported with objects or groups).

I wrote it for my University dissertation and it tends to be good enough for the majority of my projects so it might help you too if you do decide to go with Wavefront Obj.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!