Changeset 8929 in orxonox.OLD
- Timestamp:
- Jun 29, 2006, 11:45:59 PM (18 years ago)
- Location:
- branches/terrain/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/terrain/src/lib/collision_detection/cd_engine.cc
r8748 r8929 124 124 for( entityIterator = list1.begin(); entityIterator != list1.end(); entityIterator++ ) 125 125 { 126 /*Vector pos( (*entityIterator)->getAbsCoor() );126 Vector pos( (*entityIterator)->getAbsCoor() ); 127 127 Vector normal; 128 128 float height = pos.y; … … 131 131 ( *entityIterator )->registerCollision( 132 132 *entityIterator, terrain, pos, normal ); 133 } */133 } 134 134 } 135 135 } -
branches/terrain/src/lib/graphics/importer/md3/md3_data.h
r8490 r8929 70 70 71 71 72 73 72 //! class to store the md2 data in 74 73 class MD3Data : public BaseObject -
branches/terrain/src/lib/graphics/importer/terrain/terrain.cc
r8775 r8929 171 171 } 172 172 173 void Terrain::tick( float _dt ) 174 { 175 for ( unsigned int i = 0; i < buffers.size(); ++i ) 176 broker->release( buffers[i].vbIdentifier, buffers[i].ibIdentifier ); 177 buffers.clear(); 178 pTerrainPage page = NULL; 179 //Extract the frustum planes out of the modelview matrix. 180 frustum->extractPlanes(); 181 // Lets see which pages are visible. 182 determineVisiblePages( root ); 183 int wantedLeft, wantedRight, wantedBottom, wantedTop, minLOD; 184 pTerrainPage neighbor = NULL; 185 page = activePages; 186 bool dirty; 187 current = 0; 188 BufferInfo bi; 189 broker->acquire( bi.vbIdentifier, bi.ibIdentifier ); 190 buffers.push_back( bi ); 191 int dirtyRounds = 0; 192 do { 193 dirtyRounds++; 194 dirty = false; 195 page = activePages; 196 while ( page ) { 197 if ( !page->isActive() ) { 198 pTerrainPage tmp = page; 199 page = tmp->getNext(); 200 tmp->setVisibility( false ); 201 continue; 202 } 203 wantedLeft = wantedRight = wantedBottom = wantedTop = page->getWantedLOD(); 204 if ( ( neighbor = page->getLeft() ) && ( neighbor->isActive() ) ) 205 wantedLeft = neighbor->getWantedLOD(); 206 if ( ( neighbor = page->getRight() ) && ( neighbor->isActive() ) ) 207 wantedRight = neighbor->getWantedLOD(); 208 if ( ( neighbor = page->getTop() ) && ( neighbor->isActive() ) ) 209 wantedTop = neighbor->getWantedLOD(); 210 if ( ( neighbor = page->getBottom() ) && ( neighbor->isActive() ) ) 211 wantedBottom = neighbor->getWantedLOD(); 212 213 minLOD = std::min( std::min( wantedBottom, wantedTop ), 214 std::min( wantedLeft, wantedRight ) ); 215 if ( minLOD < page->getWantedLOD()-1 ) { 216 page->setWantedLOD( minLOD+1 ); 217 dirty = true; 218 } 219 page = page->getNext(); 220 } 221 } while ( dirty ); 222 223 page = activePages; 224 while ( page ) { 225 assert( page->isActive() ); 226 page->updateTesselation(); 227 page = page->getNext(); 228 } 229 //If there is some data in the buffer, we need to upload the data 230 //into the vram... 231 if ( buffers[current].numIndices != 0 ) { 232 BufferInfo bi = buffers[current]; 233 glBindBufferARB( GL_ARRAY_BUFFER_ARB, bi.vbIdentifier ); 234 glBufferDataARB( GL_ARRAY_BUFFER_ARB, MAX_VERTICES*sizeof( Vertex ), 235 vertices, GL_DYNAMIC_DRAW_ARB ); 236 glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, bi.ibIdentifier ); 237 glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, MAX_INDICES*sizeof( short ), 238 indices, GL_DYNAMIC_DRAW_ARB ); 239 } 240 } 173 241 void Terrain::draw( ) 174 242 { 243 pTerrainPage page = NULL; 175 244 glGetError(); 176 pTerrainPage page = NULL; 177 frustum->extractPlanes(); 245 /*pTerrainPage page = NULL; 246 frustum->extractPlanes();*/ 247 Plane far = frustum->getPlane( Frustum::FAR ); 248 //Due to some reason, the OpenGL implementors chose the plane equation 249 //to an array of doubles. So we will make them happy. 250 double farPlane[] = { far.n.x, far.n.y, far.n.z, far.d }; 251 glEnable( GL_CLIP_PLANE0 ); 252 glClipPlane( GL_CLIP_PLANE0, farPlane ); 178 253 glPushAttrib( GL_ALL_ATTRIB_BITS ); 179 254 glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); … … 198 273 cullCount = 0; 199 274 200 / / Lets see which pages are visible.275 /*// Lets see which pages are visible. 201 276 determineVisiblePages( root ); 202 277 int wantedLeft, wantedRight, wantedBottom, wantedTop, minLOD; … … 256 331 glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, MAX_INDICES*sizeof( short ), 257 332 indices, GL_DYNAMIC_DRAW_ARB ); 258 } 333 }*/ 259 334 glEnable( GL_BLEND ); 260 335 glDepthFunc( GL_LEQUAL ); … … 312 387 page = page->getNext(); 313 388 } 314 activatedCount = 0; deactivatedCount = 0; 315 } 316 317 for ( unsigned int i = 0; i < buffers.size(); ++i ) 318 broker->release( buffers[i].vbIdentifier, buffers[i].ibIdentifier ); 319 320 buffers.clear(); 321 389 } 390 322 391 glClientActiveTextureARB( GL_TEXTURE1_ARB ); 323 392 glActiveTextureARB( GL_TEXTURE1_ARB ); … … 329 398 glPopAttrib(); 330 399 glPopClientAttrib(); 400 glDisable( GL_CLIP_PLANE0 ); 331 401 } 332 402 … … 429 499 //not the whole cross products needs to be calculated. Grab yourself 430 500 //pen and paper :) 431 _normal.x = -dZ*( alt[0] - alt[1] );432 _normal.y = -dZ*dX;433 _normal.z = 501 _normal.x = dZ*( alt[0] - alt[1] ); 502 _normal.y = dZ*dX; 503 _normal.z = -dX*( alt[2] - alt[1] ); 434 504 } 435 505 else { … … 442 512 //not the whole cross products needs to be calculated. Grab yourself 443 513 //pen and paper :) 444 _normal.x = 445 _normal.y = -dZ*dX;446 _normal.z = -dX*( alt[0] - alt[1] );514 _normal.x = -dZ*( alt[2] - alt[1] ); 515 _normal.y = dZ*dX; 516 _normal.z = dX*( alt[0] - alt[1] ); 447 517 } 448 518 } -
branches/terrain/src/lib/graphics/importer/terrain/terrain.h
r8775 r8929 117 117 118 118 void build(); 119 119 void tick( float _dt ); 120 120 inline void setActiveList( pTerrainPage _page ) 121 121 { -
branches/terrain/src/lib/graphics/importer/terrain/terrain_page.cc
r8775 r8929 138 138 float d = distance.length(); 139 139 140 assert( d > 0.000001f );141 140 float err = errors[i].diff / d ; 142 141 -
branches/terrain/src/world_entities/playable.cc
r8490 r8929 67 67 68 68 this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY); 69 69 this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_TERRAIN ); 70 70 registerVar( new SynchronizeableInt( &score, &score, "score" ) ); 71 71 registerVar( new SynchronizeableBool( &bFire, &bFire, "bFire", PERMISSION_OWNER)); -
branches/terrain/src/world_entities/terrain_entity.cc
r8748 r8929 101 101 { 102 102 this->setClassID( CL_TERRAIN, "TerrainEntity"); 103 this->toList(OM_ENVIRON _NOTICK);103 this->toList(OM_ENVIRON); 104 104 this->toReflectionList(); 105 105 … … 200 200 201 201 202 202 void TerrainEntity::tick( float _dt ) { if ( terrain ) terrain->tick( _dt ); } 203 203 204 204 void TerrainEntity::draw () const -
branches/terrain/src/world_entities/terrain_entity.h
r8741 r8929 47 47 void getAltitude( Vector& _position, Vector& _normal ); 48 48 virtual void draw() const; 49 49 virtual void tick( float _dt ); 50 50 public: 51 51 -
branches/terrain/src/world_entities/world_entity.cc
r8490 r8929 427 427 return false; 428 428 429 429 430 // get a collision event 430 431 CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject();
Note: See TracChangeset
for help on using the changeset viewer.