Mercator
|
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. | |
Public Member Functions | |
Forest (unsigned long seed=0) | |
Construct a new forest with the given seed. | |
~Forest () | |
Destruct a forest. More... | |
Area * | getArea () const |
Accessor for polygonal area. | |
PlantSpecies & | species () |
Accessor for list of species in this forest. | |
const PlantStore & | getPlants () const |
Accessor for container of vegetation. More... | |
void | setArea (Area *a) |
Assign an area to this forest. | |
void | populate () |
This function uses a pseudo-random technique to populate the forest with trees. This algorithm as the following essental properties: More... | |
Private Attributes | |
Area * | m_area |
Area of terrain affected by the presence of this forest. | |
PlantSpecies | m_species |
List of species in this forest. | |
PlantStore | m_plants |
2D spatial container with all the vegetation instances in. | |
unsigned long | m_seed |
Seed value used to initialise the random number generator. | |
RandCache | m_randCache |
Cache for optimising random number generation. | |
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 |
STL map to store a sparse array of Plant objects.
Integer key is effectively used as an index.
typedef std::map<int, PlantColumn> Mercator::Forest::PlantStore |
STL map to store a sparse array of PlantColumn objects.
The end effect is a sparse two dimensional array of plant objects which can be efficiently queried and scanned using STL iterators.
Mercator::Forest::~Forest | ( | ) |
Destruct a forest.
All contained vegetation is lost, so references to contained vegetation must not be maintained if this is likely to occur.
|
inline |
Accessor for container of vegetation.
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.
References Mercator::Effector::bbox(), Mercator::Area::contains(), m_area, Mercator::Species::m_deviation, Mercator::Species::m_parameters, m_plants, Mercator::Species::m_probability, m_randCache, m_species, Mercator::Plant::setDisplacement(), Mercator::Plant::setOrientation(), Mercator::Plant::setParameter(), and species().