"simple" World rotation

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Guest

"simple" World rotation

Post 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
mepcotterell
Posts: 10
Joined: Thu Dec 29, 2005 2:42 pm

Post 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
Edwart
Posts: 46
Joined: Fri Dec 30, 2005 12:29 pm

Post 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
mepcotterell
Posts: 10
Joined: Thu Dec 29, 2005 2:42 pm

Post by mepcotterell »

well, first... are the planets going to rotate arounf the spaceship? or around a certain point in space?
Edwart
Posts: 46
Joined: Fri Dec 30, 2005 12:29 pm

Post 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.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post 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.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Edwart
Posts: 46
Joined: Fri Dec 30, 2005 12:29 pm

Post by Edwart »

thank you for your help.

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