Archived

This topic is now archived and is closed to further replies.

KappaMic

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

Recommended Posts

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!!!!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
I don''t quite nderstand what you mean, but if you put the glRotatef before the if() statement, it may do what you want.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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..

Share this post


Link to post
Share on other sites