Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7046 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Feb 6, 2006, 11:52:50 AM (19 years ago)
Author:
patrick
Message:

trunk: heightmap modified

Location:
trunk/src/world_entities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/terrain.cc

    r7014 r7046  
    127127  WorldEntity::loadParams(root);
    128128
     129  LoadParam(root, "scale", this, Terrain, setScale)
     130      .describe("The scale in x,y,z direction");
     131
     132  LoadParam(root, "texture", this, Terrain, loadTexture)
     133      .describe("The name of the Texture for this heightMap");
     134
    129135  LoadParam(root, "vegetation", this, Terrain, loadVegetation)
    130136      .describe("the fileName of the vegetation, that should be loaded onto this terrain. (must be relative to the data-dir)") ;
    131137
    132 
    133138  LoadParam(root, "height-map", this, Terrain, loadHeightMap)
    134139      .describe("The HeightMap, splitted into two strings seperated by ','. 1: HeighMap, 2: ColorMap");
    135140
    136 
    137   LoadParam(root, "heigt-texture", this, Terrain, loadTexture)
    138       .describe("The name of the Texture for this heightMap");
     141}
     142
     143void Terrain::setScale(float x, float y, float z)
     144{
     145  this->terrainScale = Vector(x, y, z);
    139146}
    140147
     
    150157
    151158  this->heightMap = new HeightMap(hmName, hmColorName);
    152   heightMap->scale(Vector(43.0f,4.7f,43.0f));
     159//   heightMap->scale(Vector(43.0f,4.7f,43.0f));
     160  heightMap->scale(this->terrainScale);
    153161  heightMap->setAbsCoor(this->getAbsCoor());
    154162  heightMap->load();
     
    164172      delete this->heightMapMaterial;
    165173
    166 delete this->heightMapMaterial;
    167 
    168174   this->heightMapMaterial = new Material();
    169    heightMapMaterial->setTransparency(1.0);
     175
     176   PRINTF(0)("Load texture: %s\n", textureName);
    170177
    171178   heightMapMaterial->setDiffuse(1.0,1.0,1.0);
     
    176183
    177184   heightMapMaterial->setDiffuseMap(textureName);
    178    heightMapMaterial->setAmbientMap(textureName);
    179    heightMapMaterial->setSpecularMap(textureName);
    180 
    181 
    182 
     185//    heightMapMaterial->setAmbientMap(textureName);
     186//    heightMapMaterial->setSpecularMap(t extureName);
    183187}
    184188
     
    219223  else if (this->getModel())
    220224    this->getModel()->draw();
     225
    221226  if (this->vegetation)
    222227    this->vegetation->draw();
    223228
    224   if(this->heightMap)
    225         {
    226         this->heightMapMaterial->select();
    227         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    228         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    229         glEnable(GL_LIGHTING);
    230         glColorMaterial ( GL_FRONT_AND_BACK, GL_EMISSION ) ;
    231         glEnable (GL_COLOR_MATERIAL) ;
    232         this->heightMap->draw();
    233         }
     229  if( this->heightMap)
     230  {
     231    this->heightMapMaterial->select();
     232
     233    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
     234    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
     235    this->heightMap->draw();
     236  }
    234237  glPopMatrix();
    235238
    236239
    237 
    238 
    239 
    240  glMatrixMode(GL_MODELVIEW);
    241 glPushMatrix();
    242 glLoadIdentity();
    243  Vector camera =   State::getCameraNode()->getAbsCoor(); // Go on here ..........!!!
    244 
    245     /*
    246     float height =    heightMap->getHeight(camera.x, camera.z);
    247 
     240/*
     241  glMatrixMode(GL_MODELVIEW);
     242  glPushMatrix();
     243  glLoadIdentity();
     244  Vector camera =   State::getCameraNode()->getAbsCoor(); // Go on here ..........!!!
     245
     246  float height =    heightMap->getHeight(camera.x, camera.z);
    248247
    249248  glEnable (GL_COLOR_MATERIAL) ;
    250     glBegin(GL_QUADS);            // Draw The Cube Using quads
    251     glColor3f(0.0f,1.0f,0.0f);  // Color Blue
    252     glVertex3f(camera.x + 63.0f,Terrain->getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f);      // Top Right Of The Quad (Top)
    253     glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f);      // Top Left Of The Quad (Top)
    254     glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f);      // Bottom Left Of The Quad (Top)
    255     glVertex3f(camera.x+ 63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f);      // Bottom Right Of The Quad (Top)
    256    glEnd();                      // End Drawing The Plan
    257    */
    258 
    259 glPopMatrix();
    260   /* THIS IS ONLY FOR DEBUGGING INFORMATION */
     249  glBegin(GL_QUADS);            // Draw The Cube Using quads
     250  glColor3f(0.0f,1.0f,0.0f);  // Color Blue
     251  glVertex3f(camera.x + 63.0f,Terrain->getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f);      // Top Right Of The Quad (Top)
     252  glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f);      // Top Left Of The Quad (Top)
     253  glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f);      // Bottom Left Of The Quad (Top)
     254  glVertex3f(camera.x+ 63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f);      // Bottom Right Of The Quad (Top)
     255  glEnd();                      // End Drawing The Plan
     256
     257  glPopMatrix();*/
     258
     259
     260/* THIS IS ONLY FOR DEBUGGING INFORMATION */
    261261  if (this->ssp != NULL)
    262262    this->ssp->drawQuadtree();
  • trunk/src/world_entities/terrain.h

    r6956 r7046  
    1212
    1313#include "world_entity.h"
     14#include "vector.h"
    1415
    1516// FORWARD DECLARATION
     
    4445  void loadHeightMap(const char* heightMapFile, const char* colorMap = NULL);
    4546  void loadTexture(const char* textureName);
     47  void setScale(float x, float y, float z);
    4648
    4749  void buildDebugTerrain(DebugTerrain debugTerrain);
    48  
     50
    4951  float getHeight(float x, float y);
    5052  virtual void draw() const;
     
    5961   HeightMap*          heightMap;
    6062   Material*           heightMapMaterial;
     63   Vector              terrainScale;
    6164};
    6265
Note: See TracChangeset for help on using the changeset viewer.