Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 25, 2006, 3:17:20 PM (18 years ago)
Author:
bensch
Message:

orxonox/branches/cd: merged the new collision-detection back.
merged and collissions resolved.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/cd/src/lib/collision_detection/obb_tree_node.h

    r5693 r7365  
    11/*!
    22 * @file bv_tree.h
    3   *  Definition of a bounding volume tree
    4 
     3 *  Definition of a bounding volume tree
    54 */
    65
     
    87#define _OBB_TREE_NODE_H
    98
     9
    1010#include "bv_tree_node.h"
     11#include "plane.h"
    1112
    12 
    13 
    14 // FORWARD DECLARATION
    1513class BoundingVolume;
    1614class OBB;
     
    1816class Plane;
    1917class PNode;
    20 //struct sVec3D;
     18
    2119
    2220//! A class that represents a bounding volume tree
    23 class OBBTreeNode : public BVTreeNode {
     21class OBBTreeNode : public BVTreeNode
     22{
    2423
    2524
    2625  public:
    27     OBBTreeNode();
     26    OBBTreeNode(const OBBTree& tree, OBBTreeNode* prev, int depth);
    2827    virtual ~OBBTreeNode();
    2928
    30     virtual void spawnBVTree(const int depth, const sVec3D *verticesList, unsigned int length);
    31     virtual void spawnBVTree(const int depth, const modelInfo& modInfo);
     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; }
    3231
    33     BoundingVolume* getBV(int index) const { return (BoundingVolume*)this->bvElement; }
    34     inline const int getIndex() { return this->treeIndex; }
    35     inline void setTreeRef(OBBTree* tree) { this->obbTree = tree;}
     32    virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, int length);
    3633
    3734    virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB);
    38 
    3935    virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const;
    40 
    4136    void debug() const;
    4237
    43   private:
    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);
    47 
    48     void calculateBoxCovariance(OBB* box, const modelInfo& modInfo);
    49     void calculateBoxEigenvectors(OBB* box, const modelInfo& modInfo);
    50     void calculateBoxAxis(OBB* box, const modelInfo& modInfo);
     38    /**  gets the id of the current child @return id of the child */
     39    inline const int getID() { return this->nextID++; }
    5140
    5241
    53     void forkBox(OBB* box);
     42  private:
     43    void calculateBoxAxis(OBB& box, const sVec3D* verticesList, unsigned int length);
    5444
    55     bool overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB);
     45    void calculateBoxCovariance(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length);
     46    void calculateBoxEigenvectors(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length);
     47    void calculateBoxAxis(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, int length);
     48    void forkBox(OBB& box);
     49
     50    bool overlapTest(OBB& boxA, OBB& boxB, WorldEntity* nodeA, WorldEntity* nodeB);
     51
    5652
    5753  protected:
    5854    OBB*                bvElement;                  //!< the obb element
     55    OBBTreeNode*        nodePrev;                   //!< ref to the previous (parent) tree node = NULL if first
    5956    OBBTreeNode*        nodeLeft;                   //!< ref to the left tree node
    6057    OBBTreeNode*        nodeRight;                  //!< ref to the right tree node
    6158
     59
    6260  private:
    63     unsigned int        treeIndex;                  //!< Index number of the BV in the tree
    64     const sVec3D*       vertices;                   //!< pointer to the vertices data
    65     int                 numOfVertices;              //!< number of vertices in vertices data
     61    int                 treeIndex;                  //!< Index number of the BV in the tree
     62    int                 nextID;                     //!< the id of the next child
    6663    int                 depth;                      //!< the depth of the node in the tree
    67     static OBBTree*     obbTree;                    //!< reference to the obb tree
    68     Plane*              separationPlane;            //!< the separation plane of the obb
    69     const sVec3D*       sepPlaneCenter;             //!< only needed to draw plane
     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
    7071    int                 longestAxisIndex;           //!< only needed to draw plane
    7172
    7273    /* tmp saving place for obb variables */
    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
     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
    7778
    78     static float**      coMat;
    79     static float**      eigvMat;
    80     static float*       eigvlMat;
    81     static int*         rotCount;
     79    WorldEntity*        owner;
    8280};
    8381
Note: See TracChangeset for help on using the changeset viewer.