Mercator
Forest.h
1 // This file may be redistributed and modified only under the terms of
2 // the GNU General Public License (See COPYING for details).
3 // Copyright (C) 2004 Alistair Riddoch
4 
5 #ifndef MERCATOR_FOREST_H
6 #define MERCATOR_FOREST_H
7 
8 #include <Mercator/RandCache.h>
9 
10 #include <wfmath/axisbox.h>
11 #include <wfmath/polygon.h>
12 
13 #include <map>
14 
15 namespace Mercator {
16 
17 class Plant;
18 class Area;
19 
20 class SpeciesParameter;
21 
22 typedef std::map<std::string, SpeciesParameter> ParameterDict;
23 
26  public:
28  float min;
30  float range;
31 };
32 
38 class Species {
39  public:
42 
44  float m_deviation;
45 
47  ParameterDict m_parameters;
48 };
49 
56 class Forest {
57  public:
61  typedef std::map<int, Plant> PlantColumn;
62 
67  typedef std::map<int, PlantColumn> PlantStore;
68 
70  typedef std::vector<Species> PlantSpecies;
71  private:
74 
80  unsigned long m_seed;
83 
84  public:
85  explicit Forest(unsigned long seed = 0);
86  ~Forest();
87 
89  Area* getArea() const {
90  return m_area;
91  }
92 
95  return m_species;
96  }
97 
100  const PlantStore & getPlants() const {
101  return m_plants;
102  }
103 
104  void setArea(Area* a);
105 
106  void populate();
107 };
108 
109 }
110 
111 #endif // MERCATOR_FOREST_H
Mercator::Species::m_probability
float m_probability
Probability that this species will occur at each grid node.
Definition: Forest.h:41
Mercator::SpeciesParameter::range
float range
The range of values a parameter should take.
Definition: Forest.h:30
Mercator::Species
Data about a species of plant in a Forest.
Definition: Forest.h:38
Mercator::Forest::Forest
Forest(unsigned long seed=0)
Construct a new forest with the given seed.
Definition: Forest.cpp:24
Mercator::Forest::species
PlantSpecies & species()
Accessor for list of species in this forest.
Definition: Forest.h:94
Mercator::Forest::getArea
Area * getArea() const
Accessor for polygonal area.
Definition: Forest.h:89
Mercator::Forest::m_area
Area * m_area
Area of terrain affected by the presence of this forest.
Definition: Forest.h:73
Mercator::Species::m_deviation
float m_deviation
Multiplyer for how deviated from the grid items should be.
Definition: Forest.h:44
Mercator::Forest::populate
void populate()
This function uses a pseudo-random technique to populate the forest with trees. This algorithm as the...
Definition: Forest.cpp:69
Mercator::Area
Region of terrain surface which is modified.
Definition: Area.h:28
Mercator::Forest::PlantColumn
std::map< int, Plant > PlantColumn
STL map to store a sparse array of Plant objects.
Definition: Forest.h:61
Mercator::Forest::m_randCache
RandCache m_randCache
Cache for optimising random number generation.
Definition: Forest.h:82
Mercator::Forest
This is the core class for any area to be populated with vegetation.
Definition: Forest.h:56
Mercator::SpeciesParameter
A set of constraints on a plant parameter.
Definition: Forest.h:25
Mercator::Forest::m_seed
unsigned long m_seed
Seed value used to initialise the random number generator.
Definition: Forest.h:80
Mercator::Forest::~Forest
~Forest()
Destruct a forest.
Definition: Forest.cpp:35
Mercator::Species::m_parameters
ParameterDict m_parameters
Arbitrary parameters.
Definition: Forest.h:47
Mercator::SpeciesParameter::min
float min
The minimum value a parameter should take.
Definition: Forest.h:28
Mercator::Forest::m_plants
PlantStore m_plants
2D spatial container with all the vegetation instances in.
Definition: Forest.h:78
Mercator::Forest::getPlants
const PlantStore & getPlants() const
Accessor for container of vegetation.
Definition: Forest.h:100
Mercator::Forest::m_species
PlantSpecies m_species
List of species in this forest.
Definition: Forest.h:76
Mercator::Effector::bbox
const WFMath::AxisBox< 2 > & bbox() const
Accessor for the bounding box of the geometric shape.
Definition: Effector.h:46
Mercator::Plant::setDisplacement
void setDisplacement(const WFMath::Point< 2 > &d)
Set the displacement to a new value.
Definition: Plant.h:39
Mercator::Forest::PlantStore
std::map< int, PlantColumn > PlantStore
STL map to store a sparse array of PlantColumn objects.
Definition: Forest.h:67
Mercator::Forest::setArea
void setArea(Area *a)
Assign an area to this forest.
Definition: Forest.cpp:40
Mercator::Plant
This is the simple class for representing instances of vegetation.
Definition: Plant.h:19
Mercator::Plant::setOrientation
void setOrientation(const WFMath::Quaternion &o)
Set the orientation to a new value.
Definition: Plant.h:49
Mercator::Area::contains
bool contains(WFMath::CoordType x, WFMath::CoordType y) const
Determine if a point is contained by the shape of this area.
Definition: Area.cpp:251
Mercator::Forest::PlantSpecies
std::vector< Species > PlantSpecies
STL vector of plant species in this forest.
Definition: Forest.h:70
RandCache
A cache of random values.
Definition: RandCache.h:17
Mercator::Plant::setParameter
void setParameter(const std::string &, float)
Set a named parameter value for this plant.
Definition: Plant.h:64
ZeroSpiralOrdering
A spiral around 0,0.
Definition: RandCache.h:76