Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/collision_detection/obb_tree_node.h @ 5574

Last change on this file since 5574 was 5481, checked in by bensch, 19 years ago

orxonox/trunk: BV-nodes are now renddered more efficiently.

File size: 2.8 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();
28    virtual ~OBBTreeNode();
29
30    virtual void spawnBVTree(const int depth, sVec3D *verticesList, const int length);
31
32    BoundingVolume* getBV(int index) const { return (BoundingVolume*)this->bvElement; }
33    inline const int getIndex() { return this->treeIndex; }
34    inline void setTreeRef(OBBTree* tree) { this->obbTree = tree;}
35
36    virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB);
37
38    virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const;
39
40    void debug() const;
41
42  private:
43    void calculateBoxCovariance(OBB* box, sVec3D* verticesList, int length);
44    void calculateBoxEigenvectors(OBB* box, sVec3D* verticesList, int length);
45    void calculateBoxAxis(OBB* box, sVec3D* verticesList, int length);
46    void forkBox(OBB* box);
47
48    bool overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB);
49
50  protected:
51    OBB*                bvElement;                  //!< the obb element
52    OBBTreeNode*        nodeLeft;                   //!< ref to the left tree node
53    OBBTreeNode*        nodeRight;                  //!< ref to the right tree node
54
55  private:
56    unsigned int        treeIndex;                  //!< Index number of the BV in the tree
57    sVec3D*             vertices;                   //!< pointer to the vertices data
58    int                 numOfVertices;              //!< number of vertices in vertices data
59    int                 depth;                      //!< the depth of the node in the tree
60    static OBBTree*     obbTree;                    //!< reference to the obb tree
61    Plane*              separationPlane;            //!< the separation plane of the obb
62    sVec3D*             sepPlaneCenter;             //!< only needed to draw plane @todo: separationPlane drawing
63    int                 longestAxisIndex;           //!< only needed to draw plane
64
65    /* tmp saving place for obb variables */
66    sVec3D*             tmpVert1;                   //!< pointer to the vert data of obbox1
67    sVec3D*             tmpVert2;                   //!< pointer to the vert data of obbox1
68    int                 tmpLen1;                    //!< len vert data obbox1
69    int                 tmpLen2;                    //!< len vert data obbox2
70
71    static float**      coMat;
72    static float**      eigvMat;
73    static float*       eigvlMat;
74    static int*         rotCount;
75};
76
77#endif /* _OBB_TREE_NODE_H */
Note: See TracBrowser for help on using the repository browser.