Changeset 8894 in orxonox.OLD for trunk/src/lib/collision_reaction
- Timestamp:
- Jun 29, 2006, 12:19:48 AM (18 years ago)
- Location:
- trunk/src/lib/collision_reaction
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/collision_reaction/collision_event.h
r8490 r8894 9 9 #include "vector.h" 10 10 11 #include "cr_defs.h" 12 13 11 14 class WorldEntity; 12 15 class BoundingVolume; 13 16 class Plane; 17 14 18 15 19 … … 22 26 23 27 /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */ 24 inline void collide( WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)25 { this-> entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; }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; } 26 30 /** collides two WorldEntities @param entity world entity , @param ground ground plane, @param position position on the ground */ 27 inline void collide( WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position)28 { this-> entityA = entity; this->entityB = groundEntity, this->groundNormal = normal; this->position = position; }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; } 29 33 30 34 … … 44 48 inline Vector getCollisionPosition() { return this->position; } 45 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 46 57 private: 47 58 WorldEntity* entityA; //!< the collision body A … … 53 64 Vector groundNormal; //!< the ground plane with which it collides (only for bsp-model collisions 54 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 55 69 }; 56 70 -
trunk/src/lib/collision_reaction/cr_defs.h
r8190 r8894 28 28 29 29 30 //!< the collision axis x collision event 31 #define COLLISION_TYPE_AXIS_X 1 32 //!< the collision axis y collision event 33 #define COLLISION_TYPE_AXIS_Y 2 34 //!< the collision axis z collision event 35 #define COLLISION_TYPE_AXIS_Z 4 36 //!< the collision is a obb collision 37 #define COLLISION_TYPE_OBB 8 38 30 39 31 40 #endif /* _NETWORK_MANAGER */ -
trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc
r8796 r8894 1 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 4 4 Copyright (C) 2004 orx 5 5 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by 8 8 the Free Software Foundation; either version 2, or (at your option) 9 9 any later version. 10 10 11 11 ### File Specific: 12 12 main-programmer: Patrick Boenzli … … 26 26 #include <vector> 27 27 28 #include "debug.h" 29 28 30 #include "aabb.h" 31 32 #include "cr_defs.h" 29 33 30 34 using namespace std; … … 64 68 // collision->getEntityB()->getAbsCoor().debug(); 65 69 66 Vectorheight;70 float height; 67 71 AABB* box = collision->getEntityB()->getModelAABB(); 68 69 70 71 if(box!=NULL) 72 WorldEntity* entity = collision->getEntityB(); 73 74 // collision position maths 75 Vector collPos = collision->getEntityB()->getAbsCoor() + box->center - ce->getCollisionPosition(); 76 77 float CR_MAX_WALK_HEIGHT = 2.0f; 78 float CR_THRESHOLD = 0.2f; 79 80 if( box == NULL) 81 { 82 PRINTF(2)("this model has no aabb box so there is no correct collision reaction implemented. skipping\n"); 83 return; 84 } 85 86 87 switch( ce->getType()) 88 { 89 case COLLISION_TYPE_AXIS_Y: 90 91 height = collPos.y - box->halfLength[1]; 92 // PRINTF(0)("height: %f , model height: %f\n", height, box->halfLength[1]); 93 // PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z); 94 95 // object is beneath the plane (ground) 96 if( height <= 0.0f ) 97 { 98 entity->shiftCoor(Vector(0, -height, 0)); 99 } 100 // object is already in the wall 101 else if( ce->isInWall()) 102 { 103 entity->setAbsCoor(entity->getLastAbsCoor()); 104 } 105 break; 106 107 108 case COLLISION_TYPE_AXIS_X: 109 case COLLISION_TYPE_AXIS_Z: 110 break; 111 112 } 113 114 115 116 117 118 119 120 121 #if 0 122 if( box != NULL) 72 123 height = ( ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() )*(-1.0f) ; 73 124 else 74 125 height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() ; 75 126 76 if(box!=NULL) { 127 128 if( box != NULL) { 77 129 78 130 … … 90 142 return; 91 143 } 92 93 144 145 94 146 if(ce->getGroundNormal().len() >= 1.4f) { 95 147 downspeed++; … … 101 153 if(height.y > box->halfLength[1] + 0.0f ) // Above ground 102 154 { 103 if(height.y < box->halfLength[1] + 1.3f) // Snap in155 if(height.y < box->halfLength[1] + 2.3f) // Snap in 104 156 { 105 157 downspeed = 0; … … 116 168 { 117 169 //if(downspeed <= 0) downspeed =1; 118 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, -height.y + box->halfLength[1] + 2.0f /* 0.00001 *//*height.y+3.500005 + 10.0*/,0.0));170 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, -height.y + box->halfLength[1] + 2.0f,0.0)); 119 171 //collision->getEntityB()->setVelocity(Vector(0.0,0.0,0.0)); 120 172 downspeed = 0; … … 124 176 125 177 }// if(box!= NULL) 178 #endif 126 179 /* 127 180 PRINTF(0)("Collision with Ground: \n"); … … 131 184 132 185 */ 186 133 187 } 134 188 … … 141 195 void CRPhysicsGroundWalk::update(WorldEntity* owner) 142 196 { 143 for( int i = 9; i > 0; i--) { 144 this->lastPositions[i] = this->lastPositions[i-1]; 145 // PRINTF(0)("lastPosition[%i]: %f, %f, %f\n", i, lastPositions[i].x, lastPositions[i].y, lastPositions[i].z); 146 } 147 this->lastPositions[0] = owner->getAbsCoor(); 197 148 198 } 149 199 -
trunk/src/lib/collision_reaction/cr_physics_ground_walk.h
r8724 r8894 23 23 virtual void update(WorldEntity* entity); 24 24 25 25 26 private: 26 Vector lastPosition; //!< vector with the last valid position27 Vector afterLastPosition; //!< vector for the after last28 Quaternion lastDirection; //!< quat with the last valid direction29 30 Vector lastPositions[10]; //!< last 10 positions31 27 float downspeed; 32 28 };
Note: See TracChangeset
for help on using the changeset viewer.