PDA

View Full Version : How to Render an Skeletal Animation Reference Pose?



Shinobi
08-22-2003, 11:28 PM
I'm Wondering what it takes to render a reference pose out of a Half-Life .SMD pose. Let us say we have 50 Bones or Nodes whatever.

1.) Seek for the "nodes"
2.) Read ( ID, Name, ParentID) until "end"
3.) Seek for "time 0"
4.) Now loop "int i" 50x times:
BoneID pos[i].x, pos[i].y, pos[i].z, rot[i].x, rot[i].y, rot[i].z

That should be all we need. Now we just need to draw them:

for (int i=0;i<numBones;i++)
{
D3DXMATRIX mRot;
D3DXMATRIX mPos;

D3DXMatrixRotationYawPitchRoll(&mRot, rot[i].y, rot[i].x, rot[i].z);

D3DXMatrixTranslation(&mPos, pos[i].x, pos[i].y, pos[i].z);

matrix[i] = mRot*mPos;
if (node[i].iParent > -1)
{
world[i] = matrix[i] * world[bone[i].iParent];
}
else
{
world[i] = matrix[i];
}
}

When I now want to draw bones, I need to find All the Bones that do have parents, if so, I can just draw with the world matrix? For example:

D3DXMATRIX world[numNodes];

glBegin(GL_LINES);
glVertex3f(world[currentbone]._41,world[currentbone]._42,world[currentbone]._43);
glVertex3f(world[parentbone]._41,world[parentbone]._42, world[parentbone]._43);
glEnd();

world is an array of [4x4] matrices, world[x]._41 is [y=4;x=1] so the first column in the last row. But does not seem to be correct. How to fix that?