Changeset 9919 in orxonox.OLD for branches/ODE/src/lib
- Timestamp:
- Nov 5, 2006, 9:07:04 PM (18 years ago)
- Location:
- branches/ODE/src/lib/graphics
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ODE/src/lib/graphics/importer/bsp_file.cc
r9869 r9919 39 39 // STL Containers 40 40 #include <vector> 41 42 #include<ode/ode.h> 41 43 42 44 … … 332 334 this->patchTrianglesPerRow = new char[7*4*this->numPatches]; 333 335 this->VertexArrayModels = new VertexArrayModel*[this->numPatches]; 336 337 this->ODE_Geometry = new dTriMeshDataID[this->numPatches*7*7]; 338 this->ODE_Geom_IDs = new dGeomID[this->numPatches* 7 *7]; 339 334 340 335 341 PRINTF(4)("BSP FILE:NumberOfPatches: %i . \n", numPatches); … … 729 735 */ 730 736 737 uint Ind [] = {8,0,9, 0,1,9, 9,1,10, 1,2,10, 10,2,11, 2,3,11, 11,3,12, 3,4,12, 12,4,13, 4,5,13, 13,5,14, 5,6,14, 14,6,15, 6,7,15, 738 16,8,17, 8,9,17, 17,9,18, 9,10,18, 18,10,19, 10,11,19, 19,11,20, 11,12,20, 20,12,21, 12,13,21, 21,13,22, 13,14,22, 22,14,23, 14,15,23, 739 24,16,25, 16,17,25, 25,17,26, 17,18,26, 26,18,27, 18,19,27, 27,19,28, 19,20,28, 28,20,29, 20,21,29, 29,21,30, 21,22,30, 30,22,31, 22,23,31, 740 32,24,33, 24,25,33, 33,25,34, 25,26,34, 34,26,35, 26,27,35, 35,27,36, 27,28,36, 36,28,37, 28,29,37 ,37,29,38, 29,30,38, 38,30,39, 30,31,39, 741 40,32,41, 32,33,41, 41,33,42, 33,34,42, 42,34,43, 34,35,43, 43,35,44, 35,36,44, 44,36,45, 36,37,45, 45,37,46, 37,38,46, 46,38,47, 38,39,47, 742 48,40,49, 40,41,49, 49,41,50, 41,42,50, 50,42,51, 42,43,51, 51,43,52, 43,44,52, 52,44,53, 44,45,53, 53,45,54, 45,46,54, 54,46,55, 46,47,55, 743 56,48,57, 48,49,57, 57,49,58, 49,50,58, 58,50,59, 50,51,59, 59,51,60, 51,52,60, 60,52,61, 52,53,61, 61,53,62, 52,54,62, 62,54,63, 54,55,63, 0 }; 744 731 745 732 746 void BspFile::tesselate(int iface) … … 877 891 } 878 892 879 // Create indices893 // Create indices 880 894 GLuint* indices= & ((GLuint*)(this->patchIndexes))[level*level1*2*this->patchOffset]; 881 895 … … 888 902 } 889 903 } 904 905 this->ODE_Geometry[this->patchOffset] = dGeomTriMeshDataCreate(); 906 // Create ODE Triangle Mesh Geometry 907 dGeomTriMeshDataBuildSingle(this->ODE_Geometry[this->patchOffset], &((((BspVertex*)(this->patchVertice))[level1*level1*this->patchOffset ]).position[0]), sizeof(BspVertex), level1*level1, &(Ind[0]) ,7*14*3, 3* sizeof(uint) ); 890 908 891 909 -
branches/ODE/src/lib/graphics/importer/bsp_file.h
r9003 r9919 19 19 20 20 #include <vector> 21 #include <ode/ode.h> 22 21 23 class SDL_Surface; 22 24 class BspTreeNode; … … 86 88 { 87 89 int texture; //!< Texture index. 88 int effect; //!< Index into lump 12 (Effects), or -1.90 int effect; //!< Index into lump #include <ode/ode.h>12 (Effects), or -1. 89 91 int type; //!< Face type. 1=polygon, 2=patch, 3=mesh, 4=billboard 90 92 int vertex; //!< Index of first vertex. … … 159 161 AMat loadMat( char* mat ); 160 162 AMat loadAVI(char * mat); 163 dTriMeshDataID* getODE_Geometry(void) {return this->ODE_Geometry;} 161 164 162 165 … … 215 218 216 219 ::std::vector<MoviePlayer* > MovieMaterials; //!< Movieplayer Materials 220 221 dTriMeshDataID* ODE_Geometry; //!< ODE Geometry Data for patches 222 dGeomID* ODE_Geom_IDs; //!< IDs of ODE Geometry Data 217 223 }; 218 224 -
branches/ODE/src/lib/graphics/importer/bsp_manager.cc
r9869 r9919 48 48 #include "cr_defs.h" 49 49 50 #include<ode/ode.h> 51 50 52 51 53 //CREATE_FACTORY( BspManager, CL_BSP_MODEL); … … 88 90 { 89 91 // open a BSP file 92 this->world = dWorldCreate(); 93 space = dSimpleSpaceCreate(0); 94 95 //!fixme 96 for (int i=0; i<30; i++) { 97 contact[i].surface.mode = dContactBounce | dContactSoftCFM; 98 contact[i].surface.mu = dInfinity; 99 contact[i].surface.mu2 = 0; 100 contact[i].surface.bounce = 0.1; 101 contact[i].surface.bounce_vel = 0.1; 102 contact[i].surface.soft_cfm = 0.01; 103 } 104 105 90 106 91 107 … … 101 117 this->outputFraction = 1.0f; 102 118 119 contactgroup = dJointGroupCreate (0); 120 dWorldSetGravity (world,0,0,-0.5); 121 dWorldSetCFM (world,1e-5); 122 this->ODE_Geom_IDs = new dGeomID[this->bspFile->numPatches* 7 *7]; 123 124 for( int i = 0 ; i < (this->bspFile->numPatches ); i++ ) 125 { 126 this->ODE_Geom_IDs[i] = dCreateTriMesh(space,(this->bspFile->getODE_Geometry())[i],0 , 0, 0); 127 128 } 103 129 return 0; 104 130 } … … 970 996 971 997 972 #if 0 973 // Retrieve Bounding box 974 AABB* box = worldEntity->getModelAABB(); 975 976 977 Vector forwardDir = Vector(0.0,0.0,1.0); 978 Vector upDir = Vector(0.0,1.0,0.0); 979 Vector position = worldEntity->getAbsCoor(); 980 981 bool SolidFlag = false; 982 bool collision = false; 983 Vector position1 = position; 984 Vector position2 = position + Vector(0.0,1.0,0.0); 985 Vector position3 = position; 986 Vector position4 = position + Vector(0.0,1.0,0.0); 987 Vector dest = worldEntity->getAbsCoor() - upDir*40.0f; // 988 Vector dest1 = position + forwardDir*4.0f; 989 Vector dest2 = position2 + forwardDir*4.0; 990 Vector dest3 = position + forwardDir*4.0f; 991 Vector dest4 = position2 + forwardDir*4.0; 992 dest = position - Vector(0.0, 40.0,0.0); 993 Vector out = dest; 994 Vector out1; 995 Vector out2; 996 997 998 plane* testPlane; 999 1000 bool xCollision = false; 1001 bool zCollision = false; 1002 1003 1004 float height = 40; 1005 1006 1007 if( box != NULL) { 1008 position = worldEntity->getAbsCoor() + box->center; // + Vector(0.0, 1.0, 0.0) * box->halfLength[1] * 1.0f; 1009 dest = worldEntity->getAbsCoor() + box->center - Vector(0.0, 1.0, 0.0) * (box->halfLength[1] + BSP_Y_OFFSET) * 100; 1010 1011 Vector dirX = worldEntity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize(); 1012 1013 //position1 = worldEntity->getAbsCoor() + box->center - dirX * (box->halfLength[0] + BSP_X_OFFSET); 1014 dest1 = worldEntity->getAbsCoor() + box->center + dirX * (box->halfLength[0] + BSP_X_OFFSET); 1015 dest2 = worldEntity->getAbsCoor() - box->center + dirX * (box->halfLength[0] + BSP_X_OFFSET); 1016 1017 Vector dirZ = worldEntity->getAbsDirZ(); dirX.y = 0.0f; dirZ.normalize(); 1018 //position2 = worldEntity->getAbsCoor() + box->center - dirZ * (box->halfLength[2] + BSP_Z_OFFSET); 1019 dest3 = worldEntity->getAbsCoor() + box->center + dirZ * (box->halfLength[2] + BSP_Z_OFFSET); 1020 dest4 = worldEntity->getAbsCoor() - box->center + dirZ * (box->halfLength[2] + BSP_Z_OFFSET); 1021 } else { 1022 // Init positions and destinations to anything useful! 1023 1024 } 1025 1026 1027 1028 // 1st Ray: Y RAY 1029 this->inputStart = position; 1030 this->inputEnd = dest; 1031 this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &dest ); 1032 1033 1034 // 1035 if(!this->outputStartsOut ) { 1036 this->collPlane = new plane; 1037 this->collPlane->x = 0.0f; 1038 this->collPlane->y = 0.0f; 1039 this->collPlane->z = 0.0f; 1040 collision = true; 1041 } else { 1042 1043 if( this->outputFraction == 1.0f) { 1044 if(this->outputAllSolid ) { 1045 this->collPlane = new plane; 1046 this->collPlane->x = 0.0f; 1047 this->collPlane->y = 0.0f; 1048 this->collPlane->z = 0.0f; 1049 collision = true; 1050 SolidFlag = true; 1051 } else 1052 collision = false; 1053 1054 1055 out = dest; 1056 1057 } else { 1058 collision = true; 1059 out.x = position.x + (dest.x -position.x) * this->outputFraction; 1060 out.y = position.y + (dest.y -position.y) * this->outputFraction; 1061 out.z = position.z + (dest.z -position.z) * this->outputFraction; 1062 1063 Vector out3 = out + Vector(height*this->collPlane->x,height*this->collPlane->y,height*this->collPlane->z); 1064 this->out = out; 1065 } 1066 } 1067 testPlane = this->collPlane; 1068 1069 1070 bool xCollisionNeg = false; 1071 bool zCollisionNeg = false; 1072 1073 1074 1075 // 2nd Collision Detection X-RAY 1076 this->outputStartsOut = true; 1077 this->outputAllSolid = false; 1078 this->outputFraction = 1.0f; 1079 this->inputStart = position1; 1080 this->inputEnd = dest1; 1081 this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 ); 1082 1083 if(this->outputFraction < 1.0f) { 1084 out.x = dest1.x + (dest1.x -position1.x) * this->outputFraction; 1085 dest1 = position1 + (dest1 -position1) * this->outputFraction; 1086 xCollision = true; 1087 testPlane = this->collPlane; 1088 } 1089 if(this->outputAllSolid ) { 1090 1091 this->collPlane = new plane; 1092 this->collPlane->x = 0.0f; 1093 this->collPlane->y = 0.0f; 1094 this->collPlane->z = 0.0f; 1095 testPlane = this->collPlane; 1096 SolidFlag = true; 1097 xCollision = true; 1098 } 1099 //out.z = this->outputFraction; 1100 1101 1102 1103 // 3rd Collision Detection Z-RAY 1104 this->outputStartsOut = true; 1105 this->outputAllSolid = false; 1106 this->outputFraction = 1.0f; 1107 this->inputStart = position2; 1108 this->inputEnd = dest2; 1109 1110 this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 ); 1111 //out.x = this->outputFraction; 1112 1113 if(this->outputFraction < 1.0f ) { 1114 out.z = out.z = dest2.z + (dest2.z -position2.z) * this->outputFraction; 1115 dest2 = position2 + (dest2 -position2) * this->outputFraction; 1116 zCollision = true; 1117 testPlane = this->collPlane; 1118 1119 } 1120 if(this->outputAllSolid ) { 1121 this->collPlane = new plane; 1122 this->collPlane->x = 0.0f; 1123 this->collPlane->y = 0.0f; 1124 this->collPlane->z = 0.0f; 1125 testPlane = this->collPlane; 1126 1127 SolidFlag = true; 1128 zCollision = true; 1129 } 1130 1131 1132 // Return the normal here: Normal's stored in this->collPlane; 1133 if( collision) { 1134 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag); 1135 } 1136 if(xCollision) { 1137 worldEntity->registerCollision(COLLISION_TYPE_AXIS_X , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z),dest1 , SolidFlag); 1138 } 1139 1140 if(zCollision) { 1141 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), dest2 , SolidFlag); 1142 } 1143 #endif 1144 1145 } 1146 998 999 1000 // Create the World-Entities BBOX 1001 AABB* box = worldEntity->getModelAABB(); 1002 dReal aabbox [6]; 1003 1004 if( box != NULL) 1005 { 1006 1007 dGeomID RayX = dCreateRay(space,box->halfLength[0] *2.0f); 1008 dGeomRaySet (RayX, worldEntity->getAbsCoor().x - box->halfLength[0] ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z, 1009 1.0f, 0.0f, 0.0f); 1010 dGeomID RayY = dCreateRay(space,box->halfLength[1] *2.0f); 1011 dGeomRaySet (RayY, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y - box->halfLength[1], worldEntity->getAbsCoor().z, 1012 0.0f, 1.0f, 0.0f); 1013 dGeomID RayZ = dCreateRay(space,box->halfLength[2] *2.0f); 1014 dGeomRaySet (RayZ, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z - box->halfLength[2], 1015 0.0f, 0.0f, 1.0f); 1016 1017 dGeomID RayXPos = dCreateRay(space,box->halfLength[0]); 1018 dGeomRaySet (RayX, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z, 1019 1.0f, 0.0f, 0.0f); 1020 dGeomID RayYPos = dCreateRay(space,box->halfLength[1] ); 1021 dGeomRaySet (RayY, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z, 1022 0.0f, 1.0f, 0.0f); 1023 dGeomID RayZPos = dCreateRay(space,box->halfLength[2] ); 1024 dGeomRaySet (RayZ, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z, 1025 0.0f, 0.0f, 1.0f); 1026 1027 dGeomID RayXNeg = dCreateRay(space,box->halfLength[0] * 40.0f ); 1028 dGeomRaySet (RayX, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z, 1029 -1.0f, 0.0f, 0.0f); 1030 dGeomID RayYNeg = dCreateRay(space,box->halfLength[1] ); 1031 dGeomRaySet (RayY, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y , worldEntity->getAbsCoor().z, 1032 0.0f, -1.0f, 0.0f); 1033 dGeomID RayZNeg = dCreateRay(space,box->halfLength[2] ); 1034 dGeomRaySet (RayZ, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z , 1035 0.0f, 0.0f, -1.0f); 1036 1037 1038 dGeomID BBOX = dCreateBox (space,box->halfLength[0]*2.0f, box->halfLength[1]*40.0f + BSP_Y_OFFSET*30.0f ,2.0f* box->halfLength[2]); 1039 dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z); 1040 dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z); 1041 1042 1043 dGeomID BBOX2 ; 1044 1045 int g; 1046 bool collision = false; 1047 1048 for( int i = 0 ; i < this->bspFile->numPatches /* * 7 */; i++ ) 1049 { 1050 // dGeomGetAABB (this->bspFile->ODE_Geom_IDs[i],aabbox ); 1051 // BBOX2 = dCreateBox (space, aabbox[1]-aabbox[0], aabbox[3]-aabbox[2], aabbox[5]-aabbox[4]); 1052 // dGeomSetPosition (BBOX2,(aabbox[1]+ aabbox[0])/2, (aabbox[3]+ aabbox[2])/2, (aabbox[4]+ aabbox[5])/2); 1053 // dGeomDestroy(BBOX2); 1054 g = 0; 1055 if(dCollide(this->ODE_Geom_IDs[i],BBOX, 1, &contact[0].geom, sizeof(dContact)) ) { 1056 1057 if(dCollide(this->ODE_Geom_IDs[i],RayX, 1, &contact[0].geom, sizeof(dContact))) { 1058 if(dCollide(this->ODE_Geom_IDs[i],RayXPos, 1, &contact[0].geom, sizeof(dContact))) { 1059 worldEntity->registerCollision(COLLISION_TYPE_AXIS_X , this->parent, worldEntity, Vector(1.0f, 0.0f, 0.0f), 1060 Vector((float)contact[0].geom.pos[0],(float)contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 1061 1062 }//if 1063 if(dCollide(this->ODE_Geom_IDs[i],RayXNeg, 1, &contact[0].geom, sizeof(dContact))) { 1064 worldEntity->registerCollision(COLLISION_TYPE_AXIS_X_NEG , this->parent, worldEntity, Vector(1.0f, 0.0f, 0.0f), 1065 Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 1066 1067 }//if 1068 }//if 1069 1070 1071 if(dCollide(this->ODE_Geom_IDs[i],RayY, 1, &contact[0].geom, sizeof(dContact))) { 1072 1073 // worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this->parent, worldEntity, Vector(0.0f, 1.0f, 0.0f), 1074 // Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 1075 1076 //PRINTF(0)("Ground \n"); 1077 if(dCollide(this->ODE_Geom_IDs[i],RayYPos, 1, &contact[0].geom, sizeof(dContact))) { 1078 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this->parent, worldEntity, Vector(0.0f, 1.0f, 0.0f), 1079 Vector(contact[0].geom.pos[0],contact[0].geom.pos[1] ,contact[0].geom.pos[2]), false); 1080 1081 }//if 1082 else if(dCollide(this->ODE_Geom_IDs[i],RayYNeg, 1, &contact[0].geom, sizeof(dContact))) { 1083 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this->parent, worldEntity, Vector(0.0f, 1.0f, 0.0f), 1084 Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 1085 1086 }//if 1087 else { 1088 1089 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this->parent, worldEntity, Vector(0.0f, 1.0f, 0.0f), 1090 Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 1091 1092 } 1093 1094 }//if 1095 1096 if(dCollide(this->ODE_Geom_IDs[i],RayZ, 1, &contact[0].geom, sizeof(dContact))) { 1097 if(dCollide(this->ODE_Geom_IDs[i],RayZPos, 1, &contact[0].geom, sizeof(dContact))) { 1098 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z , this->parent, worldEntity, Vector(0.0f, 0.0f, 1.0f), 1099 Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 1100 1101 }//if 1102 if(dCollide(this->ODE_Geom_IDs[i],RayZNeg, 1, &contact[0].geom, sizeof(dContact))) { 1103 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z_NEG , this->parent, worldEntity, Vector(0.0f, 0.0f, 1.0f), 1104 Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false); 1105 1106 }//if 1107 1108 1109 }//if 1110 1111 } //if 1112 } //for 1113 1114 dGeomDestroy(RayX); 1115 dGeomDestroy(RayY); 1116 dGeomDestroy(RayZ); 1117 dGeomDestroy(RayXPos); 1118 dGeomDestroy(RayYPos); 1119 dGeomDestroy(RayZPos); 1120 dGeomDestroy(RayXNeg); 1121 dGeomDestroy(RayYNeg); 1122 dGeomDestroy(RayZNeg); 1123 1124 dGeomDestroy(BBOX); 1125 } // if(bbox != 0) 1126 } 1147 1127 1148 1128 -
branches/ODE/src/lib/graphics/importer/bsp_manager.h
r9110 r9919 26 26 #include <vector> 27 27 #include <deque> 28 #include <ode/ode.h> 28 29 29 30 … … 136 137 137 138 int tgl; 139 140 dWorldID world; 141 dSpaceID space; 142 dJointGroupID contactgroup; 143 dContact contact[300]; 144 dGeomID* ODE_Geom_IDs; //!< IDs of ODE Geometry Data 145 138 146 }; 139 147 -
branches/ODE/src/lib/graphics/importer/static_model.h
r9869 r9919 61 61 void acquireData(const StaticModelData::Pointer& data); 62 62 const StaticModelData::Pointer& dataPointer() const { return this->data; }; 63 //StaticModelData* dataPointer(){return this->data;}; 63 64 64 65 inline void setScaleFactor(float scaleFactor) { this->data->setScaleFactor(scaleFactor); }; -
branches/ODE/src/lib/graphics/text_engine/text_engine.cc
r9869 r9919 86 86 void TextEngine::enableFonts() 87 87 { 88 if ( !TTF_WasInit())88 if (false /*!TTF_WasInit()*/) 89 89 { 90 90 if(TTF_Init()==-1) … … 102 102 void TextEngine::disableFonts() 103 103 { 104 if ( TTF_WasInit())104 if (false /*TTF_WasInit()*/) 105 105 { 106 106 // Font::removeDefaultFont(); … … 141 141 SDL_version compile_version; 142 142 SDL_version link_version; 143 TTF_VERSION(&compile_version);144 link_version = *TTF_Linked_Version();143 //TTF_VERSION(&compile_version); 144 // link_version = *TTF_Linked_Version(); 145 145 146 146 if (compile_version.major == link_version.major &&
Note: See TracChangeset
for help on using the changeset viewer.