Changeset 7468 in orxonox.OLD for trunk/src/lib/graphics
- Timestamp:
- May 1, 2006, 11:06:09 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/height_map.cc
r7467 r7468 11 11 ### File Specific: 12 12 main-programmer: bottac@ee.ethz.ch 13 14 review: patrick boenzli, patrick@orxonox.ethz.ch 13 15 */ 14 16 … … 31 33 32 34 35 /** 36 * default constructor 37 * @param i1 38 */ 33 39 Tile::Tile(int i1, int j1, int i2, int j2, HeightMap* hm ) 34 40 { … … 37 43 lowResModel = new VertexArrayModel(); 38 44 39 this->load(i1,j1,i2,j2,hm,highResModel,4); 40 this->load(i1,j1,i2,j2,hm,lowResModel, 8); 41 } 45 this->load(i1, j1, i2, j2, hm, highResModel,4); 46 this->load(i1, j1, i2, j2, hm, lowResModel, 8); 47 } 48 42 49 43 50 Tile::~Tile() 44 51 { 45 delete highResModel; 46 delete lowResModel; 47 } 52 if( highResModel) 53 delete highResModel; 54 if( lowResModel) 55 delete lowResModel; 56 } 57 48 58 49 59 void Tile::draw() 50 60 { 51 // This Draws the LOD's 52 //FIXME 53 float cameraDistance = (State::getCameraNode()->getAbsCoor() - Vector(this->x, hmref->offsetY , this->z) ).len(); 54 if(cameraDistance < 0) 55 cameraDistance = -cameraDistance; 56 if(cameraDistance > 5000 ) 57 { 58 return; 59 } 60 else if (cameraDistance >= 1000 ) 61 // draw the tile depending on the distance from the camera with different LOD (level of details) 62 float cameraDistance = fabs((State::getCameraNode()->getAbsCoor() - Vector(this->x, heightMapReference->offsetY , this->z) ).len()); 63 64 if (cameraDistance < HM_LOD_HIGH_RES ) 65 { 66 this->drawHighRes(); 67 } 68 else if( cameraDistance < HM_LOD_LOW_RES) 61 69 { 62 70 this->drawLowRes(); 63 71 } 64 else 65 { 66 this->drawHighRes(); 67 } 68 } 69 70 void Tile::drawHighRes() 71 { 72 highResModel->draw(); 73 } 74 75 void Tile::drawLowRes() 76 { 77 lowResModel->draw(); 78 } 72 } 73 79 74 80 75 /* … … 93 88 #define normalVectorField hm->normalVectorField 94 89 95 h mref= hm; // FIXME90 heightMapReference = hm; // FIXME 96 91 97 92 this->x = hm->offsetX + (heightMap->h - ((i1+i2)/2))*scaleX; -
trunk/src/lib/graphics/importer/height_map.h
r7467 r7468 23 23 #define tileSize 64 24 24 25 //!< define the LOD level distances. later this could be dynamicaly adjusted 26 #define HM_LOD_LOW_RES 5000 //!< low resolution unless farther away than LOW_RES 27 #define HM_LOD_HIGH_RES 1000 28 29 25 30 class SDL_Surface; 26 31 class Vector; … … 42 47 43 48 void draw(); 44 void drawHighRes();45 void drawLowRes();49 inline void drawHighRes() { highResModel->draw(); } 50 inline void drawLowRes() { lowResModel->draw(); } 46 51 47 52 … … 56 61 57 62 private: 58 HeightMap* hmref; //!< 59 VertexArrayModel* highResModel; //!< 60 VertexArrayModel* lowResModel; //!< 63 VertexArrayModel* highResModel; //!< heigh resolution model of the tile 64 VertexArrayModel* lowResModel; //!< low resolution model of the tile 65 66 HeightMap* heightMapReference; //!< 61 67 int highRes; //!< 62 68 int lowRes; //!<
Note: See TracChangeset
for help on using the changeset viewer.