PDA

View Full Version : Rotation around the center



debonair
10-10-2013, 07:02 PM
I have object moving from A to B on x-axis and there is no translation of object apart from it. Now, while moving, i want to rotate it around y-axis and the motion should change accordingly, i mean If it rotates 90 in clockwise while moving along +x axis, it should take a turn and move towards near plane along z axis. I have variable in gltranslatef which is modified in the loop after that i have glscalef to scale whole object which is made of hierarchical structure. Now i tried following code to achieve the expected result but its not working properly


glTranslatef(move, 0, 0);

// If I comment these 3 lines, it does not affect the output
glTranslatef(-move, 0, 0);
glRotatef(rotate,0,1,0);
glTranslatef(move, 0, 0);

glScalef(0.2, 0.2, 1.0);

debonair
10-11-2013, 05:46 PM
Bounce..!!

GClements
10-11-2013, 07:14 PM
i want to rotate it around y-axis and the motion should change accordingly, i mean If it rotates 90 in clockwise while moving along +x axis, it should take a turn and move towards near plane along z axis.
You'll need to clarify what you mean here.

If you want to model an object which always moves in the direction it's facing, and its orientation changes over time, then you'll need to maintain its position yourself (i.e. numerically integrate velocity with respect to time). As its position depends upon the complete history of its orientation, it cannot be determined solely from its current orientation, speed, and elapsed time.

debonair
10-12-2013, 04:34 PM
Thanks for your help. I got it solved.