Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/collision_reaction/collision_event.h @ 9350

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

merged the branche single_player_map with the trunk

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