Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 5047 was 5046, checked in by patrick, 19 years ago

orxonox/trunk: if a collision occures, the virtual WorldEntity::collidesWith(WorldEntity*, Vector) is called of both objects. the reaction to the collision has to be defined there. default reaction is still output into stdout console. There is now more information

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
[4541]14// FORWARD DEFINITION
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
[4614]30    virtual void spawnBVTree(const int depth, sVec3D *verticesList, const int length);
[4541]31
[4614]32    BoundingVolume* getBV(int index) const { return (BoundingVolume*)this->bvElement; }
33    inline const int getIndex() { return this->treeIndex; }
[4622]34    inline void setTreeRef(OBBTree* tree) { this->obbTree = tree;}
[4541]35
[5028]36    virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB);
[4541]37
[4702]38    virtual void drawBV(int depth, int drawMode);
[4541]39
[4746]40    void debug() const;
[4568]41
[4614]42  private:
[4632]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);
[4614]46    void forkBox(OBB* box);
[4541]47
[5028]48    bool overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB);
[4541]49
[4614]50  protected:
[4685]51    OBB*                bvElement;                  //!< the obb element
52    OBBTreeNode*        nodeLeft;                   //!< ref to the left tree node
53    OBBTreeNode*        nodeRight;                  //!< ref to the right tree node
[4541]54
[4614]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
[4622]60    static OBBTree*     obbTree;                    //!< reference to the obb tree
[4632]61    Plane*              separationPlane;            //!< the separation plane of the obb
[4836]62    sVec3D*             sepPlaneCenter;             //!< only needed to draw plane @todo: separationPlane drawing
[4632]63    int                 longestAxisIndex;           //!< only needed to draw plane
[4630]64
65    /* tmp saving place for obb variables */
[4632]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
[4630]70
[5046]71    static float**      coMat;                      //!< temp covariance matrice save place - consumes less mem
72    static float**      eigvMat;                    //!< temp eigenvector matrice save place
73    static float*       eigvlMat;                   //!< temp eigenvalue vector save place
74    static int*         rotCount;                   //!< temp rotations count save place: how many givens-rotations where needed to transform the matrix :)
[4638]75
[5046]76    GLUquadricObj*      sphereObj;
[4541]77};
78
79#endif /* _OBB_TREE_NODE_H */
Note: See TracBrowser for help on using the repository browser.