VanB's method is great if you need an accurate planetary simulation. However, if you don't need accuracy and just need one object to orbit another, then I would suggest using a spherical co-ordinate system.
Instead of using cartesian co-ordinates (x, y & z) that DBPro uses, you supply a lattitude, longtitude and radius. It is then a simple case of increasing one or both of lattitude and longtitude and you would get an orbital function.
Of course DBP needs its co-ordinates to be cartesian so you would need to have a spherical to cartesian co-ordinate conversion function.
I have a Sun, Planet and Moon demo somewhere, give me a minute ....
Here you go:
`Orbit function
`======================
`©Scraggle
`======================
`27th July 2010
`Create Objects
#constant cPLANET 1
#constant cMOON 2
#constant cSUN 3
make object sphere cPLANET, 20
make object sphere cMOON, 10
make object sphere cSUN, 50
color object cPLANET, rgb( 0, 255, 0 )
color object cMOON, rgb( 128, 128, 128 )
color object cSUN, rgb( 255, 255, 0 )
position object cSUN, 0, 0, 0
position camera 0, 0, 0, -200
point camera 0, 0, 0, 0
`Create UDT's
type vect
x as float
y as float
z as float
endtype
type satellite
theta as float
phi as float
radius as float
speed as float
endtype
`set global variables
global coords as vect
global planet as satellite
global moon as satellite
`initialse variables for planet and moon
planet.Theta = 0.0
planet.Phi = 45.0
planet.Radius = 75.0
planet.Speed = 1.0
moon.Theta = 0.0
moon.Phi = 0.0
moon.Radius = 20.0
moon.Speed = 5.0
sync on
sync rate 60
do
//convert the spherical co-ordinates to cartesian
spherical2cartesian( planet.Theta, planet.Phi, planet.Radius )
//increase the orbit position
planet.Theta = wrapvalue(planet.Theta + planet.Speed)
//orbit the planet
position object cPLANET, object position x(cSUN) + coords.x, object position y(cSUN) + coords.y, object position z(cSUN) + coords.z
//similar code for the moon
spherical2cartesian( moon.Theta, moon.Phi, moon.Radius )
moon.Theta = wrapvalue(moon.Theta + moon.Speed)
position object cMOON, object position x(cPLANET) + coords.x, object position y(cPLANET) + coords.y, object position z(cPLANET) + coords.z
sync
loop
end
`Convert spherical coordinates to cartesian
function spherical2cartesian( theta as float, phi as float, radius as float )
coords.x = radius * sin(theta) * cos(phi)
coords.y = radius * sin(theta) * sin(phi)
coords.z = radius * cos(theta)
endfunction