terraindecor.h

00001 /*--License:
00002         Lilith 3D Engine
00003         Copyright Lee Thomason (Grinning Lizard Software) 2002-2004
00004         www.grinninglizard.com/lilith
00005 
00006         This program is free software; you can redistribute it and/or
00007         modify it under the terms of the GNU General Public License
00008         as published by the Free Software Foundation; either version 2
00009         of the License, or (at your option) any later version.
00010 
00011         This program is distributed in the hope that it will be useful,
00012         but WITHOUT ANY WARRANTY; without even the implied warranty of
00013         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014         GNU General Public License for more details.
00015 
00016         You should have received a copy of the GNU General Public License
00017         along with this program; if not, write to the Free Software
00018         Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020         The full text of the license can be found in license.txt
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         // Where the forest is located! Never changes...trees leave of come it 
00066         // depending on the altitude.
00067         grinliz::BitArray< lilith3d::VERTEXSIZE, lilith3d::VERTEXSIZE > forest;
00068         grinliz::BitArray< TerrainMesh::PATCHSIZE, TerrainMesh::PATCHSIZE >   grassLand;
00069 
00070         // Decor is the owner of this memory! Be sure to delete.
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 

Generated on Fri Mar 23 19:36:22 2007 for Lilith3D by  doxygen 1.5.1-p1