Changeset 7498 in orxonox.OLD for trunk/src/lib/graphics/importer
- Timestamp:
- May 3, 2006, 1:16:35 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
r7497 r7498 328 328 329 329 330 330 /** 331 * constructor 332 * @param heightMapName file name of the height map 333 */ 331 334 HeightMap::HeightMap(const std::string& heightMapName) 332 335 : VertexArrayModel() … … 337 340 } 338 341 342 343 /** 344 * constructor 345 * @param heightMapName file name of the height map 346 * @param colorMapName file name of the color map 347 */ 339 348 HeightMap::HeightMap(const std::string& heightMapName, const std::string& colorMapName) 340 349 : VertexArrayModel() 341 350 { 342 343 351 this->init(heightMapName); 344 352 … … 355 363 PRINTF(0)("Rmask: %i\n", this->colorMap->format->Rmask); 356 364 PRINTF(0)("Gmask: %i\n", this->colorMap->format->Gmask); 365 366 this->colors = (unsigned char *) colorMap->pixels; 367 this->hasColourMap = true; 357 368 } 358 369 else 370 { 359 371 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 */ 379 380 HeightMap::~HeightMap() 380 381 { … … 430 431 431 432 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 */ 435 441 void HeightMap::load() 436 442 { 437 438 443 //Create a Dynamicly sized 2D-Array for Tiles 439 444 tiles = new Tile** [heightMap->h/tileSize]; … … 450 455 } 451 456 } 452 453 } 454 455 456 void HeightMap::draw() 457 } 458 459 460 /** 461 * this function draws the height map 462 */ 463 void HeightMap::draw() const 457 464 { 458 465 const PNode* camera = State::getCameraNode(); … … 473 480 } 474 481 } 475 476 } 482 } 483 484 485 /** 486 * this function generates the normal vector field 487 */ 477 488 void HeightMap::generateNormalVectorField() 478 489 { … … 485 496 normalVectorField [i]= new (Vector [heightMap->w]); 486 497 487 488 489 490 498 // Initialize 491 499 for(int i=0; i< heightMap->h; i++) … … 524 532 525 533 } 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 */ 533 541 void HeightMap::scale(Vector v) 534 542 { … … 539 547 } 540 548 549 550 /** 551 * sets the absolute coordinates of the height map 552 * @param v the moving vector 553 */ 541 554 void HeightMap::setAbsCoor(Vector v) 542 555 { 543 556 offsetX = v.x; 544 557 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 */ 549 568 float HeightMap::getHeight(float x, float y) 550 569 { 551 552 570 x -= offsetX; 553 571 y -= offsetZ; 554 555 572 556 573 int xInt = (int)( x / scaleX); … … 571 588 float height = heights[yInt + (xInt)*heightMap->w]*scaleY; 572 589 573 574 590 float a = normalVectorField[(xInt)][yInt].x; 575 591 float b = normalVectorField [(xInt)][yInt].z; -
trunk/src/lib/graphics/importer/height_map.h
r7497 r7498 92 92 void scale( Vector V); 93 93 94 void draw() ;94 void draw() const; 95 95 96 96
Note: See TracChangeset
for help on using the changeset viewer.