Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7491 in orxonox.OLD


Ignore:
Timestamp:
May 3, 2006, 12:32:07 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

    r7490 r7491  
    133133
    134134    w = j1;
     135
     136    // add a vertex to the list
    135137    model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right
    136     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);
     138    model->addNormal(normalVectorField[i % this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].y,
     139                     normalVectorField[i % this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].z,
     140                     normalVectorField[i % this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].x);
    137141    model->addTexCoor((float)(j1-sampleRate) /(texRate), (float)(i %this->heightMapReference->heightMap->h)/(texRate));
    138 
    139     model->addColor(r/255.0,g/255.0,b/255.0);
    140 
    141     for(int j = j1  ; j <= j2    ;  j += sampleRate)
    142     {
    143 
    144 
    145       // To be fixed
    146       if(this->heightMapReference->hasColourMap)
     142    model->addColor(r/255.0f,g/255.0f,b/255.0f);
     143
     144
     145    for(int j = j1; j <= j2; j += sampleRate)
     146    {
     147      // adjust the colors acording to the color map
     148      if( this->heightMapReference->hasColourMap)
    147149      {
    148         r = colors[(3*j+2 + 3*i*(this->heightMapReference->heightMap->w )) ];
    149         g =  colors[(3*j+1 + 3*i*(this->heightMapReference->heightMap->w)) ];
    150         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)];
    151153      }
    152       height = (float)(unsigned char) this->heightMapReference->heights[(j +sampleRate+ i*(this->heightMapReference->heightMap->w )) ];
    153       height += (float)(unsigned char) this->heightMapReference->heights[(j+ 1 + sampleRate + (i+1)*(this->heightMapReference->heightMap->w )) ];
    154       height +=  (float) (unsigned char) this->heightMapReference->heights[(j -1+ sampleRate   + (i+1)*(this->heightMapReference->heightMap->w ))];
    155       height +=  (float)(unsigned char)this->heightMapReference->heights[(j +sampleRate+ (i+2)*(this->heightMapReference->heightMap->w )) ];
    156       height +=  (float)(unsigned char)this->heightMapReference->heights[(j+sampleRate + (i)*(this->heightMapReference->heightMap->w )) ];
    157       height=height/5.0;
     154      height =  (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * (this->heightMapReference->heightMap->w)];
     155      height += (float)(unsigned char)this->heightMapReference->heights[j + 1 + sampleRate + (i + 1) *
     156                                                                        (this->heightMapReference->heightMap->w)];
     157      height += (float)(unsigned char)this->heightMapReference->heights[j - 1 + sampleRate + (i + 1) *
     158                                                                        (this->heightMapReference->heightMap->w )];
     159      height += (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + (i + 2) *
     160                                                                        (this->heightMapReference->heightMap->w)];
     161      height += (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * (this->heightMapReference->heightMap->w)];
     162      height /= 5.0;
    158163
    159164      model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i) + shiftX ,((double)(height)*scaleY) + shiftY ,scaleZ*(j) + shiftZ); // Top Right
     
    341346  if(heightMap!=NULL)
    342347  {
     348    /*
     349        WHAT about following checks:
     350    - image size (rectangular?)
     351    - image file type (bw?)
     352
     353    */
    343354
    344355    PRINTF(0)("loading Image %s\n", height_map_name.c_str());
Note: See TracChangeset for help on using the changeset viewer.