PDA

View Full Version : rotation issue

mathx
07-14-2001, 03:10 AM
Hello,

Ok, I've been coding for a couple of weeks, but so far this is the toughest problem I've faced. When I create an object (let's say a cube) on the center of the world, and I rotate it, all functions very well. But when I create it let's say on the left of the world, it rotates around the world's axis, not around the object's axis. I've came up with 2 solutions: create all objects on the center, rotate them and translate for the position, or do some calculations, multiply a certain matrix to the current one, and rotate only the object. Is this right? Is there another solution?

Thanks,
Matheus.

07-14-2001, 07:21 AM
I personally prefeer the Matrix method. Both are good though

mathx
07-14-2001, 02:08 PM
Hello,

And what is the exact transformation? For example, if the cube is located for the right of the world axis, I call glTranslate with "x" being half of the cube's width? Is that right?

Thanks,
Matheus Degiovani.

zed
07-14-2001, 11:35 PM
theres some links at www.flipcode.com (http://www.flipcode.com) so some nice linear algebra tutorials

basically youre on the right track

translate the object to world pos 0,0,0
apply the rotation
translate it back to where it was