Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6494 in orxonox.OLD


Ignore:
Timestamp:
Jan 11, 2006, 5:18:15 PM (18 years ago)
Author:
bensch
Message:

orxonox/branches/height_map: copy the heightMap to the trunk_merge-branche

Location:
height_map_merge/src/lib/graphics/importer
Files:
2 edited

Legend:

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

    r6100 r6494  
    1010
    1111   ### File Specific:
    12    main-programmer:
     12   main-programmer: bottac@ee.ethz.ch
    1313*/
    1414
     
    1717#include "texture.h"
    1818#include "vector.h"
    19 
     19#include "material.h"
     20#include "p_node.h"
     21#include "state.h"
     22#include "resource_manager.h"
    2023#include "debug.h"
    2124
     
    2730#endif
    2831
    29 HeightMap::HeightMap() : StaticModel()
    30 {
    31        
    32 }
    33 
    34 HeightMap::HeightMap(const char* height_map_name = NULL) : StaticModel()
     32Tile::Tile(int i1, int j1, int i2, int j2, HeightMap* hm )
     33{
     34
     35PRINTF(0)("Tile Constructor\n");
     36highResModel = new VertexArrayModel();
     37lowResModel  = new VertexArrayModel();
     38
     39this->load(i1,j1,i2,j2,hm,highResModel,4);
     40this->load(i1,j1,i2,j2,hm,lowResModel, 32);
     41}
     42
     43Tile::Tile()
     44{
     45PRINTF(0)("ooops *********************************************************************************************************************************************************************************************************** \n");
     46}
     47
     48Tile::~Tile()
     49{
     50 delete highResModel;
     51 delete lowResModel;
     52}
     53
     54void Tile::draw()
     55{
     56 lowResModel->draw();
     57}
     58
     59void Tile::drawHighRes()
     60{
     61 highResModel->draw();
     62}
     63
     64void Tile::drawLowRes()
     65{
     66 lowResModel->draw();
     67}
     68
     69/*
     70*/
     71void Tile::load(int i1, int j1, int i2, int j2, HeightMap* hm, VertexArrayModel* model, int Res)
     72{
     73
     74        #define heightMap hm->heightMap
     75        #define colours   hm->colours
     76        #define scaleX hm->scaleX
     77        #define scaleY hm->scaleY
     78        #define scaleZ hm->scaleZ
     79        #define shiftX hm->shiftX
     80        #define shiftY hm->shiftY
     81        #define shiftZ hm->shiftZ
     82        #define normalVectorField hm->normalVectorField
     83
     84        int sampleRate = Res;
     85
     86        unsigned char height = 0;
     87        int offset = 0;
     88
     89        float r = 0.0;
     90        float g = 0.0;
     91        float b = 0.0;
     92
     93
     94PRINTF(0)("loadin * \n");
     95
     96 if(heightMap != NULL && heightMap->format->BitsPerPixel == 8 )
     97
     98        SDL_LockSurface(heightMap);
     99
     100        for(int i = i1 ; i <= i2  ; i +=sampleRate)
     101        {
     102                int w = 0;
     103
     104
     105
     106                 if(hm->hasColourMap)
     107                 {
     108                 r = (float)colours[3*w+2 + 3*i*(heightMap->w )];
     109                 g = (float)colours[3*w+1 + 3*i*(heightMap->w)];
     110                 b = (float)colours[3*w+0 + 3*i*(heightMap->w)];
     111                 }
     112
     113                w = j1;
     114                model->addVertex(scaleX*(heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right
     115                model->addNormal(normalVectorField[i][w].y,normalVectorField[i][w].z,normalVectorField[i][w].x);
     116                model->addTexCoor((((w -sampleRate)/sampleRate)%4)/4.0,(((i-sampleRate)/sampleRate)%4)/4.0);
     117                model->addColor(r/255.0,g/255.0,b/255.0);
     118
     119            for(int j = j1  ; j <= j2    ;  j += sampleRate)
     120            {
     121
     122
     123                 // To be fixed
     124                 if(hm->hasColourMap)
     125                 {
     126                 r = (float)colours[3*j+2 + 3*i*(heightMap->w )];
     127                 g = (float)colours[3*j+1 + 3*i*(heightMap->w)];
     128                 b = (float)colours[3*j+0 + 3*i*(heightMap->w)];
     129                 }
     130                height =  hm->heights[j+sampleRate + i*(heightMap->w )];
     131                model->addVertex(scaleX*(heightMap->h -i) + shiftX ,((double)(height)*scaleY) + shiftY ,scaleZ*(j) + shiftZ); // Top Right
     132                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);
     134
     135                model->addColor(r/255.0,g/255.0,b/255.0);
     136
     137
     138                w = j;
     139            }
     140
     141
     142                model->addVertex(scaleX*(heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right
     143                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);
     145                model->addColor(r/255.0,g/255.0,b/255.0);
     146
     147        }
     148
     149
     150
     151
     152
     153        SDL_UnlockSurface(heightMap);
     154        int cnt = 0;
     155        for(int i = i1   ; i < i2  ; i +=sampleRate)
     156        {
     157
     158            for(int j = j1-sampleRate  ; j < j2  + 2*sampleRate  ;  j += sampleRate)
     159            {
     160
     161                model->addIndice(cnt);
     162                model->addIndice(cnt  + (j2 -j1 + 3* sampleRate  )/ sampleRate );
     163                cnt++;
     164
     165            }
     166
     167
     168
     169                 model->newStripe();
     170
     171
     172        }
     173         cnt += (j2 -j1 + 3* sampleRate)/ sampleRate;
     174
     175                for(int j = j1 ; j <= j2    ;  j += sampleRate)
     176            {
     177                int i = i1;
     178
     179                 // To be fixed
     180                 if(hm->hasColourMap)
     181                 {
     182                 r = (float)colours[3*j+2 + 3*i*(heightMap->w )];
     183                 g = (float)colours[3*j+1 + 3*i*(heightMap->w)];
     184                 b = (float)colours[3*j+0 + 3*i*(heightMap->w)];
     185                 }
     186
     187                model->addVertex(scaleX*(heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right
     188                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);
     190                model->addColor(r/255.0,g/255.0,b/255.0);
     191
     192            }
     193
     194                for(int j = j1  ; j <= j2    ;  j += sampleRate)
     195            {
     196                int i = i1;
     197                height =  hm->heights[j+sampleRate + i*(heightMap->w )];
     198                model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right
     199                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);
     201                model->addColor(r/255.0,g/255.0,b/255.0);
     202
     203            }
     204
     205
     206
     207            for(int j = j1  ; j <= j2    ;  j += sampleRate)
     208            {
     209                int i = i2;
     210
     211                 // To be fixed
     212                 if(hm->hasColourMap)
     213                 {
     214                 r = (float)colours[3*j+2 + 3*i*(heightMap->w )];
     215                 g = (float)colours[3*j+1 + 3*i*(heightMap->w)];
     216                 b = (float)colours[3*j+0 + 3*i*(heightMap->w)];
     217                 }
     218
     219                model->addVertex(scaleX*(heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right
     220                model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x);
     221                model->addTexCoor(((j/sampleRate)%texRate)/texRatef,(((i- sampleRate)/sampleRate)%texRate)/texRatef);
     222                model->addColor(r/255.0,g/255.0,b/255.0);
     223
     224            }
     225
     226
     227            for(int j = j1 ; j <= j2    ;  j += sampleRate)
     228            {
     229                int i = i2;
     230                height =  hm->heights[j+sampleRate + i*(heightMap->w )];
     231                model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right
     232                model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x);
     233                model->addTexCoor(((j/sampleRate)%texRate)/texRatef,((i/sampleRate)%texRate)/texRatef);
     234                model->addColor(r/255.0,g/255.0,b/255.0);
     235
     236            }
     237
     238
     239
     240
     241         // link Boarder Stripe
     242            for(int j = j1-sampleRate  ; j < j2    ;  j += sampleRate)
     243            {
     244
     245                model->addIndice(cnt);
     246                model->addIndice(cnt  + (j2 -j1 +  sampleRate  )/ sampleRate );
     247                cnt++;
     248
     249            }
     250
     251                cnt++;
     252
     253                 model->newStripe();
     254
     255
     256
     257
     258
     259         cnt += (j2-j1)/ sampleRate;
     260
     261        // link 2nd BoarderStripe
     262            for(int j = j1-sampleRate  ; j < j2    ;  j += sampleRate)
     263            {
     264
     265                model->addIndice(cnt);
     266                model->addIndice(cnt  + (j2 -j1 +  sampleRate  )/ sampleRate );
     267                cnt++;
     268
     269            }
     270
     271
     272
     273         model->finalize();
     274
     275
     276
     277
     278        #undef heightMap
     279        #undef colours
     280        #undef scaleX
     281        #undef scaleY
     282        #undef scaleZ
     283        #undef shiftX
     284        #undef shiftY
     285        #undef shiftZ
     286        #undef normalVectorField
     287
     288}
     289
     290HeightMap::HeightMap()
     291{
     292
     293}
     294
     295HeightMap::HeightMap(const char* height_map_name = NULL) : VertexArrayModel()
    35296{
    36297   this->setClassID(CL_HEIGHT_MAP, "HeightMap");
    37298   heightMap =  IMG_Load(height_map_name);
    38299   if(heightMap!=NULL) {
    39        
    40                 PRINTF(0)("loading Image %s\n", height_map_name);
    41                 PRINTF(0)("width : %i\n", heightMap->w);
    42                  PRINTF(0)("hight : %i\n", heightMap->h);
    43                 PRINTF(0)("%i Byte(s) per Pixel \n", heightMap->format->BytesPerPixel);
    44                 PRINTF(0)("Rshift : %i\n", heightMap->format->Rshift);
    45                 PRINTF(0)("Bshift: %i\n", heightMap->format->Bshift);
    46                 PRINTF(0)("Gshift: %i\n", heightMap->format->Gshift);
    47                 PRINTF(0)("Rmask: %i\n", heightMap->format->Rmask);
    48                  PRINTF(0)("Gmask: %i\n", heightMap->format->Gmask);           
    49                 }
    50                  
     300
     301                PRINTF(0)("loading Image %s\n", height_map_name);
     302                PRINTF(0)("width : %i\n", heightMap->w);
     303                 PRINTF(0)("height : %i\n", heightMap->h);
     304                PRINTF(0)("%i Byte(s) per Pixel \n", heightMap->format->BytesPerPixel);
     305                PRINTF(0)("Rshift : %i\n", heightMap->format->Rshift);
     306                PRINTF(0)("Bshift: %i\n", heightMap->format->Bshift);
     307                PRINTF(0)("Gshift: %i\n", heightMap->format->Gshift);
     308                PRINTF(0)("Rmask: %i\n", heightMap->format->Rmask);
     309                 PRINTF(0)("Gmask: %i\n", heightMap->format->Gmask);
     310                }
     311
    51312     else       PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name);
    52 }
    53 
    54 
     313
     314
     315  generateNormalVectorField();
     316
     317  shiftX = 0;
     318  shiftY = 0;
     319  shiftZ = 0;
     320
     321}
     322
     323HeightMap::HeightMap(const char* height_map_name = NULL, const char* colour_map_name = NULL) : VertexArrayModel()
     324{
     325this->setClassID(CL_HEIGHT_MAP, "HeightMap");
     326
     327   heightMap =  IMG_Load(height_map_name);
     328   if(heightMap!=NULL) {
     329
     330                 PRINTF(0)("loading Image %s\n", height_map_name);
     331                 PRINTF(0)("width : %i\n", heightMap->w);
     332                 PRINTF(0)("height : %i\n", heightMap->h);
     333                 PRINTF(0)("%i Byte(s) per Pixel \n", heightMap->format->BytesPerPixel);
     334                 PRINTF(0)("Rshift : %i\n", heightMap->format->Rshift);
     335                 PRINTF(0)("Bshift: %i\n", heightMap->format->Bshift);
     336                 PRINTF(0)("Gshift: %i\n", heightMap->format->Gshift);
     337                 PRINTF(0)("Rmask: %i\n", heightMap->format->Rmask);
     338                 PRINTF(0)("Gmask: %i\n", heightMap->format->Gmask);
     339                }
     340
     341     else       PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name);
     342
     343
     344    generateNormalVectorField();
     345
     346  colourMap=NULL;
     347  if(colour_map_name != NULL)
     348  {
     349  colourMap = IMG_Load(colour_map_name);
     350  }
     351  if(colourMap != NULL)
     352                {
     353                 PRINTF(0)("loading Image %s\n", colour_map_name);
     354                 PRINTF(0)("width : %i\n", colourMap->w);
     355                 PRINTF(0)("height : %i\n", colourMap->h);
     356                 PRINTF(0)("%i Byte(s) per Pixel \n", colourMap->format->BytesPerPixel);
     357                 PRINTF(0)("Rshift : %i\n", colourMap->format->Rshift);
     358                 PRINTF(0)("Bshift: %i\n", colourMap->format->Bshift);
     359                 PRINTF(0)("Gshift: %i\n", colourMap->format->Gshift);
     360                 PRINTF(0)("Rmask: %i\n", colourMap->format->Rmask);
     361                 PRINTF(0)("Gmask: %i\n", colourMap->format->Gmask);
     362                 }
     363                 else       PRINTF(0)("oops! couldn't load colorMap for some reason.\n");
     364
     365
     366
     367  if(colourMap != NULL)
     368  {
     369  colours = (unsigned char *) colourMap->pixels;
     370  hasColourMap = true;
     371  }
     372  else hasColourMap = false;
     373
     374
     375   heights  = (unsigned char*) heightMap->pixels;
     376
     377
     378}
    55379HeightMap::~HeightMap()
    56380{
    57         delete heightMap;
     381        delete heightMap;
    58382}
    59383
    60384void HeightMap::load()
    61385{
    62  unsigned char height = 0;
    63  int offset = 0;
    64 
    65  char *  bmp = (char*) heightMap->pixels;
    66 
    67   if(heightMap != NULL && heightMap->format->BitsPerPixel == 8 )
    68         {
    69         SDL_LockSurface(heightMap);
    70         for(int i = 0 ; i < heightMap->h  ; i +=2)
    71         {
    72             for(int j = 0; j < heightMap->w   ;  j += 2)
    73             {
    74                 // get local hight from heightMap
    75                 // This seems to work only on 8-Bit Grayscale-Bitmaps
    76                 height = bmp[j + i*(heightMap->w )];
    77                
    78                        
    79                 /*height = heightMap->format->palette->colors[offset].r +
    80                            heightMap->format->palette->colors[offset].g +
    81                            heightMap->format->palette->colors[offset].b ; */
    82                                        
    83                                
    84                 this->addVertex( 20*(heightMap->h - i) , (( (double)height)/0.3)-1200  ,20*j);
    85              } 
    86         }
    87         SDL_UnlockSurface(heightMap);
    88 
    89 
    90 
    91         int c = (heightMap->w)/2 ; // One line
    92         for(int i = 0; i < (heightMap->w)/2  -2  ; i ++)
    93         {
    94             for(int j = 0; j < (heightMap->h)/2 - 2; j++)
    95             {
    96                  
    97                 /* Two Triangles or ...*/
    98                
    99                 //this->addFace (3, VERTEX_ONLY,j + (i+1)*c,j+1+i*c , j + i*c );
    100                 //this->addFace (3, VERTEX_ONLY,j + (i+1)*c,j + (i+1)*c +1 ,j+i*c +1 );                         
    101                                  
    102                 /* ... one square*/
    103 
    104                 this->addFace (4 ,VERTEX_ONLY,j+i*c,j+(i+1)*c  ,j + (i+1)*c +1, j +i*c+1 );
    105             }
    106                                
    107                        
    108                                
    109         }
    110                
    111 
    112         }//if
    113   else
    114         {
    115 
    116   //make a cube
    117   this->setName("HardCore");
    118   this->addVertex (-0.5, -0.5, 0.5);
    119   this->addVertex (0.5, -0.5, 0.5);
    120   this->addVertex (-0.5, 0.5, 0.5);
    121   this->addVertex (0.5, 0.5, 0.5);
    122   this->addVertex (-0.5, 0.5, -0.5);
    123   this->addVertex (0.5, 0.5, -0.5);
    124   this->addVertex (-0.5, -0.5, -0.5);
    125   this->addVertex (0.5, -0.5, -0.5);
    126        
    127 
    128 
    129 
    130   this->addFace (3, VERTEX_ONLY, 4, 3, 2);
    131 
    132         }
    133       this->finalize();
    134 
    135 
    136 }
     386
     387//Create a Dynamicly sized 2D-Array for Tiles
     388tiles =  new Tile** [heightMap->h/tileSize];
     389for(int i=0;i <    heightMap->h/tileSize ; i++)
     390tiles [i]= new (Tile* [heightMap->w /tileSize ]);
     391
     392//SetUp Arrays
     393for(int i = 0; i < (heightMap->h - tileSize )/ tileSize; i ++)
     394{
     395        for(int j = 0; j < (heightMap->w - tileSize )/ tileSize; j ++)
     396        {
     397
     398         tiles[i][j] =    new Tile( i*tileSize ,  j*tileSize , (i+1)*tileSize, (j+1)*tileSize , this ) ;
     399        }
     400}
     401
     402}
     403
     404
     405void HeightMap::draw()
     406{
     407const PNode* camera = State::getCamera();
     408Vector v = camera->getAbsCoor();
     409
     410int i_min = 1;
     411int i_max = (heightMap->h - tileSize)/ tileSize;
     412int j_min = 1;
     413int j_max= (heightMap->w - tileSize) / tileSize;
     414
     415// calc i_min , i_max j_min and j_maxt
     416
     417int centerX =  (int)((heightMap->h - ((v.x - shiftX)/ (float)scaleX ))/ tileSize);
     418int  centerY = (int)((v.z - shiftZ)/ (float)scaleZ )/ tileSize;
     419//PRINTF(0)("i_max %i \n" , i_max);
     420//PRINTF(0)("CENTERY %i \n ",centerY );
     421i_min = max(centerX  -1, i_min);
     422i_max = min(centerX +2 , i_max );
     423
     424j_min = max(centerY -1,1);
     425j_max = min(centerY +2, j_max);
     426
     427
     428for(int i = 1; i <  i_min        ; i ++)
     429{
     430        for(int j = 1; j < j_max ; j++)
     431        {
     432
     433         tiles[i][j]->drawLowRes();
     434        }
     435}
     436for(int i = i_min; i <  i_max    ; i ++)
     437{
     438        for(int j = j_min; j < j_max ; j++)
     439        {
     440
     441         tiles[i][j]->drawHighRes();
     442        }
     443}
     444
     445for(int i = i_max; i <  (heightMap->h -tileSize)/tileSize        ; i ++)
     446{
     447        for(int j = 1; j < j_max ; j++)
     448        {
     449
     450         tiles[i][j]->drawLowRes();
     451        }
     452}
     453
     454
     455for(int i = 1; i < (heightMap->h -tileSize)/tileSize; i++ )
     456{
     457        for(int j = 1; j < j_min; j++)
     458        {
     459         tiles[i][j]->drawLowRes();
     460        }
     461}
     462for(int i = 1; i < (heightMap->h -tileSize)/tileSize; i++)
     463{
     464        for(int j = j_max; j < (heightMap->w -tileSize)/tileSize; j++ )
     465        {
     466        tiles[i][j]->drawLowRes();
     467        }
     468}
     469
     470}
     471void HeightMap::generateNormalVectorField()
     472{
     473int delta = 1;
     474heights  = (unsigned char*) heightMap->pixels;
     475
     476//Create a Dynamicly sized 2D-Array to store our normals
     477normalVectorField =  new Vector* [heightMap->h];
     478for(int i=0;i<heightMap->h;i++)
     479normalVectorField [i]= new (Vector [heightMap->w]);
     480
     481
     482
     483// !!! Does not yet calculate the normals of some border points!!!!!
     484
     485if(heightMap != NULL && heightMap->format->BitsPerPixel == 8 )
     486        {
     487        SDL_LockSurface(heightMap);
     488        for(int i = 0 ; i < heightMap->h - 1  ; i ++)
     489        {
     490            for(int j = 0; j < heightMap->w  - 1  ;  j ++)
     491            {
     492
     493
     494                delta = (int)heights[j + (i+1)*(heightMap->w )] -  (int) heights[j + i*(heightMap->w )];
     495                Vector a =  Vector(-scaleX,(float)delta*scaleY  ,0.0f);
     496
     497                delta = (int)heights[j+1 + i*(heightMap->w )] - (int)heights[j + i*(heightMap->w )];
     498                Vector b =  Vector(0.0f,(float) delta*scaleY ,scaleZ);
     499
     500
     501                 normalVectorField[i][j] = b.cross(a);
     502                 normalVectorField[i][j].normalize();
     503
     504             }
     505        }
     506        SDL_UnlockSurface(heightMap);
     507
     508}
     509
     510}
     511
     512
     513
     514
     515
     516void HeightMap::scale(Vector v)
     517{
     518 scaleX = v.x;
     519 scaleY = v.y;
     520 scaleZ = v.z;
     521}
     522
     523void HeightMap::shift(Vector v)
     524{
     525 shiftX = v.x;
     526 shiftY = v.y;
     527 shiftZ = v.z;
     528}
     529
     530
     531float HeightMap::getHeight(float x, float y)
     532{
     533 int xInt = (int)x / scaleX;  x -= (float)xInt*scaleX; xInt = heightMap->h - xInt;
     534 int yInt = (int)y / scaleZ;    y -= (float)yInt*scaleZ;
     535 if(xInt <= 0 || xInt >= heightMap->h || yInt <= 0 || yInt >= heightMap->w  ) return 0.0f;
     536 float height = heights[yInt + (xInt)*heightMap->w]*scaleY;
     537 float a = normalVectorField[(xInt)][yInt].x;
     538 float b = normalVectorField [(xInt)][yInt].z;
     539 float c = normalVectorField [(xInt)][yInt].y;
     540  height -= ( (a/c)*(x) + (b/c)*(y))*scaleY;
     541 return height;
     542}
  • height_map_merge/src/lib/graphics/importer/height_map.h

    r6100 r6494  
    1414
    1515
    16 #include "static_model.h"
     16#include "vertex_array_model.h"
     17
     18
     19#define texRate      4
     20#define texRatef     4.0f
     21#define tileSize     64
    1722
    1823class SDL_Surface;
    1924class Vector;
     25class Material;
     26class PNode;
     27class Texture;
     28class HeightMap;
    2029
    21 class HeightMap : public StaticModel
     30class Tile
    2231{
    2332public:
     33void draw();
     34void drawHighRes();
     35void drawLowRes();
     36int getRes();
     37int setHighRes(bool b);
     38Tile(int i1, int j1, int i2, int j2, HeightMap* hm ) ;
     39Tile();
     40~Tile();
     41
     42
     43
     44private:
     45VertexArrayModel* highResModel;
     46VertexArrayModel* lowResModel;
     47int highRes;
     48int lowRes;
     49void load(int i1, int j1, int i2, int i2, HeightMap* hm, VertexArrayModel* model, int Res);
     50};
     51
     52class HeightMap : public VertexArrayModel
     53{
     54public:
     55void draw();
    2456void load();
    25 void load(const char*, int);
     57void load(int Mode);
     58void load(const char*, int Mode);
     59void scale( Vector V);
     60void shift (Vector V);
     61float getHeight(float x, float y);
    2662HeightMap();
    2763HeightMap(const char*);
     64HeightMap(const char*, const char*);
    2865~HeightMap();
     66
     67friend class Tile;
    2968
    3069private:
    3170SDL_Surface* heightMap;
     71SDL_Surface* colourMap;
     72unsigned char* heights;
     73unsigned char* colours;
    3274
     75void generateNormalVectorField();
     76void drawRect(int xBottomLeft, int yBottomLeft, int xTopRight, int yTopRight );
     77void fixBoarder(int xBottomLeft, int yBottomLeft, int xTopRight, int yTopRight);
     78Vector  **  normalVectorField ;
     79Tile    ***  tiles;
     80Vector     camCoords;
     81Material * tmp_mat;
     82Material* red_mat;
     83Texture* texture;
     84const PNode* camera;
     85float scaleX ;
     86float scaleY ;
     87float scaleZ ;
     88float shiftX ;
     89float shiftY ;
     90float shiftZ ;
     91int   cmScaleX;
     92int   cmScaleY;
     93bool  hasColourMap;
     94
     95inline int abs(int val)
     96{
     97 if(val < 0) val = -val;
     98 return val;
     99}
     100inline int max(int x, int y)
     101{
     102 return (x>y)? x:y;
     103}
     104inline int min(int x, int y)
     105{
     106return (x<y)? x: y;
     107}
    33108};
Note: See TracChangeset for help on using the changeset viewer.