Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7468 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
May 1, 2006, 11:06:09 PM (19 years ago)
Author:
patrick
Message:

orxonox: reading through the code and adjusting here and there, whatever dropps in to my eye

Location:
trunk/src/lib/graphics/importer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/importer/height_map.cc

    r7467 r7468  
    1111   ### File Specific:
    1212   main-programmer: bottac@ee.ethz.ch
     13
     14   review: patrick boenzli, patrick@orxonox.ethz.ch
    1315*/
    1416
     
    3133
    3234
     35/**
     36 * default constructor
     37 *  @param i1
     38 */
    3339Tile::Tile(int i1, int j1, int i2, int j2, HeightMap* hm )
    3440{
     
    3743  lowResModel  = new VertexArrayModel();
    3844
    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
    4249
    4350Tile::~Tile()
    4451{
    45   delete highResModel;
    46   delete lowResModel;
    47 }
     52  if( highResModel)
     53    delete highResModel;
     54  if( lowResModel)
     55    delete lowResModel;
     56}
     57
    4858
    4959void Tile::draw()
    5060{
    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)
    6169  {
    6270    this->drawLowRes();
    6371  }
    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
    7974
    8075/*
     
    9388        #define normalVectorField hm->normalVectorField
    9489
    95   hmref = hm; // FIXME
     90  heightMapReference = hm; // FIXME
    9691
    9792  this->x = hm->offsetX + (heightMap->h - ((i1+i2)/2))*scaleX;
  • trunk/src/lib/graphics/importer/height_map.h

    r7467 r7468  
    2323#define tileSize     64
    2424
     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
    2530class SDL_Surface;
    2631class Vector;
     
    4247
    4348    void draw();
    44     void drawHighRes();
    45     void drawLowRes();
     49    inline void drawHighRes() { highResModel->draw(); }
     50    inline void drawLowRes() { lowResModel->draw(); }
    4651
    4752
     
    5661
    5762  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;                             //!<
    6167    int                                        highRes;                           //!<
    6268    int                                        lowRes;                            //!<
Note: See TracChangeset for help on using the changeset viewer.