Changeset 8328 in orxonox.OLD for branches/terrain/src/lib
- Timestamp:
- Jun 12, 2006, 5:17:14 PM (18 years ago)
- Location:
- branches/terrain/src/lib
- Files:
-
- 7 edited
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 {
Note: See TracChangeset
for help on using the changeset viewer.