- Timestamp:
- Dec 4, 2005, 11:28:35 PM (19 years ago)
- Location:
- branches/collision_detection/src/lib/collision_detection
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/collision_detection/src/lib/collision_detection/bounding_volume.h
r5870 r5922 32 32 33 33 public: 34 Vector center; //!< Center point of box 34 Vector center; //!< Weighter average center point of box 35 Vector arithCenter; //!< Arithmetical center of the box 35 36 36 37 const modelInfo* modelInf; //!< Reference to the model's ModelInfo -
branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc
r5920 r5922 28 28 29 29 #include <list> 30 #include <vector> 30 31 #include "debug.h" 31 32 … … 171 172 /* now calculate the centroid of the entire convex hull, weighted average of triangle centroids */ 172 173 center += centroid[i] * facelet[i]; 174 /* the arithmetical center */ 173 175 } 174 176 /* take the average of the centroid sum */ … … 197 199 } 198 200 201 202 std::vector<int> vertIndexVector; //!< vertex indexes list 203 int vertIndex; //!< index to vertex 204 bool vertexFound; //!< vertex found flag 205 Vector arithCenter; //!< aritmetical center 206 207 208 /* calculate the arithmetical center of the box */ 209 210 /* go thourgh all vertices, add only the used vertices indexes */ 211 for( int i = 0; i < length; ++i) 212 { 213 for(int j = 0; j < 3; ++j) 214 { 215 vertIndex = modelInf.pTriangles[triangleIndexes[i]].indexToVertices[j]; 216 217 vertexFound = false; 218 for( int i = 0; i < vertIndexVector.size(); i++) 219 { 220 if( vertIndexVector[i] == vertIndex) 221 vertexFound = true; 222 } 223 if( !vertexFound) 224 vertIndexVector.push_back(vertIndex); 225 } 226 } 227 /* now realy calculate the center */ 228 for( int i = 0; i < vertIndexVector.size(); ++i) 229 { 230 tmpVec = (sVec3D*)(&modelInf.pVertices[vertIndexVector[i]]); 231 arithCenter += *tmpVec; 232 } 233 arithCenter.debug(); 234 box.arithCenter = arithCenter / vertIndexVector.size(); 235 236 237 238 199 239 PRINTF(3)("\nOBB Covariance Matrix:\n"); 200 240 for(int j = 0; j < 3; ++j) … … 207 247 PRINT(3)("\n"); 208 248 } 209 PRINTF(3)("\nOBB Center:\n\t\t%11.2f\t %11.2f\t %11.2f\n", center.x, center.y, center.z); 249 PRINTF(3)("\nWeighteed OBB Center:\n\t\t%11.2f\t %11.2f\t %11.2f\n", center.x, center.y, center.z); 250 PRINTF(3)("\nArithmetical OBB Center:\n\t\t%11.2f\t %11.2f\t %11.2f\n", arithCenter.x, arithCenter.y, arithCenter.z); 210 251 211 252 /* write back the covariance matrix data to the object oriented bouning box */ … … 267 308 void OBBTreeNode::calculateBoxAxis(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, unsigned int length) 268 309 { 269 270 sVec3D* verticesList;271 272 310 273 311 PRINTF(3)("Calculate Box Axis\n"); … … 385 423 float newHalfLength[3]; 386 424 387 for( int i = 0; i < 3; ++i)425 for( int i = 0; i < 3; ++i) 388 426 { 389 427 centerOffset[i] = (maxLength[i] + minLength[i]) / 2.0f; // min length is negatie … … 453 491 454 492 455 ./* find the center of the box */493 /* find the center of the box */ 456 494 457 495 this->separationPlane = Plane(box.axis[longestAxisIndex], box.center);
Note: See TracChangeset
for help on using the changeset viewer.