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
RevLine 
[7959]1/*!
2 * @file collision_event.h
3 *  Definition of a collision event
[9888]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"
16
[8894]17#include "cr_defs.h"
18
19
[7959]20class WorldEntity;
21class BoundingVolume;
[8182]22class Plane;
[7959]23
[9889]24namespace CoRe
25{
[7959]26
[9889]27  //! A class representing a simple collision
28  class CollisionEvent
29  {
30  public:
31    CollisionEvent();
32    virtual ~CollisionEvent();
[8894]33
[9889]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    }
[7959]47
48
[9889]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    }
[7959]69
[9889]70    /** @return ground plane if collided with bsp model */
71    inline Vector getGroundNormal()
72    {
73      return this->groundNormal;
74    }
[7959]75
[9889]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    }
[7959]81
[9889]82    /** @return the type of the collision */
83    inline int getType()
84    {
85      return this->collisionType;
86    }
[8182]87
[9889]88    /** @return true if the entity is in the wall */
89    inline bool isInWall()
90    {
91      return this->bInWall;
92    }
[8894]93
94
[9889]95  private:
96    WorldEntity*      entityA;                       //!< the collision body A
97    WorldEntity*      entityB;                       //!< the collision body B
[8894]98
[9889]99    BoundingVolume*   bvA;                           //!< reference to the bounding volume A
100    BoundingVolume*   bvB;                           //!< reference to the bounding volume B
[7959]101
[9889]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
[8182]104
[9889]105    bool              bInWall;                       //!< true if is in wall
106    int               collisionType;                 //!< collision type
107  };
[8894]108
[9889]109}
[7959]110#endif /* _COLLISION_EVENT_H */
Note: See TracBrowser for help on using the repository browser.