Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

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
[6617]19#include "plane.h"
[6022]20#include "model.h"
[4811]21
[5405]22// FORWARD DECLARATION
[4813]23class Quadtree;
[4805]24
[4868]25
[4805]26//! A class for a Quadtree Node representation
27class QuadtreeNode : public BaseObject {
[9869]28  ObjectListDeclaration(QuadtreeNode);
[4805]29
[4845]30  public:
[4887]31    QuadtreeNode(sTriangleExt** triangles, int numTriangles,
[4896]32                 const float* pVertices, int numVertices,
[4897]33                 Quadtree* quadtree, QuadtreeNode* parent,
[4923]34                 Rectangle* rect, int treeDepth, const int maxDepth, int index
35                );
[5430]36    QuadtreeNode(const modelInfo* pModelInfo, Quadtree* quadtree, const int maxDepth);
[4845]37    virtual ~QuadtreeNode();
[4805]38
[4911]39    void buildHashTable(QuadtreeNode** nodeList, int* index);
[4923]40    inline Rectangle* getDimension() { return this->pDimension; }
[4904]41
[4968]42    bool includesPoint(const Vector& v) const;
[4956]43    sTriangleExt* getTriangle(const Vector& position) const;
44    float getHeight(const Vector& position) const;
45
46
[4922]47    void drawTree() const;
[4921]48    void draw() const;
[4812]49
50
[4845]51  private:
[4852]52    void init();
[4805]53
[4898]54    void separateNode(float minLength);
55    void separateNode();
[4897]56    Rectangle* getDimFromModel();
[4896]57
[4956]58    bool sameSide(const Vector& p1, const Vector&p2, const Vector& a, const Vector& b) const;
59    bool pointInTriangle(const Vector&p, const Vector& a, const Vector& b, const Vector& c) const;
[4923]60
[4896]61  protected:
62    QuadtreeNode*                   parent;             //!< reference to the paren QuadtreeNode (NULL if rootnode)
63    QuadtreeNode*                   nodeA;              //!< reference to the node A
64    QuadtreeNode*                   nodeB;              //!< reference to the node B
65    QuadtreeNode*                   nodeC;              //!< reference to the node C
66    QuadtreeNode*                   nodeD;              //!< reference to the node D
[4968]67    QuadtreeNode**                  nodes;              //!< reference to the quadtree nodes (nodeA, nodeB, nodeC, nodeD=[0..3])
[4896]68
[4923]69
[4845]70  private:
71    Quadtree*                       quadtree;           //!< reference to the quadtree
72    Vector                          center;             //!< center coordinate of the quadtree node - relative coordinates in model space(!)
73    float                           axisLength;         //!< axis length of the quadtree
74    float                           maxHeigth;          //!< max height of the model in the quadtree
[4851]75    float                           offset;             //!< offset of the actual quadtree rectangle
[4811]76
[4887]77    int                             treeDepth;          //!< the depth of the tree
[4898]78    int                             maxDepth;           //!< the maximal depth of the tree
[4900]79    int                             indexNode;          //!< the index number of the node
[4923]80    int                             nodeIter;           //!< temp helping variable for the hashing algorithm
[4887]81
[4851]82    sTriangleExt**                  pTriangles;         //!< reference to the triangles of the node
83    const float*                    pVertices;          //!< reference to vertices data
[4845]84    unsigned int                    numTriangles;       //!< number of triangles of the Node
[4868]85    unsigned int                    numVertices;        //!< number of vertices of the node
[5430]86    const modelInfo*                pModelInfo;         //!< reference to the modelInfo of the object
[4851]87    Rectangle*                      pDimension;         //!< pointer to the local rectangle properties
[4921]88
89    bool                            bDraw;              //!< shall it be drawn? DEBUG only
[4805]90};
91
92#endif /* _QUADTREE_NODE_H */
Note: See TracBrowser for help on using the repository browser.