Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8328 in orxonox.OLD


Ignore:
Timestamp:
Jun 12, 2006, 5:17:14 PM (18 years ago)
Author:
ponder
Message:
  • Renamed Terrain into TerrainEntity in order to avoid conflicts between the importer/terrain class and the world_entities/terrain.
  • Changed TerrainEntity to support the new terrain class.
Location:
branches/terrain/src
Files:
14 edited
2 moved

Legend:

Unmodified
Added
Removed
  • branches/terrain/src/lib/collision_detection/cd_engine.cc

    r8186 r8328  
    2222#include "model.h"
    2323#include "world_entity.h"
    24 #include "terrain.h"
     24#include "terrain_entity.h"
     25
    2526// #include "player.h"
    2627
     
    99100  if( likely( this->terrain != NULL))
    100101  {
    101     Quadtree* q = dynamic_cast<Terrain*>(this->terrain)->ssp->getQuadtree();
    102 //    QuadtreeNode* n = q->getQuadtreeFromPosition(this->player->getAbsCoor());
     102        //kraus: TODO put collision detection for terrain class here...
     103    //Quadtree* q = dynamic_cast<TerrainEntity*>(this->terrain)->ssp->getQuadtree();
     104        //QuadtreeNode* n = q->getQuadtreeFromPosition(this->player->getAbsCoor());
    103105  }
    104106 
  • branches/terrain/src/lib/collision_detection/cd_engine.h

    r8186 r8328  
    1616class WorldEntity;
    1717class OBBTree;
    18 class Terrain;
     18class TerrainEntity;
    1919class BspManager;
    2020//class Player;
     
    5050  inline void disable(const int options) { int temp = this->state & options; this->state ^= temp; }
    5151
    52   inline void setTerrain(Terrain* terrain) { this->terrain = terrain; }
     52  inline void setTerrain( TerrainEntity* terrain) { this->terrain = terrain; }
    5353  inline void setBSPModel(BspManager* bspManager) { this->bspManager = bspManager; }
    5454
     
    8383  OBBTree*                rootTree;                         //!< for testing purposes a root tree
    8484
    85   Terrain*                terrain;                          //!< this it a ref to the terrain, serving as a ground for all WE
     85  TerrainEntity*                terrain;                          //!< this it a ref to the terrain, serving as a ground for all WE
    8686  BspManager*             bspManager;
    8787};
  • branches/terrain/src/lib/graphics/importer/terrain/frustum.h

    r8319 r8328  
    1717#include "types.h"
    1818#include "glincl.h"
    19 
     19#include <stdio.h>
    2020#define m( _row,_col )  _m[_col*4+_row-5]
    2121
     22#define CHECK_GL_ERROR( _d ) do { \
     23        GLenum __err = glGetError(); \
     24        if ( __err != GL_NO_ERROR ) \
     25                printf( "check%s: %s\n", _d, (char*)gluErrorString( __err ) );\
     26        }\
     27        while ( 0 )
     28       
    2229/**
    2330 * Code borrowed from Lighthouse 3D
  • branches/terrain/src/lib/graphics/importer/terrain/terrain.cc

    r8321 r8328  
    33#include "terrain_page.h"
    44#include "glincl.h"
     5#include "util/loading/resource_manager.h"
     6#include "debug.h"
    57
    68#ifdef HAVE_SDL_SDL_IMAGE_H
     
    1214void Terrain::build()
    1315{
    14         SDL_Surface *tmpData = IMG_Load( heightmapSource.c_str() );
     16        ResourceManager *MANAGER = ResourceManager::getInstance();
     17        std::string full = MANAGER->getFullName( heightmapSource );
     18        SDL_Surface *tmpData = IMG_Load( full.c_str() );
    1519        if ( !tmpData ) {
    16                 printf( "sorry, can't load!!!\n" );
     20                PRINTF(0)( "I' sorry, I can't load %s\n", full.c_str() );
    1721                return;
    1822        }               
     
    2529        memcpy( heightfield.data, tmpData->pixels, sizeof(UByte)*dataSize );
    2630        SDL_FreeSurface( tmpData );
    27         //TODO: Check for modulo!
     31        //TODO: Perform some checks...
    2832        pagesX = (heightfield.width/(pageSize-1) );
    2933        pagesZ = (heightfield.height/(pageSize-1) );
    30         tex = new Texture( lightmapSource );
    31        
     34        tex = (Texture*)MANAGER->load( lightmapSource );
     35       
     36        //TODO: Determine layer visibility!
    3237        printf( "creating terrain pages ( %d, %d )...", pagesX, pagesZ );
    3338        pages = new pTerrainPage[pagesX*pagesZ];       
     
    7277        newPage->setPosition( Triple( scale.x*_xOffset, 0.0f, scale.z*_zOffset ) );
    7378        newPage->calculateErrors();
    74        
    75         //newPage->calculateMinMax();
    7679        return newPage;
    7780}
     
    8184//              through the activePages list is sufficient to remove all invisible
    8285//              pages.
     86//              DONE
    8387void Terrain::determineVisiblePages( pTerrainQuad _node )
    8488{
     
    111115void Terrain::draw( )
    112116{
     117        glGetError();
    113118        pTerrainPage page = NULL;
    114        
    115119        frustum->extractPlanes();
    116        
    117120        glEnableClientState( GL_VERTEX_ARRAY );
     121
    118122        glEnableClientState( GL_TEXTURE_COORD_ARRAY );
    119123        glEnable( GL_TEXTURE_2D );
    120124        glEnable( GL_DEPTH_TEST );
    121         glEnable( GL_CULL_FACE );
    122 
    123        
     125        glDisable( GL_CULL_FACE );
    124126        glBindTexture( GL_TEXTURE_2D, tex->getTexture() );
    125127        glDisable( GL_LIGHTING );
    126 
    127128        glEnable( GL_COLOR_MATERIAL );
    128129        glColor3f( 1.0f, 1.0f, 1.0f );
    129130        cullCount = 0;
    130        
    131131        // Lets see which pages are visible.
    132132        determineVisiblePages( root );
     
    134134        int count = 0;
    135135        page = activePages;     
    136        
    137136        while ( page ) {
    138137                if ( !page->isActive() ) {
    139138                        pTerrainPage tmp = page;
    140139                        page = tmp->getNext();
     140                        tmp->setVisibility( false );
    141141                        tmp->deactivate();
     142                        deactivatedCount++;
    142143                        continue;
    143144                }       
     
    149150                page = page->getNext();
    150151        }
    151        
    152152        //printf( "%d pages activated, %d pages deactivated\n", activatedCount, deactivatedCount );
    153153        activatedCount = 0; deactivatedCount = 0;
    154         //float percentage = (float)cullCount/(float)(pagesX*pagesZ)*100.0f;
     154        float percentage = (float)cullCount/(float)(pagesX*pagesZ)*100.0f;
    155155        //printf( "culled %f%% terrain pages away\n",  percentage );
    156156}
     
    205205                for ( int z = 0; z < _height; ++z ) {
    206206                        pTerrainPage page = getPage( _x0+x, _z0+z );
    207                         page->chooseLOD( );
    208                         page->show( );
     207                        page->setVisibility( true );                   
     208                        page->chooseLOD();
     209
    209210                }
    210211        }
  • branches/terrain/src/lib/graphics/importer/terrain/terrain.h

    r8319 r8328  
    6767       
    6868                void getAltitude( Triple& _alt, Triple& _normal );
     69               
    6970                void showPages( int _x0, int _z0, int _width, int _height );
    7071                                       
     
    106107                inline float getAltitude( int _x, int _z ) const;
    107108               
    108                 inline void setLightmap( std::string &_lightmap )
     109                inline void setLightmap( const std::string &_lightmap )
    109110                {
    110111                        lightmapSource = _lightmap;
    111112                }
    112                 inline void setHeightmap( std::string &_heightmap )
     113                inline void setHeightmap( const std::string &_heightmap )
    113114                {
    114115                        heightmapSource = _heightmap;
     
    180181inline float Terrain::getAltitude( int _x, int _z ) const
    181182{
    182         if ( _x > heightfield.width || _z > heightfield.height )
    183                 return 0.0f;
    184183        return heightfield.data[heightfield.pitch*_z+_x]/255.0f;       
    185184}
  • branches/terrain/src/lib/graphics/importer/terrain/terrain_page.cc

    r8321 r8328  
    1010 
    1111        ### File Specific:
    12         main programmer: Marco Biasini
     12        main-programmer: Marco Biasini
    1313 
    1414 */
     
    1919#include <math.h>
    2020
    21 #define CHECK_GL_ERROR() do { \
     21#define CHECK_GL_ERROR( _d ) do { \
    2222        GLenum __err = glGetError(); \
    2323        if ( __err != GL_NO_ERROR ) \
    24                 printf( (char*)gluErrorString( __err ) );\
     24                printf( "check%s: %s\n", _d, (char*)gluErrorString( __err ) );\
    2525        }\
    2626        while ( 0 )
     
    7777void TerrainPage::activate()
    7878{
     79       
    7980        pTerrainPage list = owner->getActiveList();
    8081        next = list;
     
    202203        int stride = 1 << _lod;
    203204        for ( int z = 0; z < owner->getPageSize()-stride; z+=stride ) {
    204                 if ( z > 0 ) {
    205                        
     205                if ( z > 0 ) {                 
    206206                        //Connect the two rows together by inserting the last index of last row
    207207                        //and the first index of the next row two times. This will produce two
     
    278278void TerrainPage::draw( )
    279279{
    280        
     280        //These give an error
    281281        assert( glIsEnabled( GL_VERTEX_ARRAY ) );
    282282        assert( !glIsEnabled( GL_NORMAL_ARRAY ) );
    283         assert( isVisible ); assert( numIndices );
     283        assert( isVisible ); assert( numIndices > 0 );
     284        assert( active );
    284285        active = false;
     286        CHECK_GL_ERROR( "1" ); 
    285287        glVertexPointer( 3, GL_FLOAT, 0, vertices );
    286288        glTexCoordPointer( 2, GL_FLOAT, 0, coords );   
     
    290292        if ( owner->debug() )
    291293                drawBox( );
    292        
    293         CHECK_GL_ERROR();
     294               
     295        CHECK_GL_ERROR( "2" ); 
    294296}
    295297
  • branches/terrain/src/lib/graphics/importer/terrain/terrain_page.h

    r8321 r8328  
    247247                        show( );
    248248                }
     249                active = true;
    249250        }
    250251        else {
  • branches/terrain/src/story_entities/game_world.cc

    r8271 r8328  
    3030#include "camera.h"
    3131#include "environment.h"
    32 #include "terrain.h"
    3332#include "test_entity.h"
    34 #include "terrain.h"
     33#include "terrain_entity.h"
    3534#include "playable.h"
    3635#include "environments/mapped_water.h"
  • branches/terrain/src/story_entities/game_world_data.cc

    r7810 r8328  
    3131#include "player.h"
    3232#include "camera.h"
    33 #include "terrain.h"
     33#include "terrain_entity.h"
    3434#include "skybox.h"
    3535#include "md2Model.h"
     
    199199      BaseObject* created = Factory::fabricate(element);
    200200      if( created != NULL )
    201         PRINTF(4)("Created a %s: %s\n", created->getClassName(), created->getName());
     201        PRINTF(2)("Created a %s: %s\n", created->getClassName(), created->getName());
    202202
    203203      //todo do this more elegant
     
    207207        State::setSkyBox(dynamic_cast<SkyBox*>(this->sky));
    208208      }
     209               
    209210      if( element->Value() == "Terrain" && created->isA(CL_TERRAIN))
    210211      {
    211         this->terrain = dynamic_cast<Terrain*>(created);
     212        this->terrain = dynamic_cast<TerrainEntity*>(created);
    212213        CDEngine::getInstance()->setTerrain(terrain);
    213214      }
  • branches/terrain/src/story_entities/game_world_data.h

    r7460 r8328  
    1414class Camera;
    1515class Player;
    16 class Terrain;
     16class TerrainEntity;
    1717class WorldEntity;
    1818
     
    5757    Player*                       localPlayer;    //!< The player, you fly through the level.
    5858    WorldEntity*                  sky;            //!< The environmental sky of orxonox
    59     Terrain*                      terrain;        //!< The terrain - ground
     59    TerrainEntity*                terrain;        //!< The terrain - ground
    6060
    6161    OrxSound::OggPlayer*          music;          //!< Reference to the SoundEngine's music player (OggPlayer)
  • branches/terrain/src/story_entities/multi_player_world_data.cc

    r8068 r8328  
    3131#include "camera.h"
    3232#include "environment.h"
    33 #include "terrain.h"
     33#include "terrain_entity.h"
    3434#include "test_entity.h"
    35 #include "terrain.h"
    3635#include "md2Model.h"
    3736#include "world_entities/projectiles/projectile.h"
     
    157156        if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
    158157        {
    159           this->terrain = dynamic_cast<Terrain*>(created);
     158          this->terrain = dynamic_cast<TerrainEntity*>(created);
    160159          CDEngine::getInstance()->setTerrain(terrain);
    161160        }
     
    188187          if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
    189188          {
    190             this->terrain = dynamic_cast<Terrain*>(created);
     189            this->terrain = dynamic_cast<TerrainEntity*>(created);
    191190            CDEngine::getInstance()->setTerrain(terrain);
    192191          }
  • branches/terrain/src/story_entities/simple_game_menu.cc

    r8035 r8328  
    3030#include "world_entity.h"
    3131#include "elements/image_entity.h"
    32 #include "terrain.h"
     32#include "terrain_entity.h"
    3333#include "camera.h"
    3434
  • branches/terrain/src/util/multiplayer_team_deathmatch.cc

    r8147 r8328  
    3232
    3333#include "shared_network_data.h"
    34 #include "terrain.h"
     34#include "terrain_entity.h"
    3535#include "class_list.h"
    3636#include "space_ships/space_ship.h"
  • branches/terrain/src/world_entities/WorldEntities.am

    r8271 r8328  
    88                world_entities/skysphere.cc \
    99                world_entities/skybox.cc \
    10                 world_entities/terrain.cc \
     10                world_entities/terrain_entity.cc \
    1111                world_entities/satellite.cc \
    1212                world_entities/movie_entity.cc \
     
    6363                skysphere.h \
    6464                skybox.h \
    65                 terrain.h \
     65                terrain_entity.h \
    6666                satellite.h \
    6767                movie_entity.h \
  • branches/terrain/src/world_entities/terrain_entity.cc

    r8321 r8328  
    1616
    1717
    18 #include "terrain.h"
    19 
     18#include "terrain_entity.h"
     19#include "terrain/terrain.h"
    2020#include "util/loading/load_param.h"
    2121#include "util/loading/factory.h"
     
    2626#include "network_game_manager.h"
    2727
    28 #include "height_map.h"
    2928#include "material.h"
    3029
     
    3534using namespace std;
    3635
    37 CREATE_FACTORY(Terrain, CL_TERRAIN);
     36CREATE_FACTORY( TerrainEntity, CL_TERRAIN );
    3837
    3938/**
    4039 *  standard constructor
    4140 */
    42 Terrain::Terrain (const TiXmlElement* root)
    43 {
    44   this->init();
    45 
    46 
    47   if( root != NULL)
    48     this->loadParams(root);
    49 
    50   //  if (this->model != NULL)
    51   //this->ssp = new SpatialSeparation((Model*)this->model, 10.0f);
     41TerrainEntity::TerrainEntity (const TiXmlElement* root)
     42{
     43        this->init();
     44
     45
     46        if( root != NULL)
     47                this->loadParams(root);
     48        terrain->build( );
    5249}
    5350
    5451
    5552/**
    56  *  Constructor for loading a Terrain out of a file
     53 *  Constructor for loading a TerrainEntity out of a file
    5754 * @param fileName The file to load data from.
    5855
    5956   this either loads out of an OBJ-file, or loads a heightmap if no .obj-extension is found.
    6057*/
    61 Terrain::Terrain(const std::string& fileName)
     58TerrainEntity::TerrainEntity(const std::string& fileName )
    6259{
    6360  this->init();
     
    7673 *  a Constructor for the Debug-Worlds
    7774 */
    78 Terrain::Terrain(DebugTerrain debugTerrain)
     75TerrainEntity::TerrainEntity(DebugTerrainEntity debugTerrainEntity)
    7976{
    8077  this->init();
    81   this->buildDebugTerrain(debugTerrain);
     78  this->buildDebugTerrainEntity(debugTerrainEntity);
    8279}
    8380
     
    8683
    8784*/
    88 Terrain::~Terrain ()
     85TerrainEntity::~TerrainEntity ()
    8986{
    9087  if (objectList)
    9188    glDeleteLists(this->objectList, 1);
    92   if( this->ssp)
    93     delete ssp;
     89
    9490  if (this->vegetation)
    9591  {
    96     ResourceManager::getInstance()->unload(this->vegetation);
    97   }
    98 
    99   if(this->heightMap)
    100     delete heightMap;
    101 }
    102 
    103 
    104 void Terrain::init()
    105 {
    106   this->setClassID(CL_TERRAIN, "Terrain");
     92    ResourceManager::getInstance()->unload( this->vegetation );
     93  }
     94
     95  if( this->terrain )
     96    delete terrain;
     97}
     98
     99
     100void TerrainEntity::init()
     101{
     102  this->setClassID( CL_TERRAIN, "TerrainEntity");
    107103  this->toList(OM_ENVIRON_NOTICK);
    108104  this->toReflectionList();
    109105
    110106  this->objectList = 0;
    111   this->ssp = NULL;
    112107  this->vegetation = NULL;
    113108
    114   this->heightMap = NULL;
    115 
    116   this->heightMapMaterial = new Material();
    117 }
    118 
    119 
    120 void Terrain::loadParams(const TiXmlElement* root)
    121 {
    122   WorldEntity::loadParams(root);
    123 
    124   LoadParam(root, "scale", this, Terrain, setScale)
    125   .describe("The scale in x,y,z direction");
    126 
    127   LoadParam(root, "texture", this, Terrain, loadTexture)
    128   .describe("The name of the Texture for this heightMap");
    129 
    130   LoadParam(root, "vegetation", this, Terrain, loadVegetation)
    131   .describe("the fileName of the vegetation, that should be loaded onto this terrain. (must be relative to the data-dir)") ;
    132 
    133   LoadParam(root, "height-map", this, Terrain, loadHeightMap)
    134   .describe("The HeightMap, splitted into two strings seperated by ','. 1: HeighMap, 2: ColorMap");
    135 
    136 }
    137 
    138 void Terrain::setScale(float x, float y, float z)
    139 {
    140   this->terrainScale = Vector(x, y, z);
    141 }
    142 
    143 void Terrain::loadHeightMap(const std::string& heightMapFile, const std::string& colorMap)
    144 {
    145   if (this->heightMap != NULL)
    146     delete this->heightMap;
    147   this->heightMap = NULL;
    148 
    149   std::string hmName = ResourceManager::getFullName(heightMapFile);
    150   std::string hmColorName = ResourceManager::getFullName(colorMap);
    151 
    152 
    153   this->heightMap = new HeightMap(hmName, hmColorName);
    154   //   heightMap->scale(Vector(43.0f,4.7f,43.0f));
    155   heightMap->scale(this->terrainScale);
    156   heightMap->setAbsCoor(this->getAbsCoor());
    157   heightMap->load();
    158 }
    159 
    160 
    161 void Terrain::loadTexture(const std::string& textureName)
    162 {
    163   PRINTF(4)("Load texture: %s\n", textureName.c_str());
    164 
    165   heightMapMaterial->setDiffuse(1.0,1.0,1.0);
    166   heightMapMaterial->setAmbient(1.0,1.0,1.0 );
    167   heightMapMaterial->setSpecular(1.0,1.0,1.0);
    168   heightMapMaterial->setShininess(.5);
    169   heightMapMaterial->setTransparency(1.0);
    170 
    171   heightMapMaterial->setDiffuseMap(textureName);
    172   //   heightMapMaterial->setAmbientMap(textureName);
    173   //   heightMapMaterial->setSpecularMap(textureName);
    174 }
    175 
    176 
    177 
    178 void Terrain::loadVegetation(const std::string& vegetationFile)
     109  this->terrain = new Terrain();
     110
     111  //this->heightMapMaterial = new Material();
     112}
     113
     114
     115void TerrainEntity::loadParams(const TiXmlElement* root)
     116{
     117        WorldEntity::loadParams(root);
     118
     119        LoadParam(root, "scale", this, TerrainEntity, setScale)
     120                .describe("The scale in x,y,z direction");
     121       
     122        LoadParam( root, "lightmap", this, TerrainEntity, loadLightmap )
     123                .describe("The name of the lightmap.");
     124               
     125        LoadParam( root, "elevationmap", this, TerrainEntity, loadElevationmap )
     126                .describe( "The name of the elevation map. Must be an 8bit image" );
     127               
     128}
     129
     130void TerrainEntity::setScale(float x, float y, float z)
     131{
     132        terrain->setScale( Triple( x, y, z ) );
     133}
     134
     135void TerrainEntity::loadElevationmap( const std::string& _eleFile )
     136{
     137        terrain->setHeightmap( _eleFile );
     138}
     139
     140void TerrainEntity::loadLightmap( const std::string& _lightFile )
     141{
     142        terrain->setLightmap( _lightFile );
     143}
     144
     145
     146
     147void TerrainEntity::loadVegetation(const std::string& vegetationFile)
    179148{
    180149  PRINTF(4)("loadVegetation: %s\n", vegetationFile.c_str());
     
    194163
    195164
    196 void Terrain::draw () const
    197 {
    198   glPushMatrix();
     165void TerrainEntity::draw () const
     166{
     167        glMatrixMode( GL_MODELVIEW );
     168        glPushMatrix();
    199169
    200170  /* translate */
    201   glTranslatef (this->getAbsCoor ().x,
     171 /* glTranslatef (this->getAbsCoor ().x,
    202172                this->getAbsCoor ().y,
    203                 this->getAbsCoor ().z);
     173                this->getAbsCoor ().z );*/
    204174  /* rotate */
    205175  // Vector tmpRot = this->getAbsDir().getSpacialAxis();
    206176  //glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    207177
    208   if (this->objectList)
     178  /*if (this->objectList)
    209179    glCallList(this->objectList);
    210180  else if (this->getModel())
     
    213183  if (this->vegetation)
    214184    this->vegetation->draw();
    215 
    216   if( this->heightMap)
    217   {
    218     this->heightMapMaterial->select();
    219 
    220     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    221     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    222     this->heightMap->draw();
    223   }
    224   glPopMatrix();
    225 
    226 
     185*/
     186
     187        Vector cam = State::getCameraNode()->getAbsCoor();
     188       
     189        if ( this->terrain ) {
     190                terrain->setCameraPosition( Triple( cam.x, cam.y, cam.z ) );
     191                terrain->draw( );
     192        }
     193
     194        glPopMatrix();
    227195  /*
    228196    glMatrixMode(GL_MODELVIEW);
     
    236204    glBegin(GL_QUADS);            // Draw The Cube Using quads
    237205    glColor3f(0.0f,1.0f,0.0f);  // Color Blue
    238     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)
     206    glVertex3f(camera.x + 63.0f,TerrainEntity->getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f);      // Top Right Of The Quad (Top)
    239207    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)
    240208    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)
     
    244212    glPopMatrix();*/
    245213
    246 
    247   /* THIS IS ONLY FOR DEBUGGING INFORMATION */
    248   if (this->ssp != NULL)
    249     this->ssp->drawQuadtree();
    250 }
    251 
    252 
    253 void Terrain::buildDebugTerrain(DebugTerrain debugTerrain)
    254 {
    255   // if the terrain is the Terrain of Dave
    256   if (debugTerrain == TERRAIN_DAVE)
     214}
     215
     216
     217void TerrainEntity::buildDebugTerrainEntity(DebugTerrainEntity debugTerrainEntity)
     218{
     219        terrain->build( );
     220  /*
     221  // if the TerrainEntity is the TerrainEntity of Dave
     222  if (debugTerrainEntity == TERRAINENTITY_DAVE)
    257223  {
    258224    objectList = glGenLists(1);
     
    389355    glEndList();
    390356  }
    391 
    392   if (debugTerrain == TERRAIN_BENSCH)
     357        */
     358  if (debugTerrainEntity == TERRAINENTITY_BENSCH)
    393359  {
    394360    /*
     
    424390}
    425391
    426 float Terrain::getHeight(float x, float y)
    427 {
    428   if(this->heightMap != NULL)
    429     return (this->heightMap->getHeight(x, y));
    430   return 0;
    431 }
     392float TerrainEntity::getHeight( float x, float z )
     393{
     394        Triple altitude( x, 0.0f, z ), normal( 0.0f, 0.0f, 0.0f );
     395        if ( terrain )
     396                terrain->getAltitude( altitude, normal );
     397               
     398  return altitude.y;
     399}
  • branches/terrain/src/world_entities/terrain_entity.h

    r8321 r8328  
    11/*!
    2  * @file terrain.h
    3   *  Defines and handles the terrain of the World
     2 * @file TerrainEntity.h
     3
     4  *  Defines and handles the TerrainEntity of the World
    45
    56    @todo implement it
    67
    7     The terrain should either be build from a Model a OBJModel or from a HeightMap.
     8    The TerrainEntity should either be build from a Model a OBJModel or from a HeightMap.
    89*/
    910
    10 #ifndef _TERRAIN_H
    11 #define _TERRAIN_H
     11#ifndef _TERRAINENTITY_H
     12#define _TERRAINENTITY_H
    1213
    1314#include "world_entity.h"
     
    1516
    1617// FORWARD DECLARATION
    17 class SpatialSeparation;
    18 class HeightMap;
    1918class Material;
     19class Terrain;
    2020
    2121//! A simple method to call a desired debug world.
    22 enum DebugTerrain {TERRAIN_DAVE, TERRAIN_BENSCH};
     22enum DebugTerrainEntity {TERRAINENTITY_DAVE, TERRAINENTITY_BENSCH};
    2323
    2424
    25 //! A Class to handle Terrain of orxonox
    26 class Terrain : public WorldEntity
     25//! A Class to handle TerrainEntity of orxonox
     26class TerrainEntity : public WorldEntity
    2727{
    2828
    29  public:
    30   Terrain(const TiXmlElement* root = NULL);
    31   Terrain(const std::string& fileName);
    32   Terrain(DebugTerrain debugTerrain);
    33   virtual ~Terrain();
     29        public:
     30                TerrainEntity(const TiXmlElement* root = NULL);
     31                TerrainEntity(const std::string& fileName);
     32                TerrainEntity(DebugTerrainEntity debugTerrainEntity);
     33                virtual ~TerrainEntity();
    3434
    35   void init();
    36   virtual void loadParams(const TiXmlElement* root);
     35                void init();
     36                virtual void loadParams(const TiXmlElement* root);
    3737
    38   void loadVegetation(const std::string& vegetationFile);
     38                void loadVegetation(const std::string& vegetationFile);
    3939
    40   void loadHeightMap(const std::string& heightMapFile, const std::string& colorMap);
    41   void loadTexture(const std::string& textureName);
    42   void setScale(float x, float y, float z);
     40                void loadElevationmap( const std::string& _eleFile );
     41                void loadLightmap(const std::string& _lightFile );
     42                void setScale( float x, float y, float z );
    4343
    44   void buildDebugTerrain(DebugTerrain debugTerrain);
     44                void buildDebugTerrainEntity(DebugTerrainEntity debugTerrainEntity);
    4545
    46   float getHeight(float x, float y);
    47   virtual void draw() const;
     46                float getHeight(float x, float y);
     47                virtual void draw() const;
    4848
    49   public:
    50     SpatialSeparation* ssp;
    51 
    52  private:
    53    Model*              vegetation;
    54    int                 objectList;
    55 
    56    HeightMap*          heightMap;
    57    Material*           heightMapMaterial;
    58    Vector              terrainScale;
     49        public:
     50       
     51        private:
     52                 Model*                 vegetation;
     53                 int                    objectList;
     54                 Terrain*                               terrain;
     55                 Vector                 TerrainEntityScale;
    5956};
    6057
    61 #endif /* _TERRAIN_H */
     58#endif /* _TerrainEntity_H */
Note: See TracChangeset for help on using the changeset viewer.