Changeset 6447 in orxonox.OLD for branches/collision_detection/src
- Timestamp:
- Jan 9, 2006, 12:39:15 AM (19 years ago)
- Location:
- branches/collision_detection/src/lib/collision_detection
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/collision_detection/src/lib/collision_detection/bv_tree_node.h
r5882 r6447 34 34 inline const int getIndex() const { return this->treeIndex; } 35 35 36 virtual void spawnBVTree(const modelInfo& modInfo, const int* triangleIndexes, unsignedint length) = 0;36 virtual void spawnBVTree(const modelInfo& modInfo, const int* triangleIndexes, int length) = 0; 37 37 virtual void collideWith(const BVTreeNode& treeNode, const WorldEntity& nodeA, const WorldEntity& nodeB) const = 0; 38 38 virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const = 0; -
branches/collision_detection/src/lib/collision_detection/obb_tree.cc
r5882 r6447 66 66 this->flushTree(); 67 67 } 68 this->rootNode = new OBBTreeNode(*this, depth-1);68 this->rootNode = new OBBTreeNode(*this, NULL, depth-1); 69 69 70 70 /* triangles indexes created */ -
branches/collision_detection/src/lib/collision_detection/obb_tree.h
r5882 r6447 32 32 33 33 /** returns the next if for the obb tree node @return integer id number of the next node */ 34 const int getID() { return ++this->id;}34 inline const int getID() { return ++this->id;} 35 35 /** returns the root node of the bounding volume tree @return reference to the root node */ 36 36 inline const OBBTreeNode* getRootNode() const { return this->rootNode; } … … 40 40 private: 41 41 OBBTreeNode* rootNode; //!< reference to the root node of the tree 42 int id; 42 int id; //!< the next id of a obb tree node 43 43 int depth; //!< the depth of the tree to generate 44 44 }; -
branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc
r6140 r6447 11 11 ### File Specific: 12 12 main-programmer: Patrick Boenzli 13 co-programmer: ...14 13 */ 15 14 … … 44 43 * @param depth: the depth of the obb tree to generate 45 44 */ 46 OBBTreeNode::OBBTreeNode (const OBBTree& tree, unsignedint depth)45 OBBTreeNode::OBBTreeNode (const OBBTree& tree, OBBTreeNode* prev, int depth) 47 46 : BVTreeNode() 48 47 { … … 50 49 51 50 this->obbTree = &tree; 51 this->nodePrev = prev; 52 52 this->depth = depth; 53 this->nextID = 0; 53 54 54 55 this->nodeLeft = NULL; … … 64 65 if( OBBTreeNode_sphereObj == NULL) 65 66 OBBTreeNode_sphereObj = gluNewQuadric(); 67 68 /* debug ids */ 69 if( this->nodePrev) 70 this->treeIndex = 100 * this->depth + this->nodePrev->getID(); 71 else 72 this->treeIndex = 0; 66 73 } 67 74 … … 95 102 * on the triangle informations (triangle soup not polygon soup) 96 103 */ 97 void OBBTreeNode::spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, unsignedint length)104 void OBBTreeNode::spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, int length) 98 105 { 99 106 PRINTF(3)("\n==============================Creating OBB Tree Node==================\n"); 100 107 PRINT(3)(" OBB Tree Infos: \n"); 101 PRINT(3)("\tDepth: %i \n\tTree Index: %i \n\tNumber of Triangles: %i\n", depth, t reeIndex, length);108 PRINT(3)("\tDepth: %i \n\tTree Index: %i \n\tNumber of Triangles: %i\n", depth, this->treeIndex, length); 102 109 this->depth = depth; 103 110 … … 107 114 this->bvElement->triangleIndexesLength = length; 108 115 109 /* create the bo xes in three steps */116 /* create the bounding boxes in three steps */ 110 117 this->calculateBoxCovariance(*this->bvElement, modelInf, triangleIndexes, length); 111 118 this->calculateBoxEigenvectors(*this->bvElement, modelInf, triangleIndexes, length); … … 119 126 if( this->triangleIndexLength1 >= 3) 120 127 { 121 this->nodeLeft = new OBBTreeNode(*this->obbTree, depth - 1);128 this->nodeLeft = new OBBTreeNode(*this->obbTree, this, depth - 1); 122 129 this->nodeLeft->spawnBVTree(modelInf, this->triangleIndexList1, this->triangleIndexLength1); 123 130 } 124 131 if( this->triangleIndexLength2 >= 3) 125 132 { 126 this->nodeRight = new OBBTreeNode(*this->obbTree, depth - 1);133 this->nodeRight = new OBBTreeNode(*this->obbTree, this, depth - 1); 127 134 this->nodeRight->spawnBVTree(modelInf, this->triangleIndexList2, this->triangleIndexLength2); 128 135 } … … 139 146 * @param length: the length of the indexes array 140 147 */ 141 void OBBTreeNode::calculateBoxCovariance(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, unsignedint length)148 void OBBTreeNode::calculateBoxCovariance(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length) 142 149 { 143 150 float facelet[length]; //!< surface area of the i'th triangle of the convex hull … … 269 276 */ 270 277 void OBBTreeNode::calculateBoxEigenvectors(OBB& box, const modelInfo& modelInf, 271 const int* triangleIndexes, unsignedint length)278 const int* triangleIndexes, int length) 272 279 { 273 280 … … 305 312 * @param length: the length of the indexes array 306 313 */ 307 void OBBTreeNode::calculateBoxAxis(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, unsignedint length)314 void OBBTreeNode::calculateBoxAxis(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length) 308 315 { 309 316 … … 448 455 449 456 /* find the center of the box */ 450 451 457 this->separationPlane = Plane(box.axis[longestAxisIndex], box.center); 452 458 this->sepPlaneCenter[0] = box.center.x; -
branches/collision_detection/src/lib/collision_detection/obb_tree_node.h
r5882 r6447 25 25 26 26 public: 27 OBBTreeNode(const OBBTree& tree, unsignedint depth);27 OBBTreeNode(const OBBTree& tree, OBBTreeNode* prev, int depth); 28 28 virtual ~OBBTreeNode(); 29 29 … … 31 31 virtual inline const BoundingVolume* getBV() const { return (BoundingVolume*)this->bvElement; } 32 32 33 virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, unsignedint length);33 virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, int length); 34 34 35 35 virtual void collideWith(const BVTreeNode& treeNode, const WorldEntity& nodeA, const WorldEntity& nodeB) const; … … 37 37 void debug() const; 38 38 39 /** gets the id of the current child @return id of the child */ 40 inline const int getID() { return this->nextID++; } 39 41 40 42 private: 41 43 void calculateBoxAxis(OBB& box, const sVec3D* verticesList, unsigned int length); 42 44 43 void calculateBoxCovariance(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, unsignedint length);44 void calculateBoxEigenvectors(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, unsignedint length);45 void calculateBoxAxis(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, unsignedint length);45 void calculateBoxCovariance(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length); 46 void calculateBoxEigenvectors(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length); 47 void calculateBoxAxis(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length); 46 48 void forkBox(OBB& box); 47 49 … … 51 53 protected: 52 54 OBB* bvElement; //!< the obb element 55 OBBTreeNode* nodePrev; //!< ref to the previous (parent) tree node = NULL if first 53 56 OBBTreeNode* nodeLeft; //!< ref to the left tree node 54 57 OBBTreeNode* nodeRight; //!< ref to the right tree node … … 56 59 57 60 private: 58 unsigned int treeIndex; //!< Index number of the BV in the tree 61 int treeIndex; //!< Index number of the BV in the tree 62 int nextID; //!< the id of the next child 59 63 int depth; //!< the depth of the node in the tree 60 64 const OBBTree* obbTree; //!< reference to the obb tree
Note: See TracChangeset
for help on using the changeset viewer.