[7959] | 1 | /*! |
---|
| 2 | * @file collision_event.h |
---|
| 3 | * Definition of a collision event |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _COLLISION_EVENT_H |
---|
| 7 | #define _COLLISION_EVENT_H |
---|
| 8 | |
---|
| 9 | #include "vector.h" |
---|
| 10 | |
---|
| 11 | class WorldEntity; |
---|
| 12 | class BoundingVolume; |
---|
[8182] | 13 | class Plane; |
---|
[7959] | 14 | |
---|
| 15 | |
---|
| 16 | //! A class representing a simple collision |
---|
| 17 | class CollisionEvent { |
---|
| 18 | |
---|
| 19 | public: |
---|
| 20 | CollisionEvent(); |
---|
| 21 | virtual ~CollisionEvent(); |
---|
| 22 | |
---|
| 23 | /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */ |
---|
| 24 | inline void collide(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB) |
---|
| 25 | { this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; } |
---|
[8182] | 26 | /** collides two WorldEntities @param entity world entity , @param ground ground plane, @param position position on the ground */ |
---|
[8490] | 27 | inline void collide(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position) |
---|
| 28 | { this->entityA = entity; this->entityB = groundEntity, this->groundNormal = normal; this->position = position; } |
---|
[7959] | 29 | |
---|
| 30 | |
---|
| 31 | /** @return CollisionEvent WorldEntity A */ |
---|
[7964] | 32 | inline WorldEntity* getEntityA() const { return this->entityA; } |
---|
[7959] | 33 | /** @return CollisionEvent WorldEntity B */ |
---|
[7964] | 34 | inline WorldEntity* getEntityB() const { return this->entityB; } |
---|
[7959] | 35 | /** @return Bounding Volume from EntityA */ |
---|
[7964] | 36 | inline BoundingVolume* getBVA() const { return this->bvA; } |
---|
[7959] | 37 | /** @return Bounding Volume from EntityB */ |
---|
[7964] | 38 | inline BoundingVolume* getBVB() const { return this->bvB; } |
---|
[7959] | 39 | |
---|
[8490] | 40 | /** @return ground plane if collided with bsp model */ |
---|
| 41 | inline Vector getGroundNormal() { return this->groundNormal; } |
---|
[7959] | 42 | |
---|
[8490] | 43 | /** @return position of the position, only accurate if this is a collision with the ground!!! */ |
---|
| 44 | inline Vector getCollisionPosition() { return this->position; } |
---|
[8182] | 45 | |
---|
[7959] | 46 | private: |
---|
| 47 | WorldEntity* entityA; //!< the collision body A |
---|
| 48 | WorldEntity* entityB; //!< the collision body B |
---|
| 49 | |
---|
[8028] | 50 | BoundingVolume* bvA; //!< reference to the bounding volume A |
---|
| 51 | BoundingVolume* bvB; //!< reference to the bounding volume B |
---|
[8182] | 52 | |
---|
[8490] | 53 | Vector groundNormal; //!< the ground plane with which it collides (only for bsp-model collisions |
---|
[8182] | 54 | Vector position; //!< position of the collision on the ground plane |
---|
[7959] | 55 | }; |
---|
| 56 | |
---|
| 57 | #endif /* _COLLISION_EVENT_H */ |
---|