Changeset 8328 in orxonox.OLD for branches/terrain
- Timestamp:
- Jun 12, 2006, 5:17:14 PM (18 years ago)
- Location:
- branches/terrain/src
- Files:
-
- 14 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/terrain/src/lib/collision_detection/cd_engine.cc
r8186 r8328 22 22 #include "model.h" 23 23 #include "world_entity.h" 24 #include "terrain.h" 24 #include "terrain_entity.h" 25 25 26 // #include "player.h" 26 27 … … 99 100 if( likely( this->terrain != NULL)) 100 101 { 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()); 103 105 } 104 106 -
branches/terrain/src/lib/collision_detection/cd_engine.h
r8186 r8328 16 16 class WorldEntity; 17 17 class OBBTree; 18 class Terrain ;18 class TerrainEntity; 19 19 class BspManager; 20 20 //class Player; … … 50 50 inline void disable(const int options) { int temp = this->state & options; this->state ^= temp; } 51 51 52 inline void setTerrain( Terrain* terrain) { this->terrain = terrain; }52 inline void setTerrain( TerrainEntity* terrain) { this->terrain = terrain; } 53 53 inline void setBSPModel(BspManager* bspManager) { this->bspManager = bspManager; } 54 54 … … 83 83 OBBTree* rootTree; //!< for testing purposes a root tree 84 84 85 Terrain * terrain; //!< this it a ref to the terrain, serving as a ground for all WE85 TerrainEntity* terrain; //!< this it a ref to the terrain, serving as a ground for all WE 86 86 BspManager* bspManager; 87 87 }; -
branches/terrain/src/lib/graphics/importer/terrain/frustum.h
r8319 r8328 17 17 #include "types.h" 18 18 #include "glincl.h" 19 19 #include <stdio.h> 20 20 #define m( _row,_col ) _m[_col*4+_row-5] 21 21 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 22 29 /** 23 30 * Code borrowed from Lighthouse 3D -
branches/terrain/src/lib/graphics/importer/terrain/terrain.cc
r8321 r8328 3 3 #include "terrain_page.h" 4 4 #include "glincl.h" 5 #include "util/loading/resource_manager.h" 6 #include "debug.h" 5 7 6 8 #ifdef HAVE_SDL_SDL_IMAGE_H … … 12 14 void Terrain::build() 13 15 { 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() ); 15 19 if ( !tmpData ) { 16 printf( "sorry, can't load!!!\n");20 PRINTF(0)( "I' sorry, I can't load %s\n", full.c_str() ); 17 21 return; 18 22 } … … 25 29 memcpy( heightfield.data, tmpData->pixels, sizeof(UByte)*dataSize ); 26 30 SDL_FreeSurface( tmpData ); 27 //TODO: Check for modulo!31 //TODO: Perform some checks... 28 32 pagesX = (heightfield.width/(pageSize-1) ); 29 33 pagesZ = (heightfield.height/(pageSize-1) ); 30 tex = new Texture( lightmapSource ); 31 34 tex = (Texture*)MANAGER->load( lightmapSource ); 35 36 //TODO: Determine layer visibility! 32 37 printf( "creating terrain pages ( %d, %d )...", pagesX, pagesZ ); 33 38 pages = new pTerrainPage[pagesX*pagesZ]; … … 72 77 newPage->setPosition( Triple( scale.x*_xOffset, 0.0f, scale.z*_zOffset ) ); 73 78 newPage->calculateErrors(); 74 75 //newPage->calculateMinMax();76 79 return newPage; 77 80 } … … 81 84 // through the activePages list is sufficient to remove all invisible 82 85 // pages. 86 // DONE 83 87 void Terrain::determineVisiblePages( pTerrainQuad _node ) 84 88 { … … 111 115 void Terrain::draw( ) 112 116 { 117 glGetError(); 113 118 pTerrainPage page = NULL; 114 115 119 frustum->extractPlanes(); 116 117 120 glEnableClientState( GL_VERTEX_ARRAY ); 121 118 122 glEnableClientState( GL_TEXTURE_COORD_ARRAY ); 119 123 glEnable( GL_TEXTURE_2D ); 120 124 glEnable( GL_DEPTH_TEST ); 121 glEnable( GL_CULL_FACE ); 122 123 125 glDisable( GL_CULL_FACE ); 124 126 glBindTexture( GL_TEXTURE_2D, tex->getTexture() ); 125 127 glDisable( GL_LIGHTING ); 126 127 128 glEnable( GL_COLOR_MATERIAL ); 128 129 glColor3f( 1.0f, 1.0f, 1.0f ); 129 130 cullCount = 0; 130 131 131 // Lets see which pages are visible. 132 132 determineVisiblePages( root ); … … 134 134 int count = 0; 135 135 page = activePages; 136 137 136 while ( page ) { 138 137 if ( !page->isActive() ) { 139 138 pTerrainPage tmp = page; 140 139 page = tmp->getNext(); 140 tmp->setVisibility( false ); 141 141 tmp->deactivate(); 142 deactivatedCount++; 142 143 continue; 143 144 } … … 149 150 page = page->getNext(); 150 151 } 151 152 152 //printf( "%d pages activated, %d pages deactivated\n", activatedCount, deactivatedCount ); 153 153 activatedCount = 0; deactivatedCount = 0; 154 //float percentage = (float)cullCount/(float)(pagesX*pagesZ)*100.0f;154 float percentage = (float)cullCount/(float)(pagesX*pagesZ)*100.0f; 155 155 //printf( "culled %f%% terrain pages away\n", percentage ); 156 156 } … … 205 205 for ( int z = 0; z < _height; ++z ) { 206 206 pTerrainPage page = getPage( _x0+x, _z0+z ); 207 page->chooseLOD( ); 208 page->show( ); 207 page->setVisibility( true ); 208 page->chooseLOD(); 209 209 210 } 210 211 } -
branches/terrain/src/lib/graphics/importer/terrain/terrain.h
r8319 r8328 67 67 68 68 void getAltitude( Triple& _alt, Triple& _normal ); 69 69 70 void showPages( int _x0, int _z0, int _width, int _height ); 70 71 … … 106 107 inline float getAltitude( int _x, int _z ) const; 107 108 108 inline void setLightmap( std::string &_lightmap )109 inline void setLightmap( const std::string &_lightmap ) 109 110 { 110 111 lightmapSource = _lightmap; 111 112 } 112 inline void setHeightmap( std::string &_heightmap )113 inline void setHeightmap( const std::string &_heightmap ) 113 114 { 114 115 heightmapSource = _heightmap; … … 180 181 inline float Terrain::getAltitude( int _x, int _z ) const 181 182 { 182 if ( _x > heightfield.width || _z > heightfield.height )183 return 0.0f;184 183 return heightfield.data[heightfield.pitch*_z+_x]/255.0f; 185 184 } -
branches/terrain/src/lib/graphics/importer/terrain/terrain_page.cc
r8321 r8328 10 10 11 11 ### File Specific: 12 main 12 main-programmer: Marco Biasini 13 13 14 14 */ … … 19 19 #include <math.h> 20 20 21 #define CHECK_GL_ERROR( ) do { \21 #define CHECK_GL_ERROR( _d ) do { \ 22 22 GLenum __err = glGetError(); \ 23 23 if ( __err != GL_NO_ERROR ) \ 24 printf( (char*)gluErrorString( __err ) );\24 printf( "check%s: %s\n", _d, (char*)gluErrorString( __err ) );\ 25 25 }\ 26 26 while ( 0 ) … … 77 77 void TerrainPage::activate() 78 78 { 79 79 80 pTerrainPage list = owner->getActiveList(); 80 81 next = list; … … 202 203 int stride = 1 << _lod; 203 204 for ( int z = 0; z < owner->getPageSize()-stride; z+=stride ) { 204 if ( z > 0 ) { 205 205 if ( z > 0 ) { 206 206 //Connect the two rows together by inserting the last index of last row 207 207 //and the first index of the next row two times. This will produce two … … 278 278 void TerrainPage::draw( ) 279 279 { 280 280 //These give an error 281 281 assert( glIsEnabled( GL_VERTEX_ARRAY ) ); 282 282 assert( !glIsEnabled( GL_NORMAL_ARRAY ) ); 283 assert( isVisible ); assert( numIndices ); 283 assert( isVisible ); assert( numIndices > 0 ); 284 assert( active ); 284 285 active = false; 286 CHECK_GL_ERROR( "1" ); 285 287 glVertexPointer( 3, GL_FLOAT, 0, vertices ); 286 288 glTexCoordPointer( 2, GL_FLOAT, 0, coords ); … … 290 292 if ( owner->debug() ) 291 293 drawBox( ); 292 293 CHECK_GL_ERROR( );294 295 CHECK_GL_ERROR( "2" ); 294 296 } 295 297 -
branches/terrain/src/lib/graphics/importer/terrain/terrain_page.h
r8321 r8328 247 247 show( ); 248 248 } 249 active = true; 249 250 } 250 251 else { -
branches/terrain/src/story_entities/game_world.cc
r8271 r8328 30 30 #include "camera.h" 31 31 #include "environment.h" 32 #include "terrain.h"33 32 #include "test_entity.h" 34 #include "terrain .h"33 #include "terrain_entity.h" 35 34 #include "playable.h" 36 35 #include "environments/mapped_water.h" -
branches/terrain/src/story_entities/game_world_data.cc
r7810 r8328 31 31 #include "player.h" 32 32 #include "camera.h" 33 #include "terrain .h"33 #include "terrain_entity.h" 34 34 #include "skybox.h" 35 35 #include "md2Model.h" … … 199 199 BaseObject* created = Factory::fabricate(element); 200 200 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()); 202 202 203 203 //todo do this more elegant … … 207 207 State::setSkyBox(dynamic_cast<SkyBox*>(this->sky)); 208 208 } 209 209 210 if( element->Value() == "Terrain" && created->isA(CL_TERRAIN)) 210 211 { 211 this->terrain = dynamic_cast<Terrain *>(created);212 this->terrain = dynamic_cast<TerrainEntity*>(created); 212 213 CDEngine::getInstance()->setTerrain(terrain); 213 214 } -
branches/terrain/src/story_entities/game_world_data.h
r7460 r8328 14 14 class Camera; 15 15 class Player; 16 class Terrain ;16 class TerrainEntity; 17 17 class WorldEntity; 18 18 … … 57 57 Player* localPlayer; //!< The player, you fly through the level. 58 58 WorldEntity* sky; //!< The environmental sky of orxonox 59 Terrain *terrain; //!< The terrain - ground59 TerrainEntity* terrain; //!< The terrain - ground 60 60 61 61 OrxSound::OggPlayer* music; //!< Reference to the SoundEngine's music player (OggPlayer) -
branches/terrain/src/story_entities/multi_player_world_data.cc
r8068 r8328 31 31 #include "camera.h" 32 32 #include "environment.h" 33 #include "terrain .h"33 #include "terrain_entity.h" 34 34 #include "test_entity.h" 35 #include "terrain.h"36 35 #include "md2Model.h" 37 36 #include "world_entities/projectiles/projectile.h" … … 157 156 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) 158 157 { 159 this->terrain = dynamic_cast<Terrain *>(created);158 this->terrain = dynamic_cast<TerrainEntity*>(created); 160 159 CDEngine::getInstance()->setTerrain(terrain); 161 160 } … … 188 187 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) 189 188 { 190 this->terrain = dynamic_cast<Terrain *>(created);189 this->terrain = dynamic_cast<TerrainEntity*>(created); 191 190 CDEngine::getInstance()->setTerrain(terrain); 192 191 } -
branches/terrain/src/story_entities/simple_game_menu.cc
r8035 r8328 30 30 #include "world_entity.h" 31 31 #include "elements/image_entity.h" 32 #include "terrain .h"32 #include "terrain_entity.h" 33 33 #include "camera.h" 34 34 -
branches/terrain/src/util/multiplayer_team_deathmatch.cc
r8147 r8328 32 32 33 33 #include "shared_network_data.h" 34 #include "terrain .h"34 #include "terrain_entity.h" 35 35 #include "class_list.h" 36 36 #include "space_ships/space_ship.h" -
branches/terrain/src/world_entities/WorldEntities.am
r8271 r8328 8 8 world_entities/skysphere.cc \ 9 9 world_entities/skybox.cc \ 10 world_entities/terrain .cc \10 world_entities/terrain_entity.cc \ 11 11 world_entities/satellite.cc \ 12 12 world_entities/movie_entity.cc \ … … 63 63 skysphere.h \ 64 64 skybox.h \ 65 terrain .h \65 terrain_entity.h \ 66 66 satellite.h \ 67 67 movie_entity.h \ -
branches/terrain/src/world_entities/terrain_entity.cc
r8321 r8328 16 16 17 17 18 #include "terrain .h"19 18 #include "terrain_entity.h" 19 #include "terrain/terrain.h" 20 20 #include "util/loading/load_param.h" 21 21 #include "util/loading/factory.h" … … 26 26 #include "network_game_manager.h" 27 27 28 #include "height_map.h"29 28 #include "material.h" 30 29 … … 35 34 using namespace std; 36 35 37 CREATE_FACTORY( Terrain, CL_TERRAIN);36 CREATE_FACTORY( TerrainEntity, CL_TERRAIN ); 38 37 39 38 /** 40 39 * standard constructor 41 40 */ 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); 41 TerrainEntity::TerrainEntity (const TiXmlElement* root) 42 { 43 this->init(); 44 45 46 if( root != NULL) 47 this->loadParams(root); 48 terrain->build( ); 52 49 } 53 50 54 51 55 52 /** 56 * Constructor for loading a Terrain out of a file53 * Constructor for loading a TerrainEntity out of a file 57 54 * @param fileName The file to load data from. 58 55 59 56 this either loads out of an OBJ-file, or loads a heightmap if no .obj-extension is found. 60 57 */ 61 Terrain ::Terrain(const std::string& fileName)58 TerrainEntity::TerrainEntity(const std::string& fileName ) 62 59 { 63 60 this->init(); … … 76 73 * a Constructor for the Debug-Worlds 77 74 */ 78 Terrain ::Terrain(DebugTerrain debugTerrain)75 TerrainEntity::TerrainEntity(DebugTerrainEntity debugTerrainEntity) 79 76 { 80 77 this->init(); 81 this->buildDebugTerrain (debugTerrain);78 this->buildDebugTerrainEntity(debugTerrainEntity); 82 79 } 83 80 … … 86 83 87 84 */ 88 Terrain ::~Terrain()85 TerrainEntity::~TerrainEntity () 89 86 { 90 87 if (objectList) 91 88 glDeleteLists(this->objectList, 1); 92 if( this->ssp) 93 delete ssp; 89 94 90 if (this->vegetation) 95 91 { 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 100 void TerrainEntity::init() 101 { 102 this->setClassID( CL_TERRAIN, "TerrainEntity"); 107 103 this->toList(OM_ENVIRON_NOTICK); 108 104 this->toReflectionList(); 109 105 110 106 this->objectList = 0; 111 this->ssp = NULL;112 107 this->vegetation = NULL; 113 108 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 115 void 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 130 void TerrainEntity::setScale(float x, float y, float z) 131 { 132 terrain->setScale( Triple( x, y, z ) ); 133 } 134 135 void TerrainEntity::loadElevationmap( const std::string& _eleFile ) 136 { 137 terrain->setHeightmap( _eleFile ); 138 } 139 140 void TerrainEntity::loadLightmap( const std::string& _lightFile ) 141 { 142 terrain->setLightmap( _lightFile ); 143 } 144 145 146 147 void TerrainEntity::loadVegetation(const std::string& vegetationFile) 179 148 { 180 149 PRINTF(4)("loadVegetation: %s\n", vegetationFile.c_str()); … … 194 163 195 164 196 void Terrain::draw () const 197 { 198 glPushMatrix(); 165 void TerrainEntity::draw () const 166 { 167 glMatrixMode( GL_MODELVIEW ); 168 glPushMatrix(); 199 169 200 170 /* translate */ 201 glTranslatef (this->getAbsCoor ().x,171 /* glTranslatef (this->getAbsCoor ().x, 202 172 this->getAbsCoor ().y, 203 this->getAbsCoor ().z );173 this->getAbsCoor ().z );*/ 204 174 /* rotate */ 205 175 // Vector tmpRot = this->getAbsDir().getSpacialAxis(); 206 176 //glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 207 177 208 if (this->objectList)178 /*if (this->objectList) 209 179 glCallList(this->objectList); 210 180 else if (this->getModel()) … … 213 183 if (this->vegetation) 214 184 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(); 227 195 /* 228 196 glMatrixMode(GL_MODELVIEW); … … 236 204 glBegin(GL_QUADS); // Draw The Cube Using quads 237 205 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) 239 207 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) 240 208 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) … … 244 212 glPopMatrix();*/ 245 213 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 217 void TerrainEntity::buildDebugTerrainEntity(DebugTerrainEntity debugTerrainEntity) 218 { 219 terrain->build( ); 220 /* 221 // if the TerrainEntity is the TerrainEntity of Dave 222 if (debugTerrainEntity == TERRAINENTITY_DAVE) 257 223 { 258 224 objectList = glGenLists(1); … … 389 355 glEndList(); 390 356 } 391 392 if (debugTerrain == TERRAIN_BENSCH)357 */ 358 if (debugTerrainEntity == TERRAINENTITY_BENSCH) 393 359 { 394 360 /* … … 424 390 } 425 391 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 } 392 float 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 1 1 /*! 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 4 5 5 6 @todo implement it 6 7 7 The terrainshould 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. 8 9 */ 9 10 10 #ifndef _TERRAIN _H11 #define _TERRAIN _H11 #ifndef _TERRAINENTITY_H 12 #define _TERRAINENTITY_H 12 13 13 14 #include "world_entity.h" … … 15 16 16 17 // FORWARD DECLARATION 17 class SpatialSeparation;18 class HeightMap;19 18 class Material; 19 class Terrain; 20 20 21 21 //! A simple method to call a desired debug world. 22 enum DebugTerrain {TERRAIN_DAVE, TERRAIN_BENSCH};22 enum DebugTerrainEntity {TERRAINENTITY_DAVE, TERRAINENTITY_BENSCH}; 23 23 24 24 25 //! A Class to handle Terrain of orxonox26 class Terrain : public WorldEntity25 //! A Class to handle TerrainEntity of orxonox 26 class TerrainEntity : public WorldEntity 27 27 { 28 28 29 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(); 34 34 35 36 35 void init(); 36 virtual void loadParams(const TiXmlElement* root); 37 37 38 38 void loadVegetation(const std::string& vegetationFile); 39 39 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 ); 43 43 44 void buildDebugTerrain(DebugTerrain debugTerrain);44 void buildDebugTerrainEntity(DebugTerrainEntity debugTerrainEntity); 45 45 46 47 46 float getHeight(float x, float y); 47 virtual void draw() const; 48 48 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; 59 56 }; 60 57 61 #endif /* _T ERRAIN_H */58 #endif /* _TerrainEntity_H */
Note: See TracChangeset
for help on using the changeset viewer.