#### Archived

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

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

This topic is 6495 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 on other sites
The problem is that i want the cube to rotate around an x,y,z position....

##### 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 on other sites
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..

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
gaxio
10

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631778
• Total Posts
3002310
×