Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/test/src/lib/collision_detection/aabb_tree_node.h @ 10230

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