Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 18, 2006, 1:18:40 PM (18 years ago)
Author:
bottac
Message:

Some bugs fixed

File:
1 edited

Legend:

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

    r6472 r6529  
    3737lowResModel  = new VertexArrayModel();
    3838
    39 this->load(i1,j1,i2,j2,hm,highResModel,4);
    40 this->load(i1,j1,i2,j2,hm,lowResModel, 32);
     39this->load(i1,j1,i2,j2,hm,highResModel,2);
     40this->load(i1,j1,i2,j2,hm,lowResModel, 8);
    4141}
    4242
     
    8484        int sampleRate = Res;
    8585       
    86         unsigned char height = 0;
     86         float height = 0;
    8787        int offset = 0;
    8888       
     
    128128                 b = (float)colours[3*j+0 + 3*i*(heightMap->w)];
    129129                 }
    130                 height =  hm->heights[j+sampleRate + i*(heightMap->w )];
     130                height = (float)(unsigned char) hm->heights[j +sampleRate+ i*(heightMap->w )];
     131                height += (float)(unsigned char) hm->heights[j+ 1 + sampleRate + (i+1)*(heightMap->w )];
     132                height +=  (float) (unsigned char) hm->heights[j -1+ sampleRate   + (i+1)*(heightMap->w )];
     133                height +=  (float)(unsigned char)hm->heights[j +sampleRate+ (i+2)*(heightMap->w )];
     134                height +=  (float)(unsigned char)hm->heights[j+sampleRate + (i)*(heightMap->w )];
     135               
     136                height=height/5.0;
     137               
    131138                model->addVertex(scaleX*(heightMap->h -i) + shiftX ,((double)(height)*scaleY) + shiftY ,scaleZ*(j) + shiftZ); // Top Right     
    132139                model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x);
    133                 model->addTexCoor(((j/sampleRate)%texRate)/texRatef,((i/sampleRate)%texRate)/texRatef, ((j/sampleRate)%heightMap->w)/float(heightMap->w),((i/sampleRate)%heightMap->h)/float(heightMap->h));
    134 
     140                model->addTexCoor((float)j /(texRate), (float)(i %heightMap->h)/(texRate));
     141               
     142                //PRINTF(0)("TexCoord:  %f %f \n",(float)j / 100.0, (float)(i %heightMap->h)/100.0);
     143               
    135144                model->addColor(r/255.0,g/255.0,b/255.0);
    136                
    137                
    138145                w = j;
    139146            }
     
    142149                model->addVertex(scaleX*(heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right
    143150                model->addNormal(normalVectorField[i][w].y,normalVectorField[i][w].z,normalVectorField[i][w].x);
    144                 model->addTexCoor((((w+sampleRate)/sampleRate)%4)/4.0,(((i+ sampleRate)/sampleRate)%4)/4.0);
     151                model->addTexCoor((((w+sampleRate)/sampleRate))/4.0,(((i+ sampleRate)/sampleRate))/4.0);
    145152                model->addColor(r/255.0,g/255.0,b/255.0);
    146153               
     
    187194                model->addVertex(scaleX*(heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right
    188195                model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x);
    189                 model->addTexCoor(((j/sampleRate)%texRate)/texRatef,(((i - sampleRate)/sampleRate)%texRate)/texRatef, ((j/sampleRate)%heightMap->w)/float(heightMap->w),(((i - sampleRate) /sampleRate)%heightMap->h)/float(heightMap->h));
     196                model->addTexCoor(((j/sampleRate))/texRatef,(((i - sampleRate)/sampleRate))/texRatef, ((j/sampleRate)%heightMap->w)/float(heightMap->w),(((i - sampleRate) /sampleRate)%heightMap->h)/float(heightMap->h));
    190197                model->addColor(r/255.0,g/255.0,b/255.0);               
    191198       
     
    195202            {
    196203                int i = i1;
    197                 height =  hm->heights[j+sampleRate + i*(heightMap->w )];
     204                height = (float)(unsigned char) hm->heights[j +sampleRate+ i*(heightMap->w )];
     205                height += (float)(unsigned char) hm->heights[j+ 1 + sampleRate + (i+1)*(heightMap->w )];
     206                height +=  (float) (unsigned char) hm->heights[j -1+ sampleRate   + (i+1)*(heightMap->w )];
     207                height +=  (float)(unsigned char)hm->heights[j +sampleRate+ (i+2)*(heightMap->w )];
     208                height +=  (float)(unsigned char)hm->heights[j+sampleRate + (i)*(heightMap->w )];
     209                height=height/5.0;
     210               
    198211                model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right     
    199212                model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x);
    200                 model->addTexCoor(((j/sampleRate)%texRate)/texRatef,(((i)/sampleRate)%texRate)/texRatef, ((j/sampleRate)%heightMap->w)/float(heightMap->w),(((i)/sampleRate)%heightMap->h)/float(heightMap->h));
     213                model->addTexCoor(((j/sampleRate))/texRatef,(((i)/sampleRate))/texRatef, ((j/sampleRate)%heightMap->w)/float(heightMap->w),(((i)/sampleRate)%heightMap->h)/float(heightMap->h));
    201214                model->addColor(r/255.0,g/255.0,b/255.0);
    202215           
     
    228241            {
    229242                int i = i2;
    230                 height =  hm->heights[j+sampleRate + i*(heightMap->w )];
     243                        height = (float)(unsigned char) hm->heights[j +sampleRate+ i*(heightMap->w )];
     244                height += (float)(unsigned char) hm->heights[j+ 1 + sampleRate + (i+1)*(heightMap->w )];
     245                height +=  (float) (unsigned char) hm->heights[j -1+ sampleRate   + (i+1)*(heightMap->w )];
     246                height +=  (float)(unsigned char)hm->heights[j +sampleRate+ (i+2)*(heightMap->w )];
     247                height +=  (float)(unsigned char)hm->heights[j+sampleRate + (i)*(heightMap->w )];
     248                height=height/5.0;
    231249                model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right     
    232250                model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x);
     
    349367  colourMap = IMG_Load(colour_map_name);
    350368  }
     369 
    351370  if(colourMap != NULL)
    352371                {
     
    373392 
    374393       
    375    heights  = (unsigned char*) heightMap->pixels;
     394  heights  = (unsigned char*) heightMap->pixels;
    376395
    377396
     
    409428
    410429int i_min = 1;
    411 int i_max = (heightMap->h - tileSize)/ tileSize;
     430int i_max = (heightMap->h - tileSize )/ tileSize;
    412431int j_min = 1;
    413432int j_max= (heightMap->w - tileSize) / tileSize;
Note: See TracChangeset for help on using the changeset viewer.