Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7494 in orxonox.OLD for trunk/src/lib/graphics/importer


Ignore:
Timestamp:
May 3, 2006, 12:47:29 AM (19 years ago)
Author:
patrick
Message:

resuming work on the hm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/importer/height_map.cc

    r7492 r7494  
    154154      height =  (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * (this->heightMapReference->heightMap->w)];
    155155      height += (float)(unsigned char)this->heightMapReference->heights[j + 1 + sampleRate + (i + 1) *
    156                                                                         (this->heightMapReference->heightMap->w)];
     156                                                                        this->heightMapReference->heightMap->w];
    157157      height += (float)(unsigned char)this->heightMapReference->heights[j - 1 + sampleRate + (i + 1) *
    158                                                                         (this->heightMapReference->heightMap->w )];
     158                                                                        this->heightMapReference->heightMap->w];
    159159      height += (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + (i + 2) *
    160                                                                         (this->heightMapReference->heightMap->w)];
     160                                                                        this->heightMapReference->heightMap->w];
    161161      height += (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * (this->heightMapReference->heightMap->w)];
    162162      height /= 5.0;
     
    174174      w = j;
    175175    }
    176 
    177 
    178176    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);
    180180    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);
    182182  }
    183183
     
    217217    model->addTexCoor((float)j /(texRate), (float)((i - sampleRate) %this->heightMapReference->heightMap->h)/(texRate));
    218218    model->addColor(r/255.0f, g/255.0f, b/255.0f);
    219 
    220   }
     219  }
     220
    221221
    222222  for(int j = j1  ; j <= j2    ;  j += sampleRate)
    223223  {
    224224    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];
    230233    height=height/5.0;
    231234
    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);
    234241    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)
    242247  {
    243248    int i = i2;
    244 
    245249    // 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);
    255263    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)
    262269  {
    263270    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];
    266274    height +=  (float) (unsigned char) this->heightMapReference->heights[(j -1+ sampleRate   + (i+1)*(this->heightMapReference->heightMap->w ))];
    267275    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.