- Timestamp:
- May 3, 2006, 12:36:31 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/height_map.cc
r7491 r7492 127 127 if( this->heightMapReference->hasColourMap) 128 128 { 129 r = colors[3 * w + 2 + 3 * i * (this->heightMapReference->heightMap->w)];130 g = colors[3 * w + 1 + 3 * i * (this->heightMapReference->heightMap->w)];131 b = colors[3 * w + 0 + 3 * i * (this->heightMapReference->heightMap->w)];129 r = colors[3 * w + 2 + 3 * i * this->heightMapReference->heightMap->w]; 130 g = colors[3 * w + 1 + 3 * i * this->heightMapReference->heightMap->w]; 131 b = colors[3 * w + 0 + 3 * i * this->heightMapReference->heightMap->w]; 132 132 } 133 133 … … 140 140 normalVectorField[i % this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].x); 141 141 model->addTexCoor((float)(j1-sampleRate) /(texRate), (float)(i %this->heightMapReference->heightMap->h)/(texRate)); 142 model->addColor(r/255.0f, g/255.0f,b/255.0f);142 model->addColor(r/255.0f, g/255.0f, b/255.0f); 143 143 144 144 … … 148 148 if( this->heightMapReference->hasColourMap) 149 149 { 150 r = colors[3 * j + 2 + 3 * i * (this->heightMapReference->heightMap->w)];151 g = colors[3 * j + 1 + 3 * i * (this->heightMapReference->heightMap->w)];152 b = colors[3 * j + 0 + 3 * i * (this->heightMapReference->heightMap->w)];150 r = colors[3 * j + 2 + 3 * i * this->heightMapReference->heightMap->w]; 151 g = colors[3 * j + 1 + 3 * i * this->heightMapReference->heightMap->w]; 152 b = colors[3 * j + 0 + 3 * i * this->heightMapReference->heightMap->w]; 153 153 } 154 154 height = (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * (this->heightMapReference->heightMap->w)]; … … 162 162 height /= 5.0; 163 163 164 model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i) + shiftX ,((double)(height)*scaleY) + shiftY ,scaleZ*(j) + shiftZ); // Top Right 165 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); 164 model->addVertex(scaleX * (this->heightMapReference->heightMap->h -i) + shiftX , 165 ((double)(height)*scaleY) + shiftY , 166 scaleZ*(j) + shiftZ); // Top Right 167 model->addNormal(normalVectorField[i % this->heightMapReference->heightMap->h][j % this->heightMapReference->heightMap->w].y, 168 normalVectorField[i % this->heightMapReference->heightMap->h][j % this->heightMapReference->heightMap->w].z, 169 normalVectorField[i % this->heightMapReference->heightMap->h][j % this->heightMapReference->heightMap->w].x); 166 170 model->addTexCoor((float)(j) /(texRate), (float)(i %this->heightMapReference->heightMap->h)/(texRate)); 167 171 model->addColor(r/255.0f, g/255.0f, b/255.0f); 168 172 //PRINTF(0)("TexCoord: %f %f \n",(float)j / 100.0, (float)(i %this->heightMapReference->h)/100.0); 169 173 170 model->addColor(r/255.0,g/255.0,b/255.0);171 174 w = j; 172 175 } … … 177 180 model->addTexCoor((float)(j2+sampleRate) /(texRate), (float)(i %this->heightMapReference->heightMap->h)/(texRate)); 178 181 model->addColor(r/255.0,g/255.0,b/255.0); 179 180 } 181 182 183 184 182 } 185 183 186 184 SDL_UnlockSurface(this->heightMapReference->heightMap); 187 185 int cnt = 0; 188 for(int i = i1 ; i < i2 ; i +=sampleRate) 189 { 190 191 for(int j = j1-sampleRate ; j < j2 + 2*sampleRate ; j += sampleRate) 192 { 193 186 187 for( int i = i1; i < i2; i +=sampleRate) 188 { 189 for( int j = j1-sampleRate; j < j2 + 2 * sampleRate; j += sampleRate) 190 { 194 191 model->addIndice(cnt); 195 192 model->addIndice(cnt + (j2 -j1 + 3* sampleRate )/ sampleRate ); 196 193 cnt++; 197 198 } 199 200 201 194 } 202 195 model->newStripe(); 203 204 205 196 } 206 197 cnt += (j2 -j1 + 3* sampleRate)/ sampleRate; 207 198 208 for( int j = j1 ; j <= j2 ;j += sampleRate)199 for( int j = j1; j <= j2; j += sampleRate) 209 200 { 210 201 int i = i1; … … 213 204 if(this->heightMapReference->hasColourMap) 214 205 { 215 r = (float)colors[(3*j+2 + 3*i*(this->heightMapReference->heightMap->w )) ]; 216 g = (float)colors[(3*j+1 + 3*i*(this->heightMapReference->heightMap->w)) ]; 217 b = (float)colors[(3*j+0 + 3*i*(this->heightMapReference->heightMap->w))]; 218 } 219 220 model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right 221 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); 206 r = (float)colors[3 * j + 2 + 3 * i * this->heightMapReference->heightMap->w]; 207 g = (float)colors[3 * j + 1 + 3 * i * this->heightMapReference->heightMap->w]; 208 b = (float)colors[3 * j + 0 + 3 * i * this->heightMapReference->heightMap->w]; 209 } 210 211 model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i) + shiftX , 212 shiftY , 213 scaleZ*(j) + shiftZ); // Top Right 214 model->addNormal(normalVectorField[i % this->heightMapReference->heightMap->h][j % this->heightMapReference->heightMap->w].y, 215 normalVectorField[i % this->heightMapReference->heightMap->h][j % this->heightMapReference->heightMap->w].z, 216 normalVectorField[i % this->heightMapReference->heightMap->h][j % this->heightMapReference->heightMap->w].x); 222 217 model->addTexCoor((float)j /(texRate), (float)((i - sampleRate) %this->heightMapReference->heightMap->h)/(texRate)); 223 model->addColor(r/255.0 ,g/255.0,b/255.0);218 model->addColor(r/255.0f, g/255.0f, b/255.0f); 224 219 225 220 }
Note: See TracChangeset
for help on using the changeset viewer.