Mercator
Forest.h
00001 // This file may be redistributed and modified only under the terms of
00002 // the GNU General Public License (See COPYING for details).
00003 // Copyright (C) 2004 Alistair Riddoch
00004 
00005 #ifndef MERCATOR_FOREST_H
00006 #define MERCATOR_FOREST_H
00007 
00008 #include <Mercator/RandCache.h>
00009 
00010 #include <wfmath/axisbox.h>
00011 #include <wfmath/polygon.h>
00012 
00013 #include <map>
00014 
00015 namespace Mercator {
00016 
00017 class Plant;
00018 class Area;
00019 
00020 class SpeciesParameter;
00021 
00022 typedef std::map<std::string, SpeciesParameter> ParameterDict;
00023 
00025 class SpeciesParameter {
00026   public:
00028     float min;
00030     float range;
00031 };
00032 
00038 class Species {
00039   public:
00041     float m_probability;
00042 
00044     float m_deviation;
00045 
00047     ParameterDict m_parameters;
00048 };
00049 
00056 class Forest {
00057   public:
00061     typedef std::map<int, Plant> PlantColumn;
00062 
00067     typedef std::map<int, PlantColumn> PlantStore;
00068 
00070     typedef std::vector<Species> PlantSpecies;
00071   private:
00073     Area* m_area;
00074     
00076     PlantSpecies m_species;
00078     PlantStore m_plants;
00080     unsigned long m_seed;
00082     RandCache m_randCache;
00083 
00084   public:
00085     explicit Forest(unsigned long seed = 0);
00086     ~Forest();
00087 
00089     Area* getArea() const {
00090         return m_area;
00091     }
00092 
00094     PlantSpecies & species() {
00095         return m_species;
00096     }
00097 
00100     const PlantStore & getPlants() const {
00101         return m_plants;
00102     }
00103 
00104     void setArea(Area* a);
00105 
00106     void populate();
00107 };
00108 
00109 }
00110 
00111 #endif // MERCATOR_FOREST_H