Planets

How to start

 mySphere = new PSphere(100, 40, 1024, 512, *params);
 rendering = new initOgre();
 rendering->start();
 rendering->setSceneAndRun(mySphere);
 delete mySphere;
 rendering->cleanup();
 delete rendering;

The objects PSphere and ResourceParameter are the only things you need. To set up the Ogre 3D environment (as such the scene and the lights), the class initOgre can be used.

Designing the planet

ResourceParameter is the class containing all the information of the planet. This object can be generated by a graphical user interface or it could be even be built inside of a main function. It's a simple object containing variables and getter/setter methods. It has been thought that it can be expanded, if someone need other information to build the planet.

string terrainFirstColor;
string terrainSecondColor;
string waterFirstColor;
string waterSecondColor;
string mountainFirstColor;
string mountainSecondColor;
float waterFraction;
float radius;
int seed;
vector  frequency;
vector  amplitude;

Put objects on the planet

The planet offers a functionality that permits to put and manage objects on the planet. These objects can be virtual, that is objects that can not be seen (such resources like gas, really small things, ghosts or even big things that we don't want to show). Otherwise it's also possible to load already made 3D objects, in .MESH format, with the relative materials (.material files) and textures.
The PHspere class contains a list of ObjectInfo objects, and each of these objects, contain the following informations:

Planets

The function which let you put 3D objects (.MESH files) on the planet is attachMesh() of the class PSphere. You can check in any moment if an object with the same name has already been put on the planet with the function checkIfObjectIsIn().

Accessibility

The planet provides a functionality to know where the liquid part (usually water) is. This is usefull if someone want to interact with the planet, and need to know where the water is, for example to move objects on the surface (animals, vehicles etc.). The accessibility system is made through a binary grid, which says where the water is.

Planets

As in the previous image, the grid can be thought black and white, where the black part represents the water. To ask the planet where the water it has been provided the function checkAccessibility() where you can specify the position, and it returns a boolean value which indicates if there's water or not. Not only that ! The previous function says also if in a certain position there's already another object, so there's no possibility to put another one. So the returned value is true if there are no objects in the specified position.

Graphical User Interface

This project provides also a GUI which gives a user-frindly way to specify planet's parameters. This GUI has been created using QT. As the project is developed at the moment, the GUI starts immediately before generating the planet. So the code which starts the planet's rendering it's inside of the GUI main code. It can simply moved to another position if the use of the GUI is not desired. How the GUI works can be seen in the usage page.