Problems with Bone Matrices

Started by
3 comments, last by IgnisDeus 18 years, 7 months ago
I'm writing a bone exporter for Maya, using Maya's API. The problem I'm having is I'm getting some wierd results of the matrices for each joint. I copied the Maya API documentation that comes with Maya, for this particular case. This is a webpage for the class that gives me all the "transformation" information for the joint. I've used the asMatrix, asRotateMatrix, and asScaleMatrix, and logged all the data. Make sure to read the "Description" section. I've read it 3 times now, and I still don't see how it can screw up the matrices so bad. First, I created a 4 joint skeleton. The first parent joint starts at the origin, then the second child joint goes up 3, next joint up 3, and the last joint up 3. No rotation, no scaling, only moving up 3 each joint, starting from 0, 0, 0. But here's what tripped me out. The first and last joint do not have the identity matrix. Not even in their rotation matrix. Here's the data that comes out: Current Transform: joint1 (Parent joint) Loc: (0, 0, 0) Normal Matrix: 0.000000, 1.000000, 0.000000, 0.000000 Normal Matrix: -1.000000, 0.000000, 0.000000, 0.000000 Normal Matrix: 0.000000, 0.000000, 1.000000, 0.000000 Normal Matrix: 0.000000, 0.000000, 0.000000, 1.000000 Rotate Matrix: 0.000000, 1.000000, 0.000000, 0.000000 Rotate Matrix: -1.000000, 0.000000, 0.000000, 0.000000 Rotate Matrix: 0.000000, 0.000000, 1.000000, 0.000000 Rotate Matrix: 0.000000, 0.000000, 0.000000, 1.000000 Scale Matrix: 1.000000, 0.000000, 0.000000, 0.000000 Scale Matrix: 0.000000, 1.000000, 0.000000, 0.000000 Scale Matrix: 0.000000, 0.000000, 1.000000, 0.000000 Scale Matrix: 0.000000, 0.000000, 0.000000, 1.000000 ---------------------------------------------------------- Current Transform: joint2 Loc: (0, 3, 0) Normal Matrix: 1.000000, 0.000000, 0.000000, 0.000000 Normal Matrix: 0.000000, 1.000000, 0.000000, 0.000000 Normal Matrix: 0.000000, 0.000000, 1.000000, 0.000000 Normal Matrix: 3.000000, 0.000000, 0.000000, 1.000000 Rotate Matrix: 1.000000, 0.000000, 0.000000, 0.000000 Rotate Matrix: 0.000000, 1.000000, 0.000000, 0.000000 Rotate Matrix: 0.000000, 0.000000, 1.000000, 0.000000 Rotate Matrix: 0.000000, 0.000000, 0.000000, 1.000000 Scale Matrix: 1.000000, 0.000000, 0.000000, 0.000000 Scale Matrix: 0.000000, 1.000000, 0.000000, 0.000000 Scale Matrix: 0.000000, 0.000000, 1.000000, 0.000000 Scale Matrix: 0.000000, 0.000000, 0.000000, 1.000000 ---------------------------------------------------------- Current Transform: joint3 Loc: (0, 6, 0) Normal Matrix: 1.000000, 0.000000, 0.000000, 0.000000 Normal Matrix: 0.000000, 1.000000, 0.000000, 0.000000 Normal Matrix: 0.000000, 0.000000, 1.000000, 0.000000 Normal Matrix: 3.000000, 0.000000, 0.000000, 1.000000 Rotate Matrix: 1.000000, 0.000000, 0.000000, 0.000000 Rotate Matrix: 0.000000, 1.000000, 0.000000, 0.000000 Rotate Matrix: 0.000000, 0.000000, 1.000000, 0.000000 Rotate Matrix: 0.000000, 0.000000, 0.000000, 1.000000 Scale Matrix: 1.000000, 0.000000, 0.000000, 0.000000 Scale Matrix: 0.000000, 1.000000, 0.000000, 0.000000 Scale Matrix: 0.000000, 0.000000, 1.000000, 0.000000 Scale Matrix: 0.000000, 0.000000, 0.000000, 1.000000 ---------------------------------------------------------- Current Transform: joint4 (last child joint) Loc: (0, 9, 0) Normal Matrix: 0.000000, -1.000000, 0.000000, 0.000000 Normal Matrix: 1.000000, 0.000000, 0.000000, 0.000000 Normal Matrix: 0.000000, 0.000000, 1.000000, 0.000000 Normal Matrix: 3.000000, 0.000000, 0.000000, 1.000000 Rotate Matrix: 0.000000, -1.000000, 0.000000, 0.000000 Rotate Matrix: 1.000000, 0.000000, 0.000000, 0.000000 Rotate Matrix: 0.000000, 0.000000, 1.000000, 0.000000 Rotate Matrix: 0.000000, 0.000000, 0.000000, 1.000000 Scale Matrix: 1.000000, 0.000000, 0.000000, 0.000000 Scale Matrix: 0.000000, 1.000000, 0.000000, 0.000000 Scale Matrix: 0.000000, 0.000000, 1.000000, 0.000000 Scale Matrix: 0.000000, 0.000000, 0.000000, 1.000000 The normal matrix does the transform from the previous joint. So even though joint4 has 3.0, it's 9.0. And I don't know why it's in the X position. In Maya, Y is the up position. But I don't know whats up with -1.0 where there should be an identity matrix. As you can see, joint 2 and 3 are going good, just like any joints between the first and the last. Why am I getting such wierd results? Thanks for reading!
Advertisement
all the transformations are relative. That first bone, whose matrix is not identity, is a 90-degree rotation around z-axis, so transforms x onto y. So, in world space, each of those relative 3.0 x-axis translations become 3.0 unit y-axis translations. Finally, the last bone translates 3.0 units to 9.0, then rotates back to the original orientation (undoes the first bone's 90 degrees).
Ok, I figured it was rotating it (why?) so I rotated the main joint -90 degrees along the Z axis. Now, the first joint has the identity matrix, but the 4th joint still has the same matrix. But I think I found out the problem. Each joint has an orientation, so I just have to change that. Thanks for the help!

[Edited by - IgnisDeus on September 8, 2005 3:39:59 AM]
No, of course it doesn't need to undo the rotation with the final bone. My personal theory was that was something you did to make it "look" right. Like I said, all rotations are relative so when you corrected the first bone to be identity, you didn't change the 4th bone at all, it still turns Z -90 from its parent. I think your question is not how to fix it but is more like "How did it get this way?"

Maybe Maya did it on its own, maybe you did it accidentally... But it's one of those two things! (Otherwise, what else?)
Well I'm not that dumb, I didn't change anything to make it "look". Maya assigns each bone's axis system so that the x-axis points toward the next joint. I have a feeling this is going to cause problems when exporting. Shouldn't every joint be an identity matrix when it's not moved from the bindpose?

This topic is closed to new replies.

Advertisement