Changeset 8321 in orxonox.OLD for branches/terrain/src/lib/graphics/importer
- Timestamp:
- Jun 11, 2006, 9:02:58 PM (19 years ago)
- Location:
- branches/terrain/src/lib/graphics/importer/terrain
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/terrain/src/lib/graphics/importer/terrain/terrain.cc
r8319 r8321 156 156 } 157 157 158 159 158 160 void Terrain::getAltitude( Triple& _alt, Triple& _normal ) 159 161 { 160 162 float xScaled = _alt.x / scale.x, zScaled = _alt.z / scale.z; 163 //The offset on the map 164 int xOff = (int)xScaled, zOff = (int)zScaled; 165 //The interpolation values. 166 float u = xScaled-xOff, v = zScaled-zOff; 167 168 float dX = scale.x / ( pageSize-1 ); 169 float dZ = scale.z / ( pageSize-1 ); 170 171 //If u is bigger than v, we are on the lower triangle... 172 if ( u > v ) { 173 174 float alt[] = { 175 getAltitude( xOff+0, zOff+0 )*scale.y, 176 getAltitude( xOff+1, zOff+0 )*scale.y, 177 getAltitude( xOff+1, zOff+1 )*scale.y }; 178 _alt.y = (1.0f-u)*(1.0-v)*alt[0]+u*(1.0f-v)*alt[1]+u*v*alt[2]; 179 180 //Since we know about the directions of some x and z-coordinates, 181 //not the whole cross products needs to be calculated. Grab yourself 182 //pen and paper :) 183 _normal.x = -dZ*( alt[0] - alt[1] ); 184 _normal.y = -dZ*dX; 185 _normal.z = dX*( alt[2] - alt[1] ); 186 } 187 else { 188 float alt[] = { 189 getAltitude( xOff+0, zOff+0 )*scale.y, 190 getAltitude( xOff+0, zOff+1 )*scale.y, 191 getAltitude( xOff+1, zOff+1 )*scale.y }; 192 _alt.y = (1.0f-u)*(1.0-v)*alt[0]+(1.0f-u)*v*alt[1]+u*v*alt[2]; 193 //Since we know about the directions of some x and z-coordinates, 194 //not the whole cross products needs to be calculated. Grab yourself 195 //pen and paper :) 196 _normal.x = dZ*( alt[2] - alt[1] ); 197 _normal.y = -dZ*dX; 198 _normal.z = -dX*( alt[0] - alt[1] ); 199 } 161 200 } 162 201 -
branches/terrain/src/lib/graphics/importer/terrain/terrain_page.cc
r8319 r8321 65 65 wantedLOD = TerrainPage::MAX_LODS-1; 66 66 } 67 67 // Calculate the tween factor. This is differently if the LOD is 0. 68 if ( wantedLOD > 0 ) { 69 70 } 71 else { 72 73 } 68 74 return wantedLOD; 69 75 } -
branches/terrain/src/lib/graphics/importer/terrain/terrain_page.h
r8320 r8321 44 44 */ 45 45 TerrainPage( Terrain *_owner, int _xOffset, int _zOffset ); 46 46 47 /** 47 48 * This is used only internally for communication between the TerrainPage and … … 58 59 59 60 /** 60 * Makes the terrain look as if it were created with the given level of61 * @brief Makes the terrain look as if it were created with the given level of 61 62 * detail. 62 63 */ … … 64 65 65 66 /** 66 * Draws a box around the TerrainPage. For debugging purposes.67 * @brief Draws a box around the TerrainPage. For debugging purposes. 67 68 */ 68 69 void drawBox(); 69 70 70 71 /** 71 * Calculates the smallest fitting axis aligned bounding box for this TerrainPage.72 * @brief Calculates the smallest fitting axis aligned bounding box for this TerrainPage. 72 73 */ 73 74 virtual void calculateBounds(); … … 75 76 76 77 /** 77 * Sets the visibility to _flag. If the visibility changed, the vertex and index78 * @brief Sets the visibility to _flag. If the visibility changed, the vertex and index 78 79 * arrays are allocated or freed, respectively. 79 80 */ … … 81 82 82 83 /** 83 * Prepares the page for rendering.84 * @brief Prepares the page for rendering. 84 85 */ 85 86 void show( ); 86 87 87 88 /** 89 * @brief Frees most of the memory for economomical reasons. 90 */ 91 void hide( ); 92 93 /** 94 * @brief Updates the tesselation if necessary. 95 */ 96 void updateTesselation( ); 97 98 /** 99 * @return The current tesselation level. 100 */ 101 int getLOD() { return currentLOD; } 102 103 /** 104 * @return The curren tween factor. This is a floating point value between 0.0f and 1.0f 105 */ 106 float getTween() { return 0.0f; } 107 108 /** 109 * @brief Determines the new LOD which should be used by this terrain page based on 110 * the distance from the camera. 88 111 * 89 */ 90 void hide( ); 91 92 /** 93 * Updates the tesselation if necessary. 94 */ 95 void updateTesselation( ); 96 97 /** 98 * Returns the current tesselation level. 99 */ 100 int getLOD() { return currentLOD; } 101 102 /** 103 * Returns the curren tween factor. This is a floating point value between 0.0f and 1.0f 104 */ 105 float getTween() { return 0.0f; } 106 107 /** 108 * Determines the new LOD which should be used by this terrain page based on 109 * the distance from the camera. 110 * Note: No geometry is updated in this method. You need to call 112 * No geometry is updated in this method. You need to call 111 113 * updateTesselation() in order to see a change in geometry. This method is 112 114 * just a recommandation. … … 118 120 * current frame, this function returns true, else you'll get false as the 119 121 * return value. 122 * @return True if the page needs an update and false if not. 120 123 */ 121 124 bool isDirty() { return forceTesselation; } 122 125 123 126 /** 124 * Calculates the maximal errors for every LOD.127 * @brief Calculates the maximal errors for every LOD. 125 128 */ 126 129 void calculateErrors(); 127 130 128 131 /** 129 * Calculates the error for the given LOD. We just need to know the "worst"132 * @brief Calculates the error for the given LOD. We just need to know the "worst" 130 133 * vertex for choosing an appropriate LOD. 131 134 */ … … 164 167 165 168 /** 166 * Returnsthe next active page169 * @return the next active page 167 170 */ 168 171 inline pTerrainPage getNext() { return next; } … … 174 177 175 178 /** 176 * Returns the wanted LOD. Make sure you call this method after a call to179 * @return Returns the wanted LOD. Make sure you call this method after a call to 177 180 * chooseLOD() or you will get screwed values. 178 181 */ … … 180 183 181 184 /** 182 * Removes the page from the active page list.185 * @brief Removes the page from the active page list. 183 186 */ 184 187 void deactivate(); 185 188 186 189 /** 187 * Inserts the page into the active page list.190 * @brief Inserts the page into the active page list. 188 191 */ 189 192 void activate(); 193 190 194 protected: 191 195 … … 216 220 int currentLOD, 217 221 wantedLOD; 222 float tween; 218 223 pTerrainPage left, 219 224 right,
Note: See TracChangeset
for help on using the changeset viewer.