Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

merged the presentation back

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