Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6529 in orxonox.OLD for branches/height_map/src/lib/graphics


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

Some bugs fixed

Location:
branches/height_map/src/lib/graphics/importer
Files:
4 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;
  • branches/height_map/src/lib/graphics/importer/height_map.h

    r6472 r6529  
    1717
    1818
    19 #define texRate      4
     19#define texRate      22
    2020#define texRatef     4.0f
    21 #define tileSize     64
     21#define tileSize     32
    2222
    2323class SDL_Surface;
  • branches/height_map/src/lib/graphics/importer/static_model.cc

    r6472 r6529  
    289289         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    290290    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    291 
     291       
    292292  if (groupName == NULL)
    293293     return;
  • branches/height_map/src/lib/graphics/importer/vertex_array_model.cc

    r6472 r6529  
    3434{
    3535
    36    this->tex1 = new Texture("pictures/ground.tga");
    37   this->tex1->setName("test1");
    38   this->tex2 = new Texture("pictures/heightmapHelloCM.bmp");
    39   this->tex2->setName("test2");
     36
    4037
    4138 
     
    182179  this->texCoords1.push_back(u);
    183180  this->texCoords1.push_back(v);
    184   this->texCoords2.push_back(w);
    185   this->texCoords2.push_back(x);
     181  //this->texCoords2.push_back(w);
     182  //this->texCoords2.push_back(x);
    186183  this->pModelInfo.numTexCoor++;
    187184}
     
    190187  this->texCoords1.push_back(u);
    191188  this->texCoords1.push_back(v);
    192   this->texCoords2.push_back(0.0);
    193   this->texCoords2.push_back(0.0);
     189 
    194190  this->pModelInfo.numTexCoor++;
    195191}
Note: See TracChangeset for help on using the changeset viewer.