Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

more design, thinner interface

File size: 3.8 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    Collision* collision = this->_collisionList.back();
98
99    // check if there is already a collision defined between these objects
100    if( !collision->match(*entity, *groundEntity))
101    {
102      collision = CREngine::getInstance()->popCollisionObject();
103      collision->collide( entity, groundEntity);
104    }
105
106    // now register the new collision event
107    CollisionEvent* collisionEvent = CREngine::getInstance()->popCollisionEventObject();
108    collisionEvent->collide( type, entity, groundEntity, normal, position, bInWall);
109    collision->registerCollisionEvent( collisionEvent);
110  }
111
112
113  /**
114   * checks if two objects are
115   */
116  bool CollisionTube::needCollisionChecking(const WorldEntity& entityA, const WorldEntity& entityB)
117  {
118    //if( !this->isReactive( entityA, entityB) )
119    //  return false;
120
121    //if( entityA->)
122
123  }
124
125
126  /**
127   * handles all collisions in registered in this tube
128   */
129  void CollisionTube::handleCollisions()
130  {
131    //
132  }
133
134
135}
136
Note: See TracBrowser for help on using the repository browser.