00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef LILITH_TERRAIN_DECOR_INCLUDED
00024 #define LILITH_TERRAIN_DECOR_INCLUDED
00025
00026 #include "terrainmesh.h"
00027 #include "../grinliz/glcontainer.h"
00028
00029
00030 #ifdef _MSC_VER
00031 #pragma warning( disable : 4786 ) // Debugger truncating names.
00032 #endif
00033 #include <map>
00034
00035 namespace lilith3d
00036 {
00037 class TreeMesh;
00038 class TreeResource;
00039 class FoliageMesh;
00040
00041
00046 class TerrainDecor : public TerrainListener
00047 {
00048 public:
00049 TerrainDecor();
00050 virtual ~TerrainDecor();
00051
00052 virtual void TerrainChange( const grinliz::Rectangle2I& vertexBounds )
00053 {
00054 Update( vertexBounds );
00055 }
00056
00057
00058 private:
00059 void Update( const grinliz::Rectangle2I& vertex );
00060 void UpdateTrees( const grinliz::Rectangle2I& vertex );
00061 void UpdateFoliage( const grinliz::Rectangle2I& vertex );
00062 const TreeResource* ShouldHaveTree( float zBase, int xIndex, int yIndex );
00063 const StaticResource* ShouldHaveFoliage( int patchX, int patchY );
00064
00065
00066
00067 grinliz::BitArray< lilith3d::VERTEXSIZE, lilith3d::VERTEXSIZE > forest;
00068 grinliz::BitArray< TerrainMesh::PATCHSIZE, TerrainMesh::PATCHSIZE > grassLand;
00069
00070
00071 grinliz::MapId< TreeMesh* > meshMap;
00072 grinliz::MapId< FoliageMesh* > foliageMap;
00073
00074 grinliz::Random rand;
00075 TerrainMesh* tmesh;
00076
00077 const TreeResource* trees[MAX_TREE_RESOURCE];
00078 const StaticResource* foliageResource[MAX_FOLIAGE_RESOURCE];
00079 int nTrees, nFoliage;
00080 };
00081 };
00082
00083 #endif
00084