PDA

View Full Version : Giving an object 2 rot. points



Ksama
01-21-2012, 04:35 PM
Hey everyone , and thank you for taking the time to read this :D
(I am very new to Opengl)

I created a puppet model : Head ,neck,body,2 arms , 2 legs.
Each arm is made by 2 separate objects ( don't know if i should call them object just 2 stretched cubes).

No with one button i have to make both parts move , having as a rotating point the <<arm of the puppet>>. After a long struggle i managed this.

But now with a different button i have to move only the lower part , having as a rotation point the <<elbow of the puppet>>
I managed that also , but then i couldn't get it to move with the upper part again when the appropriate button was pressed.
(That is the code you see )
Here is some of my code :

glColor3ub(20,50,225); //LEFT UPPER ARM
glPushMatrix();
glTranslatef(33.0,-32.0,0.0);
glRotatef(Upperrot,1.0,0.0,0.0);
glTranslatef(0.0,15.0,0.0);
glScalef(0.7,1.9,0.5);
glutSolidCube(20.0);
glPopMatrix();



glColor3ub(20,50,225); //LEFT BOTTOM ARM
glPushMatrix();

glRotatef(0,0,0,0);

glTranslatef(33.0,-72.0,0.0);
glRotatef(Lowerrot,1.0,0.0,0.0);
glTranslatef(0.0,-15.0,0.0);


glScalef(0.7,1.9,0.5);
glutSolidCube(20.0);
glPopMatrix();


With every Trasf and Rot affecting each other , i am losing my sanity.
The only thing i have to change/add is on the left bottom arm.
Any suggestions ? i have to add more glRotatef and glTransferf ? Can i even put pushmatix inside another pushmatrix ?

I would appreciate your help , thank you very much !

Ksama
01-21-2012, 07:38 PM
Problem solved :D
Tried a bunch of different Trans and rotates after another and now it worked :D