Good times. A simple gravity simulator isn't too difficult get working.
Screenshots of my earlier work ('Planets') can be found here:
http://dandixon.us/programming/planets.htmWhat language will you be writing this in?
And turns out there's little difference between 2D and 3D as far as the math is concerned.
You're going to want to create a class for each body. This needs to have variables to store the X,Y,Z position and X,Y,Z velocity of each body along with the mass. Diameter, Color, Texture, etc... are all optional.
You'll start by either hard coding the initial positions and velocities or loading them from a file.
Then for each frame of the simulation you'll calculate the change in velocity of each body on every other body:
Here's some pseudo-code:
For A = 1 to Total#OfBodies
For B = 1 to Total#OfBodies
If A is not equal to B then
D = Distance between bodies A & B
Force = G * MassOfB / D * D
VelocityChange.X = VelocityChange.X + (Force * (X distance between bodies A & B) / D))
VelocityChange.Y = VelocityChange.Y + (Force * (Y distance between bodies A & B) / D))
VelocityChange.Z = VelocityChange.Z + (Force * (Z distance between bodies A & B) / D))
Next B
BodyAVelocity = BodyAVelocity + (Fv * TimeScale)
Next A
G = Gravity Constant
I use: 6.6725985 * (10 ^ (-11)) * (59736 * (10 ^ 20)) which is the 'real gravity constant in kg' * the mass of earth (since I store all masses where 1 = Earth)
Starting out you can just set G = 1 or .00001 or something like that.
TimeScale is the length of time that each frame represents. Again, just hardcode this to be 1.
Then once you've calculated each body's new velocity for that frame you add it to its current position:
For A = 1 to Total#OfBodies
BodyAPosition = BodyAPosition + (BodyAVelocity * TimeScale)
Next A
Then you draw the scene using the new positions that you just calculated.
Does that help? Just ask if you have any more questions. I'd enjoy seeing what you come up with.