Changeset 4632 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Jun 14, 2005, 6:31:21 PM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc
r4631 r4632 102 102 this->bvElement = new OBB(); 103 103 PRINTF(0)("Created OBBox\n"); 104 this->calculateBox Attributes1(this->bvElement, verticesList, length);104 this->calculateBoxCovariance(this->bvElement, verticesList, length); 105 105 PRINTF(0)("Calculated attributes1\n"); 106 this->calculateBox Attributes2(this->bvElement, verticesList, length);106 this->calculateBoxEigenvectors(this->bvElement, verticesList, length); 107 107 PRINTF(0)("Calculated attributes2\n"); 108 this->calculateBoxA ttributes3(this->bvElement, verticesList, length);108 this->calculateBoxAxis(this->bvElement, verticesList, length); 109 109 PRINTF(0)("Calculated attributes3\n"); 110 110 111 111 112 if( likely( this->depth > 0)) … … 127 128 128 129 129 void OBBTreeNode::calculateBox Attributes1(OBB* box, sVec3D* verticesList, int length)130 void OBBTreeNode::calculateBoxCovariance(OBB* box, sVec3D* verticesList, int length) 130 131 { 131 132 float facelet[length]; //!< surface area of the i'th triangle of the convex hull … … 218 219 219 220 220 void OBBTreeNode::calculateBox Attributes2(OBB* box, sVec3D* verticesList, int length)221 void OBBTreeNode::calculateBoxEigenvectors(OBB* box, sVec3D* verticesList, int length) 221 222 { 222 223 … … 228 229 */ 229 230 Vector** axis = new Vector*[3]; //!< the references to the obb axis 230 // float** a = new float*[4];231 // float** b = new float*[4];232 // float eigval[3];233 // int* rot = new int;234 235 236 //coMat[0] = new float[4]; coMat[1] = new float[4]; coMat[2] = new float[4]; coMat[3] = new float[4];237 //eigvMat[0] = new float[4]; eigvMat[1] = new float[4]; eigvMat[2] = new float[4]; eigvMat[3] = new float[4];238 231 239 232 coMat[1][1] = box->covarianceMatrix[0][0]; coMat[1][2] = box->covarianceMatrix[0][1]; coMat[1][3] = box->covarianceMatrix[0][2]; … … 244 237 JacobI(coMat, 3, eigvlMat, eigvMat, rotCount); 245 238 PRINTF(0)("-- Done Jacobi Decomposition\n"); 246 247 239 248 240 … … 267 259 // printf("eigenvector: %f, %f, %f\n", box->axis[1]->x, box->axis[1]->y, box->axis[1]->z); 268 260 // printf("eigenvector: %f, %f, %f\n", box->axis[2]->x, box->axis[2]->y, box->axis[2]->z); 269 270 271 // delete [] a[0]; delete [] a[1]; delete [] a[2]; delete [] a[3]; 272 // delete [] a; 273 // 274 // delete [] b[0]; delete [] b[1]; delete [] b[2]; delete [] b[3]; 275 // delete [] b; 276 // 277 // delete rot; 278 } 279 280 void OBBTreeNode::calculateBoxAttributes3(OBB* box, sVec3D* verticesList, int length) 261 } 262 263 264 void OBBTreeNode::calculateBoxAxis(OBB* box, sVec3D* verticesList, int length) 281 265 { 282 266 … … 370 354 the points depending on which side they are located 371 355 */ 372 Plane separationPlane(*box->axis[axisIndex], box->vertices[vertexIndex]); //!< separation plane373 356 tList<sVec3D> partition1; //!< the vertex partition 1 374 357 tList<sVec3D> partition2; //!< the vertex partition 2 375 358 359 360 this->separationPlane = new Plane(*box->axis[axisIndex], box->vertices[vertexIndex]); //!< separation plane 361 this->sepPlaneCenter = &box->vertices[vertexIndex]; 362 this->longestAxisIndex = axisIndex; 363 376 364 for(int i = 0; i < box->numOfVertices; ++i) 377 365 { 378 if( separationPlane.distancePoint(box->vertices[i]) > 0.0f)366 if( this->separationPlane->distancePoint(box->vertices[i]) > 0.0f) 379 367 partition1.add(&box->vertices[i]); 380 368 else … … 573 561 glEnd(); 574 562 575 /* 576 glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2], 577 cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2], 578 cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]); 579 glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2], 580 cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2], 581 cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);*/ 582 583 584 glEnd(); 563 564 if( depth != 0) 565 { 566 /* now draw the separation plane */ 567 Vector a1 = *this->bvElement->axis[(this->longestAxisIndex + 1)%3]; 568 Vector a2 = *this->bvElement->axis[(this->longestAxisIndex + 2)%3]; 569 Vector c = *this->bvElement->center; 570 float l1 = this->bvElement->halfLength[(this->longestAxisIndex + 1)%3]; 571 float l2 = this->bvElement->halfLength[(this->longestAxisIndex + 2)%3]; 572 glBegin(GL_QUADS); 573 glVertex3f(c.x + a1.x * l1 + a2.x * l2, c.y + a1.y * l1+ a2.y * l2, c.z + a1.z * l1 + a2.z * l2); 574 glVertex3f(c.x - a1.x * l1 + a2.x * l2, c.y - a1.y * l1+ a2.y * l2, c.z - a1.z * l1 + a2.z * l2); 575 glVertex3f(c.x - a1.x * l1 - a2.x * l2, c.y - a1.y * l1- a2.y * l2, c.z - a1.z * l1 - a2.z * l2); 576 glVertex3f(c.x + a1.x * l1 - a2.x * l2, c.y + a1.y * l1- a2.y * l2, c.z + a1.z * l1 - a2.z * l2); 577 578 glEnd(); 579 } 585 580 586 581 if( this->nodeLeft != NULL && depth != 0 ) -
orxonox/trunk/src/lib/collision_detection/obb_tree_node.h
r4631 r4632 16 16 class OBB; 17 17 class OBBTree; 18 class Plane; 18 19 //struct sVec3D; 19 20 … … 41 42 42 43 private: 43 void calculateBox Attributes1(OBB* box, sVec3D* verticesList, int length);44 void calculateBox Attributes2(OBB* box, sVec3D* verticesList, int length);45 void calculateBoxA ttributes3(OBB* box, sVec3D* verticesList, int length);44 void calculateBoxCovariance(OBB* box, sVec3D* verticesList, int length); 45 void calculateBoxEigenvectors(OBB* box, sVec3D* verticesList, int length); 46 void calculateBoxAxis(OBB* box, sVec3D* verticesList, int length); 46 47 void forkBox(OBB* box); 47 48 … … 59 60 int depth; //!< the depth of the node in the tree 60 61 static OBBTree* obbTree; //!< reference to the obb tree 62 Plane* separationPlane; //!< the separation plane of the obb 63 sVec3D* sepPlaneCenter; //!< only needed to draw plane \todo: separationPlane drawing 64 int longestAxisIndex; //!< only needed to draw plane 61 65 62 66 /* tmp saving place for obb variables */ 63 sVec3D* tmpVert1; 64 sVec3D* tmpVert2; 65 int tmpLen1; 66 int tmpLen2; 67 sVec3D* tmpVert1; //!< pointer to the vert data of obbox1 68 sVec3D* tmpVert2; //!< pointer to the vert data of obbox1 69 int tmpLen1; //!< len vert data obbox1 70 int tmpLen2; //!< len vert data obbox2 67 71 68 static float** coMat; 69 static float** eigvMat; 70 static float* eigvlMat; 71 static int* rotCount; 72 static float** coMat; //!< temp covariance matrice save place - consumes less mem 73 static float** eigvMat; //!< temp eigenvector matrice save place 74 static float* eigvlMat; //!< temp eigenvalue vector save place 75 static int* rotCount; //!< temp rotations count save place: how many givens-rotations where needed to transform the matrix :) 72 76 }; 73 77 -
orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc
r4631 r4632 47 47 // } 48 48 49 CDEngine::getInstance()->debugSpawnTree( 4, model->data->pVertices, model->data->numVertices);49 CDEngine::getInstance()->debugSpawnTree(2, model->data->pVertices, model->data->numVertices); 50 50 51 51 … … 82 82 void Framework::moduleDraw() const 83 83 { 84 CDEngine::getInstance()->drawBV( 3);84 CDEngine::getInstance()->drawBV(1); 85 85 86 86 LightManager::getInstance()->draw();
Note: See TracChangeset
for help on using the changeset viewer.