#ifndef _SceneGraph_H__ #define _SceneGraph_H__ #include #include "Containers.h" #include "AxisAlignedBox3.h" #include "Matrix4x4.h" namespace GtpVisibilityPreprocessor { /** Basic scene graph node, we are interested only in bounding boxes and topology of the scene graph */ class SceneGraphNode { public: virtual ~SceneGraphNode(); virtual bool IsLeaf() const = 0; virtual void UpdateBox() = 0; //protected: AxisAlignedBox3 mBox; }; /** Scene graph interior node. */ class SceneGraphInterior: public SceneGraphNode { public: virtual bool IsLeaf() const { return false; } virtual void UpdateBox(); ~SceneGraphInterior(); //protected: SceneGraphNodeContainer mChildren; }; /** Scene graph leaf node. */ class SceneGraphLeaf: public SceneGraphNode { public: SceneGraphLeaf(bool isDynamic = false): mIsDynamic(isDynamic){} ~SceneGraphLeaf(); virtual void Transform(const Matrix4x4 &trafo); virtual bool IsDynamic() const { return mIsDynamic;} virtual bool IsLeaf() const { return true; } virtual void UpdateBox(); ObjectContainer mGeometry; protected: bool mIsDynamic; Matrix4x4 mTrafo; }; /** Scene graph class */ class SceneGraph { public: SceneGraph(); ~SceneGraph(); bool Export(const std::string filename); int CollectObjects(ObjectContainer &instances); int AssignObjectIds(); void GetStatistics(int &intersectables, int &faces) const; AxisAlignedBox3 GetBox() const { return mRoot->mBox; } /** Exports binary version of the scene. */ void ExportScene(const std::string filename); /** Loads binary version of the scene. */ void LoadScene(const std::string filename); SceneGraphInterior *GetRoot(); //void SetRoot(SceneGraphNode *sgNnode); void SetRoot(SceneGraphInterior *sgNnode); void AddChild(SceneGraphNode *node); int GetSize() const; protected: SceneGraphInterior *mRoot; }; } #endif