Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 5699 was 5699, checked in by bensch, 18 years ago

orxonox/branches/collision_detection: switched from pointers to Values, to save debug-time deleting all the nice little new Pointer-arrays

@patrick: hope you approve

File size: 3.1 KB
RevLine 
[4614]1/*!
[5039]2 * @file bv_tree.h
[4836]3  *  Definition of a bounding volume tree
[4541]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
[5405]14// FORWARD DECLARATION
[4541]15class BoundingVolume;
[4557]16class OBB;
[4622]17class OBBTree;
[4632]18class Plane;
[4700]19class PNode;
[4550]20//struct sVec3D;
[4541]21
22//! A class that represents a bounding volume tree
23class OBBTreeNode : public BVTreeNode {
24
25
[4614]26  public:
27    OBBTreeNode();
28    virtual ~OBBTreeNode();
[4541]29
[5688]30    virtual void spawnBVTree(const int depth, const sVec3D *verticesList, unsigned int length);
[5684]31    virtual void spawnBVTree(const int depth, const modelInfo& modInfo);
[4541]32
[4614]33    BoundingVolume* getBV(int index) const { return (BoundingVolume*)this->bvElement; }
34    inline const int getIndex() { return this->treeIndex; }
[4622]35    inline void setTreeRef(OBBTree* tree) { this->obbTree = tree;}
[4541]36
[5028]37    virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB);
[4541]38
[5481]39    virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const;
[4541]40
[4746]41    void debug() const;
[4568]42
[4614]43  private:
[5688]44    void calculateBoxCovariance(OBB* box, const sVec3D* verticesList, unsigned int length);
45    void calculateBoxEigenvectors(OBB* box, const sVec3D* verticesList, unsigned int length);
46    void calculateBoxAxis(OBB* box, const sVec3D* verticesList, unsigned int length);
[5693]47
[5684]48    void calculateBoxCovariance(OBB* box, const modelInfo& modInfo);
49    void calculateBoxEigenvectors(OBB* box, const modelInfo& modInfo);
50    void calculateBoxAxis(OBB* box, const modelInfo& modInfo);
51
[5693]52
[4614]53    void forkBox(OBB* box);
[4541]54
[5028]55    bool overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB);
[4541]56
[4614]57  protected:
[4685]58    OBB*                bvElement;                  //!< the obb element
59    OBBTreeNode*        nodeLeft;                   //!< ref to the left tree node
60    OBBTreeNode*        nodeRight;                  //!< ref to the right tree node
[4541]61
[4614]62  private:
63    unsigned int        treeIndex;                  //!< Index number of the BV in the tree
[5688]64    const sVec3D*       vertices;                   //!< pointer to the vertices data
[4614]65    int                 numOfVertices;              //!< number of vertices in vertices data
66    int                 depth;                      //!< the depth of the node in the tree
[4622]67    static OBBTree*     obbTree;                    //!< reference to the obb tree
[5699]68    Plane               separationPlane;            //!< the separation plane of the obb
[5693]69    const sVec3D*       sepPlaneCenter;             //!< only needed to draw plane
[4632]70    int                 longestAxisIndex;           //!< only needed to draw plane
[4630]71
72    /* tmp saving place for obb variables */
[4632]73    sVec3D*             tmpVert1;                   //!< pointer to the vert data of obbox1
74    sVec3D*             tmpVert2;                   //!< pointer to the vert data of obbox1
75    int                 tmpLen1;                    //!< len vert data obbox1
76    int                 tmpLen2;                    //!< len vert data obbox2
[5431]77
78    static float**      coMat;
79    static float**      eigvMat;
80    static float*       eigvlMat;
81    static int*         rotCount;
[4541]82};
83
84#endif /* _OBB_TREE_NODE_H */
Note: See TracBrowser for help on using the repository browser.