• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 551
  • Last Modified:

Rotate Robot.

Hi Guys ,

I am actually doing to robot.Whoch has a head,torso waist,hand,forearm and leg.i have successfully written the code to draw everything.Now i need to do some thing like , when the user on the s button it shuld move the torso 5 degrees and along with it even the hand,forearm and th leg should move.Now all the head ,leg and arm,torso are everything inside the same method.Now how do i do something like when the user click s move only the torso,head arm and forearm in the robot.The leg should not move.

Can anyone help on this.

Thanks
0
srihari1986
Asked:
srihari1986
1 Solution
 
guitaristxCommented:
I assume that you have a routine that draws your robot, similar to this:

void drawRobot()
{
     drawLegs();

     drawTorso();

     drawArms();

     drawHead();
}

If not, it would benefit you to do it this way (even if it's not separated out into separate functions, like above).  Once this is done, modify your code this way:

void drawRobot()
{
     glPushMatrix();
     drawLegs();

     glTranslate(/*coordinate somewhere on the center axis of the robot*/);
     glRotate(/*number of degrees*/);

     drawTorso();

     drawArms();

     drawHead();
     glPopMatrix();
}

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now