HELP!! HOW TO MOVE AN OBJECT!! NEWBIE HERE!!!

Started by
3 comments, last by KappaMic 23 years, 6 months ago
Hi, i''m a newbie... so.... I''ve a little problem, I''m working around a tut (the rotating quad) and i want that after 10 rotation (i can count them), the cube will move to the right of 10 pixels (countinuing it''s rotations). How can i do this??? Please help me. Many thanks!!!!
Advertisement
int count = 0;while(!done){    count++;    if(count >= 10)        glTranslatef(10, 0, 0);  // Move        glRotatef(rot, 1, 1, 1);    DrawCube();}


That''s a pretty simple example, it should do what you want. If you replace the 10 with a variable, you can make it continually move. This code will just rotate the cube on all axis and then move to the right 10 and rotate in that position.

Ben
The problem is that i want the cube to rotate around an x,y,z position....

I don''t quite nderstand what you mean, but if you put the glRotatef before the if() statement, it may do what you want.
No matter what you do like that your object will be rotating with respect to 0,0,0.. So you must

Push your current matrix to the stack
build your object (which will be created at the origin
//Next two can be done in any order
rotate it
translate it
pop the matrix


Done..

This topic is closed to new replies.

Advertisement