# 3 Joints, how to Synchronise

• 03-05-2006
Bobby230
3 Joints, how to Synchronise
My program is of a pair of legs walking, but I dont know how to get the whole leg to Synchronise There is 3 joints that need to be considered (upper_leg, lower_leg and foot). My code is for this part is below, but is just for the upper leg. Do I do the same for the other joints or do I need to relate them in some way. The opengl website helped me a bit, but not enough to go it alone.

If you need to see any of the other code related to the walking legs, I have another post with it in. Just look for the Bobby post

cheers

Code:

```glPushMatrix();                               //rotate left leg relative to the body                                                             if (upper_leg)                               {                                             upper_leg_angle[0] = upper_leg_angle[0]+ 1.0f;                               }                               else                               {                                             upper_leg_angle[0] = upper_leg_angle[0]- 1.0f;                               //when the upper leg has reached its maximum angle in either                               //direction it should stop and go in the opposite direction                                                             if (upper_leg_angle[0] >=15.0f)                               {                                                       upper_leg = false;                               }                               if (upper_leg_angle[0] <=15.0f)                                                                                     upper_leg = true                  glPopMatrix();```
• 03-05-2006
VirtualAce
Each section must have it's own transformation matrix since each object's position or section's position and rotation is dependent on the orientation of the section it's connected to.

First you take the root transformation and use it as your base matrix.

To arrive at each section's correct matrix, you concatenate the previous matrix result with the section's transformation matrix.

So each object will have
1. Translation matrix
2. Rotation matrix
3. Scaling matrix

So if you want to transform a person an upper arm, lower arm,wrist, hand, and fingers you would do this:

1. Compute base transformation matrix

UPPER ARM:
1. For arm-> Compute or pre-compute upper arm transformation matrix
2. Mutiply base * arm

LOWER ARM:
1. Compute lower arm transformation matrix
2. Multiply upper arm * lower arm

WRIST:
1. Compute wrist transformation matrix
2. Multiply lower arm * wrist

HAND:
1. Compute hand transformation matrix
2. Multiply wrist * hand

FINGERS:
1. For each finger compute finger transformation matrix
2. Multiply hand * finger matrix

Render object.

You can use a matrix stack to get this done quickly.