Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8876 in orxonox.OLD for branches/single_player_map


Ignore:
Timestamp:
Jun 28, 2006, 5:33:20 PM (19 years ago)
Author:
patrick
Message:

collision reaction stuff

Location:
branches/single_player_map/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/single_player_map/src/defs/class_id.h

    r8793 r8876  
    187187  CL_BSP_ENTITY                 =    0x00000312,
    188188  CL_SKYDOME                    =    0x00000313,
     189  CL_DOOR                       =    0x00000314,
    189190
    190191  // Playables
     
    212213  CL_TARGETING_TURRET           =    0x000003a4,
    213214  CL_HYPERBLASTER               =    0x000003a5,
     215  CL_FPS_SNIPER_RIFLE           =    0x000003a6,
     216  CL_FPS_LASER_RIFLE            =    0x000003a7,
    214217
    215218  // Projectiles
  • branches/single_player_map/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r8864 r8876  
    2929
    3030#include "aabb.h"
     31
     32#include "cr_defs.h"
    3133
    3234using namespace std;
     
    7072  WorldEntity* entity = collision->getEntityB();
    7173
     74  // collision position maths
     75  Vector collPos =  collision->getEntityB()->getAbsCoor()  + box->center - ce->getCollisionPosition();
     76
    7277  float CR_MAX_WALK_HEIGHT = 2.0f;
    7378  float CR_THRESHOLD = 0.2f;
    7479
    75   if( box != NULL)
     80  if( box == NULL)
    7681  {
    77 
    78     Vector collPos =  collision->getEntityB()->getAbsCoor()  + box->center - ce->getCollisionPosition();
    79     height = collPos.y - box->halfLength[1];
    80 
    81     PRINTF(0)("height: %f          , model height: %f\n", height, box->halfLength[1]);
    82     PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);
    83 
    84     // object is beneath the plane (ground)
    85     if( height < 0.0f )
    86     {
    87       entity->shiftCoor(Vector(0, -height, 0));
    88     }
    89     // object is already in the wall
    90     else if( ce->isInWall())
    91     {
    92       entity->setAbsCoor(entity->getLastAbsCoor());
    93     }
    94 
    95 
    96 
     82    PRINTF(2)("this model has no aabb box so there is no correct collision reaction implemented. skipping\n");
     83    return;
    9784  }
     85
     86
     87  switch( ce->getType())
     88  {
     89    case COLLISION_TYPE_AXIS_Y:
     90
     91      height = collPos.y - box->halfLength[1];
     92      PRINTF(0)("height: %f          , model height: %f\n", height, box->halfLength[1]);
     93      PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);
     94
     95      // object is beneath the plane (ground)
     96      if( height <= 0.0f )
     97      {
     98        entity->shiftCoor(Vector(0, -height, 0));
     99      }
     100      // object is already in the wall
     101      else if( ce->isInWall())
     102      {
     103        entity->setAbsCoor(entity->getLastAbsCoor());
     104      }
     105      break;
     106
     107
     108    case COLLISION_TYPE_AXIS_X:
     109    case COLLISION_TYPE_AXIS_Z:
     110      break;
     111
     112    }
     113
     114
     115
    98116
    99117
     
    177195void CRPhysicsGroundWalk::update(WorldEntity* owner)
    178196{
    179   for( int i = 9; i > 0; i--) {
    180     this->lastPositions[i] = this->lastPositions[i-1];
    181     //     PRINTF(0)("lastPosition[%i]: %f, %f, %f\n", i, lastPositions[i].x, lastPositions[i].y, lastPositions[i].z);
    182   }
    183   this->lastPositions[0] = owner->getAbsCoor();
     197
    184198}
    185199
  • branches/single_player_map/src/lib/collision_reaction/cr_physics_ground_walk.h

    r8724 r8876  
    2323    virtual void update(WorldEntity* entity);
    2424
     25
    2526  private:
    26     Vector       lastPosition;                //!< vector with the last valid position
    27     Vector       afterLastPosition;           //!< vector for the after last
    28     Quaternion   lastDirection;               //!< quat with the last valid direction
    29 
    30     Vector       lastPositions[10];           //!< last 10 positions
    3127    float        downspeed;
    3228};
  • branches/single_player_map/src/world_entities/door.cc

    r8875 r8876  
    6767  WorldEntity::loadParams(root);
    6868
    69 //   LoadParam(root, "", this, Door, set)
    70 //       .describe("sets the animation of the md2 model")
    71 //       .defaultValues(1);
     69  LoadParam(root, "", this, Door, setActionRadius)
     70      .describe("sets the action radius of the door")
     71      .defaultValues(1);
    7272
    7373}
    7474
    7575
    76 void  Door::setAnim(int animationIndex, int animPlaybackMode)
     76void  Door::setAnimation(int animationIndex, int animPlaybackMode)
    7777{
    7878  if( likely(this->getModel(0) != NULL))
     
    8686    ((InteractiveModel*)this->getModel(0))->tick(time);
    8787
     88
     89}
     90
     91
     92/**
     93 * open the door
     94 */
     95void Door::open()
     96{
     97  if( this->bLocked)
     98    return;
     99
     100//   this->setAnimation();
     101
     102}
     103
     104
     105/**
     106 * close the door
     107 */
     108void Door::close()
     109{
    88110
    89111}
  • branches/single_player_map/src/world_entities/door.h

    r8875 r8876  
    1818    virtual void loadParams(const TiXmlElement* root);
    1919
    20     void setAnim(int animationIndex, int animPlaybackMode);
    2120    void setActionRadius(float radius) { this->actionRadius = radius; }
    2221
     
    2625    void close();
    2726
     27    void lock() { this->bLocked = true; }
     28    void unlock() { this->bLocked = false; }
     29    bool isLocked() const { return this->bLocked; }
     30
     31
    2832  private:
    2933    bool checkOpen();
     34    void setAnimation(int animationIndex, int animPlaybackMode);
     35
    3036
    3137  private:
    3238    bool           bOpen;             //!< true if the door is open
     39    bool           bLocked;           //!< true if this door is locked
    3340    float          actionRadius;      //!< action radius
     41
    3442
    3543};
Note: See TracChangeset for help on using the changeset viewer.