Changeset 5932 in orxonox.OLD for branches/collision_detection
- Timestamp:
- Dec 5, 2005, 11:26:19 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc
r5929 r5932 199 199 } 200 200 } 201 for( int i = 0; i < 3; ++i)201 for( int i = 0; i < 3; ++i) 202 202 { 203 203 box.covarianceMatrix[i][0] = covariance[i][0]; … … 216 216 217 217 /* go thourgh all vertices, add only the used vertices indexes */ 218 for( int i = 0; i < length; ++i)219 {220 for(int j = 0; j < 3; ++j)221 {222 vertIndex = modelInf.pTriangles[triangleIndexes[i]].indexToVertices[j];223 224 vertexFound = false;225 for( int i = 0; i < vertIndexVector.size(); i++)226 {227 if( vertIndexVector[i] == vertIndex)228 vertexFound = true;229 }230 if( !vertexFound)231 vertIndexVector.push_back(vertIndex);232 }233 }234 /* now realy calculate the center */235 for( int i = 0; i < vertIndexVector.size(); ++i)236 {237 tmpVec = (sVec3D*)(&modelInf.pVertices[vertIndexVector[i]]);238 arithCenter += *tmpVec;239 }240 box.arithCenter = arithCenter / vertIndexVector.size();218 // for( int i = 0; i < length; ++i) 219 // { 220 // for(int j = 0; j < 3; ++j) 221 // { 222 // vertIndex = modelInf.pTriangles[triangleIndexes[i]].indexToVertices[j]; 223 // 224 // vertexFound = false; 225 // for( int i = 0; i < vertIndexVector.size(); i++) 226 // { 227 // if( vertIndexVector[i] == vertIndex) 228 // vertexFound = true; 229 // } 230 // if( !vertexFound) 231 // vertIndexVector.push_back(vertIndex); 232 // } 233 // } 234 // /* now realy calculate the center */ 235 // for( int i = 0; i < vertIndexVector.size(); ++i) 236 // { 237 // tmpVec = (sVec3D*)(&modelInf.pVertices[vertIndexVector[i]]); 238 // arithCenter += *tmpVec; 239 // } 240 // box.arithCenter = arithCenter / vertIndexVector.size(); 241 241 242 242 … … 254 254 } 255 255 PRINTF(3)("\nWeighteed OBB Center:\n\t\t%11.4f\t %11.4f\t %11.4f\n", center.x, center.y, center.z); 256 PRINTF(3)("\nArithmetical OBB Center:\n\t\t%11.4f\t %11.4f\t %11.4f\n", box.arithCenter.x, box.arithCenter.y, box.arithCenter.z);256 // PRINTF(3)("\nArithmetical OBB Center:\n\t\t%11.4f\t %11.4f\t %11.4f\n", box.arithCenter.x, box.arithCenter.y, box.arithCenter.z); 257 257 258 258 /* write back the covariance matrix data to the object oriented bouning box */ … … 320 320 const sVec3D* tmpVec; //!< variable taking tmp vectors 321 321 322 /*323 this step is split up in three: first there will be made a bounding box which is324 very badly centered. In the section step there will be calculated a new center325 and a better bounding box.326 */327 328 /* get a bad bounding box axis */329 // halfLength[0] = -1.0f;330 // for( int j = 0; j < length; ++j)331 // {332 // for( int i = 0; i < 3; ++i)333 // {334 // tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);335 // tmpLength = fabs(p0.distancePoint(*tmpVec));336 // if( tmpLength > halfLength[0])337 // halfLength[0] = tmpLength;338 // }339 // }340 //341 // halfLength[1] = -1.0f;342 // for( int j = 0; j < length; ++j)343 // {344 // for( int i = 0; i < 3; ++i)345 // {346 // tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);347 // tmpLength = fabs(p0.distancePoint(*tmpVec));348 // if( tmpLength > halfLength[1])349 // halfLength[1] = tmpLength;350 // }351 // }352 //353 // halfLength[2] = -1.0f;354 // for( int j = 0; j < length; ++j)355 // {356 // for( int i = 0; i < 3; ++i)357 // {358 // tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);359 // tmpLength = fabs(p0.distancePoint(*tmpVec));360 // if( tmpLength > halfLength[2])361 // halfLength[2] = tmpLength;362 // }363 // }364 365 366 322 367 323 /* get the maximal dimensions of the body in all directions */ … … 420 376 /* calculate the real centre of the body by using the axis length */ 421 377 float centerOffset[3]; 422 float newHalfLength[3];423 378 424 379 for( int i = 0; i < 3; ++i) 425 380 { 426 381 centerOffset[i] = (maxLength[i] + minLength[i]) / 2.0f; // min length is negatie 427 newHalfLength[i] = (maxLength[i] - minLength[i]) / 2.0f; // min length is negative 428 box.center += (box.axis[i] * centerOffset[i]); // update the new center vector 429 halfLength[i] = newHalfLength[i]; 430 } 382 box.halfLength[i] = (maxLength[i] - minLength[i]) / 2.0f; // min length is negative 383 } 384 box.center.x += centerOffset[0]; 385 box.center.y += centerOffset[1]; 386 box.center.z += centerOffset[2]; 387 431 388 PRINTF(3)("\n"); 432 389 PRINT(3)("\tAxis Length x: %f (max: %11.2f, \tmin: %11.2f)\n", halfLength[0], maxLength[0], minLength[0]); … … 435 392 436 393 437 box.halfLength[0] = halfLength[0];438 box.halfLength[1] = halfLength[1];439 box.halfLength[2] = halfLength[2];394 // box.halfLength[0] = halfLength[0]; 395 // box.halfLength[1] = halfLength[1]; 396 // box.halfLength[2] = halfLength[2]; 440 397 } 441 398 … … 808 765 } 809 766 810 if( this->nodeLeft == NULL || this->nodeRight == NULL)767 if( this->nodeLeft == NULL || this->nodeRight == NULL) 811 768 depth = 0; 812 769 if( !(drawMode & DRAW_SINGLE && depth != 0))
Note: See TracChangeset
for help on using the changeset viewer.