Changeset 9415 in orxonox.OLD for branches/terrain/src/lib/graphics/importer/terrain/terrain_page.h
- Timestamp:
- Jul 24, 2006, 12:59:44 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/terrain/src/lib/graphics/importer/terrain/terrain_page.h
r9414 r9415 1 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 4 4 Copyright (C) 2006 orx 5 5 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by 8 8 the Free Software Foundation; either version 2, or (at your option) 9 9 any later version. 10 10 11 11 ### File Specific: 12 12 main programmer: Marco Biasini 13 13 14 14 */ 15 15 … … 27 27 28 28 struct Vertex { 29 TexCoord t; 29 TexCoord t; 30 30 Vector p; 31 31 }; … … 43 43 enum { TP_LEFT = 0, TP_RIGHT = 1, TP_BOTTOM = 2, TP_TOP = 3 }; 44 44 const static int MAX_LODS = 5; 45 45 46 46 /** 47 47 * Creates a new terrain page with its lower left corner set … … 52 52 */ 53 53 TerrainPage( Terrain *_owner, int _xOffset, int _zOffset ); 54 54 55 55 /** 56 56 * This is used only internally for communication between the TerrainPage and … … 58 58 */ 59 59 inline bool isActive() { return active; } 60 60 61 61 virtual ~TerrainPage(); 62 62 /** 63 * @brief Makes the terrain look as if it were created with the given level of 63 * @brief Makes the terrain look as if it were created with the given level of 64 64 * detail. 65 65 */ 66 66 void mimick( int _level ) {} 67 67 68 68 /** 69 69 * @brief Draws a box around the TerrainPage. For debugging purposes. 70 70 */ 71 71 void drawBox(); 72 73 /** 72 73 /** 74 74 * @brief Calculates the smallest fitting axis aligned bounding box for this TerrainPage. 75 75 */ 76 virtual void calculateBounds(); 77 78 79 /** 80 * @brief Sets the visibility to _flag. If the visibility changed, the vertex and 76 virtual void calculateBounds(); 77 78 79 /** 80 * @brief Sets the visibility to _flag. If the visibility changed, the vertex and 81 81 * index arrays are allocated or freed, respectively. 82 82 */ … … 87 87 */ 88 88 void show( ); 89 89 90 90 /** 91 91 * @brief Frees most of the memory for economomical reasons. 92 92 */ 93 void hide( ); 94 93 void hide( ); 94 95 95 /** 96 96 * @brief Updates the tesselation if necessary. 97 97 */ 98 98 void updateTesselation( ); 99 99 100 100 /** 101 101 * @return The current tesselation level. 102 102 */ 103 103 int getLOD() { return currentLOD; } 104 105 /** 106 * @return The curren tween factor. This is a floating point value between 0.0f 104 105 /** 106 * @return The curren tween factor. This is a floating point value between 0.0f 107 107 * and 1.0f 108 108 */ 109 109 float getTween() { return 0.0f; } 110 110 111 111 /** 112 112 * @brief Determines the new LOD which should be used by this terrain page based on 113 * the distance from the camera. 113 * the distance from the camera. 114 114 * 115 * No geometry is updated in this method. You need to call 115 * No geometry is updated in this method. You need to call 116 116 * updateTesselation() in order to see a change in geometry. This method is 117 * just a recommondation for the LOD. It might be invalid due to outer 117 * just a recommondation for the LOD. It might be invalid due to outer 118 118 * constraints. 119 119 */ 120 120 int chooseLOD(); 121 121 122 122 /** 123 123 * If the terrain pages tesselation level changed between the last and the … … 127 127 */ 128 128 bool isDirty() { return forceTesselation; } 129 129 130 130 /** 131 131 * @brief Calculates the maximal errors for every LOD. 132 132 */ 133 133 void calculateErrors(); 134 134 135 135 /** 136 136 * @brief Calculates the error for the given LOD. We just need to know the "worst" … … 138 138 */ 139 139 void calculateError( int _lod ); 140 141 140 141 142 142 /** 143 143 * Tests if the terrain page would cull against the viewing frustum. … … 150 150 * pages is at the border. 151 151 */ 152 inline void setNeighbors( pTerrainPage _left, pTerrainPage _right, 152 inline void setNeighbors( pTerrainPage _left, pTerrainPage _right, 153 153 pTerrainPage _top, pTerrainPage _bottom ) 154 154 { 155 155 left = _left; right = _right; top = _top; bottom = _bottom; 156 156 } 157 157 158 158 /** 159 159 * Sets the position of the TerrainPage. Is this needed? … … 169 169 pTerrainPage getRight() { return right; } 170 170 pTerrainPage getBottom() { return bottom; } 171 pTerrainPage getTop() { return top; } 172 171 pTerrainPage getTop() { return top; } 172 173 173 /** 174 174 * Does what exactly what the name says and nothing more. 175 175 */ 176 176 void draw( ); 177 177 178 178 /** 179 179 * @return the next active page … … 181 181 inline pTerrainPage getNext() { return next; } 182 182 void setLayerVisibility( int _layer, LayerVisibility _lv ); 183 bool hasMaterial( int _layer ); 183 bool hasMaterial( int _layer ); 184 184 /** 185 185 * Returns the previous active page 186 186 */ 187 inline pTerrainPage getPrevious() { return previous; } 187 inline pTerrainPage getPrevious() { return previous; } 188 188 inline int getCurrentLOD() { return currentLOD; } 189 189 /** … … 192 192 */ 193 193 inline int getWantedLOD() { return wantedLOD; } 194 194 195 195 /** 196 196 * @brief Removes the page from the active page list. 197 197 */ 198 198 void deactivate(); 199 200 /** 199 200 /** 201 201 * @brief Inserts the page into the active page list. 202 202 */ 203 void activate(); 203 void activate(); 204 204 205 205 inline void setWantedLOD( int _lod ) … … 212 212 wantedLOD = _lod; 213 213 } 214 214 215 215 protected: 216 216 217 217 /** 218 218 * @brief Tesselates one row of the terrain page. … … 221 221 * @param _zStride Defines the step-size vertically. 222 222 * @param _adaptLeft True if the left neighbor has a coarser 223 * tesselation level. 223 * tesselation level. 224 224 * @param _adaptRight True if the right neighbor has a coarser 225 225 * tesselation level. … … 228 228 void tesselateTopRow( int _z, int _stride, bool _adaptLeft, bool _adaptRight ); 229 229 void tesselateBottomRow( int _z, int _stride, bool _adaptLeft, bool _adaptRight ); 230 /** 230 /** 231 231 * @brief Returns four boolean values in the oder 232 232 */ 233 233 void determineBorderAdaption( bool _adapt[] ); 234 234 235 235 /** 236 236 * @brief Adds the given index to the index-array 237 237 */ 238 238 inline void addIndex( unsigned short _index ); 239 239 240 240 /** 241 241 * @brief We programmers are very lazy :) This method just adds the last added index … … 243 243 */ 244 244 inline void addAgain(); 245 246 245 246 247 247 void getCoord( int _x, int _z, TexCoord& _coord) const; 248 249 /** 248 249 /** 250 250 * Fills _vertex with the vertex information at index. 251 251 */ 252 252 void getVertex( int _x, int _z, Vector& _vertex ) const; 253 253 254 254 /** 255 255 * Use this method to safely get a vertex at location ( _x, _z ). If it wasn't 256 * created before, this method does that for you. 257 */ 256 * created before, this method does that for you. 257 */ 258 258 unsigned short getIndex( int _x, int _z ); 259 259 void tesselateLevelFourPage( bool _adapt[] ); … … 261 261 * Generates the tesselation for the given level of detail. 262 262 */ 263 void tesselate( int _lod ); 263 void tesselate( int _lod ); 264 264 265 265 float getAltitude( int _x, int _z ) const; 266 266 267 267 int currentLOD, 268 268 wantedLOD; 269 pTerrainPage left, 269 pTerrainPage left, 270 270 right, 271 271 top, … … 283 283 GLuint ibIdentifier, 284 284 vbIdentifier; 285 #endif 285 #endif 286 286 bool isVisible; 287 287 pTerrainPage next; … … 313 313 } 314 314 315 inline void TerrainPage::addAgain() 316 { 317 indices[numIndices] = indices[numIndices-1]; numIndices++; 315 inline void TerrainPage::addAgain() 316 { 317 indices[numIndices] = indices[numIndices-1]; numIndices++; 318 318 } 319 319
Note: See TracChangeset
for help on using the changeset viewer.