Changeset 7490 in orxonox.OLD for trunk/src/lib/graphics/importer
- Timestamp:
- May 3, 2006, 12:17:51 AM (19 years ago)
- Location:
- trunk/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/height_map.cc
r7482 r7490 39 39 Tile::Tile(int i1, int j1, int i2, int j2, HeightMap* heightMapReference ) 40 40 { 41 PRINTF(0)("Tile Constructor\n"); 41 PRINTF(4)("Tile Constructor\n"); 42 42 43 this->highResModel = new VertexArrayModel(); 43 44 this->lowResModel = new VertexArrayModel(); … … 87 88 88 89 // #define heightMap this->heightMapReference->heightMap 89 #define colo urs this->heightMapReference->colours90 #define colors this->heightMapReference->colors 90 91 #define scaleX this->heightMapReference->scaleX 91 92 #define scaleY this->heightMapReference->scaleY … … 97 98 98 99 100 //FIXME: OLD implementation 99 101 this->x = this->heightMapReference->offsetX + ( this->heightMapReference->heightMap->h - ((i1 + i2) / 2)) * scaleX; 100 102 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 101 108 102 109 float height = 0; … … 108 115 109 116 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 ) 113 118 114 119 SDL_LockSurface(this->heightMapReference->heightMap); 115 SDL_LockSurface(this->heightMapReference->colo urMap);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) 118 123 { 119 124 int w = 0; 120 125 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)]; 128 132 } 129 133 … … 142 146 if(this->heightMapReference->hasColourMap) 143 147 { 144 r = colo urs[(3*j+2 + 3*i*(this->heightMapReference->heightMap->w )) ];145 g = colo urs[(3*j+1 + 3*i*(this->heightMapReference->heightMap->w)) ];146 b = colo urs[(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))]; 147 151 } 148 152 height = (float)(unsigned char) this->heightMapReference->heights[(j +sampleRate+ i*(this->heightMapReference->heightMap->w )) ]; … … 204 208 if(this->heightMapReference->hasColourMap) 205 209 { 206 r = (float)colo urs[(3*j+2 + 3*i*(this->heightMapReference->heightMap->w )) ];207 g = (float)colo urs[(3*j+1 + 3*i*(this->heightMapReference->heightMap->w)) ];208 b = (float)colo urs[(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))]; 209 213 } 210 214 … … 242 246 if(this->heightMapReference->hasColourMap) 243 247 { 244 r = (float)colo urs[3*j+2 + 3*i*(this->heightMapReference->heightMap->w )];245 g = (float)colo urs[3*j+1 + 3*i*(this->heightMapReference->heightMap->w)];246 b = (float)colo urs[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)]; 247 251 } 248 252 … … 305 309 306 310 307 SDL_UnlockSurface(this->heightMapReference->colo urMap);311 SDL_UnlockSurface(this->heightMapReference->colorMap); 308 312 309 313 model->finalize(); … … 313 317 314 318 // #undef heightMap 315 #undef colo urs319 #undef colors 316 320 #undef scaleX 317 321 #undef scaleY … … 361 365 } 362 366 363 HeightMap::HeightMap(const std::string& height_map_name = NULL, const std::string& colo ur_map_name = NULL)367 HeightMap::HeightMap(const std::string& height_map_name = NULL, const std::string& color_map_name = NULL) 364 368 : VertexArrayModel() 365 369 { … … 387 391 generateNormalVectorField(); 388 392 389 colo urMap=NULL;390 if(colo ur_map_name != "")391 { 392 colo urMap = IMG_Load(colour_map_name.c_str());393 } 394 395 if(colo urMap != NULL)396 { 397 PRINTF(0)("loading Image %s\n", colo ur_map_name.c_str());398 PRINTF(0)("width : %i\n", colo urMap->w);399 PRINTF(0)("height : %i\n", colo urMap->h);400 PRINTF(0)("%i Byte(s) per Pixel \n", colo urMap->format->BytesPerPixel);401 PRINTF(0)("Rshift : %i\n", colo urMap->format->Rshift);402 PRINTF(0)("Bshift: %i\n", colo urMap->format->Bshift);403 PRINTF(0)("Gshift: %i\n", colo urMap->format->Gshift);404 PRINTF(0)("Rmask: %i\n", colo urMap->format->Rmask);405 PRINTF(0)("Gmask: %i\n", colo urMap->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); 406 410 } 407 411 else … … 410 414 411 415 412 if(colo urMap != NULL)413 { 414 colo urs = (unsigned char *) colourMap->pixels;416 if(colorMap != NULL) 417 { 418 colors = (unsigned char *) colorMap->pixels; 415 419 hasColourMap = true; 416 420 } … … 429 433 { 430 434 delete heightMap; 431 delete colo urMap;435 delete colorMap; 432 436 433 437 -
trunk/src/lib/graphics/importer/height_map.h
r7469 r7490 17 17 18 18 #include "vertex_array_model.h" 19 #include "p_node.h" 19 20 20 21 … … 37 38 38 39 //!< one part of the height map 39 class Tile 40 class Tile : public PNode 40 41 { 41 42 public: … … 47 48 48 49 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(); } 51 52 52 53 … … 108 109 private: 109 110 SDL_Surface* heightMap; 110 SDL_Surface* colo urMap;111 SDL_Surface* colorMap; 111 112 unsigned char* heights; 112 unsigned char* colo urs;113 unsigned char* colors; 113 114 114 115 Vector** normalVectorField;
Note: See TracChangeset
for help on using the changeset viewer.