#ifndef _SceneGraph_H__ #define _SceneGraph_H__ #include #include "Containers.h" #include "AxisAlignedBox3.h" #include "Matrix4x4.h" namespace GtpVisibilityPreprocessor { class SceneGraphLeafIntersectable; class CKTB; /** 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; virtual AxisAlignedBox3 GetBox() const { return mBox; } 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: /** Copy constructor. */ SceneGraphLeaf(SceneGraphLeaf const&); SceneGraphLeaf(); SceneGraphLeaf(bool isDynamic); ~SceneGraphLeaf(); void LoadTransform(const Matrix4x4 &m); void GetTransform(Matrix4x4 &m) const; virtual AxisAlignedBox3 GetBox() const; /** Returns the box without the trafo. */ virtual AxisAlignedBox3 GetOriginalBox() const; virtual void ApplyTransform(const Matrix4x4 &trafo); virtual bool IsDynamic() const { return mIsDynamic;} virtual bool IsLeaf() const { return true; } virtual void UpdateBox(); bool HasChanged() { return mHasChanged; } void SetHasChanged(bool hasChanged) {mHasChanged = hasChanged;} SceneGraphLeafIntersectable *GetIntersectable() { return mIntersectable; } const Matrix4x4 &GetTransformation() const { return mTrafo; } //void SetGeometry(ObjectContainer *geometry); /// used as actual pvs entry: note should be pointer to geometry!! ObjectContainer mGeometry; protected: SceneGraphLeafIntersectable *mIntersectable; bool mIsDynamic; bool mHasChanged; Matrix4x4 mTrafo; bool mDeleteGeometry; }; /** 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->GetBox(); } /** 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