- Timestamp:
- May 3, 2006, 12:47:29 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/height_map.cc
r7492 r7494 154 154 height = (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * (this->heightMapReference->heightMap->w)]; 155 155 height += (float)(unsigned char)this->heightMapReference->heights[j + 1 + sampleRate + (i + 1) * 156 (this->heightMapReference->heightMap->w)];156 this->heightMapReference->heightMap->w]; 157 157 height += (float)(unsigned char)this->heightMapReference->heights[j - 1 + sampleRate + (i + 1) * 158 (this->heightMapReference->heightMap->w )];158 this->heightMapReference->heightMap->w]; 159 159 height += (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + (i + 2) * 160 (this->heightMapReference->heightMap->w)];160 this->heightMapReference->heightMap->w]; 161 161 height += (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * (this->heightMapReference->heightMap->w)]; 162 162 height /= 5.0; … … 174 174 w = j; 175 175 } 176 177 178 176 model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right 179 model->addNormal(normalVectorField[i % this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].y,normalVectorField[i % this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].z,normalVectorField[i% this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].x); 177 model->addNormal(normalVectorField[i % this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].y, 178 normalVectorField[i % this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].z, 179 normalVectorField[i% this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].x); 180 180 model->addTexCoor((float)(j2+sampleRate) /(texRate), (float)(i %this->heightMapReference->heightMap->h)/(texRate)); 181 model->addColor(r/255.0 ,g/255.0,b/255.0);181 model->addColor(r/255.0f, g/255.0f, b/255.0f); 182 182 } 183 183 … … 217 217 model->addTexCoor((float)j /(texRate), (float)((i - sampleRate) %this->heightMapReference->heightMap->h)/(texRate)); 218 218 model->addColor(r/255.0f, g/255.0f, b/255.0f); 219 220 } 219 } 220 221 221 222 222 for(int j = j1 ; j <= j2 ; j += sampleRate) 223 223 { 224 224 int i = i1; 225 height = (float)(unsigned char) this->heightMapReference->heights[(j +sampleRate+ i*(this->heightMapReference->heightMap->w )) ]; 226 height += (float)(unsigned char) this->heightMapReference->heights[(j+ 1 + sampleRate + (i+1)*(this->heightMapReference->heightMap->w )) ]; 227 height += (float) (unsigned char) this->heightMapReference->heights[(j -1+ sampleRate + (i+1)*(this->heightMapReference->heightMap->w ))]; 228 height += (float)(unsigned char)this->heightMapReference->heights[(j +sampleRate+ (i+2)*(this->heightMapReference->heightMap->w )) ]; 229 height += (float)(unsigned char)this->heightMapReference->heights[(j+sampleRate + (i)*(this->heightMapReference->heightMap->w )) ]; 225 height = (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * this->heightMapReference->heightMap->w]; 226 height += (float)(unsigned char)this->heightMapReference->heights[j + 1 + sampleRate + (i + 1) * 227 this->heightMapReference->heightMap->w]; 228 height += (float)(unsigned char)this->heightMapReference->heights[j - 1 + sampleRate + (i + 1) * 229 this->heightMapReference->heightMap->w]; 230 height += (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + (i + 2) * 231 this->heightMapReference->heightMap->w]; 232 height += (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * this->heightMapReference->heightMap->w]; 230 233 height=height/5.0; 231 234 232 model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right 233 model->addNormal(normalVectorField[i % this->heightMapReference->heightMap->h][j % this->heightMapReference->heightMap->w].y,normalVectorField[i % this->heightMapReference->heightMap->h][j% this->heightMapReference->heightMap->w].z,normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].x); 235 model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i) + shiftX , 236 ((double)(height)*scaleY) +shiftY , 237 scaleZ*(j) + shiftZ); // Top Right 238 model->addNormal(normalVectorField[i % this->heightMapReference->heightMap->h][j % this->heightMapReference->heightMap->w].y, 239 normalVectorField[i % this->heightMapReference->heightMap->h][j% this->heightMapReference->heightMap->w].z, 240 normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].x); 234 241 model->addTexCoor((float)j /(texRate), (float)(i %this->heightMapReference->heightMap->h)/(texRate)); 235 model->addColor(r/255.0,g/255.0,b/255.0); 236 237 } 238 239 240 241 for(int j = j1 ; j <= j2 ; j += sampleRate) 242 model->addColor(r/255.0f, g/255.0f, b/255.0f); 243 } 244 245 246 for(int j = j1; j <= j2; j += sampleRate) 242 247 { 243 248 int i = i2; 244 245 249 // To be fixed 246 if(this->heightMapReference->hasColourMap) 247 { 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)]; 251 } 252 253 model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right 254 model->addNormal(normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].y,normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].z,normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].x); 250 if( this->heightMapReference->hasColourMap) 251 { 252 r = (float)colors[3 * j + 2 + 3 * i * this->heightMapReference->heightMap->w]; 253 g = (float)colors[3 * j + 1 + 3 * i * this->heightMapReference->heightMap->w]; 254 b = (float)colors[3 * j + 0 + 3 * i * this->heightMapReference->heightMap->w]; 255 } 256 257 model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i) + shiftX , 258 shiftY , 259 scaleZ*(j) + shiftZ); // Top Right 260 model->addNormal(normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].y, 261 normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].z, 262 normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].x); 255 263 model->addTexCoor((float)j /(texRate), (float)((i+ sampleRate) %this->heightMapReference->heightMap->h)/(texRate)); 256 model->addColor(r/255.0,g/255.0,b/255.0); 257 258 } 259 260 261 for(int j = j1 ; j <= j2 ; j += sampleRate) 264 model->addColor(r/255.0f, g/255.0f, b/255.0f); 265 } 266 267 268 for(int j = j1; j <= j2; j += sampleRate) 262 269 { 263 270 int i = i2; 264 height = (float)(unsigned char) this->heightMapReference->heights[(j +sampleRate+ i*(this->heightMapReference->heightMap->w )) ]; 265 height += (float)(unsigned char) this->heightMapReference->heights[(j+ 1 + sampleRate + (i+1)*(this->heightMapReference->heightMap->w )) ]; 271 height = (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * this->heightMapReference->heightMap->w]; 272 height += (float)(unsigned char)this->heightMapReference->heights[j + 1 + sampleRate + (i + 1) 273 * this->heightMapReference->heightMap->w]; 266 274 height += (float) (unsigned char) this->heightMapReference->heights[(j -1+ sampleRate + (i+1)*(this->heightMapReference->heightMap->w ))]; 267 275 height += (float)(unsigned char)this->heightMapReference->heights[(j +sampleRate+ (i+2)*(this->heightMapReference->heightMap->w ))];
Note: See TracChangeset
for help on using the changeset viewer.