mercator 0.4.0
A terrain generation library for the Worldforge system.
|
This is the core class for any area to be populated with vegetation. More...
#include <Forest.h>
Public Types | |
typedef std::map< int, Plant > | PlantColumn |
STL map to store a sparse array of Plant objects. More... | |
typedef std::map< int, PlantColumn > | PlantStore |
STL map to store a sparse array of PlantColumn objects. More... | |
typedef std::vector< Species > | PlantSpecies |
STL vector of plant species in this forest. More... | |
Public Member Functions | |
Forest (unsigned long seed=0) | |
Construct a new forest with the given seed. More... | |
~Forest () | |
Destruct a forest. More... | |
Area * | getArea () const |
Accessor for polygonal area. More... | |
PlantSpecies & | species () |
Accessor for list of species in this forest. More... | |
const PlantStore & | getPlants () const |
Accessor for container of vegetation. More... | |
void | setArea (Area *a) |
Assign an area to this forest. More... | |
void | populate () |
This function uses a pseudo-random technique to populate the forest with trees. This algorithm as the following essental properties: More... | |
This is the core class for any area to be populated with vegetation.
Each instance of vegetation is represented by the Plant class, and are stored in a 2 dimensional mapping container, which allows the entire contents to be iterated, or a given square two dimenstional area to be examined using the STL map API.
typedef std::map<int, Plant> Mercator::Forest::PlantColumn |
typedef std::vector<Species> Mercator::Forest::PlantSpecies |
typedef std::map<int, PlantColumn> Mercator::Forest::PlantStore |
|
explicit |
Construct a new forest with the given seed.
Definition at line 24 of file Forest.cpp.
|
default |
Destruct a forest.
All contained vegetation is lost, so references to contained vegetation must not be maintained if this is likely to occur.
|
inline |
|
inline |
void Mercator::Forest::populate | ( | ) |
This function uses a pseudo-random technique to populate the forest with trees. This algorithm as the following essental properties:
This function will have no effect if the area defining the forest remains uninitialised. Any previously generated contents are erased. For each instance a new seed is used to ensure it is repeatable, and height, displacement and orientation are calculated.
Definition at line 67 of file Forest.cpp.
References Mercator::Effector::bbox(), Mercator::Area::contains(), Mercator::Plant::m_displacement, Mercator::Plant::m_orientation, and species().
void Mercator::Forest::setArea | ( | Area * | a | ) |
Assign an area to this forest.
Definition at line 38 of file Forest.cpp.
|
inline |
Accessor for list of species in this forest.
Definition at line 96 of file Forest.h.
Referenced by populate().