Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sphere World Implementation C++

What would be the best way to implement, store, and render spherical worlds, such as the ones in spore or infinity but without the in-between stages of spore, and multiple worlds ala infinity universe. Make no assumptions on how the planet itself is generated or its size/scale.

like image 521
Tom J Nowell Avatar asked Jan 23 '09 16:01

Tom J Nowell


2 Answers

For rendering, you'll need to use some sort of level-of-detail algorithm in order to seamlessly move from close to the planet's surface to far away. There are many dynamic LOD algorithms (see here). An older algorithm, called ROAM, can be adapted to handle spherical objects, or planets (spherical ROAM). Geometry clipmaps is a newer, more popular algorithm that can be adapted to spherical surfaces as well.

As for storing the data, you may want to look into procedural generation (depending on your needs) for texturing, heightmaps, etc. This is similar to how Infinity and Spore do things. You can read a little about procedural texturing here. Procedural heightmaps are simpler, depending on how complex/realistic you want your terrain. On the simplest level, you can simply displace your vertex height by a perlin noise function.

like image 134
thekidder Avatar answered Sep 20 '22 10:09

thekidder


If you are looking for something to store data about the surface in, you might look at HEALpix. It is software developed by the astronomical community specifically for mapping the sky (another spherical surface).

HEALpix creates a mesh that describes the position and size of the surface faces and assigns each one an ID. You can then use that ID as the key or index to access as much detail as you want about that particular level.

HEASpix provides methods to find neighboring surface areas and can give center and vertex positions for each mesh point.

It is a hierarchical mesh that allows you to subdivide each face as much as you want so you could in theory have parts of the mesh at low resolution and other parts at higher levels of detail if you wanted. It has the nice property that it is infinitely divisible (up to your memory limits) and each pixel of the grid at a given resolution has the same area as all the other ones at that resolution level.

The distribution package provides a lot of stuff that you probably won't need but the core libraries should be useful.

like image 32
dagorym Avatar answered Sep 20 '22 10:09

dagorym