Mercator
Public Types | Public Member Functions | Private Attributes | List of all members
Mercator::Forest Class Reference

This is the core class for any area to be populated with vegetation. More...

#include <Forest.h>

Public Types

typedef std::map< int, PlantPlantColumn
 STL map to store a sparse array of Plant objects. More...
 
typedef std::map< int, PlantColumnPlantStore
 STL map to store a sparse array of PlantColumn objects. More...
 
typedef std::vector< SpeciesPlantSpecies
 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...
 
AreagetArea () const
 Accessor for polygonal area.
 
PlantSpeciesspecies ()
 Accessor for list of species in this forest.
 
const PlantStoregetPlants () 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

Aream_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.
 

Detailed Description

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.

Member Typedef Documentation

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.

Constructor & Destructor Documentation

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.

Member Function Documentation

const PlantStore& Mercator::Forest::getPlants ( ) const
inline

Accessor for container of vegetation.

Returns
A const reference to the container.
void Mercator::Forest::populate ( )

This function uses a pseudo-random technique to populate the forest with trees. This algorithm as the following essental properties:

  • It is repeatable. It can be repeated on the client and the server, and give identical results.
  • It is location independant. It gives the same results even if the forest is in a different place.
  • It is shape and size independant. A given area of the forest is the same even if the borders of the forest change.
  • It is localisable. It is possible to only partially populate the the forest, and still get the same results in that area.

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().


The documentation for this class was generated from the following files: