format of frame transform matrices in .x files??

Started by
0 comments, last by kovacsp 18 years, 1 month ago
So, I'm writing a directX x file parser that will load into my 3DModel class in c++. The idea is that if I write a parser (w/o using specific dX functions) I will be API independent. Anyways, I loaded in the mesh fine, but I'm having a HUGE amount of trouble trying to skin it... or even display the bones correctly. I'm using the generic "Tiny" model to test all my code. So.. my problem is that I'm not sure what the matrices I'm reading in actually mean. I've read a lot on skinning, but can't figure it out for this specific file format. Do the matrices describe transformations relative to the parent bone? Are they relative to the initial root bone? My code right now looks like this::

void Skeleton::UpdateBone(Gfx::pbone_t parentBone, Gfx::pbone_t currBone, std::vector<VertLine> &lineBuffer) 
{
if (parentBone)
		currBone->localMatrix_ = currBone->refMatrix_ * parentBone->localMatrix_;
	else 
		currBone->localMatrix_ = currBone->refMatrix_;

		
	currBone->finalMatrix_ = currBone->skinMatrix_ * currBone->localMatrix_;

	//Loop through all children and call UpdateBone on the bones
	for (uint32_t i=0; i < currBone->children_.size(); ++i)
		UpdateBone(currBone, currBone->children_, lineBuffer);
}


Line buffer is the array of points to express the bones as lines, but I removed the code for cleanliness Here, refMatrix refers to the reference pose matrix (that I read in from the FrameTransformation template), and skinMatrix refers to the matrix read in from the SkinWeight template. Am I doing something wrong? I feel like I've tried all possible combinations of matrices and it just won't work... I'm created small x files to try contrived examples of bone linking (right angles and stuff) and it works fine... any ideas?
Advertisement
Hi,

check this article. You may find some useful code inside it.

kp
------------------------------------------------------------Neo, the Matrix should be 16-byte aligned for better performance!

This topic is closed to new replies.

Advertisement