Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

collision_detection: some source reformat and function reorg

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
27  public:
28    OBBTreeNode(const OBBTree& tree, unsigned int depth);
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
33    {
34      return (BoundingVolume*)this->bvElement;
35    }
36
37    virtual void spawnBVTree(const sVec3D *verticesList, unsigned int length);
38    virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, unsigned int length);
39
40    virtual void collideWith(const BVTreeNode& treeNode, const WorldEntity& nodeA, const WorldEntity& nodeB) const;
41    virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const;
42    void debug() const;
43
44
45  private:
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    void forkBox(OBB& box);
52
53    bool overlapTest(const OBB& boxA, const OBB& boxB, const WorldEntity& nodeA, const WorldEntity& nodeB) const;
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 modelInfo*    modelInf;                   //!< pointer to the models modelInfo object
68    const int*          triangleIndexes;            //!< indexes to the used model triangles
69
70    const sVec3D*       vertices;                   //!< pointer to the vertices data
71    int                 numOfVertices;              //!< number of vertices in vertices data
72    Plane               separationPlane;            //!< the separation plane of the obb
73    const sVec3D*       sepPlaneCenter;             //!< only needed to draw plane
74    int                 longestAxisIndex;           //!< only needed to draw plane
75
76    /* tmp saving place for obb variables */
77    sVec3D*             tmpVert1;                   //!< pointer to the vert data of obbox1
78    sVec3D*             tmpVert2;                   //!< pointer to the vert data of obbox1
79    int                 tmpLen1;                    //!< len vert data obbox1
80    int                 tmpLen2;                    //!< len vert data obbox2
81
82    static float**      coMat;
83    static float**      eigvMat;
84    static float*       eigvlMat;
85    static int*         rotCount;
86
87};
88
89#endif /* _OBB_TREE_NODE_H */
Note: See TracBrowser for help on using the repository browser.