Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/cd_merge/src/lib/collision_detection/obb_tree_node.h @ 6657

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

orxonox/cd_merge: merged the old collision-detection here.

File size: 3.2 KB
RevLine 
[4614]1/*!
[5039]2 * @file bv_tree.h
[6657]3 *  Definition of a bounding volume tree
[4614]4 */
[4541]5
6#ifndef _OBB_TREE_NODE_H
7#define _OBB_TREE_NODE_H
8
[6657]9
[4541]10#include "bv_tree_node.h"
11
[4550]12
[4541]13class BoundingVolume;
[4557]14class OBB;
[4622]15class OBBTree;
[4632]16class Plane;
[4700]17class PNode;
[4541]18
[6657]19
[4541]20//! A class that represents a bounding volume tree
[6657]21class OBBTreeNode : public BVTreeNode
22{
[4541]23
24
[4614]25  public:
[6657]26    OBBTreeNode(const OBBTree& tree, OBBTreeNode* prev, int depth);
[4614]27    virtual ~OBBTreeNode();
[4541]28
[6657]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
[6657]32    virtual void spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, int length);
[4541]33
[6657]34    virtual void collideWith(const BVTreeNode& treeNode, const WorldEntity& nodeA, const WorldEntity& nodeB) const;
[5481]35    virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const;
[4746]36    void debug() const;
[4568]37
[6657]38    /**  gets the id of the current child @return id of the child */
39    inline const int getID() { return this->nextID++; }
40
41
[4614]42  private:
[6657]43    void calculateBoxAxis(OBB& box, const sVec3D* verticesList, unsigned int length);
[5693]44
[6657]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);
[5684]49
[6657]50    bool overlapTest(const OBB& boxA, const OBB& boxB, const WorldEntity& nodeA, const WorldEntity& nodeB) const;
[5693]51
[4541]52
[4614]53  protected:
[4685]54    OBB*                bvElement;                  //!< the obb element
[6657]55    OBBTreeNode*        nodePrev;                   //!< ref to the previous (parent) tree node = NULL if first
[4685]56    OBBTreeNode*        nodeLeft;                   //!< ref to the left tree node
57    OBBTreeNode*        nodeRight;                  //!< ref to the right tree node
[4541]58
[6657]59
[4614]60  private:
[6657]61    int                 treeIndex;                  //!< Index number of the BV in the tree
62    int                 nextID;                     //!< the id of the next child
[4614]63    int                 depth;                      //!< the depth of the node in the tree
[6657]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
[4632]71    int                 longestAxisIndex;           //!< only needed to draw plane
[4630]72
73    /* tmp saving place for obb variables */
[6657]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
[4541]78};
79
80#endif /* _OBB_TREE_NODE_H */
Note: See TracBrowser for help on using the repository browser.