| [7959] | 1 | /*! | 
|---|
 | 2 |  * @file collision_event.h | 
|---|
 | 3 |  *  Definition of a collision event | 
|---|
| [10013] | 4 |  * | 
|---|
 | 5 |  *  A collision event represents a collision of two bouning boxes. Every CollisionEvent belongs to a Collision object that | 
|---|
 | 6 |  *  represents the collision of two WorldEntities. | 
|---|
 | 7 |  * | 
|---|
 | 8 |  *  There are different types of collisions: obb collisions and bsp collisions. Both collision types use different techniques | 
|---|
 | 9 |  *  to represent collisions. This is why this class saves bounding boxes from the OBB as well as the planes from BSP. | 
|---|
| [7959] | 10 |  */ | 
|---|
 | 11 |  | 
|---|
 | 12 | #ifndef _COLLISION_EVENT_H | 
|---|
 | 13 | #define _COLLISION_EVENT_H | 
|---|
 | 14 |  | 
|---|
 | 15 | #include "vector.h" | 
|---|
| [10013] | 16 | #include "cr_engine.h" | 
|---|
| [7959] | 17 |  | 
|---|
| [8894] | 18 | #include "cr_defs.h" | 
|---|
 | 19 |  | 
|---|
 | 20 |  | 
|---|
| [7959] | 21 | class WorldEntity; | 
|---|
 | 22 | class BoundingVolume; | 
|---|
| [8182] | 23 | class Plane; | 
|---|
| [7959] | 24 |  | 
|---|
| [10013] | 25 | namespace CoRe | 
|---|
 | 26 | { | 
|---|
| [7959] | 27 |  | 
|---|
| [10013] | 28 |   //! A class representing a simple collision | 
|---|
 | 29 |   class CollisionEvent | 
|---|
 | 30 |   { | 
|---|
 | 31 |   public: | 
|---|
 | 32 |     CollisionEvent(); | 
|---|
 | 33 |     virtual ~CollisionEvent(); | 
|---|
| [8894] | 34 |  | 
|---|
| [10013] | 35 |     /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */ | 
|---|
 | 36 |     inline void collide(CREngine::CollisionType type, WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB) | 
|---|
 | 37 |     { this->collisionType = type; this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; } | 
|---|
 | 38 |     /** collides two WorldEntities @param entity world entity , @param ground ground plane, @param position position on the ground */ | 
|---|
 | 39 |     inline void collide(CREngine::CollisionType type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall) | 
|---|
 | 40 |     { | 
|---|
 | 41 |       this->collisionType = type; | 
|---|
 | 42 |       this->entityA = entity; | 
|---|
 | 43 |       this->entityB = groundEntity; | 
|---|
 | 44 |       this->groundNormal = normal; | 
|---|
 | 45 |       this->position = position; | 
|---|
 | 46 |       this->bInWall = bInWall; | 
|---|
 | 47 |     } | 
|---|
| [7959] | 48 |  | 
|---|
 | 49 |  | 
|---|
| [10013] | 50 |     /** @return CollisionEvent WorldEntity A */ | 
|---|
 | 51 |     inline const WorldEntity* getEntityA() const  { return this->entityA; } | 
|---|
 | 52 |     /** @return CollisionEvent WorldEntity B */ | 
|---|
 | 53 |     inline const WorldEntity* getEntityB() const  { return this->entityB; } | 
|---|
 | 54 |     /** @return Bounding Volume from EntityA */ | 
|---|
 | 55 |     inline const BoundingVolume* getBVA() const { return this->bvA; } | 
|---|
 | 56 |     /** @return Bounding Volume from EntityB */ | 
|---|
 | 57 |     inline const BoundingVolume* getBVB() const {  return this->bvB;  } | 
|---|
| [7959] | 58 |  | 
|---|
| [10013] | 59 |     /** @return ground plane if collided with bsp model */ | 
|---|
 | 60 |     inline const Vector& getGroundNormal() const  { return this->groundNormal; } | 
|---|
| [7959] | 61 |  | 
|---|
| [10013] | 62 |     /** @return position of the position, only accurate if this is a collision with the ground!!! */ | 
|---|
 | 63 |     inline const Vector& getCollisionPosition() const  {  return this->position;  } | 
|---|
| [7959] | 64 |  | 
|---|
| [10013] | 65 |     /** @return the type of the collision */ | 
|---|
 | 66 |     inline int getType() const  {  return this->collisionType;  } | 
|---|
| [8182] | 67 |  | 
|---|
| [10013] | 68 |     /** @return true if the entity is in the wall */ | 
|---|
 | 69 |     inline bool isInWall() const  {  return this->bInWall;  } | 
|---|
| [8894] | 70 |  | 
|---|
 | 71 |  | 
|---|
| [10013] | 72 |   private: | 
|---|
 | 73 |     WorldEntity*      entityA;                       //!< the collision body A | 
|---|
 | 74 |     WorldEntity*      entityB;                       //!< the collision body B | 
|---|
| [8894] | 75 |  | 
|---|
| [10013] | 76 |     BoundingVolume*   bvA;                           //!< reference to the bounding volume A | 
|---|
 | 77 |     BoundingVolume*   bvB;                           //!< reference to the bounding volume B | 
|---|
| [7959] | 78 |  | 
|---|
| [10013] | 79 |     Vector            groundNormal;                  //!< the ground plane with which it collides (only for bsp-model collisions | 
|---|
 | 80 |     Vector            position;                      //!< position of the collision on the ground plane | 
|---|
| [8182] | 81 |  | 
|---|
| [10013] | 82 |     bool              bInWall;                       //!< true if is in wall | 
|---|
 | 83 |     int               collisionType;                 //!< collision type | 
|---|
 | 84 |   }; | 
|---|
| [8894] | 85 |  | 
|---|
| [10013] | 86 | } | 
|---|
| [7959] | 87 | #endif /* _COLLISION_EVENT_H */ | 
|---|