Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/collision_detection/src/lib/collision_detection/obb_tree_node.h @ 5705

Last change on this file since 5705 was 5705, checked in by patrick, 18 years ago

collision_detection: slowly removing old functions and exchanging them with the new interface

File size: 3.3 KB
Line 
1/*!
2 * @file bv_tree.h
3  *  Definition of a bounding volume tree
4
5 */
6
7#ifndef _OBB_TREE_NODE_H
8#define _OBB_TREE_NODE_H
9
10#include "bv_tree_node.h"
11
12
13
14// FORWARD DECLARATION
15class BoundingVolume;
16class OBB;
17class OBBTree;
18class Plane;
19class PNode;
20//struct sVec3D;
21
22//! A class that represents a bounding volume tree
23class OBBTreeNode : public BVTreeNode {
24
25
26  public:
27    OBBTreeNode(const OBBTree* tree);
28    OBBTreeNode(const OBBTree* tree, bool bRoot);
29    virtual ~OBBTreeNode();
30
31    /*  this function returns the bounding volume of this tree node @return: returns the BV */
32    virtual inline const BoundingVolume* getBV() const { return (BoundingVolume*)this->bvElement; }
33   
34   
35    virtual void spawnBVTree(const int depth, const sVec3D *verticesList, unsigned int length);
36    virtual void spawnBVTree(const int depth, const modelInfo& modelInf, 
37                             const int* triangleIndexes, unsigned int length);
38
39    virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB);
40    virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const;
41    void debug() const;
42
43   
44  private:
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& modelInf, const int* triangleIndexes, unsigned int length);
49    void calculateBoxEigenvectors(OBB* box, const modelInfo& modelInf, const int* triangleIndexes, unsigned int length);
50    void calculateBoxAxis(OBB* box, const modelInfo& modelInf, const int* triangleIndexes, unsigned int length);
51
52    void forkBox(OBB* box);
53
54    bool overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB);
55
56   
57  protected:
58    OBB*                bvElement;                  //!< the obb element
59    OBBTreeNode*        nodeLeft;                   //!< ref to the left tree node
60    OBBTreeNode*        nodeRight;                  //!< ref to the right tree node
61
62
63  private:
64    unsigned int        treeIndex;                  //!< Index number of the BV in the tree
65    int                 depth;                      //!< the depth of the node in the tree
66    const OBBTree*      obbTree;                    //!< reference to the obb tree
67   
68    const sVec3D*       vertices;                   //!< pointer to the vertices data
69    int                 numOfVertices;              //!< number of vertices in vertices data
70    Plane               separationPlane;            //!< the separation plane of the obb
71    const sVec3D*       sepPlaneCenter;             //!< only needed to draw plane
72    int                 longestAxisIndex;           //!< only needed to draw plane
73
74    /* tmp saving place for obb variables */
75    sVec3D*             tmpVert1;                   //!< pointer to the vert data of obbox1
76    sVec3D*             tmpVert2;                   //!< pointer to the vert data of obbox1
77    int                 tmpLen1;                    //!< len vert data obbox1
78    int                 tmpLen2;                    //!< len vert data obbox2
79
80    static float**      coMat;
81    static float**      eigvMat;
82    static float*       eigvlMat;
83    static int*         rotCount;
84   
85};
86
87#endif /* _OBB_TREE_NODE_H */
Note: See TracBrowser for help on using the repository browser.