Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/coll_rect/src/lib/collision_reaction/collision_tube.cc @ 9939

Last change on this file since 9939 was 9939, checked in by patrick, 17 years ago

removed some comilation problems.

File size: 4.0 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Patrick Boenzli
13*/
14
15#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION_REACTION
16
17#include "collision_tube.h"
18
19#include "world_entity.h"
20
21#include "collision.h"
22#include "collision_event.h"
23#include "collision_reaction.h"
24
25#include "cr_object_damage.h"
26#include "cr_physics_ground_walk.h"
27#include "cr_physics_full_walk.h"
28
29
30
31namespace CoRe
32{
33
34  ObjectListDefinition(CollisionTube);
35
36  CollisionTube* CollisionTube::instance = NULL;
37
38
39  /**
40   * standard constructor
41   * @todo this constructor is not jet implemented - do it
42   */
43  CollisionTube::CollisionTube ()
44  {
45    this->registerObject(this, CollisionTube::_objectList);
46  }
47
48
49  /**
50   * standard deconstructor
51   */
52  CollisionTube::~CollisionTube ()
53  {
54    this->_collisionList.clear();
55  }
56
57
58  /**
59   * registers a new CollisionEvent
60   * @param entityA one collision object
61   * @param entityB the other collision objectName
62   * @param bvA bounding volume of object A
63   * @param bvB bounding volume of object B
64   *
65   * this function doesn't check if the entities in question actualy are registered for any collisions
66   */
67  void CollisionTube::registerCollisionEvent(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
68  {
69    Collision* collision = this->_collisionList.back();
70
71    // check if there is already a collision defined between these objects
72    if( !collision->match(*entityA, *entityB))
73    {
74      collision = CREngine::getInstance()->popCollisionObject();
75      collision->collide( entityA, entityB);
76    }
77
78    // now register the new collision event
79    CollisionEvent* collisionEvent = CREngine::getInstance()->popCollisionEventObject();
80    collisionEvent->collide( CREngine::CR_COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB);
81    collision->registerCollisionEvent( collisionEvent);
82  }
83
84
85  /**
86   * registers a new CollisionEvent, only used by ground to object collision (eg. bsp model)
87   * @param type type of collision as stated in cr_def.h
88   * @param entity the WorldEntity colliding with the ground
89   * @param groundEntity the WorldEntity representing the ground
90   * @param normal the normal vector for the ground (up) - not always specified
91   * @param position the position of the collision relative to the object center
92   * @param bInWall true if the entity is in the ground material
93   */
94  void CollisionTube::registerCollisionEvent(CREngine::CollisionType type, WorldEntity* entity, WorldEntity* groundEntity,
95                              const Vector& normal, const Vector& position, bool bInWall)
96  {
97    // get last collision
98    Collision* collision = this->_collisionList.back();
99
100    // check if there is already a collision defined between these objects
101    if( collision != NULL && !collision->match(*entity, *groundEntity))
102    {
103      // get a new collision object
104      collision = CREngine::getInstance()->popCollisionObject();
105      collision->collide( entity, groundEntity);
106    }
107
108    // now register the new collision event
109    CollisionEvent* collisionEvent = CREngine::getInstance()->popCollisionEventObject();
110    collisionEvent->collide( type, entity, groundEntity, normal, position, bInWall);
111    collision->registerCollisionEvent( collisionEvent);
112  }
113
114
115
116  /**
117   * handles all collisions in registered in this tube
118   */
119  void CollisionTube::handleCollisions()
120  {
121    // for all collisions:
122    std::vector<Collision*>::iterator collisions = this->_collisionList.begin();
123    for(; collisions < this->_collisionList.end(); collisions++)
124    {
125
126
127      // for all collision events of each collision:
128      Collision::iterator events = (*collisions)->begin();
129      for(; events < (*collisions)->end(); events++)
130      {
131
132      }
133    }
134  }
135
136
137
138
139
140
141
142}// namespace end
143
Note: See TracBrowser for help on using the repository browser.