Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7490 in orxonox.OLD


Ignore:
Timestamp:
May 3, 2006, 12:17:51 AM (18 years ago)
Author:
patrick
Message:

resuming work on the hm

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

Legend:

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

    r7482 r7490  
    3939Tile::Tile(int i1, int j1, int i2, int j2, HeightMap* heightMapReference )
    4040{
    41   PRINTF(0)("Tile Constructor\n");
     41  PRINTF(4)("Tile Constructor\n");
     42
    4243  this->highResModel = new VertexArrayModel();
    4344  this->lowResModel  = new VertexArrayModel();
     
    8788
    8889// #define heightMap this->heightMapReference->heightMap
    89 #define colours   this->heightMapReference->colours
     90#define colors   this->heightMapReference->colors
    9091#define scaleX this->heightMapReference->scaleX
    9192#define scaleY this->heightMapReference->scaleY
     
    9798
    9899
     100  //FIXME: OLD implementation
    99101  this->x = this->heightMapReference->offsetX + ( this->heightMapReference->heightMap->h - ((i1 + i2) / 2)) * scaleX;
    100102  this->z = this->heightMapReference->offsetZ + ((j1 + j2 ) / 2 ) * scaleZ;
     103  //NEW:
     104  this->setAbsCoor(this->heightMapReference->offsetX + ( this->heightMapReference->heightMap->h - ((i1 + i2) / 2)) * scaleX,
     105                   0,
     106                   this->heightMapReference->offsetZ + ((j1 + j2 ) / 2 ) * scaleZ);
     107
    101108
    102109  float height = 0;
     
    108115
    109116
    110 
    111 
    112   if(this->heightMapReference->heightMap != NULL && this->heightMapReference->heightMap->format->BitsPerPixel == 8 )
     117  //if( this->heightMapReference->heightMap != NULL && this->heightMapReference->heightMap->format->BitsPerPixel == 8 )
    113118
    114119  SDL_LockSurface(this->heightMapReference->heightMap);
    115   SDL_LockSurface(this->heightMapReference->colourMap);
    116 
    117   for(int i = i1 ; i <= i2  ; i +=sampleRate)
     120  SDL_LockSurface(this->heightMapReference->colorMap);
     121
     122  for( int i = i1 ; i <= i2  ; i +=sampleRate)
    118123  {
    119124    int w = 0;
    120125
    121 
    122 
    123     if(this->heightMapReference->hasColourMap)
    124     {
    125       r = colours[(3*w+2 + 3*i*(this->heightMapReference->heightMap->w )) ];
    126       g = colours[(3*w+1 + 3*i*(this->heightMapReference->heightMap->w)) ];
    127       b = colours[(3*w+0 + 3*i*(this->heightMapReference->heightMap->w))];
     126    // adjust the colors acoring to the color map
     127    if( this->heightMapReference->hasColourMap)
     128    {
     129      r = colors[3 * w + 2 + 3 * i * (this->heightMapReference->heightMap->w)];
     130      g = colors[3 * w + 1 + 3 * i * (this->heightMapReference->heightMap->w)];
     131      b = colors[3 * w + 0 + 3 * i * (this->heightMapReference->heightMap->w)];
    128132    }
    129133
     
    142146      if(this->heightMapReference->hasColourMap)
    143147      {
    144         r = colours[(3*j+2 + 3*i*(this->heightMapReference->heightMap->w )) ];
    145         g =  colours[(3*j+1 + 3*i*(this->heightMapReference->heightMap->w)) ];
    146         b =  colours[(3*j+0 + 3*i*(this->heightMapReference->heightMap->w))];
     148        r = colors[(3*j+2 + 3*i*(this->heightMapReference->heightMap->w )) ];
     149        g =  colors[(3*j+1 + 3*i*(this->heightMapReference->heightMap->w)) ];
     150        b =  colors[(3*j+0 + 3*i*(this->heightMapReference->heightMap->w))];
    147151      }
    148152      height = (float)(unsigned char) this->heightMapReference->heights[(j +sampleRate+ i*(this->heightMapReference->heightMap->w )) ];
     
    204208    if(this->heightMapReference->hasColourMap)
    205209    {
    206       r = (float)colours[(3*j+2 + 3*i*(this->heightMapReference->heightMap->w )) ];
    207       g = (float)colours[(3*j+1 + 3*i*(this->heightMapReference->heightMap->w)) ];
    208       b = (float)colours[(3*j+0 + 3*i*(this->heightMapReference->heightMap->w))];
     210      r = (float)colors[(3*j+2 + 3*i*(this->heightMapReference->heightMap->w )) ];
     211      g = (float)colors[(3*j+1 + 3*i*(this->heightMapReference->heightMap->w)) ];
     212      b = (float)colors[(3*j+0 + 3*i*(this->heightMapReference->heightMap->w))];
    209213    }
    210214
     
    242246    if(this->heightMapReference->hasColourMap)
    243247    {
    244       r = (float)colours[3*j+2 + 3*i*(this->heightMapReference->heightMap->w )];
    245       g = (float)colours[3*j+1 + 3*i*(this->heightMapReference->heightMap->w)];
    246       b = (float)colours[3*j+0 + 3*i*(this->heightMapReference->heightMap->w)];
     248      r = (float)colors[3*j+2 + 3*i*(this->heightMapReference->heightMap->w )];
     249      g = (float)colors[3*j+1 + 3*i*(this->heightMapReference->heightMap->w)];
     250      b = (float)colors[3*j+0 + 3*i*(this->heightMapReference->heightMap->w)];
    247251    }
    248252
     
    305309
    306310
    307   SDL_UnlockSurface(this->heightMapReference->colourMap);
     311  SDL_UnlockSurface(this->heightMapReference->colorMap);
    308312
    309313  model->finalize();
     
    313317
    314318// #undef heightMap
    315         #undef colours
     319        #undef colors
    316320        #undef scaleX
    317321        #undef scaleY
     
    361365}
    362366
    363 HeightMap::HeightMap(const std::string& height_map_name = NULL, const std::string& colour_map_name = NULL)
     367HeightMap::HeightMap(const std::string& height_map_name = NULL, const std::string& color_map_name = NULL)
    364368    : VertexArrayModel()
    365369{
     
    387391  generateNormalVectorField();
    388392
    389   colourMap=NULL;
    390   if(colour_map_name != "")
    391   {
    392     colourMap = IMG_Load(colour_map_name.c_str());
    393   }
    394 
    395   if(colourMap != NULL)
    396   {
    397     PRINTF(0)("loading Image %s\n", colour_map_name.c_str());
    398     PRINTF(0)("width : %i\n", colourMap->w);
    399     PRINTF(0)("height : %i\n", colourMap->h);
    400     PRINTF(0)("%i Byte(s) per Pixel \n", colourMap->format->BytesPerPixel);
    401     PRINTF(0)("Rshift : %i\n", colourMap->format->Rshift);
    402     PRINTF(0)("Bshift: %i\n", colourMap->format->Bshift);
    403     PRINTF(0)("Gshift: %i\n", colourMap->format->Gshift);
    404     PRINTF(0)("Rmask: %i\n", colourMap->format->Rmask);
    405     PRINTF(0)("Gmask: %i\n", colourMap->format->Gmask);
     393  colorMap=NULL;
     394  if(color_map_name != "")
     395  {
     396    colorMap = IMG_Load(color_map_name.c_str());
     397  }
     398
     399  if(colorMap != NULL)
     400  {
     401    PRINTF(0)("loading Image %s\n", color_map_name.c_str());
     402    PRINTF(0)("width : %i\n", colorMap->w);
     403    PRINTF(0)("height : %i\n", colorMap->h);
     404    PRINTF(0)("%i Byte(s) per Pixel \n", colorMap->format->BytesPerPixel);
     405    PRINTF(0)("Rshift : %i\n", colorMap->format->Rshift);
     406    PRINTF(0)("Bshift: %i\n", colorMap->format->Bshift);
     407    PRINTF(0)("Gshift: %i\n", colorMap->format->Gshift);
     408    PRINTF(0)("Rmask: %i\n", colorMap->format->Rmask);
     409    PRINTF(0)("Gmask: %i\n", colorMap->format->Gmask);
    406410  }
    407411  else
     
    410414
    411415
    412   if(colourMap != NULL)
    413   {
    414     colours = (unsigned char *) colourMap->pixels;
     416  if(colorMap != NULL)
     417  {
     418    colors = (unsigned char *) colorMap->pixels;
    415419    hasColourMap = true;
    416420  }
     
    429433{
    430434  delete heightMap;
    431   delete colourMap;
     435  delete colorMap;
    432436
    433437
  • trunk/src/lib/graphics/importer/height_map.h

    r7469 r7490  
    1717
    1818#include "vertex_array_model.h"
     19#include "p_node.h"
    1920
    2021
     
    3738
    3839//!< one part of the height map
    39 class Tile
     40class Tile : public PNode
    4041{
    4142  public:
     
    4748
    4849    void draw();
    49     inline void drawHighRes() { highResModel->draw(); }
    50     inline void drawLowRes() { lowResModel->draw(); }
     50    inline void drawHighRes() const { highResModel->draw(); }
     51    inline void drawLowRes() const { lowResModel->draw(); }
    5152
    5253
     
    108109  private:
    109110    SDL_Surface*                          heightMap;
    110     SDL_Surface*                          colourMap;
     111    SDL_Surface*                          colorMap;
    111112    unsigned char*                        heights;
    112     unsigned char*                        colours;
     113    unsigned char*                        colors;
    113114
    114115    Vector**                              normalVectorField;
Note: See TracChangeset for help on using the changeset viewer.