Jump to content
  • Advertisement
Sign in to follow this  
Pilpel

Skeletal animation in Assimp

This topic is 1336 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

I'm trying to learn how to do skeletal animation in Assimp and, as many people told me already, it's pretty harsh.

Until now I didn't really care about the order of the nodes and the respect to each node's parent. I just queried each node's mesh(es) and uploaded the required data (vertices, uvs, normals) to the GPU.

The result was looking good. I could even display models (that could also contain animations) in their bind pose without errors.

 

So, after attempting to learn skeletal animation I have a two questions:

1. Each node has a Matrix4x4 mTransformation member and I don't know why. Is it supposed to transform the vertices of the related meshes? Until now I didn't care about this data member at all.

2. Is there a good book that covers this subject widely? The (many) online tutorials I found are hard for me to understand.

Share this post


Link to post
Share on other sites
Advertisement

From the assimp docs: "mTransformation: The transformation relative to the node's parent."

 

The nodes (bones, frames, pick-a-name) form a hierarchy. The mTransformation is used to transform from the node's parent's space to the node's space in bind pose.

 

This article may give you a start in understanding skinned meshes (assuming that's where you're heading) and skeletal animation. In that article, the mTransformation you're asking about is called a "local transform."

 

From your description, it appears you're using only the transform for the node that "owns" a mesh. That's equivalent to using a world matrix to render a triangle. Skeletal animation of a skinned mesh is a whole new ballgame. That involves all the other nodes (without meshes) which represent the bones which will deform the mesh during animation.

 

You may want to look at Frank Luna's books Introduction to 3D Game Programming (he has one for DirectX 9 and one for DirectX 11). Also, Carl Granberg's Character Animation with Direct3D. I'm sure others will post their favorite books for various APIs (you don't mention what you're using for rendering.)

 

If you're not fully comfortable with matrices, and transformations from one space to another, you'll also need to spend some time brushing up on the concepts.

Share this post


Link to post
Share on other sites

From your description, it appears you're using only the transform for the node that "owns" a mesh.

What do you mean? I don't use the mTransformation matrix at all. How come I could display 3d models correctly until now if I haven't used it?

 

I render with OpenGL, btw.

Share this post


Link to post
Share on other sites

I could even display models (that could also contain animations) in their bind pose

 

 


What do you mean? I don't use the mTransformation matrix at all. How come I could display 3d models correctly until now if I haven't used it?

 

You said yourself the models appear in "bind pose." If you're not using the local matrix for rendering the mesh then it's not in bind pose, unless the local transform happens to be an identity matrix. If the local transform for the mesh is an identity matrix, that's a result of the modeling technique, not your rendering application. In future, you may work with models for which the local matrices are not identity, and/or for which the local matrix must be multiplied by a to-root matrix to appear as expected. Rendering the mesh vertices without transformation may result in something that looks close to what you expect, but you're not displaying it "correctly" with regard to your programming routines.

Edited by Buckeye

Share this post


Link to post
Share on other sites

I found this tutorial useful :

 

http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html

 

It shows how to render a skinned mesh from Assimp, using OpenGL.

 

Hope it helps smile.png

Didn't find that tutorial useful because its code relies on a system that was built in previous tutorials. The explanations weren't so good either. (that's just my reflection)

 

 


I could even display models (that could also contain animations) in their bind pose

 

 


What do you mean? I don't use the mTransformation matrix at all. How come I could display 3d models correctly until now if I haven't used it?

 

You said yourself the models appear in "bind pose." If you're not using the local matrix for rendering the mesh then it's not in bind pose, unless the local transform happens to be an identity matrix. If the local transform for the mesh is an identity matrix, that's a result of the modeling technique, not your rendering application. In future, you may work with models for which the local matrices are not identity, and/or for which the local matrix must be multiplied by a to-root matrix to appear as expected. Rendering the mesh vertices without transformation may result in something that looks close to what you expect, but you're not displaying it "correctly" with regard to your programming routines.

That's weird. I did manage to render the next (pretty complex) 3d model without caring about mTransformation.

Untitled.png

 

Anyway, I'm currently reading the tutorial you posted. I'll come back here if I have any questions.

Share this post


Link to post
Share on other sites

If you're rendering a model without worrying about the bone transformations, then you're not rendering an animated model. You're rendering a static model. That barbarian guy up there with his arms out in a T shape? Yeah, he's in his rest pose. That is how he was likely modeled from the start. If you want to render him as he picks up his axe and lops off a head, you're going to have to start worrying about those bone transformations because that's how it's done.

Share this post


Link to post
Share on other sites

If you want to render him as he picks up his axe and lops off a head, you're going to have to start worrying about those bone transformations because that's how it's done.

I thought they were "node transformations" and not "bone transformation"..?

Also, as Buckeye stated:

Rendering the mesh vertices without transformation may result in something that looks close to what you expect, but you're not displaying it "correctly" with regard to your programming routines.

It seems that even without worrying about animations, not using the mTransformation data member produces incorrect (?) results, and I was just lucky that it displays the model correctly?

Edited by Pilpel

Share this post


Link to post
Share on other sites

I thought they were "node transformations" and not "bone transformation"..?

 

 

The nodes (bones, frames, pick-a-name) ...

 

 

Also, from the article linked above:
 

What's a Bone? The term "frame" is used because it refers to a mathematical "frame of reference," or an orientation (SRT) with respect to (for instance) the world. The term "bone" is frequently used instead of "frame" because the concept can be used to simulate how a bone would cause the skin around it to move.

 

Add "node" to the list of synonyms. Assimp uses the term node.

 

 

I was just lucky that it displays the model correctly?


Yes. On the left - meshes without proper transforms. On the right - with proper transforms.

 

[attachment=26753:without-with.png]

Edited by Buckeye

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!