Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7497 in orxonox.OLD for trunk/src


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

constructor cleanup, some warning eliminated

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

Legend:

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

    r7496 r7497  
    326326
    327327
    328 HeightMap::HeightMap()
    329 {
    330 }
    331 
    332 
    333 HeightMap::HeightMap(const std::string& height_map_name = "")
     328
     329
     330
     331HeightMap::HeightMap(const std::string& heightMapName)
    334332    : VertexArrayModel()
    335333{
    336   this->setClassID(CL_HEIGHT_MAP, "HeightMap");
    337   heightMap =  IMG_Load(height_map_name.c_str());
    338   if(heightMap!=NULL)
    339   {
    340     /*
    341         WHAT about following checks:
    342     - image size (rectangular?)
    343     - image file type (bw?)
    344 
    345     */
    346 
    347     PRINTF(0)("loading Image %s\n", height_map_name.c_str());
    348     PRINTF(0)("width : %i\n", heightMap->w);
    349     PRINTF(0)("height : %i\n", heightMap->h);
    350     PRINTF(0)("%i Byte(s) per Pixel \n", heightMap->format->BytesPerPixel);
    351     PRINTF(0)("Rshift : %i\n", heightMap->format->Rshift);
    352     PRINTF(0)("Bshift: %i\n", heightMap->format->Bshift);
    353     PRINTF(0)("Gshift: %i\n", heightMap->format->Gshift);
    354     PRINTF(0)("Rmask: %i\n", heightMap->format->Rmask);
    355     PRINTF(0)("Gmask: %i\n", heightMap->format->Gmask);
    356   }
    357 
    358   else
    359     PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name.c_str());
    360 
    361 
    362   generateNormalVectorField();
    363 
    364   shiftX = 0;
    365   shiftY = 0;
    366   shiftZ = 0;
    367 
    368 }
    369 
    370 HeightMap::HeightMap(const std::string& height_map_name = NULL, const std::string& color_map_name = NULL)
     334  this->init(heightMapName);
     335
     336  this->colorMap = NULL;
     337}
     338
     339HeightMap::HeightMap(const std::string& heightMapName, const std::string& colorMapName)
    371340    : VertexArrayModel()
    372341{
    373   this->setClassID(CL_HEIGHT_MAP, "HeightMap");
    374 
    375   heightMap =  IMG_Load(height_map_name.c_str());
    376   if(heightMap!=NULL)
    377   {
    378 
    379     PRINTF(0)("loading Image %s\n", height_map_name.c_str());
    380     PRINTF(0)("width : %i\n", heightMap->w);
    381     PRINTF(0)("height : %i\n", heightMap->h);
    382     PRINTF(0)("%i Byte(s) per Pixel \n", heightMap->format->BytesPerPixel);
    383     PRINTF(0)("Rshift : %i\n", heightMap->format->Rshift);
    384     PRINTF(0)("Bshift: %i\n", heightMap->format->Bshift);
    385     PRINTF(0)("Gshift: %i\n", heightMap->format->Gshift);
    386     PRINTF(0)("Rmask: %i\n", heightMap->format->Rmask);
    387     PRINTF(0)("Gmask: %i\n", heightMap->format->Gmask);
    388   }
    389 
    390   else
    391     PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name.c_str());
    392 
    393 
    394   generateNormalVectorField();
    395 
    396   colorMap=NULL;
    397   if(color_map_name != "")
    398   {
    399     colorMap = IMG_Load(color_map_name.c_str());
    400   }
    401 
    402   if(colorMap != NULL)
    403   {
    404     PRINTF(0)("loading Image %s\n", color_map_name.c_str());
    405     PRINTF(0)("width : %i\n", colorMap->w);
    406     PRINTF(0)("height : %i\n", colorMap->h);
    407     PRINTF(0)("%i Byte(s) per Pixel \n", colorMap->format->BytesPerPixel);
    408     PRINTF(0)("Rshift : %i\n", colorMap->format->Rshift);
    409     PRINTF(0)("Bshift: %i\n", colorMap->format->Bshift);
    410     PRINTF(0)("Gshift: %i\n", colorMap->format->Gshift);
    411     PRINTF(0)("Rmask: %i\n", colorMap->format->Rmask);
    412     PRINTF(0)("Gmask: %i\n", colorMap->format->Gmask);
     342
     343  this->init(heightMapName);
     344
     345  this->colorMap = IMG_Load(colorMapName.c_str());
     346  if( this->colorMap != NULL)
     347  {
     348    PRINTF(0)("loading Image %s\n", colorMapName.c_str());
     349    PRINTF(0)("width : %i\n", this->colorMap->w);
     350    PRINTF(0)("height : %i\n", this->colorMap->h);
     351    PRINTF(0)("%i Byte(s) per Pixel \n", this->colorMap->format->BytesPerPixel);
     352    PRINTF(0)("Rshift : %i\n", this->colorMap->format->Rshift);
     353    PRINTF(0)("Bshift: %i\n", this->colorMap->format->Bshift);
     354    PRINTF(0)("Gshift: %i\n", this->colorMap->format->Gshift);
     355    PRINTF(0)("Rmask: %i\n", this->colorMap->format->Rmask);
     356    PRINTF(0)("Gmask: %i\n", this->colorMap->format->Gmask);
    413357  }
    414358  else
     
    438382  delete colorMap;
    439383
    440 
    441384  for(int i=0;i <    heightMap->h/tileSize ; i++)
    442385  {
     
    450393  delete[] tiles;
    451394
    452 
    453 
    454 
    455 
    456395  for(int i=0;i<heightMap->h;i++)
    457396    delete[] normalVectorField [i];
    458397  delete[] normalVectorField;
    459 
    460 
    461 
    462 
    463 
    464 
    465 
    466 }
     398}
     399
     400
     401
     402void HeightMap::init(const std::string& heightMapName)
     403{
     404  this->setClassID(CL_HEIGHT_MAP, "HeightMap");
     405
     406  this->shiftX = 0;
     407  this->shiftY = 0;
     408  this->shiftZ = 0;
     409
     410  heightMap =  IMG_Load(heightMapName.c_str());
     411  if( heightMap != NULL)
     412  {
     413    /*
     414    WHAT about following checks:
     415    - image size (rectangular?)
     416    - image file type (bw?)
     417    */
     418    PRINTF(1)("loading Image %s\n", heightMapName.c_str());
     419    PRINTF(1)("width : %i\n", heightMap->w);
     420    PRINTF(1)("height : %i\n", heightMap->h);
     421    PRINTF(1)("%i Byte(s) per Pixel \n", heightMap->format->BytesPerPixel);
     422    PRINTF(1)("Rshift : %i\n", heightMap->format->Rshift);
     423    PRINTF(1)("Bshift: %i\n", heightMap->format->Bshift);
     424    PRINTF(1)("Gshift: %i\n", heightMap->format->Gshift);
     425    PRINTF(1)("Rmask: %i\n", heightMap->format->Rmask);
     426    PRINTF(1)("Gmask: %i\n", heightMap->format->Gmask);
     427  }
     428  else
     429    PRINTF(1)("oops! couldn't load %s for some reason.\n", heightMapName.c_str());
     430
     431  generateNormalVectorField();
     432}
     433
    467434
    468435void HeightMap::load()
     
    587554
    588555
    589   int xInt = (int)x / scaleX;
     556  int xInt = (int)( x / scaleX);
    590557  x -= (float)((int)x);
    591558  xInt = heightMap->h - xInt;
    592   int yInt = (int)y / scaleZ;
     559  int yInt = (int)( y / scaleZ);
    593560  y -= (float) ((int) y); /*yInt = heightMap->w - yInt;*/
    594561
  • trunk/src/lib/graphics/importer/height_map.h

    r7490 r7497  
    7777
    7878  public:
    79     HeightMap();
    80     HeightMap(const std::string&);
    81     HeightMap(const std::string&, const std::string&);
     79    HeightMap(const std::string& heightMapName);
     80    HeightMap(const std::string& heightMapName, const std::string& colorMapName);
    8281    virtual ~HeightMap();
     82
     83    void init(const std::string& heightMapName);
    8384
    8485    void setAbsCoor(Vector V);
Note: See TracChangeset for help on using the changeset viewer.