Sign in to follow this  
skow

OpenGL Advise on animating a model

Recommended Posts

I have been doing plenty of OpenGL for years now, and there has always been one thing I have avoided, animation (with in GL). So now that ends, but currently I am at a point where I need a little advice. I’m looking to export from 3d studio max and import into my game. For my attempt of loading I’m using the free animated model found at http://www.3drt.com/downloads.htm. As I see it I have a few options: • Getting each of the “frames” as their own set of vertices and normals, then interpolating between each frame (which I would do in the vertex shader). • Attempt to animate the model using the method max is. The problem as I see with the first method is the memory the model would take up. For example a model with 3k verts and 60 frames (assuming about a 3 frame per second interval) would take 6 * 3000 * 60 * 4 = 4.3 mb. This size would double if I added tangent and bittangets, seems a little high. The nice thing is if I interpolate in the pixel shader I can draw this via vertex arrays. The second possibility leaves me a little confused. It appears the model is broken down into bip (?) components of head, pelvis, spine, etc. These components each have an array of ‘transform time’, ‘transform 4x4 matrices’. Is this for bone animation? My animation knowledge really is lacking. Which is the direction you would recommend going? Any reading/site you may suggest? I have basically been googleing around with no clear direction.

Share this post


Link to post
Share on other sites
If you want to animate a character you surely should use bones.

Given a model and a set of bones you first transform the bones into 4x4 matrices. To create the proper hierarchy you multiply each bone by it's parents inverse matrices. Then calculate the position of the vertices relative to the bones (by applying the matrix's inverse to the vertices). Usually each vertex is assined to one bone (one matrix).
Then, for each frame, you determine the current time of the animation. If the time e.g. is 3.4 you will have to create a new set of matrices by using 0.4 of animation-frame 4 and (1-0.4) of frame 3. You then apply this set to the vertices and you will get an animation with interpolation.

I think there are better ways to implement this, quaternions should do better interpolation, and maybe are faster, but this is the way I did it some time ago.
Unfortunatly it does not seem that I used any docs for this, so there is nothing I can recommend.

The other thing you mentioned, storing vertex positions for every frame, might be an option where bones cannot be used. It could be usefull for facial animation, as it would need far to many bones to animate it. Also Vertex Keys (?) give you more freedom in designing your model. I didn't program this, so I cannot recommend any sides for this either.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this