Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4923 was 4923, checked in by patrick, 19 years ago

orxonox/trunk: more cleanup, and more cleanup to come

File size: 3.8 KB
Line 
1/*!
2 *  \file proto_class.h
3 *  Definition of a QuadtreeNode which represents a quad in a Quadtree
4
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.
12 */
13
14#ifndef _QUADTREE_NODE_H
15#define _QUADTREE_NODE_H
16
17#include "base_object.h"
18#include "vector.h"
19#include "abstract_model.h"
20
21// FORWARD DEFINITION
22class Quadtree;
23
24
25//! A class for a Quadtree Node representation
26class QuadtreeNode : public BaseObject {
27
28  public:
29    QuadtreeNode(sTriangleExt** triangles, int numTriangles,
30                 const float* pVertices, int numVertices,
31                 Quadtree* quadtree, QuadtreeNode* parent,
32                 Rectangle* rect, int treeDepth, const int maxDepth, int index
33                );
34    QuadtreeNode(modelInfo* pModelInfo, Quadtree* quadtree, const int maxDepth);
35    virtual ~QuadtreeNode();
36
37    void buildHashTable(QuadtreeNode** nodeList, int* index);
38    bool includesPoint(const Vector& v);
39    float getHeight(const Vector& position);
40    inline Rectangle* getDimension() { return this->pDimension; }
41
42    void drawTree() const;
43    void draw() const;
44
45
46  private:
47    void init();
48
49    void separateNode(float minLength);
50    void separateNode();
51    Rectangle* getDimFromModel();
52
53
54  protected:
55    QuadtreeNode*                   parent;             //!< reference to the paren QuadtreeNode (NULL if rootnode)
56    QuadtreeNode*                   nodeA;              //!< reference to the node A
57    QuadtreeNode*                   nodeB;              //!< reference to the node B
58    QuadtreeNode*                   nodeC;              //!< reference to the node C
59    QuadtreeNode*                   nodeD;              //!< reference to the node D
60    QuadtreeNode**                  nodes;              //!< reference to the quadtree nodes
61
62
63  private:
64    Quadtree*                       quadtree;           //!< reference to the quadtree
65    Vector                          center;             //!< center coordinate of the quadtree node - relative coordinates in model space(!)
66    float                           axisLength;         //!< axis length of the quadtree
67    float                           maxHeigth;          //!< max height of the model in the quadtree
68    float                           offset;             //!< offset of the actual quadtree rectangle
69
70    int                             treeDepth;          //!< the depth of the tree
71    int                             maxDepth;           //!< the maximal depth of the tree
72    int                             indexNode;          //!< the index number of the node
73    int                             nodeIter;           //!< temp helping variable for the hashing algorithm
74
75    sTriangleExt**                  pTriangles;         //!< reference to the triangles of the node
76    const float*                    pVertices;          //!< reference to vertices data
77    unsigned int                    numTriangles;       //!< number of triangles of the Node
78    unsigned int                    numVertices;        //!< number of vertices of the node
79    modelInfo*                      pModelInfo;         //!< reference to the modelInfo of the object
80    Rectangle*                      pDimension;         //!< pointer to the local rectangle properties
81
82    bool                            bDraw;              //!< shall it be drawn? DEBUG only
83};
84
85#endif /* _QUADTREE_NODE_H */
Note: See TracBrowser for help on using the repository browser.