Jump to content
  • Advertisement
Sign in to follow this  
jasonhtml

understanding SkinWeights in the .x file format

This topic is 3905 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've been learning the basics of writing a text .x file and so far i've got the hang of most of it except for SkinWeights. this was taken from a .x model and im just using it as an example: SkinWeights { "Joint1"; 1; 1116; 1.000000; 1.000000,0.000000,0.000000,0.000000, 0.000000,1.000000,0.000000,0.000000, 0.000000,0.000000,1.000000,0.000000, -2.038026,-2.592926,0.183448,1.000000;; <- what do these values represent? } i understand that frame transforms have a 4x4 matrix for their rotation, position, ect. but why would the SkinWeights need it?

Share this post


Link to post
Share on other sites
Advertisement
DirectX documentation: http://msdn2.microsoft.com/de-de/library/bb147388(en-us,VS.85).aspx

"The matrix matrixOffset transforms the mesh vertices to the space of the bone. When concatenated to the bone's transform, this provides the world space coordinates of the mesh as affected by the bone."

Share this post


Link to post
Share on other sites
ok, well i dont get what that means exactly... because isn't the world space coordinates of the mesh already set by the Frame's position and it's parent's?

Share this post


Link to post
Share on other sites
The offset matrix transforms from mesh space (in which the vertex data is given) to bone space in bind pose. Bind pose is the pose of the model it was modelled in. If you transform a vertex position by this matrix, you get the vertex position local to the bone. Now imagine you rotate the bone a bit, build the matrix cascade from the present rotation and all parent bones and transform the local vertex position back to mesh-global position. Your vertex would now be slightly moved along with the bone's rotation. And that's what skinning is all about.

My suggestion is: extract that matrix and store it for every bone. Ingame you calculate each bone's transform matrix from present orientation through each parent to the mesh-global space. This is the matrix that transforms a vertex from the present bone space to the mesh space. You take the offset matrix, concatenate the freshly calculated transform matrix to it and you have a matrix that can transform a vertex from default position to the position given by the skeleton.

Share this post


Link to post
Share on other sites
thx... but, i dont really think that answers my question... i just want to know what the SkinWeights matrix is. because all position/rotation/ect data is already accounted for in the FrameTransform, ect.

Share this post


Link to post
Share on other sites
I apologize in advance if some of what I say is inaccurate.

Quote:
i just want to know what the SkinWeights matrix is. because all position/rotation/ect data is already accounted for in the FrameTransform, ect.


Not all of it. The transformation for each bone transforms verties from bone space to character space (and when combined with the world matrix, the vertices will be in world space), but the vertices are not initially in bone space. They are in bind space (or mesh space or object space, whatever term you're more comfortable with). Therefore, we need another transform to transform the vertices from bind space to bone space. The offset transform does just that. After applying this transform, the vertices will be in bone space and the bone transformations will transform them properly.

There's an article here that describes the entire process in detail.

Share this post


Link to post
Share on other sites
ok, i think i understand now...

so, if the bone doesn't already fit directly to the mesh, then i would have to supply an offset to put the vertices in their respective bone space. otherwise, i would just put the negative offset of the bone to put the vertices in the bone space(at 0,0,0 if the bone is already positioned according to the mesh) so, then the only point of having the SkinWeights matrix is so that one set of bones can work with many different meshes without altering the bone set in any way.

correct?

i hope that made sense :/ after reading it, i can tell it might be hard to understand

EDIT: after looking at another .x file for reference, i figured it out. i was only partially right.

"i would just put the negative offset of the bone to put the vertices in the bone space(at 0,0,0 if the bone is already positioned according to the mesh)"

should be:

i would just put the negative offset of the bone AND ITS PARENTS to put the vertices in the bone space(at 0,0,0 if the bone is already positioned according to the mesh)


so, thank you for the help and the article!

[Edited by - jasonhtml on January 16, 2008 7:53:28 PM]

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!