Solar System in 3d (part 1)

NOTE: THE SECOND (AND BEST) PART OF THIS POST IS NOW AVAILABLE HERE.

# Solar System in 3d (part 1)

I'm keen to start a new project now that JPARSEC is mature and no more great new things are to be added to it, at least for now. I always wanted to learn 3d programming so the natural way is to develop a program to simulate the Solar System in 3d, including the terrain of planetary bodies.

From time to time I have studied some simple pieces of code from other people, done mainly using Java 3d. Java 3d is an old 3d library that cannot handle important things like a proper lighting and shadow system. Java 3d is also very slow in some GPUs (mainly NVidia). Other libraries I've seen are not stable enough or properly documented (I'm thinking on Ardor3D), and since I'm new to this world I really need a library well documented to let me work confidently, without having troubles from the beginning with the crude OpenGL library, which is hard to use.

## Which 3d library ?

The main two libraries I came around are libGDX and JMonkeyEngine. The first one is mainly for 2d games (3d is in progress), and JMonkeyEngine is a mature 3d engine. So I have decided to start using JMonkey for this development. JMonkey's examples are clear and the wiki explains with good detail how things should be done.

The first milestone in this project is to create a realistic rendering of the surface of Mars. The program should allow one to travel around the planet using high resolution data from MOLA, and the colors should be realistic despite the MDIM data from Viking is in B&W. After that, the plan is to improve the program with some options (to search for features, select the planet+satellites system, and so on). Only after having an almost finished program I would go for other bodies to render them also in high resolution.

## Starting

A key reference to render Mars in 3d using Java is the work by Mike Jacobs using Java 3d. The program made by him lacks some features like a continuos level of detail (CLOD) squeme, but shows how to read MOLA data, construct the mesh, and calculate the normals and basic lighting. As it was written it can be used to render little portions of the planet with high detail. Since everything is copied to RAM memory a large region cannot be rendered.

My first approach was to extend this Java 3d code, so I simplified the code and made some improvements. One was to allow a resolution reduction factor to render a more extended region with less detail. This also allowed to include a low resolution version of the Mars elevation data to render an extended region with little detail. Another modification I did allow to render the surface considering the spherical distortion of the planet. These changes were useful to obtain better renderings, but the impossibility of travelling around the complete planet with a CLOD squeme is a very big limitation.

These images show the results that can be achieved with the modified version of the program by M. Jacobs. Elevation is exaggerated by a factor 3. Detail can be great, but the planet cannot be rendered completely at once, the program startup time is long, and realistic lighting is not possible. Source code for my modified version is available under request, but I prefer not to include it by now since the credit for this should go to Mike Jacobs, that clearly explains how he did this and provides his source code. NOTE: THE ORIGINAL SOURCE CODE IS NO LONGER AVAILABLE, SO I HAVE POSTED IT HERE.

In a forthcoming post I will start explaining the JMonkey version, detailing points like the CLOD squeme or how to efficiently store the planet data, among others. Eventually this new project will become a real application (even for Android!) or maybe I will integrate it inside JPARSEC.

## Discussion

   __    __   ____    ___    __ __
/____//____/\___\_\/_/ |_|/_//_/