
Rotation & Translation Problem..
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,,,

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
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
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
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.....?
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement