Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jan 11, 2006, 2:11:16 PM (18 years ago)
Author:
bottac
Message:

Added Class Tile to HeightMap (allows a primitive LOD Implementation).

Location:
branches/height_map/src/lib/graphics/importer
Files:
6 edited

Legend:

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

    r6329 r6472  
    2929#include <SDL/SDL_image.h>
    3030#endif
     31
     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, ((j/sampleRate)%heightMap->w)/float(heightMap->w),((i/sampleRate)%heightMap->h)/float(heightMap->h));
     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, ((j/sampleRate)%heightMap->w)/float(heightMap->w),(((i - sampleRate) /sampleRate)%heightMap->h)/float(heightMap->h));
     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, ((j/sampleRate)%heightMap->w)/float(heightMap->w),(((i)/sampleRate)%heightMap->h)/float(heightMap->h));
     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, ((j/sampleRate)%heightMap->w)/float(heightMap->w),(((i - sampleRate)/sampleRate)%heightMap->h)/float(heightMap->h));
     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, ((j/sampleRate)%heightMap->w)/float(heightMap->w),((i/sampleRate)%heightMap->h)/float(heightMap->h));
     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}
    31289
    32290HeightMap::HeightMap()
     
    86344    generateNormalVectorField();
    87345
    88 
     346  colourMap=NULL;
    89347  if(colour_map_name != NULL)
    90348  {
    91349  colourMap = IMG_Load(colour_map_name);
     350  }
    92351  if(colourMap != NULL)
    93352                {
     
    102361                 PRINTF(0)("Gmask: %i\n", colourMap->format->Gmask);
    103362                 }
    104                  else       PRINTF(4)("oops! couldn't load %s for some reason.\n", colour_map_name);
     363                 else       PRINTF(0)("oops! couldn't load colorMap for some reason.\n");
    105364
    106365                 
     
    114373 
    115374       
    116   shiftX = 0;
    117   shiftY = 0;
    118   shiftZ = 0;
    119   }
     375   heights  = (unsigned char*) heightMap->pixels;
    120376
    121377
     
    129385{
    130386
    131 unsigned char height = 0;
    132  int offset = 0;
    133  int g = 0;
    134  
    135 
    136  
    137  heights  = (unsigned char*) heightMap->pixels;
    138 
    139 
    140 
    141  
    142  if(heightMap != NULL && heightMap->format->BitsPerPixel == 8 )
    143        
    144         SDL_LockSurface(heightMap);
    145 
    146      
    147         for(int i = 0 ; i < heightMap->h -sampleRate ; i +=sampleRate)
    148         {
    149                 int j = 0;
    150 
    151                 float r;
    152                 float g;
    153                 float b;
    154             for(int j = 0 ; j < heightMap->w -sampleRate  ;  j += sampleRate)
    155             {
    156                  // To be fixed
    157                  r = (float)colours[3*j+2 + 3*i*(heightMap->w )];
    158                  g = (float)colours[3*j+1 + 3*i*(heightMap->w)];
    159                  b = (float)colours[3*j+0 + 3*i*(heightMap->w)];
    160                
    161                         height =  heights[j+sampleRate + i*(heightMap->w )];
    162                 this->addVertex(scaleX*(heightMap->h -i) + shiftX ,((double)(height)*scaleY) + shiftY ,scaleZ*(j+sampleRate) + shiftZ); // Top Right
    163 
    164        
    165                 this->addNormal(normalVectorField[i][j+sampleRate].y,normalVectorField[i][j+sampleRate].z,normalVectorField[i][j+sampleRate].x);
    166                 this->addTexCoor(((j/sampleRate)%texRate)/texRatef,((i/sampleRate)%texRate)/texRatef);
    167 
    168                 this->addColor(r/255.0,g/255.0,b/255.0);
    169 
    170 
    171             }
    172                
    173            
    174                  j = (heightMap->w/sampleRate - sampleRate);
    175 
    176                 this->addVertex(scaleX*(heightMap->h -i)+ shiftX,-1000.0,scaleZ*(j+sampleRate)+ shiftZ); // Top Right
    177 
    178                 this->addNormal(normalVectorField[i][j+sampleRate].y,normalVectorField[i][j+sampleRate].z,normalVectorField[i][j+sampleRate].x);
    179                 this->addTexCoor(((j/sampleRate)%4)/4.0,((i/sampleRate)%4)/4.0);
    180                 this->addColor(0.1,0.1,0.9);
    181                                        
    182 
    183                
    184 
    185                 }
    186 
    187         SDL_UnlockSurface(heightMap);
    188 
    189 
    190         int cnt = 0;
    191         for(int i = 0 ; i < heightMap->h - 2*sampleRate ; i +=sampleRate)
    192         {
    193                
    194             for(int j = 0 ; j < heightMap->w - sampleRate  ;  j += sampleRate)
    195             {
    196                
    197                 this->addIndice(cnt);
    198                 this->addIndice(cnt  + (heightMap->w)/ sampleRate );
    199                 cnt++;
    200                
    201             }
    202                
    203                 cnt++;
    204                  this->newStripe();     
    205                
    206                
     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 ) ;
    207399        }
    208 
    209         this->finalize();
    210 
    211 
    212 }
    213 
    214 
    215 
    216 
     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}
    217471void HeightMap::generateNormalVectorField()
    218472{
     
    227481
    228482
    229 // !!! Does not yet calculate any normals for some border points!!!!!
     483// !!! Does not yet calculate the normals of some border points!!!!!
    230484
    231485if(heightMap != NULL && heightMap->format->BitsPerPixel == 8 )
  • branches/height_map/src/lib/graphics/importer/height_map.h

    r6329 r6472  
    1616#include "vertex_array_model.h"
    1717
    18 #define sampleRate 4
    19 #define texRate   4
    20 #define texRatef   4.0f
     18
     19#define texRate      4
     20#define texRatef     4.0f
     21#define tileSize     64
    2122
    2223class SDL_Surface;
     
    2526class PNode;
    2627class Texture;
     28class HeightMap;
     29
     30class Tile
     31{
     32public:
     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};
    2751
    2852class HeightMap : public VertexArrayModel
    2953{
    3054public:
    31 
     55void draw();
    3256void load();
    3357void load(int Mode);
     
    4165~HeightMap();
    4266
     67friend class Tile;
    4368
    4469private:
     
    4772unsigned char* heights;
    4873unsigned char* colours;
     74
    4975void generateNormalVectorField();
    5076void drawRect(int xBottomLeft, int yBottomLeft, int xTopRight, int yTopRight );
    5177void fixBoarder(int xBottomLeft, int yBottomLeft, int xTopRight, int yTopRight);
    5278Vector  **  normalVectorField ;
     79Tile    ***  tiles;
    5380Vector     camCoords;
    5481Material * tmp_mat;
     
    7198 return val;
    7299}
    73 
     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}
    74108};
  • branches/height_map/src/lib/graphics/importer/static_model.cc

    r6072 r6472  
    227227void StaticModel::draw () const
    228228{
     229
     230      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     231    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
     232
    229233  PRINTF(4)("drawing the 3D-Models\n");
    230234  ModelGroup* tmpGroup = this->firstGroup;
     
    246250void StaticModel::draw (int groupNumber) const
    247251{
     252
     253         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     254    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
     255
    248256  if (unlikely(groupNumber >= this->groupCount))
    249257    {
     
    278286void StaticModel::draw (char* groupName) const
    279287{
     288
     289         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     290    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
     291
    280292  if (groupName == NULL)
    281293     return;
  • branches/height_map/src/lib/graphics/importer/texture.cc

    r5863 r6472  
    252252  glBindTexture(GL_TEXTURE_2D, texture);
    253253  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    254   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
     254  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    255255  // build the Texture
    256256  glTexImage2D(GL_TEXTURE_2D,
     
    271271                    surface->pixels);
    272272  glBindTexture(GL_TEXTURE_2D, 0);
     273   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     274    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
     275
    273276  return texture;
    274277}
  • branches/height_map/src/lib/graphics/importer/vertex_array_model.cc

    r6267 r6472  
    1717
    1818#include "vertex_array_model.h"
    19 
     19#include "texture.h"
    2020#include "stdlibincl.h"
    2121#include <stdarg.h>
     
    3333VertexArrayModel::VertexArrayModel()
    3434{
     35
     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");
     40
     41 
     42 
    3543  this->setClassID(CL_MODEL, "VertexArrayModel");
    3644
     
    6775{
    6876  PRINTF(4)("drawing 3D-VertexArrayModel %s\n", this->getName());
     77  //1glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
     78 
     79 glPushAttrib(GL_ALL_ATTRIB_BITS);
     80   
     81// glEnable(GL_LIGHTING);
     82 glColorMaterial ( GL_FRONT_AND_BACK, GL_EMISSION ) ;
     83  glEnable (GL_COLOR_MATERIAL) ;
     84
     85 
     86
     87   // glBindTexture(GL_TEXTURE_2D, this->tex1->getTexture());
     88
     89 // glEnable(GL_TEXTURE_2D);
     90
     91 
     92   
     93   
     94   
     95   
     96   
     97  glEnableClientState(GL_TEXTURE_COORD_ARRAY );
     98  glTexCoordPointer(2, GL_FLOAT, 0, &this->texCoords1[0]);
     99 
     100 
     101 
    69102  glEnableClientState(GL_VERTEX_ARRAY );
    70   glEnableClientState(GL_TEXTURE_COORD_ARRAY );
     103   glVertexPointer(3, GL_FLOAT, 0, &this->vertices[0]);
    71104  glEnableClientState(GL_NORMAL_ARRAY );
     105    glNormalPointer(GL_FLOAT, 0, &this->normals[0]);
    72106  glEnableClientState(GL_COLOR_ARRAY );
    73 
    74 
    75   glVertexPointer(3, GL_FLOAT, 0, &this->vertices[0]);
    76   glNormalPointer(GL_FLOAT, 0, &this->normals[0]);
    77   glTexCoordPointer(2, GL_FLOAT, 0, &this->texCoords[0]);
    78   glColorPointer(3, GL_FLOAT, 0, &this->colors[0]);
     107glColorPointer(3, GL_FLOAT, 0, &this->colors[0]);
     108//glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
     109 
     110
     111
     112 
    79113
    80114  for (GLuint i = 1; i < this->stripes.size(); ++i)
     
    85119                      &this->indices[this->stripes[i-1]] );
    86120    }
     121   
     122   
     123    glPopAttrib();
    87124}
    88125
     
    141178 *  If a TextureCoordinate line is found this function will inject it into the TextureCoordinate-Array
    142179 */
     180void VertexArrayModel::addTexCoor(float u, float v, float w, float x)
     181{
     182  this->texCoords1.push_back(u);
     183  this->texCoords1.push_back(v);
     184  this->texCoords2.push_back(w);
     185  this->texCoords2.push_back(x);
     186  this->pModelInfo.numTexCoor++;
     187}
    143188void VertexArrayModel::addTexCoor(float u, float v)
    144189{
    145   this->texCoords.push_back(u);
    146   this->texCoords.push_back(v);
     190  this->texCoords1.push_back(u);
     191  this->texCoords1.push_back(v);
     192  this->texCoords2.push_back(0.0);
     193  this->texCoords2.push_back(0.0);
    147194  this->pModelInfo.numTexCoor++;
    148195}
     
    291338            this->vertices.size()/3,
    292339            this->normals.size()/3,
    293             this->texCoords.size()/2,
     340            this->texCoords1.size()/2,
    294341            this->colors.size() )/3;
    295342  for (GLuint i = 1; i < this->stripes.size(); ++i)
  • branches/height_map/src/lib/graphics/importer/vertex_array_model.h

    r6267 r6472  
    1515/* Forward Declaration */
    1616class Material;
    17 
     17class Texture;
    1818
    1919/////////////
     
    3737  void addVertex(float x, float y, float z);
    3838  void addNormal(float x, float y, float z);
    39   void addTexCoor(float u, float v);
     39  void addTexCoor(float u, float v, float w, float x);
     40   void addTexCoor(float u, float v);
    4041  void addColor(float r, float g, float b);
    4142
     
    5859  std::vector<GLfloat>       vertices;        //!< The Array that handles the Vertices.
    5960  std::vector<GLfloat>       normals;         //!< The Array that handles the Normals.
    60   std::vector<GLfloat>       texCoords;       //!< The Array that handles the VertexTextureCoordinates.
     61  std::vector<GLfloat>       texCoords1;       //!< The Array that handles the VertexTextureCoordinates.
     62  std::vector<GLfloat>       texCoords2;       //!< The Array that handles the VertexTextureCoordinates. 
    6163  std::vector<GLfloat>       colors;          //!< The Array that handles Colors.
    6264
     
    6466
    6567  std::vector<GLuint>        stripes;         //!< A lsit of Stripes of this Model.
    66 
     68 
     69  Texture* tex1;
     70  Texture* tex2;
     71 
    6772};
    6873
Note: See TracChangeset for help on using the changeset viewer.