3 Joints, how to Synchronise

This is a discussion on 3 Joints, how to Synchronise within the C Programming forums, part of the General Programming Boards category; My program is of a pair of legs walking, but I dont know how to get the whole leg to ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    3

    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();

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Synchronise WM_TIMERs, we're going in...
    By SMurf in forum Windows Programming
    Replies: 6
    Last Post: 02-21-2003, 04:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21