#### Archived

This topic is now archived and is closed to further replies.

# rendering a skeleton

This topic is 5571 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

So I'm writing a program to load milkshape files, and I have it rendering them fine. I've started working on rendering them, but before I do that I wanted to write a program to render the skeleton itself. I wrote an algorithm to do this, but the angles all seem to go off at weird angles. I'm using just basic glPushMatrix, glRotate, and glTranslate calls, so perhaps I misunderstand what the values of rotation and translation mean in the milkshape file? Here's my algorithm. See any problems? void drawJoints(float radius, Joint *joint) { int i; //it's a recursive algorithm, so check if it's null if(joint == NULL) return; glPushMatrix(); //This bit here translates to the current joint... glTranslatef(joint->position[0], joint->position[1], joint->position[2]); //...then draws the joint. gluSphere(gluNewQuadric(),radius,10,10); //This is what I think is wrong. Ideas? glRotatef(joint->rotation[0],1,0,0); glRotatef(joint->rotation[1],0,1,0); glRotatef(joint->rotation[2],0,0,1); //for each child, draw a line to it, and then recurse. for(i=0;inumChildren;i++) { glBegin(GL_LINES) glVertex3f(0,0,0); glVertex3f(joint->children.position[0], joint->children[i].position[1], joint->children[i].position[2]); glEnd(); drawJoints(radius,&joint->children[i]); } //pop the matrix again. glPopMatrix(); } The angles that this creates are quite wrong. Any ideas? Thanks! -Ozymandias [edited by - ozymandias42 on March 19, 2003 1:15:36 PM]

##### Share on other sites
Just a side comment: There is a gluDeleteQuadric() call... So you should store a pointer to your sphere quadric, use it for all spheres you draw, and call gluDeteteQuadric(pSphere) on it when you are done, would probably go quicker and be more standard than creating a new quadric for all joints and never deleting it...

About the angles, I have never worked with ms3d or any other models before... But I assume they are euler angles... So it could be Yaw, Pitch, Roll, or Pitch, Yaw, Roll

I suggest you try different rotation axis like:

glRotatef(joint->rotation[0],0,1,0);
glRotatef(joint->rotation[1],0,0,1);
glRotatef(joint->rotation[2],1,0,0);

or

glRotatef(joint->rotation[0],0,0,1);
glRotatef(joint->rotation[1],0,1,0);
glRotatef(joint->rotation[2],1,0,0);

Also, in this statement: for(i=0;inumChildren;i++), where does iNumChildren come from?

Looking for a serious game project?
www.xgameproject.com

##### Share on other sites
Nope, none of the permutations seem to work. The example on the front page of rsn.gamedev.net seems to put all the angles and translations into a matrix and apply it at once; I wonder if that would have different results?

Oh, and numChildren is just a typo. It should be i

• 17
• 11
• 12
• 9
• 49
• ### Forum Statistics

• Total Topics
631395
• Total Posts
2999758
×