Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

collision_bibischen: more interface changes, more covariance building

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