Skip to main content
gamedev.net
🔒 Locked

(resolved)

Started by digitec devil Mar 21, 2005 at 1:02 PM 3 replies 1.6k views
Original Post
digitec devil
digitec devil
I've run into this problem a number of times and never really looked into it enough to get any answers. The problem is that I will rotate an object arbitrarily, then any subsequent translations, such as one to position the object in the world, are also affected by this rotation. So how do I translate to get the object in the desired position after this rotation has been applied? [Edited by - digitec devil on March 21, 2005 4:49:16 PM]
nts
nts
Whats the difference between your object and world space?

Can't you translate first and then do the rotation.

Alternatively what about (if using OpenGL)
glRotate(...);glPushMatrix();glLoadIdentity();glTranslatef(...);glPopMatrix();

digitec devil
digitec devil
In this case I've got two rotations followed by a translation. The translation is supposed to put the object into world space, but my local coordinate system has been rotated arbitrarily, so translating has to take that into account, no?
Thunder_Hawk
Thunder_Hawk
I'm not quite sure what you are trying to say, but I'll give it a try:

pseudo-code:
pushMatrix();
translate (x, y, z);
rotate();
rotateAgainAlongADifferentAxis();
translate (-x, -y, -z);
draw();
popMatrix();

That will rotate an object in place, even if it's not located at the origin.

[EDIT] Whoops, I got the translations backwards.

[Edited by - Thunder_Hawk on March 21, 2005 4:21:39 PM]
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Forma
digitec devil
digitec devil
Got it sorted, I can have serious lapses in mental capacity in the mornings :/ thanks guys.

[Edited by - digitec devil on March 21, 2005 4:44:53 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.