### Author Topic: Rotate around world axis.  (Read 346 times)

#### Richard Rae

• Mr. Drawsprite
• Posts: 79
##### Rotate around world axis.
« on: 2012-May-28 »
How do I make a 3d object rotate around the world axis,irrespective of the objects own roll,tilt or yaw angle.Thanks

#### mentalthink

• Prof. Inline
• Posts: 2726
• Integrated Brain
##### Re: Rotate around world axis.
« Reply #1 on: 2012-May-28 »
HI Richard you can use x_rotation phi,x,y,z

On phi, it´s a value in degress from 0 to 360, and x,y,z it´s setting put a '1' in the axis...

In example:
Make a counter whit phi and put the x_rotation phi,0,0,1, this rotate the object in Z in the viewport...
If you want have a radius from the circle... when you make the 3D mesh, change the pivot point in your 3D suite, and you have the offset...

#### Richard Rae

• Mr. Drawsprite
• Posts: 79
##### Re: Rotate around world axis.
« Reply #2 on: 2012-May-28 »
Does X_ROTATION not just rotate the object about its own axes?

#### mentalthink

• Prof. Inline
• Posts: 2726
• Integrated Brain
##### Re: Rotate around world axis.
« Reply #3 on: 2012-May-28 »
yes!!!

Try to use this:

X_rotation phi, 1+(cos(phi)*amplitude),0,1+(sin(phi)*amplitude)

I´m not sure if this will works!!!

#### Richard Rae

• Mr. Drawsprite
• Posts: 79
##### Re: Rotate around world axis.
« Reply #4 on: 2012-May-29 »
I think I am not explaining myself very well.Imagine that a cube was positioned at 0,0,0 and rotated 45 deg on the x axis and 45 deg on the y axis.I want the cube to rotate say 45 deg relative to the world x axis.If I use x_rotate then the cube would rotate on its own x axis not relative to the world x axis.I want to rotate the cube on the world axes no matter the rotation of the cube on its own axes.I hope this explains things more clearly.

#### backslider

• Prof. Inline
• Posts: 858
##### Re: Rotate around world axis.
« Reply #5 on: 2012-May-29 »
Maybe you should try the 3D Entity System.
It's very easy to handle!

http://www.glbasic.com/forum/index.php?topic=1165.0

#### coolo

• Mr. Polyvector
• Posts: 140
• Coolo ist cool!
##### Re: Rotate around world axis.
« Reply #6 on: 2012-May-29 »
Code: GLBasic [Select]
X_MOVEMENT 0, 0, 0 //Reset position first
X_ROTATION 90, 1, 0, 0 //Rotate your world!
X_PUSHMATRIX //sets the origin to the current transformation matrix