# Rotation & Translation Problem..

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

## Recommended Posts

Hi.....guys... please see this picture and help me.........actually i have 3D mesh Model.....and that model don;t have (0.0, 0.0, 0.0) origin.....so when i start to rotate with mouse....its rotation of model is far from origin......but i want to rotate like for example if i pick this triangle from center of triangle then it will rotate along picking axis.... thanks,,,

##### Share on other sites
1. Move the triangle to the origin by translating with the vector from m to the origin.
2. Rotate the triangle
3. move it back just like step 1 but in reverse.

also remember that openGL does all it's transformations in reverse order

##### Share on other sites

this is code....what u suggest now..
---------------------------
mouse
---------------------------
glTranslatef(0.0f, 0.0f, zoom); // Translate the Model in Z-Direction
glRotatef(spin_y, 1.0f, 0.0f, 0.0f); // Rotate The Model On It's X-Axis
glRotatef(spin_x, 0.0f, 1.0f, 0.0f); // Rotate The Model On It's Y-Axis
Drawobject(); // Draw object Model

--------------------

and i draw 3D mesh model with vertex array....so how can i translate vectors with model.....?

##### Share on other sites
If you want to rotate the triangle around its Origin, you first have to create it around origin.
How ever you want to rotate it, the rotation point must be (at the time it was made) the origin.

After you've created it, you translate it to its spot, where it will rotate around the point that was in origin at the creation moment.

So in Draw triangle, if its just 2D triangle in 3D world, or is it a pyramid? anyways, if its triangle as you said.

glBegin(GL_TRIANGLE_STRIP);
glVertex3f(-0.5,-0.5,0);
glVertex3f(0.5,-0.5,0);
glVertex3f(0,0.5,0);
glEnd();

For examble, that might not work since I paid no attention to it. But something like that.

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 14
• 14
• 9
• ### Forum Statistics

• Total Topics
633366
• Total Posts
3011527
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!