Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

/Users/blackie/Documents/myRepository/phobosengine-vc2005/phobosengine/phobosengine/Quadtree.h

Go to the documentation of this file.
00001 
00002 
00003 #ifndef QUADTREE_H
00004 #define QUADTREE_H
00005 
00006 
00007 #include "RenderableObject.h"
00008 
00009 #include <vector>
00010 
00011 
00012 #define         QUADTREE_NODE_MINX_MINZ         0
00013 #define         QUADTREE_NODE_MAXX_MINZ         1
00014 #define         QUADTREE_NODE_MAXX_MAXZ         2
00015 #define         QUADTREE_NODE_MINX_MAXZ         3
00016 
00017 
00018 namespace pge {
00019 
00020 
00021         class AABB;
00022         class Mesh;
00023         class MeshModel;
00024 
00025 
00026         class QuadtreeNode {
00027 
00028         public:
00029                 //************************************************************************
00030                 //
00031                 // Constructor
00032                 //
00033                 //************************************************************************
00035                 QuadtreeNode(AABB *boundingBox, int minMeshsPerNode, bool occlusionCulling);
00036 
00037 
00038                 //************************************************************************
00039                 //
00040                 // Destructor
00041                 //
00042                 //************************************************************************
00044                 virtual ~QuadtreeNode(void);
00045 
00046 
00047                 //************************************************************************
00048                 //
00049                 // Functions
00050                 //
00051                 //************************************************************************
00052                 void initRootNode(std::vector<Mesh*> *meshs);
00053                 int getMeshNum(void);
00054                 void render(void);
00055                 void renderWireframe(void);
00056 
00057 
00058         private:
00059                 //************************************************************************
00060                 //
00061                 // Functions
00062                 //
00063                 //************************************************************************
00064                 void subdivide(std::vector<Mesh*> meshs);
00065                 void addMesh(Mesh *mesh);
00066                 void addMeshs(std::vector<Mesh*> *meshs);
00067 
00068 
00069                 //************************************************************************
00070                 //
00071                 // Variables
00072                 //
00073                 //************************************************************************
00074                 AABB *m_boundingBox;
00075                 QuadtreeNode **m_nodes;
00076                 std::vector<Mesh*> *m_meshs;
00077                 int m_minMeshsPerNode;
00078                 bool m_occlusionCulling;
00079         };
00080 
00081 
00082         class Quadtree : public IRenderableObject {
00083 
00084 
00085         public:
00086                 //************************************************************************
00087                 //
00088                 // Constructor
00089                 //
00090                 //************************************************************************
00092                 Quadtree(MeshModel *model, int minMeshsPerNode, bool occlusionCulling);
00093 
00094 
00095                 //************************************************************************
00096                 //
00097                 // Destructor
00098                 //
00099                 //************************************************************************
00101                 virtual ~Quadtree(void);
00102 
00103 
00104                 //************************************************************************
00105                 //
00106                 // Functions
00107                 //
00108                 //************************************************************************
00109                 bool init(void);
00110                 void render(void);
00111                 void timer(unsigned int delay);
00112 
00113 
00114         private:
00115                 //************************************************************************
00116                 //
00117                 // Variables
00118                 //
00119                 //************************************************************************
00120                 MeshModel *m_model;
00121                 QuadtreeNode *m_root;
00122                 int m_minMeshsPerNode;
00123                 bool m_occlusionCulling;
00124         };
00125 };
00126 
00127 #endif

Generated on Mon Oct 16 12:08:10 2006 for Phobosengine by doxygen 1.3.4