Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

new structure in docs

File size: 3.2 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
24
25
26//! A class representing a simple collision
27class CollisionEvent {
28 public:
29   CollisionEvent();
30  virtual ~CollisionEvent();
31
32  /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */
33  inline void collide(int type, WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
34  { this->collisionType = type; this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; }
35  /** collides two WorldEntities @param entity world entity , @param ground ground plane, @param position position on the ground */
36  inline void collide(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)
37  { this->collisionType = type; this->entityA = entity; this->entityB = groundEntity, this->groundNormal = normal; this->position = position; this->bInWall = bInWall; }
38
39
40  /** @return CollisionEvent WorldEntity A */
41  inline WorldEntity* getEntityA() const { return this->entityA; }
42  /** @return CollisionEvent WorldEntity B */
43  inline WorldEntity* getEntityB() const { return this->entityB; }
44  /** @return Bounding Volume from EntityA */
45  inline BoundingVolume* getBVA() const { return this->bvA; }
46  /** @return Bounding Volume from EntityB */
47  inline BoundingVolume* getBVB() const { return this->bvB; }
48
49  /** @return ground plane if collided with bsp model */
50  inline Vector getGroundNormal() { return this->groundNormal; }
51
52  /** @return position of the position, only accurate if this is a collision with the ground!!! */
53  inline Vector getCollisionPosition() { return this->position; }
54
55  /** @return the type of the collision */
56  inline int getType() { return this->collisionType; }
57
58  /** @return true if the entity is in the wall */
59  inline bool isInWall() { return this->bInWall; }
60
61
62 private:
63  WorldEntity*      entityA;                       //!< the collision body A
64  WorldEntity*      entityB;                       //!< the collision body B
65
66  BoundingVolume*   bvA;                           //!< reference to the bounding volume A
67  BoundingVolume*   bvB;                           //!< reference to the bounding volume B
68
69  Vector            groundNormal;                  //!< the ground plane with which it collides (only for bsp-model collisions
70  Vector            position;                      //!< position of the collision on the ground plane
71
72  bool              bInWall;                       //!< true if is in wall
73  int               collisionType;                 //!< collision type
74};
75
76#endif /* _COLLISION_EVENT_H */
Note: See TracBrowser for help on using the repository browser.