Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/coll_rect/src/lib/collision_reaction/collision_event.h @ 9889

Last change on this file since 9889 was 9889, checked in by patrick, 18 years ago

added namspacing to collision reaction. now comes the harder part :D

File size: 3.4 KB
Line 
1/*!
2 * @file collision_event.h
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.
10 */
11
12#ifndef _COLLISION_EVENT_H
13#define _COLLISION_EVENT_H
14
15#include "vector.h"
16
17#include "cr_defs.h"
18
19
20class WorldEntity;
21class BoundingVolume;
22class Plane;
23
24namespace CoRe
25{
26
27  //! A class representing a simple collision
28  class CollisionEvent
29  {
30  public:
31    CollisionEvent();
32    virtual ~CollisionEvent();
33
34    /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */
35    inline void collide(int type, WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
36    { this->collisionType = type; this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; }
37    /** collides two WorldEntities @param entity world entity , @param ground ground plane, @param position position on the ground */
38    inline void collide(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)
39    {
40      this->collisionType = type;
41      this->entityA = entity;
42      this->entityB = groundEntity;
43      this->groundNormal = normal;
44      this->position = position;
45      this->bInWall = bInWall;
46    }
47
48
49    /** @return CollisionEvent WorldEntity A */
50    inline WorldEntity* getEntityA() const
51    {
52      return this->entityA;
53    }
54    /** @return CollisionEvent WorldEntity B */
55    inline WorldEntity* getEntityB() const
56    {
57      return this->entityB;
58    }
59    /** @return Bounding Volume from EntityA */
60    inline BoundingVolume* getBVA() const
61    {
62      return this->bvA;
63    }
64    /** @return Bounding Volume from EntityB */
65    inline BoundingVolume* getBVB() const
66    {
67      return this->bvB;
68    }
69
70    /** @return ground plane if collided with bsp model */
71    inline Vector getGroundNormal()
72    {
73      return this->groundNormal;
74    }
75
76    /** @return position of the position, only accurate if this is a collision with the ground!!! */
77    inline Vector getCollisionPosition()
78    {
79      return this->position;
80    }
81
82    /** @return the type of the collision */
83    inline int getType()
84    {
85      return this->collisionType;
86    }
87
88    /** @return true if the entity is in the wall */
89    inline bool isInWall()
90    {
91      return this->bInWall;
92    }
93
94
95  private:
96    WorldEntity*      entityA;                       //!< the collision body A
97    WorldEntity*      entityB;                       //!< the collision body B
98
99    BoundingVolume*   bvA;                           //!< reference to the bounding volume A
100    BoundingVolume*   bvB;                           //!< reference to the bounding volume B
101
102    Vector            groundNormal;                  //!< the ground plane with which it collides (only for bsp-model collisions
103    Vector            position;                      //!< position of the collision on the ground plane
104
105    bool              bInWall;                       //!< true if is in wall
106    int               collisionType;                 //!< collision type
107  };
108
109}
110#endif /* _COLLISION_EVENT_H */
Note: See TracBrowser for help on using the repository browser.