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 
76  PlantSpecies m_species;
78  PlantStore m_plants;
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 
94  PlantSpecies & species() {
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
A cache of random values.
Definition: RandCache.h:17
PlantStore m_plants
2D spatial container with all the vegetation instances in.
Definition: Forest.h:78
RandCache m_randCache
Cache for optimising random number generation.
Definition: Forest.h:82
Area * getArea() const
Accessor for polygonal area.
Definition: Forest.h:89
Definition: Area.cpp:20
PlantSpecies & species()
Accessor for list of species in this forest.
Definition: Forest.h:94
float range
The range of values a parameter should take.
Definition: Forest.h:30
unsigned long m_seed
Seed value used to initialise the random number generator.
Definition: Forest.h:80
Data about a species of plant in a Forest.
Definition: Forest.h:38
ParameterDict m_parameters
Arbitrary parameters.
Definition: Forest.h:47
float m_deviation
Multiplyer for how deviated from the grid items should be.
Definition: Forest.h:44
A set of constraints on a plant parameter.
Definition: Forest.h:25
std::map< int, PlantColumn > PlantStore
STL map to store a sparse array of PlantColumn objects.
Definition: Forest.h:67
PlantSpecies m_species
List of species in this forest.
Definition: Forest.h:76
float m_probability
Probability that this species will occur at each grid node.
Definition: Forest.h:41
std::vector< Species > PlantSpecies
STL vector of plant species in this forest.
Definition: Forest.h:70
This is the core class for any area to be populated with vegetation.
Definition: Forest.h:56
const PlantStore & getPlants() const
Accessor for container of vegetation.
Definition: Forest.h:100
float min
The minimum value a parameter should take.
Definition: Forest.h:28
Region of terrain surface which is modified.
Definition: Area.h:28
std::map< int, Plant > PlantColumn
STL map to store a sparse array of Plant objects.
Definition: Forest.h:61
Area * m_area
Area of terrain affected by the presence of this forest.
Definition: Forest.h:73