tags:

views:

211

answers:

1

I'm trying to make a basic model of the solar system in Direct X. I want to have the planets orbit the sun and the moon orbit the planets. So I have the planet/star/moon which takes a pointer to it's parent position vector. From that, how would I be able to make the object orbit at a set speed?

So for example the moon would have a pointer to the earth's position vector and a distance to stay from the earth. I'd need the moon to orbit the earth over 24 hours (or any time frame, I'm sure I would be able to adjust that myself). Similarly the earth would have a pointer to the sun's position and would rotate around that over 365 days.

I just don't know how to work out how to work out the orbital position.

+2  A: 

Try this thread for ideas:

http://stackoverflow.com/questions/1703844/making-an-object-orbit-a-fixed-point-in-directx

As an aside: Be warned graphics hardware uses single precision floats. Depending on the scales involved you may find you run out of precision quite quickly on something the scale of the solar system. If this happens don't forget you can sort object groups by z and then render them at a large distance but with full, local, Z-buffer precision. You then need to clear the Z0buffer and draw the next local group forward.

Goz
Thank you. I'd noticed that topic but I was confused about how to modify it for a position that was not 0,0,0. I can't work out in that code where the position is, but I'm sure I will figure it out and I'll post in here what I eventually come up with.
Jacob