Jump to content
  • Advertisement
Sign in to follow this  
Bru

Unity matrix manipulation. oh this is bad.

This topic is 3253 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 there. for skeletal animation from a X file in my game i used this tutorial : http://www.gamedev.net/community/forums/post.asp?forum_id=11&gforum_id=0&method=post for most of the time i didnt use skinning so i removed it's code and everything worked fine. my matrix manipulation looked like Animation matrix * World matrix. now i got a new X model that does use skinning so i added back the skinning code only to discover my animation manipulation turned into Skinning matrix * Animation matrix * World matrix *. this made it so the character didnt go to the direction it was suppoused to(also rotated wrong too). so i changed it to : skinning matrix * animation matrix * world matrix. this fixed the character going to the wrong direction,but now it seems that when i rotate the character,instead of rotating around itself it rotates around a point in object space(this point is where the character is suppoused to stand). i've been debugging this for a while and cant seem to solve it. i dont think it's the world matrix that is wrong since i didnt change it and it was fine before i added skinning... anyway,this part is where i do the manipulation:
// Create the bone matrices that transform each bone from bone space into character space
		// (via exFrameCombinedMatrixPointer) and also wraps the mesh around the bones using the bone offsets
		// in exBoneOffsetsArray
		for (unsigned int i = 0; i < Bones; ++i)
		{
			D3DXMatrixMultiply(&boneMatrices,&pMesh->exBoneOffsets, pMesh->exFrameCombinedMatrixPointer);//skinning matrix * animation matrix
			D3DXMatrixMultiply(&boneMatrices,&boneMatrices,matWorld);//(skinning matrix*animation matrix)*world matrix
		}

Share this post


Link to post
Share on other sites
Advertisement
If something "rotated wrong" or "didnt go to the direction it was suppoused to" or is "going to the wrong direction", the problem is that you don't understand it well enough to fix it.

If you did understand the math involved, you would be able to look at each step and verify that each matrix and vector is correct. Once you understand the math, it is easy to identify and fix these bugs since you can just follow the data all the way through the pipe.

The machine is doing exactly what you told it to do. The real "bug" is that you don't understand what you are doing.

I suggest that you get comfortable with some books that cover the math. Work through the books until you can do all the math on paper.

Until you can do the math yourself, you cannot explain the math to your computer in code.

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!