00001 #ifndef __Tile__
00002 #define __Tile__
00003
00004 #include "Log.h"
00005
00006
00007 #include <sys/stat.h>
00008
00009 #include <osg/StateSet>
00010 #include <osg/Texture2d>
00011
00012 class TerrainDatabase;
00013
00014
00015 class Tile
00016 {
00017 public:
00018 int size, imageSize, lod, x, y;
00019 int dataSize;
00020 byte* bitmap;
00021 float* heightmap;
00022 float pixelSize, diameter;
00023 osg::ref_ptr<osg::StateSet> stateset;
00024
00025 Tile(int _x, int _y, int _lod, TerrainDatabase* _database=0);
00026 ~Tile();
00027
00028 void Init(int _size, int _imageSize, int _x, int _y, int _lod, float _pixelSize=1., TerrainDatabase* _database=0);
00029 void ImportHeightmap(float* map, int stride=0);
00030 void AllocateHeightmap();
00031 void AllocateBitmap();
00032 void CreateStateSet();
00033
00034 float GetHeight(int _x, int _y);
00035 int LODMultiplier(int _lod);
00036
00037 private:
00038 TerrainDatabase* database;
00039 osg::ref_ptr<osg::Image> terrainImage, normalImage, baseImage;
00040
00041
00042 Log myLog;
00043 };
00044
00045 #endif