I'm trying to write a BVH file loader to get my feet wet with skeletal
animation, and I'm having a lot of trouble getting it working.
I can get the skeleton to draw, and he moves around a little bit.
However, the motion just isn't right. I must be doing the angles or
something wrong.
Please let me know if you see anything obviously wrong with the drawing
code:
struct Joint {
char name[80];
float offset[3];
int numchannels;
vector<Joint> v;
};
void drawwell(Joint j)
{
vector<Joint>::iterator iter = j.v.begin();
int fctr = mikectr % frames.size();
if (j.numchannels == 3) {
glPushMatrix();
glRotatef(0, 0, 1, frames[fctr][globalctr]);
glRotatef(1, 0, 0, frames[fctr][globalctr+1]);
glRotatef(0, 1, 0, frames[fctr][globalctr+2]);
glTranslatef(j.offset[0], j.offset[1], j.offset[2]);
glBegin(GL_POINTS);
glVertex3f(0, 0, 0);
glEnd();
globalctr+=j.numchannels;
while (iter != j.v.end()) drawwell(*iter++, 0, 0, 0);
glPopMatrix();
}
else
{
// this is for the root node
globalctr+=j.numchannels;
glPushMatrix();
glRotatef(0, 0, 1, frames[fctr][globalctr+3]);
glRotatef(1, 0, 0, frames[fctr][globalctr+4]);
glRotatef(0, 1, 0, frames[fctr][globalctr+5]);
glTranslatef(j.offset[0], j.offset[1], j.offset[2]);
glBegin(GL_POINTS);
glVertex3f(0, 0, 0);
glEnd();
while (iter != j.v.end()) drawwell(*iter++);
glPopMatrix();
}
}