Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7498 in orxonox.OLD for trunk


Ignore:
Timestamp:
May 3, 2006, 1:16:35 AM (19 years ago)
Author:
patrick
Message:

orxonox: finished first ruff cleanup. now its about the algorithms

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

Legend:

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

    r7497 r7498  
    328328
    329329
    330 
     330/**
     331 * constructor
     332 *  @param heightMapName file name of the height map
     333 */
    331334HeightMap::HeightMap(const std::string& heightMapName)
    332335    : VertexArrayModel()
     
    337340}
    338341
     342
     343/**
     344 * constructor
     345 *  @param heightMapName file name of the height map
     346 *  @param colorMapName file name of the color map
     347 */
    339348HeightMap::HeightMap(const std::string& heightMapName, const std::string& colorMapName)
    340349    : VertexArrayModel()
    341350{
    342 
    343351  this->init(heightMapName);
    344352
     
    355363    PRINTF(0)("Rmask: %i\n", this->colorMap->format->Rmask);
    356364    PRINTF(0)("Gmask: %i\n", this->colorMap->format->Gmask);
     365
     366    this->colors = (unsigned char *) colorMap->pixels;
     367    this->hasColourMap = true;
    357368  }
    358369  else
     370  {
    359371    PRINTF(0)("oops! couldn't load colorMap for some reason.\n");
    360 
    361 
    362 
    363   if(colorMap != NULL)
    364   {
    365     colors = (unsigned char *) colorMap->pixels;
    366     hasColourMap = true;
    367   }
    368   else
    369     hasColourMap = false;
    370 
    371 
    372   heights  = (unsigned char*) heightMap->pixels;
    373   shiftX = 0;
    374   shiftY = 0;
    375   shiftZ = 0;
    376 }
    377 
    378 
     372    this->hasColourMap = false;
     373  }
     374}
     375
     376
     377/**
     378 * deconstructor
     379 */
    379380HeightMap::~HeightMap()
    380381{
     
    430431
    431432  generateNormalVectorField();
    432 }
    433 
    434 
     433
     434  this->heights = (unsigned char*)heightMap->pixels;
     435}
     436
     437
     438/**
     439 * this function loads the heightmap by creatin tiles
     440 */
    435441void HeightMap::load()
    436442{
    437 
    438443  //Create a Dynamicly sized 2D-Array for Tiles
    439444  tiles =  new Tile** [heightMap->h/tileSize];
     
    450455    }
    451456  }
    452 
    453 }
    454 
    455 
    456 void HeightMap::draw()
     457}
     458
     459
     460/**
     461 * this function draws the height map
     462 */
     463void HeightMap::draw() const
    457464{
    458465  const PNode* camera = State::getCameraNode();
     
    473480    }
    474481  }
    475 
    476 }
     482}
     483
     484
     485/**
     486 * this function generates the normal vector field
     487 */
    477488void HeightMap::generateNormalVectorField()
    478489{
     
    485496    normalVectorField [i]= new (Vector [heightMap->w]);
    486497
    487 
    488 
    489 
    490498  // Initialize
    491499  for(int i=0; i< heightMap->h; i++)
     
    524532
    525533  }
    526 
    527 
    528 
    529 
    530 }
    531 
    532 
     534}
     535
     536
     537/**
     538 * scales the height map about a vector
     539 *  @param v scaling vector
     540 */
    533541void HeightMap::scale(Vector v)
    534542{
     
    539547}
    540548
     549
     550/**
     551 * sets the absolute coordinates of the height map
     552 *  @param v the moving vector
     553 */
    541554void HeightMap::setAbsCoor(Vector v)
    542555{
    543556  offsetX = v.x;
    544557  offsetY = v.y;
    545   offsetZ  = v.z;
    546 }
    547 
    548 
     558  offsetZ = v.z;
     559}
     560
     561
     562/**
     563 * returns the height at a given 2D coordinate
     564 *  @param x x coordinate of the height map (world space)
     565 *  @param y y coordinate of the height map (world space)
     566 *  @return the height (z)
     567 */
    549568float HeightMap::getHeight(float x, float y)
    550569{
    551 
    552570  x -= offsetX;
    553571  y -= offsetZ;
    554 
    555572
    556573  int xInt = (int)( x / scaleX);
     
    571588  float height = heights[yInt + (xInt)*heightMap->w]*scaleY;
    572589
    573 
    574590  float a = normalVectorField[(xInt)][yInt].x;
    575591  float b = normalVectorField [(xInt)][yInt].z;
  • trunk/src/lib/graphics/importer/height_map.h

    r7497 r7498  
    9292    void scale( Vector V);
    9393
    94     void draw();
     94    void draw() const;
    9595
    9696
Note: See TracChangeset for help on using the changeset viewer.