Okay, I’m working on a project where I’ve constructed a crude human model out of scaled wire cubes. I set them up so that there is a hierarchy of the objects (the hand is connected to the forearm which is connected to the bicep, etc) using the stack… however, when I try to do some animation tests, like rotating an arm for example, the entire arm changes it shape and becomes very “sheared” and streched out.
My through was that if I rotated the hips along the x axis for example, the legs would go with it. Then I could rotate the thigh, then the calf, then finally the foot, all on the x axis to produce a sort of kicking motion. What happens is the hips rotate fine, but then whe I try to roate the thigh, things get distorted. The same goes for the calf and foot as well. Here is an example of what I’m talking about:
…
glPushMatrix(); // Push: Beginhip
glTranslatef(0.0, -.7, 0);
glScalef(hipRatioX, hipRatioY, hipRatioZ);
glRotatef(testAnimate, 1.0, 0.0, 0.0);
glutWireCube(1.0);
// Left Thigh
glPushMatrix(); // Push: Begin left leg
glTranslatef(.34, -1.75, 0);
glRotatef(testAnimate, 1.0, 0.0, 0.0);
glScalef(thighRatioX, thighRatioY, thighRatioZ);
glutWireCube(1.0);
// Left calf
glPushMatrix();
glRotatef(testAnimate, 1.0, 0.0, 0.0);
glTranslatef(0, -0.92, 0);
glScalef(calfRatioX, calfRatioY, calfRatioZ);
glRotatef(testAnimate, 1.0, 0.0, 0.0);
glutWireCube(1.0);
// Left foot
glPushMatrix();
glTranslatef(0, -.55, .25);
glScalef(1, .1, 1.5);
glRotatef(testAnimate, 1.0, 0.0, 0.0);
glutWireCube(1.0);
glPopMatrix();
glPopMatrix();
glPopMatrix(); // Pop: End Left Leg
// other leg is drawn next
glPopMatrix(); // End Hip
…
Okay, so a couple of questions… are all the pushes and pops necessary… I mean, am I even using them correctly? Also can I rotate like this is a hierarchy and get the other body parts to move along with it with the method I am using? Do I have to use extra translates? I tried it but nothing changed. What would I have to change to make this work? Keep in mind that there are two pushes above the hip (the scence and torso pushed) and two pops below the hip as well.
I hope this made some sense… any help at all would be greatly appreciated.
Thanks,
Jesse