rotation issue

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.

I personally prefeer the Matrix method. Both are good though

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.

theres some links at 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