matrix manipulation. oh this is bad.

Started by
0 comments, last by frob 14 years, 5 months ago
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
		}

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.

This topic is closed to new replies.

Advertisement