Changeset 4630 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Jun 14, 2005, 5:19:23 PM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/collision_detection/lin_alg.h
r4628 r4630 49 49 for (iq=ip+1; iq<=N; iq++) 50 50 sm=sm+fabs(A[ip][iq]); 51 if (sm==0) { 51 if (sm==0) 52 { 53 free(B); 54 free(Z); 52 55 return; //normal return 53 56 } -
orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc
r4629 r4630 45 45 OBBTree* OBBTreeNode::obbTree = NULL; 46 46 47 float** OBBTreeNode::coMat = NULL; 48 float** OBBTreeNode::eigvMat = NULL; 49 float* OBBTreeNode::eigvlMat = NULL; 50 int* OBBTreeNode::rotCount = NULL; 51 47 52 /** 48 53 \brief standard constructor … … 53 58 this->nodeLeft = NULL; 54 59 this->nodeRight = NULL; 60 61 if(coMat == NULL) 62 { 63 coMat = new float*[4]; 64 for(int i = 0; i < 4; i++) 65 coMat[i] = new float[4]; 66 } 67 if(eigvMat == NULL) 68 { 69 eigvMat = new float*[4]; 70 for(int i = 0; i < 4; i++) 71 eigvMat[i] = new float[4]; 72 } 73 if( eigvlMat == NULL) 74 { 75 eigvlMat = new float[4]; 76 } 77 if( rotCount == NULL) 78 rotCount = new int; 55 79 } 56 80 … … 76 100 this->depth = depth; 77 101 78 this->bvElement = this->createBox();102 this->bvElement = new OBB(); 79 103 PRINTF(0)("Created OBBox\n"); 80 104 this->calculateBoxAttributes(this->bvElement, verticesList, length); … … 85 109 this->forkBox(this->bvElement); 86 110 87 } 88 } 89 90 91 OBB* OBBTreeNode::createBox() 92 { 93 return new OBB(); 94 } 111 OBBTreeNode* node1 = new OBBTreeNode(); 112 OBBTreeNode* node2 = new OBBTreeNode(); 113 114 this->nodeLeft = node1; 115 this->nodeRight = node2; 116 117 this->nodeLeft->spawnBVTree(depth - 1, this->tmpVert1, this->tmpLen1); 118 this->nodeRight->spawnBVTree(depth - 1, this->tmpVert2, this->tmpLen2); 119 120 } 121 } 122 95 123 96 124 … … 188 216 vectors 189 217 */ 190 /* Matrix V(3,3); */ //!< for eigenvectors191 /* DiagonalMatrix D(3); */ //!< for eigenvalues192 /* SymmetricMatrix C(3); */ //!< for the covariance symmetrical matrix193 218 Vector** axis = new Vector*[3]; //!< the references to the obb axis 194 219 // float** a = new float*[4]; 220 // float** b = new float*[4]; 221 // float eigval[3]; 222 // int* rot = new int; 223 224 225 //coMat[0] = new float[4]; coMat[1] = new float[4]; coMat[2] = new float[4]; coMat[3] = new float[4]; 226 //eigvMat[0] = new float[4]; eigvMat[1] = new float[4]; eigvMat[2] = new float[4]; eigvMat[3] = new float[4]; 227 228 coMat[1][1] = covariance[0][0]; coMat[1][2] = covariance[0][1]; coMat[1][3] = covariance[0][2]; 229 coMat[2][1] = covariance[1][0]; coMat[2][2] = covariance[1][1]; coMat[2][3] = covariance[1][2]; 230 coMat[3][1] = covariance[2][0]; coMat[3][2] = covariance[2][1]; coMat[3][3] = covariance[2][2]; 195 231 196 232 /* new jacobi tests */ 197 float** a = new float*[4]; 198 a[0] = new float[4]; a[1] = new float[4]; a[2] = new float[4]; a[3] = new float[4]; 199 200 float** b = new float*[4]; 201 b[0] = new float[4]; b[1] = new float[4]; b[2] = new float[4]; b[3] = new float[4]; 202 203 float eigval[3]; 204 205 int* rot = new int; 206 207 208 a[1][1] = covariance[0][0]; 209 a[1][2] = covariance[0][1]; 210 a[1][3] = covariance[0][2]; 211 a[2][1] = covariance[1][0]; 212 a[2][2] = covariance[1][1]; 213 a[2][3] = covariance[1][2]; 214 a[3][1] = covariance[2][0]; 215 a[3][2] = covariance[2][1]; 216 a[3][3] = covariance[2][2]; 217 218 219 JacobI(a, 3, eigval, b, rot); 233 JacobI(coMat, 3, eigvlMat, eigvMat, rotCount); 220 234 PRINTF(0)("-- Done Jacobi Decomposition\n"); 221 235 … … 228 242 // for(int k = 1; k < 4; ++k) 229 243 // { 230 // printf(" \b%f ", b[j][k]);244 // printf(" \b%f ", eigvMat[j][k]); 231 245 // } 232 246 // printf(" |\n"); 233 247 // } 234 248 235 axis[0] = new Vector( b[1][1], b[2][1], b[3][1]);236 axis[1] = new Vector( b[1][2], b[2][2], b[3][2]);237 axis[2] = new Vector( b[1][3], b[2][3], b[3][3]);249 axis[0] = new Vector(eigvMat[1][1], eigvMat[2][1], eigvMat[3][1]); 250 axis[1] = new Vector(eigvMat[1][2], eigvMat[2][2], eigvMat[3][2]); 251 axis[2] = new Vector(eigvMat[1][3], eigvMat[2][3], eigvMat[3][3]); 238 252 box->axis = axis; 239 253 PRINTF(0)("-- Got Axis\n"); 240 241 delete [] a[0];242 delete [] a[1];243 delete [] a[2];244 delete [] a[3];245 delete [] a;246 247 delete [] b[0];248 delete [] b[1];249 delete [] b[2];250 delete [] b[3];251 delete [] b;252 253 254 254 255 // printf("\neigenvector: %f, %f, %f\n", box->axis[0]->x, box->axis[0]->y, box->axis[0]->z); 255 256 // printf("eigenvector: %f, %f, %f\n", box->axis[1]->x, box->axis[1]->y, box->axis[1]->z); 256 257 // printf("eigenvector: %f, %f, %f\n", box->axis[2]->x, box->axis[2]->y, box->axis[2]->z); 258 259 260 // delete [] a[0]; delete [] a[1]; delete [] a[2]; delete [] a[3]; 261 // delete [] a; 262 // 263 // delete [] b[0]; delete [] b[1]; delete [] b[2]; delete [] b[3]; 264 // delete [] b; 265 // 266 // delete rot; 257 267 258 268 … … 291 301 box->halfLength = halfLength; 292 302 PRINTF(0)("-- Written Axis to obb\n"); 293 303 PRINTF(0)("-- Finished Calculating Attributes\n"); 294 304 295 305 // printf("\nwe got length: \n"); … … 403 413 element = iterator->nextElement(); 404 414 } 415 416 this->tmpVert1 = vertList1; 417 this->tmpVert2 = vertList2; 418 this->tmpLen1 = partition1.getSize(); 419 this->tmpLen2 = partition2.getSize(); 405 420 406 421 //delete iterator; … … 412 427 // printf("v[%i][2] = %f\n", i, vertList2[i][2]); 413 428 // } 414 415 /* now spawn the obb tree: create the nodes and descent */416 OBBTreeNode* node1 = new OBBTreeNode();417 OBBTreeNode* node2 = new OBBTreeNode();418 419 this->nodeLeft = node1;420 this->nodeRight = node2;421 422 this->nodeLeft->spawnBVTree(depth - 1, vertList1, partition1.getSize());423 this->nodeRight->spawnBVTree(depth - 1, vertList2, partition2.getSize());424 429 } 425 430 -
orxonox/trunk/src/lib/collision_detection/obb_tree_node.h
r4622 r4630 41 41 42 42 private: 43 OBB* createBox();44 43 void calculateBoxAttributes(OBB* box, sVec3D* verticesList, int length); 45 44 void forkBox(OBB* box); … … 58 57 int depth; //!< the depth of the node in the tree 59 58 static OBBTree* obbTree; //!< reference to the obb tree 59 60 /* tmp saving place for obb variables */ 61 sVec3D* tmpVert1; 62 sVec3D* tmpVert2; 63 int tmpLen1; 64 int tmpLen2; 65 66 static float** coMat; 67 static float** eigvMat; 68 static float* eigvlMat; 69 static int* rotCount; 60 70 }; 61 71 -
orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc
r4629 r4630 35 35 model = new MD2Model("models/tris.md2", "models/tris.pcx"); 36 36 model->tick(0.1f); 37 CDEngine::getInstance()->debugSpawnTree(2, model->data->pVertices, model->data->numVertices); 37 38 // int const length = 6; 39 // sVec3D* vertList = new sVec3D[length]; 40 // sVec3D data[length] = {{5.0, 0.0, 0.0},{2.0, 0.0, 5.0},{14.0, 0.0, 0.0}, {5.0, 0.0, 1.0}, {12.0, 0.0, 8.0}, {3.0, 5.0, 4.9}}; 41 // 42 // for(int i = 0; i < length; ++i) 43 // { 44 // vertList[i][0] = data[i][0]; 45 // vertList[i][1] = data[i][1]; 46 // vertList[i][2] = data[i][2]; 47 // } 48 49 CDEngine::getInstance()->debugSpawnTree(1, model->data->pVertices, model->data->numVertices); 38 50 39 51 … … 70 82 void Framework::moduleDraw() const 71 83 { 72 CDEngine::getInstance()->drawBV( 2);84 CDEngine::getInstance()->drawBV(1); 73 85 74 86 LightManager::getInstance()->draw();
Note: See TracChangeset
for help on using the changeset viewer.