• Advertisement
Sign in to follow this  

Rotation & Translation Problem..

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement