- Timestamp:
- Jan 18, 2006, 3:55:37 PM (19 years ago)
- Location:
- branches/height_map_merge/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/height_map_merge/src/lib/graphics/importer/height_map.cc
r6494 r6579 30 30 #endif 31 31 32 Tile::Tile(int i1, int j1, int i2, int j2, HeightMap* hm ) 32 Tile::Tile(int i1, int j1, int i2, int j2, HeightMap* hm ) 33 33 { 34 34 … … 37 37 lowResModel = new VertexArrayModel(); 38 38 39 this->load(i1,j1,i2,j2,hm,highResModel, 4);40 this->load(i1,j1,i2,j2,hm,lowResModel, 32);39 this->load(i1,j1,i2,j2,hm,highResModel,2); 40 this->load(i1,j1,i2,j2,hm,lowResModel, 8); 41 41 } 42 42 … … 54 54 void Tile::draw() 55 55 { 56 lowResModel->draw(); 56 lowResModel->draw(); 57 57 } 58 58 … … 71 71 void Tile::load(int i1, int j1, int i2, int j2, HeightMap* hm, VertexArrayModel* model, int Res) 72 72 { 73 74 75 76 77 78 79 80 81 82 83 84 85 86 unsigned charheight = 0;87 88 89 90 91 92 93 73 74 #define heightMap hm->heightMap 75 #define colours hm->colours 76 #define scaleX hm->scaleX 77 #define scaleY hm->scaleY 78 #define scaleZ hm->scaleZ 79 #define shiftX hm->shiftX 80 #define shiftY hm->shiftY 81 #define shiftZ hm->shiftZ 82 #define normalVectorField hm->normalVectorField 83 84 int sampleRate = Res; 85 86 float height = 0; 87 int offset = 0; 88 89 float r = 0.0; 90 float g = 0.0; 91 float b = 0.0; 92 93 94 94 PRINTF(0)("loadin * \n"); 95 95 96 96 if(heightMap != NULL && heightMap->format->BitsPerPixel == 8 ) 97 98 SDL_LockSurface(heightMap); 99 100 for(int i = i1 ; i <= i2 ; i +=sampleRate) 101 { 102 int w = 0; 103 104 105 106 if(hm->hasColourMap) 107 { 108 r = (float)colours[3*w+2 + 3*i*(heightMap->w )]; 109 g = (float)colours[3*w+1 + 3*i*(heightMap->w)]; 110 b = (float)colours[3*w+0 + 3*i*(heightMap->w)]; 111 } 112 113 w = j1; 114 model->addVertex(scaleX*(heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right 115 model->addNormal(normalVectorField[i][w].y,normalVectorField[i][w].z,normalVectorField[i][w].x); 116 model->addTexCoor((((w -sampleRate)/sampleRate)%4)/4.0,(((i-sampleRate)/sampleRate)%4)/4.0); 117 model->addColor(r/255.0,g/255.0,b/255.0); 118 119 for(int j = j1 ; j <= j2 ; j += sampleRate) 120 { 121 122 123 // To be fixed 124 if(hm->hasColourMap) 125 { 126 r = (float)colours[3*j+2 + 3*i*(heightMap->w )]; 127 g = (float)colours[3*j+1 + 3*i*(heightMap->w)]; 128 b = (float)colours[3*j+0 + 3*i*(heightMap->w)]; 129 } 130 height = hm->heights[j+sampleRate + i*(heightMap->w )]; 131 model->addVertex(scaleX*(heightMap->h -i) + shiftX ,((double)(height)*scaleY) + shiftY ,scaleZ*(j) + shiftZ); // Top Right 132 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 133 model->addTexCoor(((j/sampleRate)%texRate)/texRatef,((i/sampleRate)%texRate)/texRatef); 134 135 model->addColor(r/255.0,g/255.0,b/255.0); 136 137 138 w = j; 139 } 140 141 142 model->addVertex(scaleX*(heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right 143 model->addNormal(normalVectorField[i][w].y,normalVectorField[i][w].z,normalVectorField[i][w].x); 144 model->addTexCoor((((w+sampleRate)/sampleRate)%4)/4.0,(((i+ sampleRate)/sampleRate)%4)/4.0); 145 model->addColor(r/255.0,g/255.0,b/255.0); 146 147 } 148 149 150 151 152 153 SDL_UnlockSurface(heightMap); 154 int cnt = 0; 155 for(int i = i1 ; i < i2 ; i +=sampleRate) 156 { 157 158 for(int j = j1-sampleRate ; j < j2 + 2*sampleRate ; j += sampleRate) 159 { 160 161 model->addIndice(cnt); 162 model->addIndice(cnt + (j2 -j1 + 3* sampleRate )/ sampleRate ); 163 cnt++; 164 165 } 166 167 168 169 model->newStripe(); 170 171 172 } 173 cnt += (j2 -j1 + 3* sampleRate)/ sampleRate; 174 175 for(int j = j1 ; j <= j2 ; j += sampleRate) 176 { 177 int i = i1; 178 179 // To be fixed 180 if(hm->hasColourMap) 181 { 182 r = (float)colours[3*j+2 + 3*i*(heightMap->w )]; 183 g = (float)colours[3*j+1 + 3*i*(heightMap->w)]; 184 b = (float)colours[3*j+0 + 3*i*(heightMap->w)]; 185 } 186 187 model->addVertex(scaleX*(heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right 188 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 189 model->addTexCoor(((j/sampleRate)%texRate)/texRatef,(((i - sampleRate)/sampleRate)%texRate)/texRatef); 190 model->addColor(r/255.0,g/255.0,b/255.0); 191 192 } 193 194 for(int j = j1 ; j <= j2 ; j += sampleRate) 195 { 196 int i = i1; 197 height = hm->heights[j+sampleRate + i*(heightMap->w )]; 198 model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right 199 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 200 model->addTexCoor(((j/sampleRate)%texRate)/texRatef,(((i)/sampleRate)%texRate)/texRatef); 201 model->addColor(r/255.0,g/255.0,b/255.0); 202 203 } 204 205 206 207 for(int j = j1 ; j <= j2 ; j += sampleRate) 208 { 209 int i = i2; 210 211 // To be fixed 212 if(hm->hasColourMap) 213 { 214 r = (float)colours[3*j+2 + 3*i*(heightMap->w )]; 215 g = (float)colours[3*j+1 + 3*i*(heightMap->w)]; 216 b = (float)colours[3*j+0 + 3*i*(heightMap->w)]; 217 } 218 219 model->addVertex(scaleX*(heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right 220 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 221 model->addTexCoor(((j/sampleRate)%texRate)/texRatef,(((i- sampleRate)/sampleRate)%texRate)/texRatef); 222 model->addColor(r/255.0,g/255.0,b/255.0); 223 224 } 225 226 227 for(int j = j1 ; j <= j2 ; j += sampleRate) 228 { 229 int i = i2; 230 height = hm->heights[j+sampleRate + i*(heightMap->w )]; 231 model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right 232 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 233 model->addTexCoor(((j/sampleRate)%texRate)/texRatef,((i/sampleRate)%texRate)/texRatef); 234 model->addColor(r/255.0,g/255.0,b/255.0); 235 236 } 237 238 239 240 241 // link Boarder Stripe 242 for(int j = j1-sampleRate ; j < j2 ; j += sampleRate) 243 { 244 245 model->addIndice(cnt); 246 model->addIndice(cnt + (j2 -j1 + sampleRate )/ sampleRate ); 247 cnt++; 248 249 } 250 251 cnt++; 252 253 model->newStripe(); 254 255 256 257 258 259 cnt += (j2-j1)/ sampleRate; 260 261 // link 2nd BoarderStripe 262 for(int j = j1-sampleRate ; j < j2 ; j += sampleRate) 263 { 264 265 model->addIndice(cnt); 266 model->addIndice(cnt + (j2 -j1 + sampleRate )/ sampleRate ); 267 cnt++; 268 269 } 270 271 272 273 model->finalize(); 274 275 276 277 278 #undef heightMap 279 #undef colours 280 #undef scaleX 281 #undef scaleY 282 #undef scaleZ 283 #undef shiftX 284 #undef shiftY 285 #undef shiftZ 286 #undef normalVectorField 287 97 98 SDL_LockSurface(heightMap); 99 100 for(int i = i1 ; i <= i2 ; i +=sampleRate) 101 { 102 int w = 0; 103 104 105 106 if(hm->hasColourMap) 107 { 108 r = (float)colours[3*w+2 + 3*i*(heightMap->w )]; 109 g = (float)colours[3*w+1 + 3*i*(heightMap->w)]; 110 b = (float)colours[3*w+0 + 3*i*(heightMap->w)]; 111 } 112 113 w = j1; 114 model->addVertex(scaleX*(heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right 115 model->addNormal(normalVectorField[i][w].y,normalVectorField[i][w].z,normalVectorField[i][w].x); 116 model->addTexCoor((((w -sampleRate)/sampleRate)%4)/4.0,(((i-sampleRate)/sampleRate)%4)/4.0); 117 model->addColor(r/255.0,g/255.0,b/255.0); 118 119 for(int j = j1 ; j <= j2 ; j += sampleRate) 120 { 121 122 123 // To be fixed 124 if(hm->hasColourMap) 125 { 126 r = (float)colours[3*j+2 + 3*i*(heightMap->w )]; 127 g = (float)colours[3*j+1 + 3*i*(heightMap->w)]; 128 b = (float)colours[3*j+0 + 3*i*(heightMap->w)]; 129 } 130 height = (float)(unsigned char) hm->heights[j +sampleRate+ i*(heightMap->w )]; 131 height += (float)(unsigned char) hm->heights[j+ 1 + sampleRate + (i+1)*(heightMap->w )]; 132 height += (float) (unsigned char) hm->heights[j -1+ sampleRate + (i+1)*(heightMap->w )]; 133 height += (float)(unsigned char)hm->heights[j +sampleRate+ (i+2)*(heightMap->w )]; 134 height += (float)(unsigned char)hm->heights[j+sampleRate + (i)*(heightMap->w )]; 135 136 height=height/5.0; 137 138 model->addVertex(scaleX*(heightMap->h -i) + shiftX ,((double)(height)*scaleY) + shiftY ,scaleZ*(j) + shiftZ); // Top Right 139 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 140 model->addTexCoor((float)j /(texRate), (float)(i %heightMap->h)/(texRate)); 141 142 //PRINTF(0)("TexCoord: %f %f \n",(float)j / 100.0, (float)(i %heightMap->h)/100.0); 143 144 model->addColor(r/255.0,g/255.0,b/255.0); 145 w = j; 146 } 147 148 149 model->addVertex(scaleX*(heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right 150 model->addNormal(normalVectorField[i][w].y,normalVectorField[i][w].z,normalVectorField[i][w].x); 151 model->addTexCoor((((w+sampleRate)/sampleRate))/4.0,(((i+ sampleRate)/sampleRate))/4.0); 152 model->addColor(r/255.0,g/255.0,b/255.0); 153 154 } 155 156 157 158 159 160 SDL_UnlockSurface(heightMap); 161 int cnt = 0; 162 for(int i = i1 ; i < i2 ; i +=sampleRate) 163 { 164 165 for(int j = j1-sampleRate ; j < j2 + 2*sampleRate ; j += sampleRate) 166 { 167 168 model->addIndice(cnt); 169 model->addIndice(cnt + (j2 -j1 + 3* sampleRate )/ sampleRate ); 170 cnt++; 171 172 } 173 174 175 176 model->newStripe(); 177 178 179 } 180 cnt += (j2 -j1 + 3* sampleRate)/ sampleRate; 181 182 for(int j = j1 ; j <= j2 ; j += sampleRate) 183 { 184 int i = i1; 185 186 // To be fixed 187 if(hm->hasColourMap) 188 { 189 r = (float)colours[3*j+2 + 3*i*(heightMap->w )]; 190 g = (float)colours[3*j+1 + 3*i*(heightMap->w)]; 191 b = (float)colours[3*j+0 + 3*i*(heightMap->w)]; 192 } 193 194 model->addVertex(scaleX*(heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right 195 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 196 model->addTexCoor(((j/sampleRate))/texRatef,(((i - sampleRate)/sampleRate))/texRatef); 197 model->addColor(r/255.0,g/255.0,b/255.0); 198 199 } 200 201 for(int j = j1 ; j <= j2 ; j += sampleRate) 202 { 203 int i = i1; 204 height = (float)(unsigned char) hm->heights[j +sampleRate+ i*(heightMap->w )]; 205 height += (float)(unsigned char) hm->heights[j+ 1 + sampleRate + (i+1)*(heightMap->w )]; 206 height += (float) (unsigned char) hm->heights[j -1+ sampleRate + (i+1)*(heightMap->w )]; 207 height += (float)(unsigned char)hm->heights[j +sampleRate+ (i+2)*(heightMap->w )]; 208 height += (float)(unsigned char)hm->heights[j+sampleRate + (i)*(heightMap->w )]; 209 height=height/5.0; 210 211 model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right 212 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 213 model->addTexCoor(((j/sampleRate))/texRatef,(((i)/sampleRate))/texRatef); 214 model->addColor(r/255.0,g/255.0,b/255.0); 215 216 } 217 218 219 220 for(int j = j1 ; j <= j2 ; j += sampleRate) 221 { 222 int i = i2; 223 224 // To be fixed 225 if(hm->hasColourMap) 226 { 227 r = (float)colours[3*j+2 + 3*i*(heightMap->w )]; 228 g = (float)colours[3*j+1 + 3*i*(heightMap->w)]; 229 b = (float)colours[3*j+0 + 3*i*(heightMap->w)]; 230 } 231 232 model->addVertex(scaleX*(heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right 233 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 234 model->addTexCoor(((j/sampleRate)%texRate)/texRatef,(((i- sampleRate)/sampleRate)%texRate)/texRatef); 235 model->addColor(r/255.0,g/255.0,b/255.0); 236 237 } 238 239 240 for(int j = j1 ; j <= j2 ; j += sampleRate) 241 { 242 int i = i2; 243 height = (float)(unsigned char) hm->heights[j +sampleRate+ i*(heightMap->w )]; 244 height += (float)(unsigned char) hm->heights[j+ 1 + sampleRate + (i+1)*(heightMap->w )]; 245 height += (float) (unsigned char) hm->heights[j -1+ sampleRate + (i+1)*(heightMap->w )]; 246 height += (float)(unsigned char)hm->heights[j +sampleRate+ (i+2)*(heightMap->w )]; 247 height += (float)(unsigned char)hm->heights[j+sampleRate + (i)*(heightMap->w )]; 248 height=height/5.0; 249 model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right 250 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 251 model->addTexCoor(((j/sampleRate)%texRate)/texRatef,((i/sampleRate)%texRate)/texRatef); 252 model->addColor(r/255.0,g/255.0,b/255.0); 253 254 } 255 256 257 258 259 // link Boarder Stripe 260 for(int j = j1-sampleRate ; j < j2 ; j += sampleRate) 261 { 262 263 model->addIndice(cnt); 264 model->addIndice(cnt + (j2 -j1 + sampleRate )/ sampleRate ); 265 cnt++; 266 267 } 268 269 cnt++; 270 271 model->newStripe(); 272 273 274 275 276 277 cnt += (j2-j1)/ sampleRate; 278 279 // link 2nd BoarderStripe 280 for(int j = j1-sampleRate ; j < j2 ; j += sampleRate) 281 { 282 283 model->addIndice(cnt); 284 model->addIndice(cnt + (j2 -j1 + sampleRate )/ sampleRate ); 285 cnt++; 286 287 } 288 289 290 291 model->finalize(); 292 293 294 295 296 #undef heightMap 297 #undef colours 298 #undef scaleX 299 #undef scaleY 300 #undef scaleZ 301 #undef shiftX 302 #undef shiftY 303 #undef shiftZ 304 #undef normalVectorField 305 288 306 } 289 307 … … 299 317 if(heightMap!=NULL) { 300 318 301 302 303 304 305 306 307 308 309 310 319 PRINTF(0)("loading Image %s\n", height_map_name); 320 PRINTF(0)("width : %i\n", heightMap->w); 321 PRINTF(0)("height : %i\n", heightMap->h); 322 PRINTF(0)("%i Byte(s) per Pixel \n", heightMap->format->BytesPerPixel); 323 PRINTF(0)("Rshift : %i\n", heightMap->format->Rshift); 324 PRINTF(0)("Bshift: %i\n", heightMap->format->Bshift); 325 PRINTF(0)("Gshift: %i\n", heightMap->format->Gshift); 326 PRINTF(0)("Rmask: %i\n", heightMap->format->Rmask); 327 PRINTF(0)("Gmask: %i\n", heightMap->format->Gmask); 328 } 311 329 312 330 else PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name); 313 331 314 332 315 333 generateNormalVectorField(); 316 334 … … 328 346 if(heightMap!=NULL) { 329 347 330 331 332 333 334 335 336 337 338 339 348 PRINTF(0)("loading Image %s\n", height_map_name); 349 PRINTF(0)("width : %i\n", heightMap->w); 350 PRINTF(0)("height : %i\n", heightMap->h); 351 PRINTF(0)("%i Byte(s) per Pixel \n", heightMap->format->BytesPerPixel); 352 PRINTF(0)("Rshift : %i\n", heightMap->format->Rshift); 353 PRINTF(0)("Bshift: %i\n", heightMap->format->Bshift); 354 PRINTF(0)("Gshift: %i\n", heightMap->format->Gshift); 355 PRINTF(0)("Rmask: %i\n", heightMap->format->Rmask); 356 PRINTF(0)("Gmask: %i\n", heightMap->format->Gmask); 357 } 340 358 341 359 else PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name); … … 349 367 colourMap = IMG_Load(colour_map_name); 350 368 } 369 351 370 if(colourMap != NULL) 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 371 { 372 PRINTF(0)("loading Image %s\n", colour_map_name); 373 PRINTF(0)("width : %i\n", colourMap->w); 374 PRINTF(0)("height : %i\n", colourMap->h); 375 PRINTF(0)("%i Byte(s) per Pixel \n", colourMap->format->BytesPerPixel); 376 PRINTF(0)("Rshift : %i\n", colourMap->format->Rshift); 377 PRINTF(0)("Bshift: %i\n", colourMap->format->Bshift); 378 PRINTF(0)("Gshift: %i\n", colourMap->format->Gshift); 379 PRINTF(0)("Rmask: %i\n", colourMap->format->Rmask); 380 PRINTF(0)("Gmask: %i\n", colourMap->format->Gmask); 381 } 382 else PRINTF(0)("oops! couldn't load colorMap for some reason.\n"); 383 384 385 367 386 if(colourMap != NULL) 368 387 { … … 371 390 } 372 391 else hasColourMap = false; 373 374 375 392 393 394 heights = (unsigned char*) heightMap->pixels; 376 395 377 396 … … 379 398 HeightMap::~HeightMap() 380 399 { 381 400 delete heightMap; 382 401 } 383 402 … … 393 412 for(int i = 0; i < (heightMap->h - tileSize )/ tileSize; i ++) 394 413 { 395 396 397 398 399 400 } 401 402 } 403 404 405 void HeightMap::draw() 414 for(int j = 0; j < (heightMap->w - tileSize )/ tileSize; j ++) 415 { 416 417 tiles[i][j] = new Tile( i*tileSize , j*tileSize , (i+1)*tileSize, (j+1)*tileSize , this ) ; 418 } 419 } 420 421 } 422 423 424 void HeightMap::draw() 406 425 { 407 426 const PNode* camera = State::getCamera(); … … 409 428 410 429 int i_min = 1; 411 int i_max = (heightMap->h - tileSize )/ tileSize;430 int i_max = (heightMap->h - tileSize )/ tileSize; 412 431 int j_min = 1; 413 432 int j_max= (heightMap->w - tileSize) / tileSize; 414 433 415 // calc i_min , i_max j_min and j_maxt 434 // calc i_min , i_max j_min and j_maxt 416 435 417 436 int centerX = (int)((heightMap->h - ((v.x - shiftX)/ (float)scaleX ))/ tileSize); … … 426 445 427 446 428 for(int i = 1; i < i_min 429 { 430 431 432 433 434 } 435 } 436 for(int i = i_min; i < i_max 437 { 438 439 440 441 442 } 443 } 444 445 for(int i = i_max; i < (heightMap->h -tileSize)/tileSize 446 { 447 448 449 450 451 } 447 for(int i = 1; i < i_min ; i ++) 448 { 449 for(int j = 1; j < j_max ; j++) 450 { 451 452 tiles[i][j]->drawLowRes(); 453 } 454 } 455 for(int i = i_min; i < i_max ; i ++) 456 { 457 for(int j = j_min; j < j_max ; j++) 458 { 459 460 tiles[i][j]->drawHighRes(); 461 } 462 } 463 464 for(int i = i_max; i < (heightMap->h -tileSize)/tileSize ; i ++) 465 { 466 for(int j = 1; j < j_max ; j++) 467 { 468 469 tiles[i][j]->drawLowRes(); 470 } 452 471 } 453 472 … … 455 474 for(int i = 1; i < (heightMap->h -tileSize)/tileSize; i++ ) 456 475 { 457 458 459 460 461 } 462 for(int i = 1; i < (heightMap->h -tileSize)/tileSize; i++) 463 { 464 465 466 467 476 for(int j = 1; j < j_min; j++) 477 { 478 tiles[i][j]->drawLowRes(); 479 } 480 } 481 for(int i = 1; i < (heightMap->h -tileSize)/tileSize; i++) 482 { 483 for(int j = j_max; j < (heightMap->w -tileSize)/tileSize; j++ ) 484 { 485 tiles[i][j]->drawLowRes(); 486 } 468 487 } 469 488 … … 484 503 485 504 if(heightMap != NULL && heightMap->format->BitsPerPixel == 8 ) 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 505 { 506 SDL_LockSurface(heightMap); 507 for(int i = 0 ; i < heightMap->h - 1 ; i ++) 508 { 509 for(int j = 0; j < heightMap->w - 1 ; j ++) 510 { 511 512 513 delta = (int)heights[j + (i+1)*(heightMap->w )] - (int) heights[j + i*(heightMap->w )]; 514 Vector a = Vector(-scaleX,(float)delta*scaleY ,0.0f); 515 516 delta = (int)heights[j+1 + i*(heightMap->w )] - (int)heights[j + i*(heightMap->w )]; 517 Vector b = Vector(0.0f,(float) delta*scaleY ,scaleZ); 518 519 520 normalVectorField[i][j] = b.cross(a); 521 normalVectorField[i][j].normalize(); 522 523 } 524 } 525 SDL_UnlockSurface(heightMap); 507 526 508 527 } -
branches/height_map_merge/src/lib/graphics/importer/height_map.h
r6494 r6579 17 17 18 18 19 #define texRate 419 #define texRate 22 20 20 #define texRatef 4.0f 21 #define tileSize 6421 #define tileSize 32 22 22 23 23 class SDL_Surface; -
branches/height_map_merge/src/world_entities/terrain.cc
r6496 r6579 43 43 this->loadParams(root); 44 44 45 this->heightMapMaterial = new Material(); 46 heightMapMaterial->setTransparency(1.0); 47 heightMapMaterial->setIllum(0.2); 48 49 heightMapMaterial->setDiffuse(1.0,1.0,1.0); 50 heightMapMaterial->setAmbient(1.0,1.0,1.0 ); 51 heightMapMaterial->setSpecular(1.0,1.0,1.0); 52 heightMapMaterial->setShininess(.5); 53 heightMapMaterial->setTransparency(1.0); 54 55 heightMapMaterial->diffuseTexture = NULL; 56 heightMapMaterial->ambientTexture = NULL; 57 heightMapMaterial->specularTexture = NULL; 58 59 const char* texture_name = "pictures/ground.tga"; 60 heightMapMaterial->setDiffuseMap(texture_name); 61 heightMapMaterial->setAmbientMap(texture_name); 62 heightMapMaterial->setSpecularMap(texture_name); 63 45 64 // if (this->model != NULL) 46 65 //this->ssp = new SpatialSeparation((Model*)this->model, 10.0f); … … 135 154 136 155 this->heightMap = new HeightMap(hmName, hmColorName); 156 heightMap->scale(Vector(23.0f,3.5f,23.0f)); 157 heightMap->shift(Vector(-1000.0,-90.0,-4000.0)); 158 heightMap->load(); 137 159 delete[] hmName; 138 160 delete[] hmColorName; … … 187 209 this->vegetation->draw(); 188 210 189 if(this->heightMap != NULL) 190 this->heightMap->draw(); 211 if(this->heightMap) 212 { 213 this->heightMapMaterial->select(); 214 215 216 // glEnable(GL_LIGHTING); 217 glColorMaterial ( GL_FRONT_AND_BACK, GL_EMISSION ) ; 218 glEnable (GL_COLOR_MATERIAL) ; 219 this->heightMap->draw(); 220 } 191 221 glPopMatrix(); 192 222
Note: See TracChangeset
for help on using the changeset viewer.