- Timestamp:
- Jun 24, 2006, 12:38:43 PM (18 years ago)
- Location:
- branches/terrain/src/lib/graphics/importer/terrain
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/terrain/src/lib/graphics/importer/terrain/terrain.cc
r8748 r8770 12 12 #endif 13 13 14 bool validateSize( int _s ) { 15 _s-=1; 16 int s = 16; 17 while ( s <= _s ) { 18 if (s == _s ) 19 return true; 20 s*=2; 21 } 22 return false; 23 } 14 24 void Terrain::build() 15 25 { … … 21 31 return; 22 32 } 23 33 if ( !validateSize( tmpData->h ) || !validateSize( tmpData->w ) ) { 34 PRINTF(0)( "The size of the elevation map must be 2^n+1x2^m+1. and at least 17x17" ); 35 return; 36 } 37 if ( tmpData->format->BytesPerPixel != 1 ) { 38 PRINTF(0)( "The elevetation map must be an 8bit image!" ); 39 return; 40 } 24 41 heightfield.height = tmpData->h; 25 42 heightfield.width = tmpData->w; … … 29 46 memcpy( heightfield.data, tmpData->pixels, sizeof(Uint8)*dataSize ); 30 47 SDL_FreeSurface( tmpData ); 31 //TODO: Perform some checks... size, bits and so on32 48 pagesX = (heightfield.width/(pageSize-1) ); 33 49 pagesZ = (heightfield.height/(pageSize-1) ); … … 334 350 break; 335 351 case 3: 336 if( SDL_BYTEORDER == SDL_BIG_ENDIAN)352 if( SDL_BYTEORDER == SDL_BIG_ENDIAN ) 337 353 pixel = p[0] << 16 | p[1] << 8 | p[2]; 338 354 else … … 343 359 break; 344 360 default: 345 return 0; /* shouldn't happen, but avoids warnings */361 return 255; /* shouldn't happen, but avoids warnings */ 346 362 } 347 363 Uint8 r,g,b,a; -
branches/terrain/src/lib/graphics/importer/terrain/terrain.h
r8748 r8770 80 80 { 81 81 pageSize = 17; 82 pagesX = pagesZ = 0; 83 lightmap = NULL; 84 heightmapSource = ""; 85 root = NULL; 86 current = 0; 87 activePages = NULL; 82 88 scale = Triple( 1.0f, 3.0f, 1.0f ); 83 89 frustum = new Frustum(); … … 207 213 inline float Terrain::getAltitude( int _x, int _z ) const 208 214 { 215 assert( heightfield.data ); 209 216 if ( _x < 0 || _x >= heightfield.width || _z < 0 || _z >= heightfield.height ) { 210 217 return 0.0f; -
branches/terrain/src/lib/graphics/importer/terrain/terrain_page.cc
r8748 r8770 34 34 errors = new LODError[TerrainPage::MAX_LODS]; 35 35 vertices = NULL; indices = NULL; 36 position = Triple( scale.x*_xOffset, 0.0f, scale.z*_zOffset ); 36 left = top = bottom = right = NULL; 37 for ( int i = 0; i < 8; ++i ) 38 layerVisibility[i] = LV_NO; 39 40 position = Triple( scale.x*_xOffset, 41 0.0f, scale.z*_zOffset ); 37 42 isVisible = false; 38 43 next = NULL; 39 44 active = false; 40 previous = NULL; 41 currentLOD = -1; 45 previous = NULL; 46 currentLOD = -1; wantedLOD = -1; 42 47 hasfull = false; 43 48 forceTesselation = true; -
branches/terrain/src/lib/graphics/importer/terrain/terrain_page.h
r8745 r8770 83 83 84 84 /** 85 * @brief Sets the visibility to _flag. If the visibility changed, the vertex and index86 * arrays are allocated or freed, respectively.85 * @brief Sets the visibility to _flag. If the visibility changed, the vertex and 86 * index arrays are allocated or freed, respectively. 87 87 */ 88 88 inline void setVisibility( bool _flag ); … … 109 109 110 110 /** 111 * @return The curren tween factor. This is a floating point value between 0.0f and 1.0f 111 * @return The curren tween factor. This is a floating point value between 0.0f 112 * and 1.0f 112 113 */ 113 114 float getTween() { return 0.0f; } … … 271 272 int currentLOD, 272 273 wantedLOD; 273 float tween;274 274 pTerrainPage left, 275 275 right, -
branches/terrain/src/lib/graphics/importer/terrain/types.h
r8745 r8770 144 144 int pitch; 145 145 UByte *data; 146 Heightfield() { data = NULL; width=0;height=0;pitch=0;} 146 147 }; 147 148
Note: See TracChangeset
for help on using the changeset viewer.