Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/spatial_separation/quadtree_node.h @ 5819

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

orxonox/trunk: merged branches world_entities to trunk again
merged with command
svn merge -r5795:HEAD branches/world_entities/ trunk/
no conflicts (what a wonder)

File size: 4.1 KB
RevLine 
[4805]1/*!
[5039]2 * @file proto_class.h
[4923]3 *  Definition of a QuadtreeNode which represents a quad in a Quadtree
[4805]4
[4923]5  This struct is used to partition big land scapes into smaller ones for different reasons:
6    - for collision detection: only a subset of all triangles need to be tested vs a given body
7    - for object culling purposes: the quadtrees that are not in the field of view can be ommitted in the draw process
8    - for LOD (level of Detail). The models can be drawn using different LODs depending on the distance
9
10  This struct includes all the triangles, vertices, normal informations needed to make something usefull with
11  a terrain partition.
[4845]12 */
[4805]13
14#ifndef _QUADTREE_NODE_H
15#define _QUADTREE_NODE_H
16
17#include "base_object.h"
[5819]18
[4845]19#include "abstract_model.h"
[4811]20
[5405]21// FORWARD DECLARATION
[4813]22class Quadtree;
[4805]23
[4868]24
[4805]25//! A class for a Quadtree Node representation
26class QuadtreeNode : public BaseObject {
27
[4845]28  public:
[4887]29    QuadtreeNode(sTriangleExt** triangles, int numTriangles,
[4896]30                 const float* pVertices, int numVertices,
[4897]31                 Quadtree* quadtree, QuadtreeNode* parent,
[4923]32                 Rectangle* rect, int treeDepth, const int maxDepth, int index
33                );
[5430]34    QuadtreeNode(const modelInfo* pModelInfo, Quadtree* quadtree, const int maxDepth);
[4845]35    virtual ~QuadtreeNode();
[4805]36
[4911]37    void buildHashTable(QuadtreeNode** nodeList, int* index);
[4923]38    inline Rectangle* getDimension() { return this->pDimension; }
[4904]39
[4968]40    bool includesPoint(const Vector& v) const;
[4956]41    sTriangleExt* getTriangle(const Vector& position) const;
42    float getHeight(const Vector& position) const;
43
44
[4922]45    void drawTree() const;
[4921]46    void draw() const;
[4812]47
48
[4845]49  private:
[4852]50    void init();
[4805]51
[4898]52    void separateNode(float minLength);
53    void separateNode();
[4897]54    Rectangle* getDimFromModel();
[4896]55
[4956]56    bool sameSide(const Vector& p1, const Vector&p2, const Vector& a, const Vector& b) const;
57    bool pointInTriangle(const Vector&p, const Vector& a, const Vector& b, const Vector& c) const;
[4923]58
[4896]59  protected:
60    QuadtreeNode*                   parent;             //!< reference to the paren QuadtreeNode (NULL if rootnode)
61    QuadtreeNode*                   nodeA;              //!< reference to the node A
62    QuadtreeNode*                   nodeB;              //!< reference to the node B
63    QuadtreeNode*                   nodeC;              //!< reference to the node C
64    QuadtreeNode*                   nodeD;              //!< reference to the node D
[4968]65    QuadtreeNode**                  nodes;              //!< reference to the quadtree nodes (nodeA, nodeB, nodeC, nodeD=[0..3])
[4896]66
[4923]67
[4845]68  private:
69    Quadtree*                       quadtree;           //!< reference to the quadtree
70    Vector                          center;             //!< center coordinate of the quadtree node - relative coordinates in model space(!)
71    float                           axisLength;         //!< axis length of the quadtree
72    float                           maxHeigth;          //!< max height of the model in the quadtree
[4851]73    float                           offset;             //!< offset of the actual quadtree rectangle
[4811]74
[4887]75    int                             treeDepth;          //!< the depth of the tree
[4898]76    int                             maxDepth;           //!< the maximal depth of the tree
[4900]77    int                             indexNode;          //!< the index number of the node
[4923]78    int                             nodeIter;           //!< temp helping variable for the hashing algorithm
[4887]79
[4851]80    sTriangleExt**                  pTriangles;         //!< reference to the triangles of the node
81    const float*                    pVertices;          //!< reference to vertices data
[4845]82    unsigned int                    numTriangles;       //!< number of triangles of the Node
[4868]83    unsigned int                    numVertices;        //!< number of vertices of the node
[5430]84    const modelInfo*                pModelInfo;         //!< reference to the modelInfo of the object
[4851]85    Rectangle*                      pDimension;         //!< pointer to the local rectangle properties
[4921]86
87    bool                            bDraw;              //!< shall it be drawn? DEBUG only
[4805]88};
89
90#endif /* _QUADTREE_NODE_H */
Note: See TracBrowser for help on using the repository browser.