Main Page   Class Hierarchy   Compound List   File List   Compound Members  

Plants.h

00001 //
00002 // Plants.h
00003 //
00004 // Copyright (c) 2001 Virtual Terrain Project
00005 // Free for all uses, see license.txt for details.
00006 //
00007 
00008 #ifndef PLANTSH
00009 #define PLANTSH
00010 
00011 #include "Projections.h"
00012 #include "Array.h"
00013 #include "Array.inl"
00014 #include "MathTypes.h"
00015 
00016 class vtPlantDensity
00017 {
00018 public:
00019     char    *m_common_name;
00020     float   m_plant_per_m2;
00021 
00022     int     m_list_index;       // for faster lookup
00023 
00024     float   m_amount;           // these two fields are using during the
00025     int     m_iNumPlanted;      // plant distribution process
00026 };
00027 
00028 class vtBioType
00029 {
00030 public:
00031     vtBioType();
00032     ~vtBioType();
00033 
00034     void AddPlant(int i, const char *common_name, float plant_per_m2);
00035 
00036     Array<vtPlantDensity *> m_Densities;
00037 };
00038 
00039 class vtBioRegion
00040 {
00041 public:
00042     vtBioRegion();
00043     ~vtBioRegion();
00044 
00045     bool Read(const char *fname);
00046     bool Write(const char *fname);
00047     void AddType(vtBioType *bt) { m_Types.Append(bt); }
00048 
00049     Array<vtBioType *> m_Types;
00050 };
00051 
00052 class vtPlantAppearance
00053 {
00054 public:
00055     vtPlantAppearance();
00056     vtPlantAppearance(bool billboard, const char *filename, float width,
00057         float height, float shadow_radius, float shadow_darkness);
00058     virtual ~vtPlantAppearance();
00059 
00060     bool    m_bBillboard;
00061     char    *m_filename;
00062     float   m_width;
00063     float   m_height;
00064     float   m_shadow_radius;
00065     float   m_shadow_darkness;
00066     static float s_fTreeScale;
00067 };
00068 
00069 class vtPlantSpecies {
00070 public:
00071     vtPlantSpecies();
00072     virtual ~vtPlantSpecies();
00073 
00074     // copy
00075     vtPlantSpecies &operator=(const vtPlantSpecies &v);
00076 
00077     void SetSpecieID(short SpecieID) { m_iSpecieID = SpecieID; }
00078     short GetSpecieID() const { return m_iSpecieID; }
00079 
00080     void SetCommonName(const char *CommonName);
00081     char *GetCommonName() const { return m_szCommonName; }
00082 
00083     void SetSciName(const char *SciName);
00084     char *GetSciName() const { return m_szSciName; }
00085 
00086     void SetMaxHeight(float f) { m_fMaxHeight = f; }
00087     float GetMaxHeight() const { return m_fMaxHeight; }
00088 
00089     virtual void AddAppearance(bool billboard, const char *filename,
00090         float width, float height, float shadow_radius, float shadow_darkness)
00091     {
00092         vtPlantAppearance *pApp = new vtPlantAppearance(billboard, filename,
00093             width, height, shadow_radius, shadow_darkness);
00094         m_Apps.Append(pApp);
00095     }
00096 
00097     int NumAppearances() const { return m_Apps.GetSize(); }
00098     vtPlantAppearance *GetAppearance(int i) const { return m_Apps[i]; }
00099 
00100 protected:
00101     short   m_iSpecieID;
00102     char    *m_szCommonName;
00103     char    *m_szSciName;
00104     float   m_fMaxHeight;
00105     Array<vtPlantAppearance*> m_Apps;
00106 };
00107 
00108 
00109 class vtPlantList
00110 {
00111 public:
00112     vtPlantList();
00113     virtual ~vtPlantList();
00114 
00115     bool Read(const char *fname);
00116     bool Write(const char *fname);
00117 
00118     void LookupPlantIndices(vtBioType *pvtBioType);
00119     int NumSpecies() const { return m_Species.GetSize();  }
00120     vtPlantSpecies *GetSpecies(int i) const
00121     {
00122         if (i >= 0 && i < m_Species.GetSize())
00123             return m_Species[i];
00124         else
00125             return NULL;
00126     }
00127     int GetSpeciesIdByCommonName(const char *name);
00128     virtual void AddSpecies(int SpecieID, const char *common_name,
00129         const char *SciName, float max_height);
00130 
00131 protected:
00132     Array<vtPlantSpecies*> m_Species;
00133 };
00134 
00135 
00136 struct vtPlantInstance {
00137     DPoint2 m_p;
00138     float size;
00139     short species_id;
00140 };
00141 
00142 class vtPlantInstanceArray : public Array<vtPlantInstance>
00143 {
00144 public:
00145     void AddInstance(DPoint2 &pos, float size, short species_id);
00146 
00147     bool ReadVF(const char *fname);
00148     bool WriteVF(const char *fname);
00149 
00150     vtProjection m_proj;
00151 };
00152 
00153 // helper
00154 char *newstring(const char *str);
00155 
00156 #endif

Generated at Fri Aug 17 14:40:42 2001 for vtdata library by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000