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
16namespace Mercator {
17
18struct Plant;
19class Area;
20
21class SpeciesParameter;
22
23typedef std::map<std::string, SpeciesParameter> ParameterDict;
24
27 public:
29 float min;
31 float range;
32};
33
39class Species {
40 public:
43
46
48 ParameterDict m_parameters;
49};
50
57class 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);
89
91 Area* getArea() const {
92 return m_area;
93 }
94
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
Region of terrain surface which is modified.
Definition: Area.h:29
This is the core class for any area to be populated with vegetation.
Definition: Forest.h:57
std::vector< Species > PlantSpecies
STL vector of plant species in this forest.
Definition: Forest.h:71
const PlantStore & getPlants() const
Accessor for container of vegetation.
Definition: Forest.h:102
PlantSpecies & species()
Accessor for list of species in this forest.
Definition: Forest.h:96
std::map< int, PlantColumn > PlantStore
STL map to store a sparse array of PlantColumn objects.
Definition: Forest.h:68
~Forest()
Destruct a forest.
Area * getArea() const
Accessor for polygonal area.
Definition: Forest.h:91
Forest(unsigned long seed=0)
Construct a new forest with the given seed.
Definition: Forest.cpp:24
std::map< int, Plant > PlantColumn
STL map to store a sparse array of Plant objects.
Definition: Forest.h:62
void setArea(Area *a)
Assign an area to this forest.
Definition: Forest.cpp:38
void populate()
This function uses a pseudo-random technique to populate the forest with trees. This algorithm as the...
Definition: Forest.cpp:67
A set of constraints on a plant parameter.
Definition: Forest.h:26
float range
The range of values a parameter should take.
Definition: Forest.h:31
float min
The minimum value a parameter should take.
Definition: Forest.h:29
Data about a species of plant in a Forest.
Definition: Forest.h:39
ParameterDict m_parameters
Arbitrary parameters.
Definition: Forest.h:48
float m_probability
Probability that this species will occur at each grid node.
Definition: Forest.h:42
float m_deviation
Multiplyer for how deviated from the grid items should be.
Definition: Forest.h:45
A cache of random values.
Definition: RandCache.h:20