I've added a generic interface for physics, and made an implementation of it by using ODE. Since i already had some experience with ODE, everything went quite smoothly. The next step was to simulate a small spaceship with it.
My goal is to keep everything as realistic as possible - but without sacrificing playability. One of the main problems is related to speeds. The limit of light speed is approximately 300,000 km/s. If i want to stay coherent with that limit, playing in real-time, it would take 8 minutes to travel 1 AU (the distance between the sun and the Earth). If you were to start from one side of the solar system and travel on a planet of the other side, you could easily have to wait for one hour.
In addition, in real-time, many events which could be exciting become boring, because you'd have to wait from minutes to hours in order to see them. Sunrise, sunset, moonrise, eclipses, moving bodies in the sky.. are almost unnoticeable because happening very slowly. For this reason, i decided to keep the distances/speeds realistic, but to run the simulation a lot faster than in real-time: approximately 50x faster.
With that new time scale, travelling from the sun to the Earth is taking 10 seconds, which is much better for the player. In practise it is taking longer, because the ship has to accelerate/deccelerate.
Accelerations are another problem i had, and are more related to the ship's physics. Let's assume the ship is motionless in space near a station, and wants to accelerate until reaching up to light speed. The natural idea is to bind the keys to a constant acceleration force: pressing the "forward" key makes your ship accelerate in the forward direction (which increases the velocity, which in turn makes the ship advance faster and faster). Unfortunately we've got a major problem with this idea.
You see, if you use a small acceleration, it will take forever to reach light speed. If you use a high acceleration (so that you reach light speed in, say, 20 seconds), you will no longer be able to move precisely at small scales. In particular, you can forget any idea of navigating near the space station or at ground level on a planet.
My solution to this problem is to use a non-constant acceleration; in particular, an acceleration that is dependant on the velocity: the higher the velocity, the higher the acceleration. Reminds me of differencial equations, i don't know why..
Another problem is inertia. In space, there is no friction - so if you want to be realistic, if no force is applied, you should keep moving in the direction you were moving before, ad infinitum. In practise, if you start motionless on a planet and want to travel to another planet, you need to accelerate until light speed, then deccelerate. Because of inertia, this is extremely tricky. If you tried a realistic space simulator, you'll understand what i mean.
To counter inertia, i decided to change a bit the way the ship is controlled. The keys 1 to 9 are used to set a "target velocity". Your ship will keep going at that speed in whatever direction it is moving. After testing, i realized this is surprizingly easy to use and seems to be a good compromise between realism and playability. I also added some automatic friction to the mouse movement (controlling the ship's orientation) so that you do not spin forever.
The result is quite nice and easy to use: the player controls the ship orientation via the mouse (right mouse button is used to roll), while the only keys used to fly are the 1 to 9 keys to set the velocity. I think i'll post a video of that some day.
In other news, i've added a space station taken from the net. It's around 550k triangles, but the 3D engine handles it pretty well (100 fps on a geforce 6800, 200 fps on an ati X850). I haven't focused on the graphics yet, so no coherent lighting or advanced effect, but i thought it was looking quite nice (click for full screen image):