Changeset 7711 in orxonox.OLD for trunk/src/lib/collision_detection/obb_tree_node.h
- Timestamp:
- May 18, 2006, 11:44:21 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/collision_detection/obb_tree_node.h
r5693 r7711 1 1 /*! 2 2 * @file bv_tree.h 3 * Definition of a bounding volume tree 4 3 * Definition of a bounding volume tree 5 4 */ 6 5 … … 8 7 #define _OBB_TREE_NODE_H 9 8 9 10 10 #include "bv_tree_node.h" 11 #include "plane.h" 11 12 12 13 14 // FORWARD DECLARATION15 13 class BoundingVolume; 16 14 class OBB; … … 18 16 class Plane; 19 17 class PNode; 20 //struct sVec3D; 18 21 19 22 20 //! A class that represents a bounding volume tree 23 class OBBTreeNode : public BVTreeNode { 21 class OBBTreeNode : public BVTreeNode 22 { 24 23 25 24 26 25 public: 27 OBBTreeNode( );26 OBBTreeNode(const OBBTree& tree, OBBTreeNode* prev, int depth); 28 27 virtual ~OBBTreeNode(); 29 28 30 virtual void spawnBVTree(const int depth, const sVec3D *verticesList, unsigned int length);31 virtual void spawnBVTree(const int depth, const modelInfo& modInfo);29 /** this function returns the bounding volume of this tree node @return: returns the BV */ 30 virtual inline const BoundingVolume* getBV() const { return (BoundingVolume*)this->bvElement; } 32 31 33 BoundingVolume* getBV(int index) const { return (BoundingVolume*)this->bvElement; } 34 inline const int getIndex() { return this->treeIndex; } 35 inline void setTreeRef(OBBTree* tree) { this->obbTree = tree;} 32 virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, int length); 36 33 37 34 virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB); 38 39 35 virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const; 40 41 36 void debug() const; 42 37 43 private: 44 void calculateBoxCovariance(OBB* box, const sVec3D* verticesList, unsigned int length); 45 void calculateBoxEigenvectors(OBB* box, const sVec3D* verticesList, unsigned int length); 46 void calculateBoxAxis(OBB* box, const sVec3D* verticesList, unsigned int length); 47 48 void calculateBoxCovariance(OBB* box, const modelInfo& modInfo); 49 void calculateBoxEigenvectors(OBB* box, const modelInfo& modInfo); 50 void calculateBoxAxis(OBB* box, const modelInfo& modInfo); 38 /** gets the id of the current child @return id of the child */ 39 inline const int getID() { return this->nextID++; } 51 40 52 41 53 void forkBox(OBB* box); 42 private: 43 void calculateBoxAxis(OBB& box, const sVec3D* verticesList, unsigned int length); 54 44 55 bool overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB); 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); 48 void forkBox(OBB& box); 49 50 bool overlapTest(OBB& boxA, OBB& boxB, WorldEntity* nodeA, WorldEntity* nodeB); 51 56 52 57 53 protected: 58 54 OBB* bvElement; //!< the obb element 55 OBBTreeNode* nodePrev; //!< ref to the previous (parent) tree node = NULL if first 59 56 OBBTreeNode* nodeLeft; //!< ref to the left tree node 60 57 OBBTreeNode* nodeRight; //!< ref to the right tree node 61 58 59 62 60 private: 63 unsigned int treeIndex; //!< Index number of the BV in the tree 64 const sVec3D* vertices; //!< pointer to the vertices data 65 int numOfVertices; //!< number of vertices in vertices data 61 int treeIndex; //!< Index number of the BV in the tree 62 int nextID; //!< the id of the next child 66 63 int depth; //!< the depth of the node in the tree 67 static OBBTree* obbTree; //!< reference to the obb tree 68 Plane* separationPlane; //!< the separation plane of the obb 69 const sVec3D* sepPlaneCenter; //!< only needed to draw plane 64 const OBBTree* obbTree; //!< reference to the obb tree 65 66 const modelInfo* modelInf; //!< pointer to the models modelInfo object 67 const int* triangleIndexes; //!< indexes to the used model triangles 68 69 Plane separationPlane; //!< the separation plane of the obb 70 sVec3D sepPlaneCenter; //!< only needed to draw plane 70 71 int longestAxisIndex; //!< only needed to draw plane 71 72 72 73 /* tmp saving place for obb variables */ 73 sVec3D* tmpVert1;//!< pointer to the vert data of obbox174 sVec3D* tmpVert2;//!< pointer to the vert data of obbox175 int t mpLen1;//!< len vert data obbox176 int t mpLen2;//!< len vert data obbox274 int* triangleIndexList1; //!< pointer to the vert data of obbox1 75 int* triangleIndexList2; //!< pointer to the vert data of obbox1 76 int triangleIndexLength1; //!< len vert data obbox1 77 int triangleIndexLength2; //!< len vert data obbox2 77 78 78 static float** coMat; 79 static float** eigvMat; 80 static float* eigvlMat; 81 static int* rotCount; 79 WorldEntity* owner; 82 80 }; 83 81
Note: See TracChangeset
for help on using the changeset viewer.