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/Octree.h

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

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