blitzbasic

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

Offline Richard Rae

  • Mr. Drawsprite
  • **
  • Posts: 79
    • View Profile
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

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 2241
  • Integrated Brain
    • View Profile
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...

I hope can help you...  :booze:

Offline Richard Rae

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

Offline mentalthink

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

Try to use this:

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

I´m not sure if this will works!!! :-[

Offline Richard Rae

  • Mr. Drawsprite
  • **
  • Posts: 79
    • View Profile
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.

Offline backslider

  • Prof. Inline
  • *****
  • Posts: 854
    • View Profile
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
visit our alpha gameplay demo of "Fränk'n'Hänk": http://www.devandart.com/games/fnh/index.html

Offline coolo

  • Mr. Polyvector
  • ***
  • Posts: 120
  • Coolo ist cool!
    • View Profile
    • programming with design
Re: Rotate around world axis.
« Reply #6 on: 2012-May-29 »
Code: [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

//draw your world here

X_POPMATRIX

I think this should be what you need.
That's no Bug, that's my project!

http://programming-with-design.at/