mercator  0.4.0
A terrain generation library for the Worldforge system.
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 "RandCache.h"
9 
10 #include <wfmath/axisbox.h>
11 #include <wfmath/polygon.h>
12 
13 #include <map>
14 #include <string>
15 
16 namespace Mercator {
17 
18 struct Plant;
19 class Area;
20 
21 class SpeciesParameter;
22 
23 typedef std::map<std::string, SpeciesParameter> ParameterDict;
24 
27  public:
29  float min;
31  float range;
32 };
33 
39 class Species {
40  public:
43 
45  float m_deviation;
46 
48  ParameterDict m_parameters;
49 };
50 
57 class Forest {
58  public:
62  typedef std::map<int, Plant> PlantColumn;
63 
68  typedef std::map<int, PlantColumn> PlantStore;
69 
71  typedef std::vector<Species> PlantSpecies;
72  private:
73  //TODO: store as value, not pointer
75  Area* m_area;
76 
78  PlantSpecies m_species;
80  PlantStore m_plants;
82  unsigned long m_seed;
84  RandCache m_randCache;
85 
86  public:
87  explicit Forest(unsigned long seed = 0);
88  ~Forest();
89 
91  Area* getArea() const {
92  return m_area;
93  }
94 
96  PlantSpecies & species() {
97  return m_species;
98  }
99 
102  const PlantStore & getPlants() const {
103  return m_plants;
104  }
105 
106  void setArea(Area* a);
107 
108  void populate();
109 };
110 
111 }
112 
113 #endif // MERCATOR_FOREST_H
A cache of random values.
Definition: RandCache.h:19
Area * getArea() const
Accessor for polygonal area.
Definition: Forest.h:91
PlantSpecies & species()
Accessor for list of species in this forest.
Definition: Forest.h:96
float range
The range of values a parameter should take.
Definition: Forest.h:31
Data about a species of plant in a Forest.
Definition: Forest.h:39
ParameterDict m_parameters
Arbitrary parameters.
Definition: Forest.h:48
float m_deviation
Multiplyer for how deviated from the grid items should be.
Definition: Forest.h:45
A set of constraints on a plant parameter.
Definition: Forest.h:26
std::map< int, PlantColumn > PlantStore
STL map to store a sparse array of PlantColumn objects.
Definition: Forest.h:68
float m_probability
Probability that this species will occur at each grid node.
Definition: Forest.h:42
std::vector< Species > PlantSpecies
STL vector of plant species in this forest.
Definition: Forest.h:71
This is the core class for any area to be populated with vegetation.
Definition: Forest.h:57
const PlantStore & getPlants() const
Accessor for container of vegetation.
Definition: Forest.h:102
float min
The minimum value a parameter should take.
Definition: Forest.h:29
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:62