Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 3.3 KB
Line 
1/*!
2 * @file bv_tree.h
3 *  Definition of a bounding volume tree
4 */
5
6#ifndef _OBB_TREE_NODE_H
7#define _OBB_TREE_NODE_H
8
9
10#include "bv_tree_node.h"
11#include "plane.h"
12
13class BoundingVolume;
14class OBB;
15class OBBTree;
16class Plane;
17class PNode;
18
19//! A class that represents a bounding volume tree
20class OBBTreeNode : public BVTreeNode
21{
22  ObjectListDeclaration(OBBTreeNode);
23  public:
24    OBBTreeNode(const OBBTree& tree, OBBTreeNode* prev, int depth);
25    virtual ~OBBTreeNode();
26
27    /**  this function returns the bounding volume of this tree node @return: returns the BV */
28    virtual inline const BoundingVolume* getBV() const { return (BoundingVolume*)this->bvElement; }
29
30    virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, int length);
31    void createBox(Vector start, Vector end);
32
33    virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB);
34    virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const;
35    void debug() const;
36
37    /**  gets the id of the current child @return id of the child */
38    inline const int getID() { return this->nextID++; }
39
40
41  private:
42    void calculateBoxAxis(OBB& box, const sVec3D* verticesList, unsigned int length);
43
44    void calculateBoxCovariance(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length);
45    void calculateBoxEigenvectors(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length);
46    void calculateBoxAxis(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length);
47    void forkBox(OBB& box);
48
49    void collideWithOBB(OBBTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB);
50    bool overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB);
51
52
53  protected:
54    OBB*                bvElement;                  //!< the obb element
55    OBBTreeNode*        nodePrev;                   //!< ref to the previous (parent) tree node = NULL if first
56    OBBTreeNode*        nodeLeft;                   //!< ref to the left tree node
57    OBBTreeNode*        nodeRight;                  //!< ref to the right tree node
58
59
60  private:
61    int                 treeIndex;                  //!< Index number of the BV in the tree
62    int                 nextID;                     //!< the id of the next child
63    int                 depth;                      //!< the depth of the node in the tree
64    const OBBTree*      obbTree;                    //!< reference to the obb tree
65
66    const modelInfo*    modelInf;                   //!< pointer to the models modelInfo object
67    const int*          triangleIndexes;            //!< indexes to the used model triangles
68
69    Plane               separationPlane;            //!< the separation plane of the obb
70    sVec3D              sepPlaneCenter;             //!< only needed to draw plane
71    int                 longestAxisIndex;           //!< only needed to draw plane
72
73    /* tmp saving place for obb variables */
74    int*                triangleIndexList1;         //!< pointer to the vert data of obbox1
75    int*                triangleIndexList2;         //!< pointer to the vert data of obbox1
76    int                 triangleIndexLength1;       //!< len vert data obbox1
77    int                 triangleIndexLength2;       //!< len vert data obbox2
78
79    WorldEntity*        owner;
80
81};
82
83#endif /* _OBB_TREE_NODE_H */
Note: See TracBrowser for help on using the repository browser.