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
RevLine 
[4805]1/*!
[4923]2 *  \file proto_class.h
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"
[4810]18#include "vector.h"
[4845]19#include "abstract_model.h"
[4811]20
[4805]21// FORWARD DEFINITION
[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                );
[4902]34    QuadtreeNode(modelInfo* pModelInfo, Quadtree* quadtree, const int maxDepth);
[4845]35    virtual ~QuadtreeNode();
[4805]36
[4911]37    void buildHashTable(QuadtreeNode** nodeList, int* index);
[4923]38    bool includesPoint(const Vector& v);
[4904]39    float getHeight(const Vector& position);
[4923]40    inline Rectangle* getDimension() { return this->pDimension; }
[4904]41
[4922]42    void drawTree() const;
[4921]43    void draw() const;
[4812]44
45
[4845]46  private:
[4852]47    void init();
[4805]48
[4898]49    void separateNode(float minLength);
50    void separateNode();
[4897]51    Rectangle* getDimFromModel();
[4896]52
[4923]53
[4896]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
[4907]60    QuadtreeNode**                  nodes;              //!< reference to the quadtree nodes
[4896]61
[4923]62
[4845]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
[4851]68    float                           offset;             //!< offset of the actual quadtree rectangle
[4811]69
[4887]70    int                             treeDepth;          //!< the depth of the tree
[4898]71    int                             maxDepth;           //!< the maximal depth of the tree
[4900]72    int                             indexNode;          //!< the index number of the node
[4923]73    int                             nodeIter;           //!< temp helping variable for the hashing algorithm
[4887]74
[4851]75    sTriangleExt**                  pTriangles;         //!< reference to the triangles of the node
76    const float*                    pVertices;          //!< reference to vertices data
[4845]77    unsigned int                    numTriangles;       //!< number of triangles of the Node
[4868]78    unsigned int                    numVertices;        //!< number of vertices of the node
[4845]79    modelInfo*                      pModelInfo;         //!< reference to the modelInfo of the object
[4851]80    Rectangle*                      pDimension;         //!< pointer to the local rectangle properties
[4921]81
82    bool                            bDraw;              //!< shall it be drawn? DEBUG only
[4805]83};
84
85#endif /* _QUADTREE_NODE_H */
Note: See TracBrowser for help on using the repository browser.