When looking at the visual_scene nodes within a typical DAE file, are the matrices referenced relative to the previous bone? or are they relative to the origin?
iirc every transformation matrix is relative to its parent node.
Also there are exporters that will not bake the matrices and provide you with transform tags like (rotationX, rotationY, scale) in that case you need to build the matrix yourself.
I re-read the spec and you're correct, they are relative to each other.
I need to brush up on my matrices, but am i wrong in thinking i should be able to take this baked transformation matrix, multiply by a position vector, and have the destination of the bone?
My problem that I have with the Wazim tutorial (its what i'm trying to follow atm) is that I cant follow his code, and I'm getting confused by his explanation.
Though perhaps, what i'm looking for isnt even there... right now i'm trying to generate the skeleton view (so that I can validate the file has loaded in correctly) but i'll focus on what needs to happen here...
If i'm following you correctly (example for 3 joints):
Multiply individual bones by modified inverse bind pose matrices to get world space?
B1world = B1 * IBM1
B2world = B2 * IBM2
B3world = B3 * IBM3
Would this mean that B1world, B2world, B3world should now be diagonal matrices and representation of these points in space should be able to be done by multiplying a 1x4 vector by this matrix or by using the diagonal values as x,y,z,w?
Be aware that matrix multiplications are order dependant.
I'm using OpenGL and I'm not a math pro, so I'm not sure if this also applies to your code,
but in my code I've ALL multiplications in the reverse order than yours so:
B1 = Trans1 * Root;
IBM1 = BSM * IBM1;
B1world = IBM1 * B1;
Would this mean that B1world, B2world, B3world should now be diagonal matrices and representation of these points in space should be able to be done by multiplying a 1x4 vector by this matrix or by using the diagonal values as x,y,z,w?
The first, so you're using the calculated world matrices to transform your vertices(1x4 vector)
To only create the joint vertices i think you can use the diagonal values.
Ok, back again after tidying up some of the trial and error:
The code i'm using below is as follows.
RenderBones(BONE* bone, glm::vec4 originV, glm::mat4 prevB)
glm::mat4 BSM = glm::mat4(1.0f,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,0.0f,1.0f); //manually entered at this time.
glm::mat4 TRANS = bone->boneMatrix;
glm::mat4 IBM;
if(namedJoints.count(bone->boneSID) != 0)
IBM = namedJoints[bone->boneSID];
glm::mat4 B = TRANS * prevB; //TRANSFORM TIMES PREVIOUS.
IBM = BSM * IBM;
glm::mat4 BWORLD = IBM * B; //IBM * B
glm::vec4 unitVec = glm::vec4(1.0f,1.0f,1.0f,0.0f);
glm::vec4 destV = (BWORLD * unitVec);
glBegin(GL_LINES);
glVertex3f(originV.x,originV.y,originV.z);
glVertex3f(destV.x,destV.y,destV.z);
glEnd();
for(int i = 0; i<bone->children.size(); i++){
RenderBones(&bone->children[i],destV,B);
}
I suspect that i've not got something right in the way that i'm either using the data or that i'm misinterpreting how to use baked matrices.
This code appears to be traversing the skeleton right, except its resulting in a birds nest output...
Eg. the attached... |edit| upload didnt work, simply imagine a bunch of pickup sticks dropped on the ground so that there were at least the ends touching each other
I'm thinking these baked matrices need some work before i can use them in this way, i've confirmed that the values are being imported correctly, and that they're passing through... i feel i've missed something major.
|edit2|
Looking at the files Wazim has up on his site, i'm not sure that the baked transformations are exactly what i expect them to be...
I'm pretty sure the w component of the unitVector needs to be 1 in your case (otherwise it should be the vertex weight[how much the joint matrix is affecting the vertex]).
Also i think you're multiplying in DX order again, destV should be unitVec * BWORLD.