[4614] | 1 | /*! |
---|
[4541] | 2 | \file bv_tree.h |
---|
| 3 | \brief Definition of a bounding volume tree |
---|
| 4 | |
---|
[4614] | 5 | */ |
---|
[4541] | 6 | |
---|
| 7 | #ifndef _OBB_TREE_NODE_H |
---|
| 8 | #define _OBB_TREE_NODE_H |
---|
| 9 | |
---|
| 10 | #include "bv_tree_node.h" |
---|
| 11 | |
---|
[4550] | 12 | |
---|
| 13 | |
---|
[4541] | 14 | // FORWARD DEFINITION |
---|
| 15 | class BoundingVolume; |
---|
[4557] | 16 | class OBB; |
---|
[4622] | 17 | class OBBTree; |
---|
[4632] | 18 | class Plane; |
---|
[4550] | 19 | //struct sVec3D; |
---|
[4541] | 20 | |
---|
| 21 | //! A class that represents a bounding volume tree |
---|
| 22 | class OBBTreeNode : public BVTreeNode { |
---|
| 23 | |
---|
| 24 | |
---|
[4614] | 25 | public: |
---|
| 26 | OBBTreeNode(); |
---|
| 27 | virtual ~OBBTreeNode(); |
---|
[4541] | 28 | |
---|
[4614] | 29 | virtual void spawnBVTree(const int depth, sVec3D *verticesList, const int length); |
---|
[4541] | 30 | |
---|
[4614] | 31 | BoundingVolume* getBV(int index) const { return (BoundingVolume*)this->bvElement; } |
---|
| 32 | inline const int getIndex() { return this->treeIndex; } |
---|
[4622] | 33 | inline void setTreeRef(OBBTree* tree) { this->obbTree = tree;} |
---|
[4541] | 34 | |
---|
[4614] | 35 | virtual void collideWith(const BVTree &tree); |
---|
[4541] | 36 | |
---|
[4635] | 37 | virtual void drawBV(int depth, int drawMode) const; |
---|
[4541] | 38 | |
---|
[4614] | 39 | void debug(); |
---|
[4568] | 40 | |
---|
[4614] | 41 | private: |
---|
[4632] | 42 | void calculateBoxCovariance(OBB* box, sVec3D* verticesList, int length); |
---|
| 43 | void calculateBoxEigenvectors(OBB* box, sVec3D* verticesList, int length); |
---|
| 44 | void calculateBoxAxis(OBB* box, sVec3D* verticesList, int length); |
---|
[4614] | 45 | void forkBox(OBB* box); |
---|
[4541] | 46 | |
---|
| 47 | |
---|
[4614] | 48 | protected: |
---|
| 49 | OBB* bvElement; //!< the obb element |
---|
| 50 | OBBTreeNode* nodeLeft; //!< ref to the left tree node |
---|
| 51 | OBBTreeNode* nodeRight; //!< ref to the right tree node |
---|
[4541] | 52 | |
---|
| 53 | |
---|
[4614] | 54 | private: |
---|
| 55 | unsigned int treeIndex; //!< Index number of the BV in the tree |
---|
| 56 | sVec3D* vertices; //!< pointer to the vertices data |
---|
| 57 | int numOfVertices; //!< number of vertices in vertices data |
---|
| 58 | int depth; //!< the depth of the node in the tree |
---|
[4622] | 59 | static OBBTree* obbTree; //!< reference to the obb tree |
---|
[4632] | 60 | Plane* separationPlane; //!< the separation plane of the obb |
---|
| 61 | sVec3D* sepPlaneCenter; //!< only needed to draw plane \todo: separationPlane drawing |
---|
| 62 | int longestAxisIndex; //!< only needed to draw plane |
---|
[4630] | 63 | |
---|
| 64 | /* tmp saving place for obb variables */ |
---|
[4632] | 65 | sVec3D* tmpVert1; //!< pointer to the vert data of obbox1 |
---|
| 66 | sVec3D* tmpVert2; //!< pointer to the vert data of obbox1 |
---|
| 67 | int tmpLen1; //!< len vert data obbox1 |
---|
| 68 | int tmpLen2; //!< len vert data obbox2 |
---|
[4630] | 69 | |
---|
[4632] | 70 | static float** coMat; //!< temp covariance matrice save place - consumes less mem |
---|
| 71 | static float** eigvMat; //!< temp eigenvector matrice save place |
---|
| 72 | static float* eigvlMat; //!< temp eigenvalue vector save place |
---|
| 73 | static int* rotCount; //!< temp rotations count save place: how many givens-rotations where needed to transform the matrix :) |
---|
[4638] | 74 | |
---|
| 75 | GLUquadricObj* sphereObj; |
---|
[4541] | 76 | }; |
---|
| 77 | |
---|
| 78 | #endif /* _OBB_TREE_NODE_H */ |
---|