Changeset 6727 in orxonox.OLD for branches/height_map_merge/src/lib/graphics/importer
- Timestamp:
- Jan 25, 2006, 5:46:16 PM (19 years ago)
- Location:
- branches/height_map_merge/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/height_map_merge/src/lib/graphics/importer/height_map.cc
r6603 r6727 37 37 lowResModel = new VertexArrayModel(); 38 38 39 this->load(i1,j1,i2,j2,hm,highResModel, 2);39 this->load(i1,j1,i2,j2,hm,highResModel,4); 40 40 this->load(i1,j1,i2,j2,hm,lowResModel, 8); 41 41 } … … 57 57 //FIXME 58 58 float cameraDistance = (State::getCamera()->getAbsCoor() - Vector(0.0,100.0,0.0)).len(); 59 if (cameraDistance > 5000 )59 if (cameraDistance > 10000 ) 60 60 { 61 61 62 62 } 63 else if (cameraDistance > 1000 )63 else if (cameraDistance >= 50000 ) 64 64 { 65 65 this->drawLowRes(); … … 98 98 int sampleRate = Res; 99 99 100 100 float height = 0; 101 101 int offset = 0; 102 102 … … 128 128 model->addVertex(scaleX*(heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right 129 129 model->addNormal(normalVectorField[i][w].y,normalVectorField[i][w].z,normalVectorField[i][w].x); 130 model->addTexCoor(( ((w -sampleRate)/sampleRate)%4)/4.0,(((i-sampleRate)/sampleRate)%4)/4.0);130 model->addTexCoor((float)(j1-sampleRate) /(texRate), (float)(i %heightMap->h)/(texRate)); 131 131 model->addColor(r/255.0,g/255.0,b/255.0); 132 132 … … 147 147 height += (float)(unsigned char)hm->heights[j +sampleRate+ (i+2)*(heightMap->w )]; 148 148 height += (float)(unsigned char)hm->heights[j+sampleRate + (i)*(heightMap->w )]; 149 150 149 height=height/5.0; 151 150 152 151 model->addVertex(scaleX*(heightMap->h -i) + shiftX ,((double)(height)*scaleY) + shiftY ,scaleZ*(j) + shiftZ); // Top Right 153 152 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 154 model->addTexCoor((float) j/(texRate), (float)(i %heightMap->h)/(texRate));153 model->addTexCoor((float)(j) /(texRate), (float)(i %heightMap->h)/(texRate)); 155 154 156 155 //PRINTF(0)("TexCoord: %f %f \n",(float)j / 100.0, (float)(i %heightMap->h)/100.0); … … 163 162 model->addVertex(scaleX*(heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right 164 163 model->addNormal(normalVectorField[i][w].y,normalVectorField[i][w].z,normalVectorField[i][w].x); 165 model->addTexCoor(( ((w+sampleRate)/sampleRate))/4.0,(((i+ sampleRate)/sampleRate))/4.0);164 model->addTexCoor((float)(j2+sampleRate) /(texRate), (float)(i %heightMap->h)/(texRate)); 166 165 model->addColor(r/255.0,g/255.0,b/255.0); 167 166 … … 208 207 model->addVertex(scaleX*(heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right 209 208 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 210 model->addTexCoor(( (j/sampleRate))/texRatef,(((i - sampleRate)/sampleRate))/texRatef);209 model->addTexCoor((float)j /(texRate), (float)((i - sampleRate) %heightMap->h)/(texRate)); 211 210 model->addColor(r/255.0,g/255.0,b/255.0); 212 211 … … 225 224 model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right 226 225 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 227 model->addTexCoor(( (j/sampleRate))/texRatef,(((i)/sampleRate))/texRatef);226 model->addTexCoor((float)j /(texRate), (float)(i %heightMap->h)/(texRate)); 228 227 model->addColor(r/255.0,g/255.0,b/255.0); 229 228 … … 246 245 model->addVertex(scaleX*(heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right 247 246 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 248 model->addTexCoor(( (j/sampleRate)%texRate)/texRatef,(((i- sampleRate)/sampleRate)%texRate)/texRatef);247 model->addTexCoor((float)j /(texRate), (float)((i+ sampleRate) %heightMap->h)/(texRate)); 249 248 model->addColor(r/255.0,g/255.0,b/255.0); 250 249 … … 255 254 { 256 255 int i = i2; 257 256 height = (float)(unsigned char) hm->heights[j +sampleRate+ i*(heightMap->w )]; 258 257 height += (float)(unsigned char) hm->heights[j+ 1 + sampleRate + (i+1)*(heightMap->w )]; 259 258 height += (float) (unsigned char) hm->heights[j -1+ sampleRate + (i+1)*(heightMap->w )]; … … 263 262 model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right 264 263 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); 265 model->addTexCoor(( (j/sampleRate)%texRate)/texRatef,((i/sampleRate)%texRate)/texRatef);264 model->addTexCoor((float)j /(texRate), (float)(i %heightMap->h)/(texRate)); 266 265 model->addColor(r/255.0,g/255.0,b/255.0); 267 266 … … 452 451 for(int j = 1; j < j_max ; j++) 453 452 { 454 455 453 tiles[i][j]->draw(); 456 454 } … … 500 498 501 499 502 503 504 505 500 void HeightMap::scale(Vector v) 506 501 { … … 510 505 } 511 506 512 void HeightMap::shift(Vector v) 513 { 514 shiftX = v.x; 515 shiftY = v.y; 516 shiftZ = v.z; 517 } 518 519 520 float HeightMap::getHeight(float x, float y) 521 { 507 void HeightMap::setAbsCoor(Vector v) 508 { 509 offsetX = v.x; 510 offsetY = v.y; 511 offsetZ = v.z; 512 } 513 514 515 float HeightMap::getHeight(float x, float y) 516 { 517 518 //x -= offsetX; 519 //y -= offsetZ; 520 521 522 522 int xInt = (int)x / scaleX; x -= (float)xInt*scaleX; xInt = heightMap->h - xInt; 523 int yInt = (int)y / scaleZ; y -= (float)yInt*scaleZ; 524 if(xInt <= 0 || xInt >= heightMap->h || yInt <= 0 || yInt >= heightMap->w ) return 0.0f; 523 int yInt = (int)y / scaleZ; y -= (float)yInt*scaleZ; /*yInt = heightMap->w - yInt;*/ 524 525 if(xInt <= 0 || xInt >= heightMap->h || yInt <= 0 || yInt >= heightMap->w ) return shiftY; 526 525 527 float height = heights[yInt + (xInt)*heightMap->w]*scaleY; 528 526 529 float a = normalVectorField[(xInt)][yInt].x; 527 530 float b = normalVectorField [(xInt)][yInt].z; 528 531 float c = normalVectorField [(xInt)][yInt].y; 529 height -= ( (a/c)*(x) + (b/c)*(y))*scaleY; 530 return height; 531 } 532 533 height -= ( (a/c)*(x) + (b/c)*(y); 534 535 return (height ); 536 } -
branches/height_map_merge/src/lib/graphics/importer/height_map.h
r6603 r6727 10 10 11 11 ### File Specific: 12 main-programmer: 12 main-programmer: bottac@ee.ethz.ch 13 13 */ 14 14 … … 17 17 18 18 19 #define texRate 6419 #define texRate 32 20 20 #define texRatef 4.0f 21 #define tileSize 6421 #define tileSize 128 22 22 23 23 class SDL_Surface; … … 58 58 void load(const char*, int Mode); 59 59 void scale( Vector V); 60 void s hift(Vector V);60 void setAbsCoor(Vector V); 61 61 float getHeight(float x, float y); 62 float getNormal(float x, float y); 62 63 HeightMap(); 63 64 HeightMap(const char*); … … 78 79 Vector ** normalVectorField ; 79 80 Tile *** tiles; 80 Vector camCoords; 81 Vector camCoords; 82 Vector offsetCoords; 81 83 Material * tmp_mat; 82 84 Material* red_mat; … … 86 88 float scaleY ; 87 89 float scaleZ ; 88 float shiftX ; 89 float shiftY ; 90 float shiftZ ; 90 float shiftX ; // to be removed 91 float shiftY ; // to be removed 92 float shiftZ ; // to be removed 93 float offsetX; 94 float offsetY; 95 float offsetZ; 91 96 int cmScaleX; 92 97 int cmScaleY;
Note: See TracChangeset
for help on using the changeset viewer.