Page 1 of 1

"simple" World rotation

Posted: Fri Dec 30, 2005 3:22 pm
by Guest
Hi,

i use the Irrlicht-Engine for a few houres and i am suppriesed what i can do in a few houres.
but i have one problem:
i created a Spaceship and a few planets.
it moves up and down and it works fine.
now i want to rotate the planets around the spaceship.

i have no idea how does it works. the plantes rotate around there own axes and not around the spaceship.
is there an easy way to implement a rotation of the "planets" around my playership?

Thank you very much
Edwart

Posted: Fri Dec 30, 2005 3:29 pm
by mepcotterell
if the orbits are pure circles and only rotate about the x,z x,y or z,y axis's then just update their positions from a certain point using trig given the distance from the planet to the center point is the radius from which you derive ur trig functions

Posted: Fri Dec 30, 2005 3:35 pm
by Edwart
yes i only must rotate around x and y.
but i dontunderstand your tip. sorry.
can you explain itplease a little bit easier?

Thanx Edwart

Posted: Fri Dec 30, 2005 3:39 pm
by mepcotterell
well, first... are the planets going to rotate arounf the spaceship? or around a certain point in space?

Posted: Fri Dec 30, 2005 3:53 pm
by Edwart
the planets should rotate around the spaceship!

just four your info:
for the movement forward and backward i change the positions of the planets. the position of the spaceship and the camera is every time the same.

Posted: Fri Dec 30, 2005 10:22 pm
by bitplane
I think I see what you're trying to do.. you need to get the distance between your ship and a planet, rotate it, then add it to your ships position. then i think you'll need to rotate your planet back round in the other direction.

Code: Select all

planet->setPosition( 
 (planet->getPosition() - ship->getPosition()).rotateXZBy(rotation) 
  + ship->getPosition());
planet->setRotation(vector3df(0,-rotation,0));
thats a pretty bad way of doing it. you should really have your planets standing still (or orbiting each other) and move your ship and camera around.

Posted: Sat Dec 31, 2005 9:10 am
by Edwart
thank you for your help.

ok, i will try to rotate the camera and the ship and not the univers :)