Archived

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

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey all, im working on building a 3d engine/library and the one part of it that has seemed to stump me is 3d hierarchial rotation, i.e. you rotate your shoulder and your forarm and hand follows i have come up with a way to do it... rotate self->rotate joints below it using the rotation origin of the first object. the idea works well... but i think the rotations im doing are messed up, so i was wondering if anyone could point me in the direction of a turoial or some information on doing 3d hierarchial rotations using software only *no graphics libraries or other engines* thanks=)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Just to a web search on ''forward kinematics'' That''s the ''official'' term for what you''re describing.

Share this post


Link to post
Share on other sites
I''m no 3D programmer, but surely if you just define your objects in relation to the object it is attached to, then you only need to transform one object and all the others are automatically transformed as a result...

Share this post


Link to post
Share on other sites
Kylotan is right assuming that you do position your different objects in relation to some central object. I have done things like this for robot demos, here is a quick snippet. It''s in OpenGL and if you don''t understand push and pop techniques it''s probably hard to understand. Forward Kinematics is also something to look into for other types of physics simulations. I think there is a good tutorial somewhere on this website: OpenGL Effects

  
// This function calls the function to draw the rest of the robot

void GLMain::DrawRobot()
{
glPushMatrix();

glPushMatrix();

// Rotate bust

glRotatef(bustXAngle, 1.0f, 0.0f, 0.0f);
glRotatef(bustYAngle, 0.0f, 1.0f, 0.0f);

// Draw bust

DrawBust();

// Draw head

DrawHead();

glPushMatrix();

glTranslatef(-6.5f, 0.0f, 0.0f);

// Rotate left arm

glRotatef(leftArmAngle, 1.0f, 0.0f, 0.0f);

// Draw left arm

DrawArm();

glPushMatrix();

glTranslatef(0.0f, -4.5f, 0.0f);

// Rotate left forearm

glRotatef(leftForeArmAngle, 1.0f, 0.0f, 0.0f);

// Draw left forearm

DrawForeArm();

glPopMatrix();

glPopMatrix();

glPushMatrix();

glTranslatef(6.5f, 0.0f, 0.0f);

// Rotate right arm

glRotatef(rightArmAngle, 1.0f, 0.0f, 0.0f);

// Draw right arm

DrawArm();

glPushMatrix();

glTranslatef(0.0f, -4.5f, 0.0f);

// Rotate right forearm

glRotatef(rightForeArmAngle, 1.0f, 0.0f, 0.0f);

// Draw right forearm

DrawForeArm();

glPopMatrix();

glPopMatrix();

// Draw Pelvis

DrawPelvis();

glPushMatrix();

glTranslatef(-1.5f, -6.1f, 0.0f);

// Rotate left thigh

glRotatef(leftThighAngle, 1.0f, 0.0f, 0.0f);

// Draw left thigh

DrawThigh();

glPushMatrix();

glTranslatef(0.0f, -5.3f, 0.0f);

// Rotate left leg

glRotatef(leftLegAngle, 1.0f, 0.0f, 0.0f);

// Draw the left leg

DrawLeg();

glPopMatrix();

glPopMatrix();

glPushMatrix();

glTranslatef(1.5f, -6.1f, 0.0f);

// Rotate right thigh

glRotatef(rightThighAngle, 1.0f, 0.0f, 0.0f);

// Draw right thigh

DrawThigh();

glPushMatrix();

glTranslatef(0.0f, -5.3f, 0.0f);

// Rotate left leg

glRotatef(rightLegAngle, 1.0f, 0.0f, 0.0f);

// Draw the left leg

DrawLeg();

glPopMatrix();

glPopMatrix();

glPopMatrix();

glPopMatrix();
}


Well, maybe that wasn''t all that short, but you get the idea right? good!

Share this post


Link to post
Share on other sites