Changeset 10010 in orxonox.OLD for branches/coll_rect.merge/src/lib/collision_reaction/collision_event.h
- Timestamp:
- Dec 4, 2006, 4:39:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/coll_rect.merge/src/lib/collision_reaction/collision_event.h
r9869 r10010 2 2 * @file collision_event.h 3 3 * Definition of a collision event 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. 4 10 */ 5 11 … … 8 14 9 15 #include "vector.h" 16 #include "cr_engine.h" 10 17 11 18 #include "cr_defs.h" … … 16 23 class Plane; 17 24 25 namespace CoRe 26 { 27 28 //! A class representing a simple collision 29 class CollisionEvent 30 { 31 public: 32 CollisionEvent(); 33 virtual ~CollisionEvent(); 34 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 } 18 48 19 49 20 //! A class representing a simple collision 21 class CollisionEvent { 22 public: 23 CollisionEvent(); 24 virtual ~CollisionEvent(); 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; } 25 58 26 /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */ 27 inline void collide(int type, WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB) 28 { this->collisionType = type; this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; } 29 /** collides two WorldEntities @param entity world entity , @param ground ground plane, @param position position on the ground */ 30 inline void collide(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall) 31 { this->collisionType = type; this->entityA = entity; this->entityB = groundEntity, this->groundNormal = normal; this->position = position; this->bInWall = bInWall; } 59 /** @return ground plane if collided with bsp model */ 60 inline const Vector& getGroundNormal() const { return this->groundNormal; } 61 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; } 64 65 /** @return the type of the collision */ 66 inline int getType() const { return this->collisionType; } 67 68 /** @return true if the entity is in the wall */ 69 inline bool isInWall() const { return this->bInWall; } 32 70 33 71 34 /** @return CollisionEvent WorldEntity A */ 35 inline WorldEntity* getEntityA() const { return this->entityA; } 36 /** @return CollisionEvent WorldEntity B */ 37 inline WorldEntity* getEntityB() const { return this->entityB; } 38 /** @return Bounding Volume from EntityA */ 39 inline BoundingVolume* getBVA() const { return this->bvA; } 40 /** @return Bounding Volume from EntityB */ 41 inline BoundingVolume* getBVB() const { return this->bvB; } 72 private: 73 WorldEntity* entityA; //!< the collision body A 74 WorldEntity* entityB; //!< the collision body B 42 75 43 /** @return ground plane if collided with bsp model */44 inline Vector getGroundNormal() { return this->groundNormal; }76 BoundingVolume* bvA; //!< reference to the bounding volume A 77 BoundingVolume* bvB; //!< reference to the bounding volume B 45 78 46 /** @return position of the position, only accurate if this is a collision with the ground!!! */47 inline Vector getCollisionPosition() { return this->position; }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 48 81 49 /** @return the type of the collision */ 50 inline int getType() { return this->collisionType; } 82 bool bInWall; //!< true if is in wall 83 int collisionType; //!< collision type 84 }; 51 85 52 /** @return true if the entity is in the wall */ 53 inline bool isInWall() { return this->bInWall; } 54 55 56 private: 57 WorldEntity* entityA; //!< the collision body A 58 WorldEntity* entityB; //!< the collision body B 59 60 BoundingVolume* bvA; //!< reference to the bounding volume A 61 BoundingVolume* bvB; //!< reference to the bounding volume B 62 63 Vector groundNormal; //!< the ground plane with which it collides (only for bsp-model collisions 64 Vector position; //!< position of the collision on the ground plane 65 66 bool bInWall; //!< true if is in wall 67 int collisionType; //!< collision type 68 }; 69 86 } 70 87 #endif /* _COLLISION_EVENT_H */
Note: See TracChangeset
for help on using the changeset viewer.