Changeset 9003 in orxonox.OLD for trunk/src/lib/graphics
- Timestamp:
- Jul 2, 2006, 1:36:13 PM (18 years ago)
- Location:
- trunk/src/lib/graphics/importer
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/bsp_file.cc
r8894 r9003 46 46 BspFile::BspFile() 47 47 {} 48 49 BspFile::~ BspFile() 50 { 51 delete [] nodes; 52 delete [] leaves; 53 delete [] planes; 54 delete [] bspModels; 55 delete [] leafFaces; 56 delete [] faces; 57 delete [] leafBrushes; 58 delete [] brushes; 59 delete [] brushSides; 60 delete [] vertice; 61 delete [] meshverts; 62 delete [] visData; 63 delete [] textures; 64 delete [] patchVertice; 65 delete [] patchIndexes; 66 // delete [] patchTrianglesPerRow; 67 delete [] lightMaps; 68 69 for(int i = 0; i < this->numPatches; ++i) delete this->VertexArrayModels[i]; 70 // delete [] VertexArrayModels; 71 72 for(int i = 0; i < this->numTextures; ++i) 73 { 74 delete this->Materials[i].mat; 75 //delete this->Materials[i].aviMat; 76 } 77 delete [] this->Materials; 78 //delete [] testSurf; 79 80 81 82 } 48 83 49 84 /** … … 294 329 this->patchVertice = new char[8*8*44*(this->numPatches+10)]; 295 330 this->patchIndexes = new char[7*8*2*4*(this->numPatches+10)]; 296 this->patchRowIndexes = new int*[7*4*this->numPatches];331 // this->patchRowIndexes = new int*[7*4*this->numPatches]; Not needed? 297 332 this->patchTrianglesPerRow = new char[7*4*this->numPatches]; 298 333 this->VertexArrayModels = new VertexArrayModel*[this->numPatches]; … … 464 499 465 500 if(File(absFileName).exists()) { 466 PRINTF( 0)("BSP FILE: gefunden . \n");501 PRINTF(4)("BSP FILE: gefunden . \n"); 467 502 this->Materials[i] = this->loadAVI(fileName); 468 503 continue; … … 553 588 } 554 589 555 PRINTF(0)("BSP FILE: Textur %s nicht gefunden . \n", &this->textures[8+72*i]);590 PRINTF(0)("BSP FILE: Texture %s not found.",&this->textures[8+ 72*i] ); 556 591 // Default Material 557 592 this->Materials[i].mat = new Material(); … … 1012 1047 Face->meshvert = patchOffset -sz; //3*(patchOffset-sz)*level1*level1; 1013 1048 Face->n_meshverts = sz; 1014 PRINTF( 4)("BSP FILE: sz: %i. \n", sz);1015 PRINTF( 4)("BSP FILE: Face->meshvert %i . \n", Face->meshvert);1049 PRINTF(0)("BSP FILE: sz: %i. \n", sz); 1050 PRINTF(0)("BSP FILE: Face->meshvert %i . \n", Face->meshvert); 1016 1051 1017 1052 //Face->n_meshverts = sz; -
trunk/src/lib/graphics/importer/bsp_file.h
r8490 r9003 151 151 public: 152 152 BspFile(); 153 ~BspFile(); 153 154 int read(const char* name ); 154 155 void build_tree(); … … 183 184 184 185 int** patchRowIndexes; 185 VertexArrayModel** VertexArrayModels; 186 VertexArrayModel** VertexArrayModels; 186 187 int patchOffset; 187 188 -
trunk/src/lib/graphics/importer/bsp_manager.cc
r8894 r9003 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/ … … 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 } */ 78 78 79 void BspManager::load(const char* fileName, float scale) 79 BspManager::~BspManager() 80 { 81 if(this->bspFile) 82 delete this->bspFile; 83 } 84 85 int BspManager::load(const char* fileName, float scale) 80 86 { 81 87 // open a BSP file 88 89 82 90 this->bspFile = new BspFile(); 83 91 this->bspFile->scale = scale; 84 this->bspFile->read(ResourceManager::getFullName(fileName).c_str()); 92 if(this->bspFile->read(ResourceManager::getFullName(fileName).c_str()) == -1) 93 return -1; 94 85 95 this->bspFile->build_tree(); 86 96 this->root = this->bspFile->get_root(); … … 88 98 89 99 this->outputFraction = 1.0f; 100 101 return 0; 90 102 } 91 103 /* … … 99 111 this->root = this->bspFile->get_root(); 100 112 this->alreadyVisible = new bool [this->bspFile->numFaces]; 101 113 102 114 CDEngine::getInstance()->setBSPModel(this); 103 115 } … … 962 974 Vector dest = worldEntity->getAbsCoor() - upDir*40.0f; // 963 975 Vector dest1 = position + forwardDir*4.0f; 964 Vector dest2 = position2 + forwardDir ;976 Vector dest2 = position2 + forwardDir*4.0; 965 977 dest = position - Vector(0.0, 40.0,0.0); 966 978 Vector out = dest; … … 974 986 975 987 if( box != NULL) { 976 position = worldEntity->getAbsCoor() + box->center; // + box->axis[1] * box->halfLength[1]; 977 dest = worldEntity->getAbsCoor() + box->center - box->axis[1] * box->halfLength[1] * 40.0; 978 979 position1 = worldEntity->getAbsCoor() + box->center + box->axis[0] * box->halfLength[0] * 2.0f; 980 dest1 = worldEntity->getAbsCoor() + box->center - box->axis[0] * box->halfLength[0] *2.0f; 981 982 983 position2 = worldEntity->getAbsCoor() + box->center + box->axis[2] * box->halfLength[2] * 2.0f; 984 dest2 = worldEntity->getAbsCoor() + box->center - box->axis[2] * box->halfLength[2] * 2.0f; 988 position = worldEntity->getAbsCoor() + box->center + Vector(0.0, 1.0, 0.0) * box->halfLength[1]; 989 dest = worldEntity->getAbsCoor() + box->center - Vector(0.0, 1.0, 0.0) * (box->halfLength[1] + BSP_Y_OFFSET); 990 991 position1 = worldEntity->getAbsCoor() + box->center - worldEntity->getAbsDirX() * (box->halfLength[0] + BSP_X_OFFSET); 992 dest1 = worldEntity->getAbsCoor() + box->center + worldEntity->getAbsDirX() * (box->halfLength[0] + BSP_X_OFFSET); 993 994 position2 = worldEntity->getAbsCoor() + box->center - worldEntity->getAbsDirZ() * (box->halfLength[2] + BSP_Z_OFFSET); 995 dest2 = worldEntity->getAbsCoor() + box->center + worldEntity->getAbsDirZ() * (box->halfLength[2] + BSP_Z_OFFSET); 985 996 986 997 } else { … … 989 1000 } 990 1001 1002 1003 // PRINTF(0)("x and v\n"); 1004 // worldEntity->getAbsDirX().debug(); 1005 // worldEntity->getAbsDirV().debug(); 991 1006 992 1007 … … 1035 1050 plane* testPlane = this->collPlane; 1036 1051 1037 1038 1052 bool xCollision = false; 1039 1053 bool zCollision = false; 1040 if(!SolidFlag) { 1054 1041 1055 1042 1056 // 2nd Collision Detection … … 1048 1062 this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 ); 1049 1063 1050 if( !this->outputAllSolid !=1.0f) {1064 if(this->outputFraction < 1.0f) { 1051 1065 out.x = dest1.x + (dest1.x -position1.x) * this->outputFraction; 1066 dest1 = position1 + (dest1 -position1) * this->outputFraction; 1052 1067 xCollision = true; 1053 1068 testPlane = this->collPlane; 1054 1069 } 1055 if(this->outputAllSolid) { 1070 if(this->outputAllSolid ) { 1071 1072 this->collPlane = new plane; 1073 this->collPlane->x = 0.0f; 1074 this->collPlane->y = 0.0f; 1075 this->collPlane->z = 0.0f; 1076 testPlane = this->collPlane; 1056 1077 SolidFlag = true; 1057 xCollision = true; 1078 xCollision = true; 1058 1079 } 1059 1080 //out.z = this->outputFraction; 1060 1081 1061 if(!SolidFlag) { 1082 1062 1083 1063 1084 // 3rd Collision Detection … … 1067 1088 this->inputStart = position2; 1068 1089 this->inputEnd = dest2; 1090 1069 1091 this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 ); 1070 1092 //out.x = this->outputFraction; 1071 1093 1072 if(this->outputFraction !=1.0f ) {1094 if(this->outputFraction < 1.0f ) { 1073 1095 out.z = out.z = dest2.z + (dest2.z -position2.z) * this->outputFraction; 1096 dest2 = position2 + (dest2 -position2) * this->outputFraction; 1074 1097 zCollision = true; 1075 1098 testPlane = this->collPlane; 1076 1099 1077 1100 } 1078 if(this->outputAllSolid) { 1079 SolidFlag = true; 1080 zCollision = true; 1101 if(this->outputAllSolid ) { 1102 this->collPlane = new plane; 1103 this->collPlane->x = 0.0f; 1104 this->collPlane->y = 0.0f; 1105 this->collPlane->z = 0.0f; 1106 testPlane = this->collPlane; 1107 1108 SolidFlag = true; 1109 zCollision = true; 1081 1110 } 1082 } 1083 }//end if1111 1112 //end if 1084 1113 /* 1085 1114 This is how you would calculate the Coordinates where worldEntity Collided with the BSP world. … … 1091 1120 // Return the normal here: Normal's stored in this->collPlane; 1092 1121 if( collision) { 1093 PRINTF(5)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction); 1094 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y || (xCollision ? COLLISION_TYPE_AXIS_X :0) | (zCollision ? COLLISION_TYPE_AXIS_Z :0), this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag); 1095 } else { 1096 if(xCollision || zCollision) { 1097 1098 worldEntity->registerCollision((xCollision ? COLLISION_TYPE_AXIS_X :0) | (zCollision ? COLLISION_TYPE_AXIS_Z :0) , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag); 1099 } 1100 1101 } 1122 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag); 1123 } 1124 if(xCollision) { 1125 worldEntity->registerCollision(COLLISION_TYPE_AXIS_X , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z),dest1 , SolidFlag); 1126 } 1127 if(zCollision) { 1128 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), dest2 , SolidFlag); 1129 } 1130 1131 1102 1132 //else worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest, false); 1103 1133 -
trunk/src/lib/graphics/importer/bsp_manager.h
r8724 r9003 28 28 29 29 30 #define BSP_X_OFFSET 20.0f 31 #define BSP_Y_OFFSET 40.0f 32 #define BSP_Z_OFFSET 20.0f 33 30 34 31 35 // FORWARD DECLARATIONS … … 41 45 class WorldEntity; 42 46 47 48 // Obsolete 43 49 struct BspCollisionEvent 44 50 { … … 54 60 55 61 BspManager(const char* fileName, float scale = 0.4f); 56 void load(const char* fileName, float scale); 62 63 // Deconstructor 64 ~BspManager(); 65 66 57 67 58 68 // Functions 69 int load(const char* fileName, float scale); 59 70 const void draw(); 60 71 const void tick(float time); … … 99 110 Vector inputStart; 100 111 Vector inputEnd; 101 112 102 113 Vector traceMins; //!< Mins of current bbox 103 114 Vector traceMaxs; //!< Maxs of current bbox … … 112 123 ::std::deque<int> opal; //!< the others here. 113 124 114 Vector out; //!< For debugging only125 Vector out; //!< Stores collision coordinates 115 126 Vector out1; //!< For debugging only 116 127 Vector out2; //!< For debugging only 117 128 118 129 int tgl; 119 130 }; -
trunk/src/lib/graphics/importer/interactive_model.h
r8894 r9003 40 40 virtual int getAnimation() = 0; 41 41 42 virtual bool isAnimationFinished() { return false; } 43 42 44 virtual void setAnimationSpeed(float speed) {} 43 45 }; -
trunk/src/lib/graphics/importer/md2/md2Model.cc
r8894 r9003 85 85 86 86 this->scaleFactor = scale; 87 this->animationSpeed = 1.0f; 87 88 88 89 shadeDots = MD2Model::anormsDots[0]; … … 103 104 this->pModelInfo.pTexCoor = (float*)this->data->pTexCoor; 104 105 105 this->animationSpeed = 1.0f;106 106 107 107 // triangle conversion -
trunk/src/lib/graphics/importer/md2/md2Model.h
r8894 r9003 161 161 inline int MD2Model::getAnimation() { return this->animationState.type; } 162 162 virtual void setAnimationSpeed(float speed) { this->animationSpeed = speed; } 163 virtual bool isAnimationFinished() { return (this->animationState.currentFrame == this->animationState.endFrame )?true:false; } 163 164 /** scales the current model @param scaleFactor: the factor [0..1] to use for scaling */ 164 165 void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;}
Note: See TracChangeset
for help on using the changeset viewer.