pioneerspacesim/pioneer — Issue #924: Region Based Terrain Control (Solves uneven ground in cities issue)
Author: Ae-2222
Created: 2012-01-26 20:07:37+00:00
State: open

**Region Based Terrain Control**

**What it does**

- Allows terrain code to recognise arbitary regions defined with respect to a point.
- New regions can be added by any part of pioneer engine (including lua scripts - e.g. an area altered by a meteorite collision or explosion.)

**How it works**

- Each SBody has a vector of region centers and a vector of customisable data containing all the parameters needed by terrain code to depict the region.
- After region types are declared and activated the terrain code steps through the regions to find whether a point is inside.
- It is then free to use a combination of the terrain data without regions and it's own algorithms to come up with a new height/color value.

**Previous discussion** - I noticed this thread was referred to a few times.
http://www.spacesimcentral.com/forum/viewtopic.php?f=35&t=2111
Another thread: http://www.spacesimcentral.com/forum/viewtopic.php?f=35&t=1837 most of the questions about capabilities there can be answered positively now.

**Expense**
To identify a circular region the expense is a dot product which is trivial compared to fractal code.

**Extensions/To do**

- Cities
- how terrain works with layout
- outdoor/rough outposts - combination of original terrain and flattened
- industrialised cities
- can use tiled floor maps (images of roads/infrastructure or plain concrete tiles)
- nature reservations - simple to put an artificial beach/park in the middle

- Models
- currently the bases of the models protrude. If the model lua recorded the height of the base it can be buried/left as is depending on city type.
- large modular buildings are now possible without being buried

- Other uses
- terrain system can place massive features (planet deforming impacts with radial graben, polluted/desertified areas)
- lua can place mission relevant mined areas/explosion sites/depict sties of biological warfare

- Very long term
- Region trees - each region (city or cratered area) can have pointers to sub region vectors and so on. This will enable a lot of regions with only a few searches (e.g. 5 levels with 4 divisions = 4^5=1024 regions)
- Influence region based cities
- it's possible to have centers of influence e.g. wealth, industry, military, social and pick ground/building layout based on that.
- lua will then move the influence centers/their strength as polit/econ changes.

**Current state**

- terrain control is enabled for earth, but it is a matter of cut/paste to enable it for others. Terrain height/colour is rudimentary grey colour/blended/flat terrain - needs to be expanded (@s20Dan) depending on @robn 's (city tags?) city type code.

![](http://i.imgur.com/rcfAA.png)
Simple grey flat city area, with height blended perimeter. Shows colour and height control.
![](http://i.imgur.com/5DPyG.png)
Smaller city area.
![](http://i.imgur.com/hpO2p.png)
View from ground level. Bases of buildings protrude noticeably.