Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

collision reactions now only registered with collision tube. no compile

File size: 3.7 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  /**
37   * standard constructor
38   * @todo this constructor is not jet implemented - do it
39   */
40  CollisionTube::CollisionTube ()
41  {
42    this->registerObject(this, CollisionTube::_objectList);
43  }
44
45
46  /**
47   * standard deconstructor
48   */
49  CollisionTube::~CollisionTube ()
50  {
51    this->_collisionList.clear();
52  }
53
54
55  /**
56   * registers a new CollisionEvent
57   * @param entityA one collision object
58   * @param entityB the other collision objectName
59   * @param bvA bounding volume of object A
60   * @param bvB bounding volume of object B
61   *
62   * this function doesn't check if the entities in question actualy are registered for any collisions
63   */
64  void CollisionTube::registerCollisionEvent(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
65  {
66    Collision* collision = this->_collisionList.back();
67
68    // check if there is already a collision defined between these objects
69    if( !collision->match(*entityA, *entityB))
70    {
71      collision = CREngine::getInstance()->popCollisionObject();
72      collision->collide( entityA, entityB);
73    }
74
75    // now register the new collision event
76    CollisionEvent* collisionEvent = CREngine::getInstance()->popCollisionEventObject();
77    collisionEvent->collide( CREngine::CR_COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB);
78    collision->registerCollisionEvent( collisionEvent);
79  }
80
81
82  /**
83   * registers a new CollisionEvent, only used by ground to object collision (eg. bsp model)
84   * @param type type of collision as stated in cr_def.h
85   * @param entity the WorldEntity colliding with the ground
86   * @param groundEntity the WorldEntity representing the ground
87   * @param normal the normal vector for the ground (up) - not always specified
88   * @param position the position of the collision relative to the object center
89   * @param bInWall true if the entity is in the ground material
90   */
91  void CollisionTube::registerCollisionEvent(CREngine::CollisionType type, WorldEntity* entity, WorldEntity* groundEntity,
92                              const Vector& normal, const Vector& position, bool bInWall)
93  {
94    Collision* collision = this->_collisionList.back();
95
96    // check if there is already a collision defined between these objects
97    if( !collision->match(*entity, *groundEntity))
98    {
99      collision = CREngine::getInstance()->popCollisionObject();
100      collision->collide( entity, groundEntity);
101    }
102
103    // now register the new collision event
104    CollisionEvent* collisionEvent = CREngine::getInstance()->popCollisionEventObject();
105    collisionEvent->collide( type, entity, groundEntity, normal, position, bInWall);
106    collision->registerCollisionEvent( collisionEvent);
107  }
108
109
110  /**
111   * checks if two objects are
112   */
113  bool CollisionTube::needCollisionChecking(const WorldEntity& entityA, const WorldEntity& entityB)
114  {
115    //if( !this->isReactive( entityA, entityB) )
116    //  return false;
117
118    //if( entityA->)
119
120  }
121
122
123  /**
124   * handles all collisions in registered in this tube
125   */
126  void CollisionTube::handleCollisions()
127  {
128    //
129  }
130
131
132}
133
Note: See TracBrowser for help on using the repository browser.