Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 25, 2006, 5:46:16 PM (18 years ago)
Author:
bottac
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/height_map_merge/src/world_entities/terrain.cc

    r6603 r6727  
    3030
    3131#include "glincl.h"
     32
     33#include "state.h"
    3234
    3335using namespace std;
     
    154156
    155157  this->heightMap = new HeightMap(hmName, hmColorName);
    156   heightMap->scale(Vector(23.0f,3.5f,23.0f));
    157   heightMap->shift(Vector(-1000.0,-90.0,-4000.0));
     158  heightMap->scale(Vector(23.0f,1.1f,23.0f));
     159  heightMap->setAbsCoor(this->getAbsCoor());
    158160  heightMap->load();
    159161  delete[] hmName;
     
    166168{
    167169  if (this->heightMapMaterial != NULL)
    168     delete this->heightMapMaterial;
     170      delete this->heightMapMaterial;
    169171
    170172
     
    214216void Terrain::draw () const
    215217{
     218 
     219   
     220 
    216221  glMatrixMode(GL_MODELVIEW);
    217222  glPushMatrix();
    218223
    219224  /* translate */
    220   glTranslatef (this->getAbsCoor ().x,
     225 /* glTranslatef (this->getAbsCoor ().x,
    221226                this->getAbsCoor ().y,
    222227                this->getAbsCoor ().z);
     228        */     
    223229  /* rotate */
    224   Vector tmpRot = this->getAbsDir().getSpacialAxis();
    225   glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     230 // Vector tmpRot = this->getAbsDir().getSpacialAxis();
     231  //glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    226232
    227233  if (this->objectList)
     
    237243        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    238244        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    239    
    240          glEnable(GL_LIGHTING);
     245        glEnable(GL_LIGHTING);
    241246        glColorMaterial ( GL_FRONT_AND_BACK, GL_EMISSION ) ;
    242247        glEnable (GL_COLOR_MATERIAL) ;
     
    245250  glPopMatrix();
    246251
    247 
    248 
     252 glMatrixMode(GL_MODELVIEW);
     253glPushMatrix();
     254glLoadIdentity();
     255 Vector camera =   State::getCamera()->getAbsCoor(); // Go on here ..........!!!
     256    float height =    heightMap->getHeight(camera.x, camera.z);
     257   
     258  glEnable (GL_COLOR_MATERIAL) ;
     259    glBegin(GL_QUADS);            // Draw The Cube Using quads
     260    glColor3f(0.0f,1.0f,0.0f);  // Color Blue
     261    glVertex3f(camera.x + 13.0f,height+13.0f,camera.z-13.0f);      // Top Right Of The Quad (Top)
     262    glVertex3f(camera.x-13.0f, height+13.0f,camera.z-13.0f);      // Top Left Of The Quad (Top)
     263    glVertex3f(camera.x-13.0f, height+13.0f, camera.z+13.0f);      // Bottom Left Of The Quad (Top)
     264    glVertex3f(camera.x+ 13.0f, height+13.0f, camera.z+13.0f);      // Bottom Right Of The Quad (Top)
     265   glEnd();                      // End Drawing The Plan
     266   
     267   
     268glPopMatrix();
    249269  /* THIS IS ONLY FOR DEBUGGING INFORMATION */
    250270  if (this->ssp != NULL)
     
    457477{
    458478}
     479
     480float Terrain::getHeight(float x, float y)
     481{
     482        if(this->heightMap != NULL)
     483                return (this->heightMap->getHeight(x, y));
     484        return 0;
     485}
Note: See TracChangeset for help on using the changeset viewer.