Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8684 in orxonox.OLD


Ignore:
Timestamp:
Jun 21, 2006, 6:23:57 PM (18 years ago)
Author:
ponder
Message:

Tried to do the collision detection for the terrain.

Location:
branches/terrain/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/terrain/src/lib/collision_detection/cd_engine.cc

    r8328 r8684  
    101101  {
    102102        //kraus: TODO put collision detection for terrain class here...
     103        TerrainEntity *ground = dynamic_cast<TerrainEntity*>(this->terrain);
    103104    //Quadtree* q = dynamic_cast<TerrainEntity*>(this->terrain)->ssp->getQuadtree();
    104         //QuadtreeNode* n = q->getQuadtreeFromPosition(this->player->getAbsCoor());
     105        //QuadtreeNode* n = q->getQuadtreeFromPosition(this->player->getAbsCoor());
     106    std::list<WorldEntity*>::iterator iterator;
     107    PRINTF(3)("checking for collisions\n");
     108
     109    iterator = list1.begin();
     110    while ( iterator != list1.end() ) {
     111                const Vector& position = (*iterator)->getAbsCoor();
     112
     113                float height = ground->getHeight( position.x, position.z );
     114                PRINTF(2)( "height: %f\n", height );           
     115                if ( position.y < height )
     116                        (*iterator)->setAbsCoor( position.x, height, position.z );
     117    }   
    105118  }
    106119 
  • branches/terrain/src/lib/graphics/importer/terrain/terrain.cc

    r8648 r8684  
    227227                }
    228228        } while ( dirty );
    229         printf( "dirtyrounds: %d\n", dirtyRounds );
     229       
    230230        page = activePages;
    231        
    232231        while ( page ) {
    233232                page->updateTesselation();
     
    286285                }
    287286                activatedCount = 0; deactivatedCount = 0;
    288                 //printf( "%d of %d pages drawn\n", pagesX*pagesZ-cullCount, pagesX*pagesZ );
    289                 //float percentage = (float)cullCount/(float)(pagesX*pagesZ)*100.0f;
    290                 //printf( "culled %f%% terrain pages away\n",  percentage );
    291287        }
    292288       
  • branches/terrain/src/lib/graphics/importer/terrain/terrain.h

    r8642 r8684  
    233233                std::vector<BufferInfo>         buffers;                       
    234234                       
    235                 //Texture                                       *tex;
    236235                Triple                                          cameraPosition;
    237236                pFrustum                                        frustum;
  • branches/terrain/src/lib/graphics/importer/terrain/terrain_page.cc

    r8648 r8684  
    338338                        addIndex( getIndex( halfStride, 0 ) );
    339339                        addIndex( getIndex( stride, 0 ) );
    340                         addAgain(  );
     340                        addAgain( );
    341341                        addIndex( getIndex( 0, stride ) );
    342342                        addIndex( getIndex( stride, halfStride ) );
     
    352352                        addIndex( getIndex( halfStride, 0 ) );
    353353                        addIndex( getIndex( 0, 0 ) );
    354                         addAgain(  );
     354                        addAgain( );
    355355                        break;
    356356
    357357                case ADAPT_T:
    358358                        addIndex( getIndex( stride, stride ) );
    359                         addAgain(  );
     359                        addAgain( );
    360360                        addIndex( getIndex( halfStride, stride ) );
    361361                        addIndex( getIndex( stride, 0 ) );
     
    369369                        addIndex( getIndex( halfStride, stride ) );
    370370                        addIndex( getIndex( 0, stride ) );
    371                         addAgain(  );
     371                        addAgain( );
    372372                        addIndex( getIndex( stride, 0 ) );
    373373                        addIndex( getIndex( 0, halfStride ) );
     
    392392                        addIndex( getIndex( halfStride, stride ) );
    393393                        addIndex( getIndex( stride, stride ) );
    394                         addAgain(  );
     394                        addAgain( );
    395395                        break;
    396396
    397397                case ADAPT_BT:
    398398                        addIndex( getIndex( 0, 0 ) );
    399                         addAgain(  );
    400                         addIndex( getIndex( halfStride, 0 ) );
    401                         addIndex( getIndex( 0, stride ) );
    402                         addIndex( getIndex( stride, 0 ) );
    403                         addIndex( getIndex( halfStride, stride ) );
    404                         addIndex( getIndex( stride, stride ) );
    405                         addAgain(  );
     399                        addAgain( );
     400                        addIndex( getIndex( halfStride, 0 ) );
     401                        addIndex( getIndex( 0, stride ) );
     402                        addIndex( getIndex( stride, 0 ) );
     403                        addIndex( getIndex( halfStride, stride ) );
     404                        addIndex( getIndex( stride, stride ) );
     405                        addAgain( );
    406406                        break;
    407407
     
    414414                        addIndex( getIndex( halfStride, stride ) );
    415415                        addIndex( getIndex( stride, stride ) );
    416                         addAgain(  );
     416                        addAgain( );
    417417                        break;
    418418
     
    425425                        addIndex( getIndex( halfStride, 0 ) );
    426426                        addIndex( getIndex( 0, 0 ) );
    427                         addAgain(  );
     427                        addAgain( );
    428428                        break;
    429429
     
    439439                        break;
    440440        }
    441         assert( numVertices > 3 );
    442 
    443441        assert( numIndices % 2 == 0 );
    444442}
  • branches/terrain/src/lib/graphics/importer/terrain/terrain_page.h

    r8648 r8684  
    225225                 * @brief Tesselates one row of the terrain page.
    226226                 * @param _z                    The z-offset of the row
    227                  * @param _xStride              Determines the step-size horizontally
    228                  * @param _zStride              Determines the step-size vertically.
     227                 * @param _xStride              Defines the step-size horizontally
     228                 * @param _zStride              Defines the step-size vertically.
     229                 * @param _adaptLeft    True if the left neighbor has a coarser
     230                 *                                              tesselation level.             
    229231                 * @param _adaptRight   True if the right neighbor has a coarser
    230232                 *                                              tesselation level.
    231                  * @param _adaptLeft    True if the left neighbor has a coarser
    232                  *                                              tesselation level.                     
    233233                 */
    234234                void tesselateRow( int _z, int _xStride, int _zStride, bool _adaptLeft, bool _adaptRight );
  • branches/terrain/src/world_entities/terrain_entity.cc

    r8595 r8684  
    174174
    175175  /* translate */
    176  /* glTranslatef (this->getAbsCoor ().x,
    177                 this->getAbsCoor ().y,
    178                 this->getAbsCoor ().z );*/
     176   glTranslatef( this->getAbsCoor().x,
     177                 this->getAbsCoor().y,
     178                 this->getAbsCoor().z );
    179179  /* rotate */
    180180  // Vector tmpRot = this->getAbsDir().getSpacialAxis();
     
    397397float TerrainEntity::getHeight( float x, float z )
    398398{
    399         Triple altitude( x, 0.0f, z ), normal( 0.0f, 0.0f, 0.0f );
     399        Triple  altitude( x-getAbsCoor().x, 0.0f, z-getAbsCoor().z ),
     400                        normal( 0.0f, 0.0f, 0.0f );
    400401        if ( terrain )
    401402                terrain->getAltitude( altitude, normal );
Note: See TracChangeset for help on using the changeset viewer.