Changeset 8864 in orxonox.OLD
- Timestamp:
- Jun 28, 2006, 3:51:36 PM (18 years ago)
- Location:
- branches/single_player_map/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/single_player_map/src/lib/collision_reaction/collision_event.h
r8862 r8864 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, bool bInWall)28 { this-> entityA = entity; this->entityB = groundEntity, this->groundNormal = normal; this->position = position; this->bInWall = bInWall; }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 46 53 /** @return true if the entity is in the wall */ 47 54 inline bool isInWall() { return this->bInWall; } … … 59 66 60 67 bool bInWall; //!< true if is in wall 68 int collisionType; //!< collision type 61 69 }; 62 70 -
branches/single_player_map/src/lib/collision_reaction/cr_defs.h
r8190 r8864 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 */ -
branches/single_player_map/src/lib/collision_reaction/cr_physics_ground_walk.cc
r8863 r8864 66 66 // collision->getEntityB()->getAbsCoor().debug(); 67 67 68 Vectorheight;68 float height; 69 69 AABB* box = collision->getEntityB()->getModelAABB(); 70 70 WorldEntity* entity = collision->getEntityB(); … … 73 73 float CR_THRESHOLD = 0.2f; 74 74 75 //if( box != NULL)76 //{77 // 78 //Vector collPos = collision->getEntityB()->getAbsCoor() + box->center - ce->getCollisionPosition();79 //height = collPos.y - box->halfLength[1];80 // 81 //PRINTF(0)("height: %f , model height: %f\n", height, box->halfLength[1]);82 //PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);83 // 84 //// object is beneath the plane (ground)85 //if( height < 0.0f )86 //{87 //entity->shiftCoor(Vector(0, -height, 0));88 //}89 //// object is already in the wall90 //else if( ce->isInWall())91 //{92 // 93 //}94 // 95 // 96 // 97 //}75 if( box != NULL) 76 { 77 78 Vector collPos = collision->getEntityB()->getAbsCoor() + box->center - ce->getCollisionPosition(); 79 height = collPos.y - box->halfLength[1]; 80 81 PRINTF(0)("height: %f , model height: %f\n", height, box->halfLength[1]); 82 PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z); 83 84 // object is beneath the plane (ground) 85 if( height < 0.0f ) 86 { 87 entity->shiftCoor(Vector(0, -height, 0)); 88 } 89 // object is already in the wall 90 else if( ce->isInWall()) 91 { 92 entity->setAbsCoor(entity->getLastAbsCoor()); 93 } 94 95 96 97 } 98 98 99 99 … … 101 101 102 102 103 //#if 0103 #if 0 104 104 if( box != NULL) 105 105 height = ( ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() )*(-1.0f) ; … … 158 158 159 159 }// if(box!= NULL) 160 //#endif160 #endif 161 161 /* 162 162 PRINTF(0)("Collision with Ground: \n"); -
branches/single_player_map/src/lib/graphics/importer/bsp_manager.cc
r8796 r8864 1 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 4 4 Copyright (C) 2006 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: bottac@ee.ethz.ch 13 13 14 14 Inspired by: 15 15 Rendering Q3 Maps by Morgan McGuire http://graphics.cs.brown.edu/games/quake/quake3.html 16 16 Unofficial Quake 3 Map Specs by Kekoa Proudfoot http://graphics.stanford.edu/~kekoa/q3/ 17 17 18 18 Collision detection adapted from: 19 19 Quake 3 Collision Detection by Nathan Ostgard http://www.devmaster.net/articles/quake3collision/ … … 45 45 46 46 #include "aabb.h" 47 47 #include "cr_defs.h" 48 48 49 49 … … 69 69 BspManager::BspManager(const TiXmlElement* root) 70 70 { 71 72 71 72 73 73 if( root != NULL) 74 74 this->loadParams(root); 75 75 76 76 CDEngine::getInstance()->setBSPModel(this); 77 77 } */ … … 99 99 this->root = this->bspFile->get_root(); 100 100 this->alreadyVisible = new bool [this->bspFile->numFaces]; 101 101 102 102 CDEngine::getInstance()->setBSPModel(this); 103 103 } … … 962 962 upDir.z = 0.0; 963 963 Vector dest; 964 964 965 965 966 966 Vector position = worldEntity->getAbsCoor(); //+ upDir*10.0f ; … … 978 978 Vector out2; 979 979 980 980 981 981 982 982 float height = 40; 983 984 983 984 985 985 if( box != NULL) 986 986 { 987 987 position = worldEntity->getAbsCoor() + box->center; // + box->axis[1] * box->halfLength[1]; 988 988 dest = worldEntity->getAbsCoor() + box->center - box->axis[1] * box->halfLength[1] * 40.0; 989 989 990 990 position1 = worldEntity->getAbsCoor() + box->center + box->axis[0] * box->halfLength[0] * 2.0f; 991 991 dest1 = worldEntity->getAbsCoor() + box->center - box->axis[0] * box->halfLength[0] *2.0f; 992 993 992 993 994 994 position2 = worldEntity->getAbsCoor() + box->center + box->axis[2] * box->halfLength[2] * 2.0f; 995 995 dest2 = worldEntity->getAbsCoor() + box->center - box->axis[2] * box->halfLength[2] * 2.0f; 996 996 997 997 } 998 998 else 999 999 { 1000 1001 } 1002 1003 1004 1000 1001 } 1002 1003 1004 1005 1005 // 1006 1006 this->inputStart = position; … … 1025 1025 this->collPlane->z = 0.0f; 1026 1026 collision = true; 1027 } else 1027 } else 1028 1028 collision = false; 1029 1030 1029 1030 1031 1031 out = dest; 1032 1032 1033 1033 } else { 1034 1034 collision = true; … … 1046 1046 plane* testPlane = this->collPlane; 1047 1047 1048 1048 1049 1049 // 2nd Collision Detection 1050 1050 this->outputStartsOut = true; … … 1056 1056 out.x = this->outputFraction; 1057 1057 //out.z = this->outputFraction; 1058 1059 1058 1059 1060 1060 // 3rd Collision Detection 1061 1061 this->outputStartsOut = true; … … 1067 1067 //out.x = this->outputFraction; 1068 1068 out.z = this->outputFraction; 1069 1069 1070 1070 1071 1071 /* … … 1077 1077 1078 1078 // Return the normal here: Normal's stored in this->collPlane; 1079 if( collision) 1079 if( collision) 1080 1080 { 1081 1081 PRINTF(5)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction); 1082 worldEntity->registerCollision( this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out);1083 } 1084 else worldEntity->registerCollision( this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest);1082 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out); 1083 } 1084 else worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest); 1085 1085 1086 1086 } -
branches/single_player_map/src/world_entities/world_entity.cc
r8853 r8864 418 418 CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject(); 419 419 assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h 420 c->collide( entityA, entityB, bvA, bvB);420 c->collide(COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB); 421 421 422 422 for( int i = 0; i < CREngine::CR_NUMBER; ++i) … … 433 433 * @param position it collides on the plane 434 434 */ 435 bool WorldEntity::registerCollision( WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)435 bool WorldEntity::registerCollision(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall) 436 436 { 437 437 // is there any handler listening? … … 442 442 CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject(); 443 443 assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h 444 c->collide( entity, groundEntity, normal, position, bInWall);444 c->collide(type, entity, groundEntity, normal, position, bInWall); 445 445 446 446 for( int i = 0; i < CREngine::CR_NUMBER; ++i) -
branches/single_player_map/src/world_entities/world_entity.h
r8862 r8864 88 88 89 89 bool registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB); 90 bool registerCollision( WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall = false);90 bool registerCollision(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall = false); 91 91 /** @return true if there is at least on collision reaction subscribed */ 92 92 inline bool isReactive() const { return this->bReactive; }
Note: See TracChangeset
for help on using the changeset viewer.