Changeset 6529 in orxonox.OLD for branches/height_map/src
- Timestamp:
- Jan 18, 2006, 1:18:40 PM (19 years ago)
- Location:
- branches/height_map/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/height_map/src/lib/graphics/importer/height_map.cc
r6472 r6529 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 … … 84 84 int sampleRate = Res; 85 85 86 unsigned charheight = 0;86 float height = 0; 87 87 int offset = 0; 88 88 … … 128 128 b = (float)colours[3*j+0 + 3*i*(heightMap->w)]; 129 129 } 130 height = hm->heights[j+sampleRate + i*(heightMap->w )]; 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 131 138 model->addVertex(scaleX*(heightMap->h -i) + shiftX ,((double)(height)*scaleY) + shiftY ,scaleZ*(j) + shiftZ); // Top Right 132 139 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, ((j/sampleRate)%heightMap->w)/float(heightMap->w),((i/sampleRate)%heightMap->h)/float(heightMap->h)); 134 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 135 144 model->addColor(r/255.0,g/255.0,b/255.0); 136 137 138 145 w = j; 139 146 } … … 142 149 model->addVertex(scaleX*(heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right 143 150 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);151 model->addTexCoor((((w+sampleRate)/sampleRate))/4.0,(((i+ sampleRate)/sampleRate))/4.0); 145 152 model->addColor(r/255.0,g/255.0,b/255.0); 146 153 … … 187 194 model->addVertex(scaleX*(heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right 188 195 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, ((j/sampleRate)%heightMap->w)/float(heightMap->w),(((i - sampleRate) /sampleRate)%heightMap->h)/float(heightMap->h));196 model->addTexCoor(((j/sampleRate))/texRatef,(((i - sampleRate)/sampleRate))/texRatef, ((j/sampleRate)%heightMap->w)/float(heightMap->w),(((i - sampleRate) /sampleRate)%heightMap->h)/float(heightMap->h)); 190 197 model->addColor(r/255.0,g/255.0,b/255.0); 191 198 … … 195 202 { 196 203 int i = i1; 197 height = hm->heights[j+sampleRate + i*(heightMap->w )]; 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 198 211 model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right 199 212 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, ((j/sampleRate)%heightMap->w)/float(heightMap->w),(((i)/sampleRate)%heightMap->h)/float(heightMap->h));213 model->addTexCoor(((j/sampleRate))/texRatef,(((i)/sampleRate))/texRatef, ((j/sampleRate)%heightMap->w)/float(heightMap->w),(((i)/sampleRate)%heightMap->h)/float(heightMap->h)); 201 214 model->addColor(r/255.0,g/255.0,b/255.0); 202 215 … … 228 241 { 229 242 int i = i2; 230 height = hm->heights[j+sampleRate + i*(heightMap->w )]; 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; 231 249 model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right 232 250 model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x); … … 349 367 colourMap = IMG_Load(colour_map_name); 350 368 } 369 351 370 if(colourMap != NULL) 352 371 { … … 373 392 374 393 375 394 heights = (unsigned char*) heightMap->pixels; 376 395 377 396 … … 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; -
branches/height_map/src/lib/graphics/importer/height_map.h
r6472 r6529 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/src/lib/graphics/importer/static_model.cc
r6472 r6529 289 289 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 290 290 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 291 291 292 292 if (groupName == NULL) 293 293 return; -
branches/height_map/src/lib/graphics/importer/vertex_array_model.cc
r6472 r6529 34 34 { 35 35 36 this->tex1 = new Texture("pictures/ground.tga"); 37 this->tex1->setName("test1"); 38 this->tex2 = new Texture("pictures/heightmapHelloCM.bmp"); 39 this->tex2->setName("test2"); 36 40 37 41 38 … … 182 179 this->texCoords1.push_back(u); 183 180 this->texCoords1.push_back(v); 184 this->texCoords2.push_back(w);185 this->texCoords2.push_back(x);181 //this->texCoords2.push_back(w); 182 //this->texCoords2.push_back(x); 186 183 this->pModelInfo.numTexCoor++; 187 184 } … … 190 187 this->texCoords1.push_back(u); 191 188 this->texCoords1.push_back(v); 192 this->texCoords2.push_back(0.0); 193 this->texCoords2.push_back(0.0); 189 194 190 this->pModelInfo.numTexCoor++; 195 191 } -
branches/height_map/src/world_entities/terrain.cc
r6472 r6529 67 67 char* colourmapName = ResourceManager::getFullName("pictures/heightmapHelloCM.bmp"); 68 68 hm = new HeightMap(heightmapName, colourmapName); 69 hm->scale(Vector(23.0f, 0.7f,23.0f));69 hm->scale(Vector(23.0f,3.5f,23.0f)); 70 70 hm->shift(Vector(-1000.0,-90.0,-4000.0)); 71 71 hm->load(); … … 235 235 236 236 this->tmp_mat->select(); 237 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 238 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 239 237 240 238 241 hm->draw();
Note: See TracChangeset
for help on using the changeset viewer.