Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 3, 2006, 12:36:31 AM (18 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

    r7491 r7492  
    127127    if( this->heightMapReference->hasColourMap)
    128128    {
    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];
    132132    }
    133133
     
    140140                     normalVectorField[i % this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].x);
    141141    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);
    143143
    144144
     
    148148      if( this->heightMapReference->hasColourMap)
    149149      {
    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];
    153153      }
    154154      height =  (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * (this->heightMapReference->heightMap->w)];
     
    162162      height /= 5.0;
    163163
    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);
    166170      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);
    168172      //PRINTF(0)("TexCoord:  %f %f \n",(float)j / 100.0, (float)(i %this->heightMapReference->h)/100.0);
    169173
    170       model->addColor(r/255.0,g/255.0,b/255.0);
    171174      w = j;
    172175    }
     
    177180    model->addTexCoor((float)(j2+sampleRate) /(texRate), (float)(i %this->heightMapReference->heightMap->h)/(texRate));
    178181    model->addColor(r/255.0,g/255.0,b/255.0);
    179 
    180   }
    181 
    182 
    183 
    184 
     182  }
    185183
    186184  SDL_UnlockSurface(this->heightMapReference->heightMap);
    187185  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    {
    194191      model->addIndice(cnt);
    195192      model->addIndice(cnt  + (j2 -j1 + 3* sampleRate  )/ sampleRate );
    196193      cnt++;
    197 
    198     }
    199 
    200 
    201 
     194    }
    202195    model->newStripe();
    203 
    204 
    205196  }
    206197  cnt += (j2 -j1 + 3* sampleRate)/ sampleRate;
    207198
    208   for(int j = j1 ; j <= j2    ; j += sampleRate)
     199  for( int j = j1; j <= j2; j += sampleRate)
    209200  {
    210201    int i = i1;
     
    213204    if(this->heightMapReference->hasColourMap)
    214205    {
    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);
    222217    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);
    224219
    225220  }
Note: See TracChangeset for help on using the changeset viewer.