Jump to content
  • Advertisement


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


Basic transformation problem

This topic is 5655 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

I have a problem where my model is defined at the coordinate origin and I want to translate it then rotate it about the coordinate origin. If I rotate then translate then obviously all rotations will have the affect of rotating the model about its centre wherever it is in the world. So naturally I reverse the order so I am translating then rotating the model. All is well apart from when I go to translate the model again after having it rotated, only to find the model moving in the wrong direction. For example, if I keep translating along the x axis then rotate 90 degress about the Y axis the model will move backwards instead of left. I know why this is happening but I can''t find a fix. I''m sure countless people have come up against this basic transformation problem. Any thoughts.

Share this post

Link to post
Share on other sites
To shed some light on my question, I should probably being asking how do I rotate an object about an arbitrary point that is defined in modelling coordinates at the world origin (its centre is being at the world origin), and have translations appear as expected. There is a D3D function called
D3DXMatrixTransformation() that might to the trick.

Share this post

Link to post
Share on other sites
i dont know anything about direct x but in opengl i would translate to where i wanted to draw it, rotate to the approppriate angle, draw it, then rotate back to where i was and continue with my transformations. the opengl code if this helps:

glMatrixMode(GL_MODELVIEW); //select the matrix to do with rotations and transformations
glLoadIdentity(); //move to the origin, looking in the negative z direction

glTranslatef(obj_x, obj_y, obj_z); //move to the object position
glPushMatrix() //remember my current transformations
glRotatef(axis_x, axis_y, axis_z, angle); //rotate however much you want

//draw the object, it will be rotated by angle about axis

//restore transformation matrix to what it was before the rotation and continue drawing


Share this post

Link to post
Share on other sites
Just to state the obvious...
Instead of doing
    T1, R1, T2, R2   

do this...
    T1, T2, R1, R2   

or this (ugly)...
    T1, R1, -R1, T2, R1, R2   

It sounds to me like the problem is that all your transformations are in world space. If you "nest" your transformations (i.e. local vs global), you don't have to worry about reordering or undoing previous rotations.

[edited by - Jambolo on June 20, 2003 1:54:39 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!