Changeset 8217 in orxonox.OLD for branches/bsp_model
- Timestamp:
- Jun 7, 2006, 9:57:13 PM (18 years ago)
- Location:
- branches/bsp_model/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bsp_model/src/lib/collision_detection/cd_engine.cc
r8215 r8217 32 32 33 33 #include "bsp_manager.h" 34 #include "bsp_entity.h" 34 35 35 36 using namespace std; … … 101 102 std::list<BaseObject*>::const_iterator bspIterator; 102 103 std::list<WorldEntity*>::iterator entityIterator; 103 const std::list<BaseObject*>* bspList = ClassList::getList(CL_BSP_ MODEL);104 const std::list<BaseObject*>* bspList = ClassList::getList(CL_BSP_ENTITY); 104 105 if( bspList == NULL) 105 106 return; … … 108 109 for( bspIterator = bspList->begin(); bspIterator != bspList->end(); bspIterator++) { 109 110 for(entityIterator = list1.begin(); entityIterator != list1.end(); entityIterator++) 110 static_cast<BspManager*>(*bspIterator)->checkCollision(*entityIterator);111 (static_cast<BspEntity*>(*bspIterator)->getBspManager())->checkCollision(*entityIterator); 111 112 } 112 113 } -
branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc
r8216 r8217 39 39 #include "movie_player.h" 40 40 41 #include "cd_engine.h"42 43 41 #include "world_entity.h" 44 42 … … 77 75 void BspManager::load(const char* fileName, float scale) 78 76 { 79 this->setClassID(CL_BSP_MODEL, "BspManager");80 77 // open a BSP file 81 78 this->bspFile = new BspFile(); … … 85 82 this->root = this->bspFile->get_root(); 86 83 this->alreadyVisible = new bool [this->bspFile->numFaces]; 87 88 CDEngine::getInstance()->setBSPModel(this);89 90 84 } 91 85 /* … … 872 866 Vector out = dest; 873 867 874 875 876 if(!worldEntity->isA(CL_PLAYABLE)) { 877 878 879 880 } 881 else { 882 883 bool collision = false; 884 Vector position1 = position + Vector(0.0,0.1,0.0); 885 Vector position2 = position + Vector(0.0,0.2,0.0); 886 Vector dest1 = position1 + forwardDir; 887 Vector dest2 = position2 + forwardDir; 888 dest = position - Vector(0.0, 20.0,0.0); 889 Vector out1; 890 Vector out2; 891 892 this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 ); 893 if(this->outputFraction == 1.0f) out1 = dest; 894 else { 895 collision = true; 896 out1.x = position1.x + (dest1.x -position1.x) * this->outputFraction; 897 out1.y = position1.y + (dest1.y -position1.y) * this->outputFraction; 898 out1.z = position1.z + (dest1.z - position1.z) * this->outputFraction; 899 900 } 901 902 this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 ); 903 if(this->outputFraction == 1.0f) out2= dest; 904 else { 905 collision = true; 906 out2.x = position2.x + (dest2.x -position2.x) * this->outputFraction; 907 out2.y = position2.y + (dest2.y -position2.y) * this->outputFraction; 908 out2.z = position2.z + (dest2.z - position2.z) * this->outputFraction; 909 910 } 911 912 this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &dest ); 913 if(this->outputFraction == 1.0f) out = dest; 914 else { 915 collision = true; 916 out.x = position.x + (dest.x -position.x) * this->outputFraction; 917 out.y = position.y + (dest.y -position.y) * this->outputFraction; 918 out.z = position.z + (dest.z -position.z) * this->outputFraction; 919 920 Vector out3 = out + Vector(3*this->collPlane->x,3*this->collPlane->y,3*this->collPlane->z); 921 this->out = out; 922 this->out1 = out1; 923 this->out2 = out2; 868 bool collision = false; 869 870 Vector position1 = position + Vector(0.0,0.1,0.0); 871 Vector position2 = position + Vector(0.0,0.2,0.0); 872 Vector dest1 = position1 + forwardDir; 873 Vector dest2 = position2 + forwardDir; 874 dest = position - Vector(0.0, 20.0,0.0); 875 Vector out1; 876 Vector out2; 877 878 this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 ); 879 if(this->outputFraction == 1.0f) out1 = dest; 880 else { 881 collision = true; 882 out1.x = position1.x + (dest1.x -position1.x) * this->outputFraction; 883 out1.y = position1.y + (dest1.y -position1.y) * this->outputFraction; 884 out1.z = position1.z + (dest1.z - position1.z) * this->outputFraction; 885 886 } 887 888 this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 ); 889 if(this->outputFraction == 1.0f) out2= dest; 890 else { 891 collision = true; 892 out2.x = position2.x + (dest2.x -position2.x) * this->outputFraction; 893 out2.y = position2.y + (dest2.y -position2.y) * this->outputFraction; 894 out2.z = position2.z + (dest2.z - position2.z) * this->outputFraction; 895 896 } 897 898 this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &dest ); 899 if(this->outputFraction == 1.0f) out = dest; 900 else { 901 collision = true; 902 out.x = position.x + (dest.x -position.x) * this->outputFraction; 903 out.y = position.y + (dest.y -position.y) * this->outputFraction; 904 out.z = position.z + (dest.z -position.z) * this->outputFraction; 905 906 Vector out3 = out + Vector(3*this->collPlane->x,3*this->collPlane->y,3*this->collPlane->z); 907 this->out = out; 908 this->out1 = out1; 909 this->out2 = out2; 924 910 //this->drawDebugCube(&out1); 925 911 //this->drawDebugCube(&out2); … … 927 913 //this->drawDebugCube(&out3); 928 914 929 915 } 930 916 931 917 // Return the normal here: Normal's stored in this->collPlane; 932 933 if(collision) 934 worldEntity->registerCollision(worldEntity, Vector(this->collPlane->x, this->collPlane->y, this->collPlane->z), out); 935 // worldEntity->collidesWithGround(out,out1,out2); 936 } 918 if(collision) 919 worldEntity->registerCollision(worldEntity, Vector(this->collPlane->x, this->collPlane->y, this->collPlane->z), out); 920 937 921 } 938 922 -
branches/bsp_model/src/lib/graphics/importer/bsp_manager.h
r8213 r8217 20 20 */ 21 21 22 #ifndef _BSP_MANAGER_H 23 #define _BSP_MANAGER_H 24 25 22 26 #include <vector> 23 27 #include <deque> 24 28 25 #include "base_object.h" 29 26 30 27 31 // FORWARD DECLARATIONS … … 43 47 }; 44 48 45 class BspManager : public BaseObject49 class BspManager 46 50 { 47 51 public: … … 106 110 }; 107 111 112 #endif /* _BSP_MANAGER_H */ -
branches/bsp_model/src/world_entities/bsp_entity.h
r8186 r8217 18 18 class BSPEntity : public WorldEntity 19 19 { 20 20 21 21 public: 22 22 BSPEntity(const TiXmlElement* root = NULL); … … 24 24 25 25 virtual void loadParams(const TiXmlElement* root); 26 26 27 27 void setName(const std::string& name); 28 28 … … 33 33 virtual void collidesWith (WorldEntity* entity, const Vector& location); 34 34 35 /** @returns the BspManager of this entity */ 36 inline BspManager* getBspManager() { return this->bspManager; } 37 35 38 private: 36 39 BspManager* bspManager; -
branches/bsp_model/src/world_entities/playable.cc
r8147 r8217 66 66 this->bDead = false; 67 67 68 this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_MODEL); 69 68 70 registerVar( new SynchronizeableInt( &score, &score, "score" ) ); 69 71 registerVar( new SynchronizeableBool( &bFire, &bFire, "bFire", PERMISSION_OWNER)); … … 79 81 // this->setPlayer(NULL); 80 82 // IN ITS DESTRUCTOR. 81 83 82 84 assert(this->currentPlayer == NULL); 83 85 }
Note: See TracChangeset
for help on using the changeset viewer.