15#include <wfmath/MersenneTwister.h>
16#include <wfmath/intersect.h>
43static const float plant_chance = 0.04f;
44static const float plant_min_height = 5.f;
45static const float plant_height_range = 20.f;
70 WFMath::AxisBox<2> bbox(m_area->
bbox());
76 int lx = I_ROUND(bbox.lowCorner().x()),
77 ly = I_ROUND(bbox.lowCorner().y()),
78 hx = I_ROUND(bbox.highCorner().x()),
79 hy = I_ROUND(bbox.highCorner().y());
81 PlantSpecies::const_iterator I;
82 PlantSpecies::const_iterator Iend = m_species.end();
84 for(
int j = ly; j < hy; ++j) {
85 for(
int i = lx; i < hx; ++i) {
89 double prob = m_randCache(i,j);
90 I = m_species.begin();
91 for (; I != Iend; ++I) {
93 if (prob >
species.m_probability) {
102 rng.seed((
int)(prob / I->m_probability * 123456));
104 Plant & plant = m_plants[i][j];
107 (rng.rand<WFMath::CoordType>() - 0.5f) *
species.m_deviation,
108 (rng.rand<WFMath::CoordType>() - 0.5f) *
species.m_deviation);
109 plant.
m_orientation = WFMath::Quaternion(2, rng.rand<WFMath::CoordType>() * 2 * WFMath::numeric_constants<WFMath::CoordType>::pi());
Region of terrain surface which is modified.
bool contains(WFMath::CoordType x, WFMath::CoordType z) const
Determine if a point is contained by the shape of this area.
const WFMath::AxisBox< 2 > & bbox() const
Accessor for the bounding box of the geometric shape.
PlantSpecies & species()
Accessor for list of species in this forest.
~Forest()
Destruct a forest.
Forest(unsigned long seed=0)
Construct a new forest with the given seed.
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...
Data about a species of plant in a Forest.
This is the simple class for representing instances of vegetation.
WFMath::Quaternion m_orientation
Orientation of the vegetation.
WFMath::Point< 2 > m_displacement
Position of the vegetation relative to its grid point.