#ifndef _VisibilityPreprocessingManager_H__ #define _VisibilityPreprocessingManager_H__ #include using namespace std; #include "HierarchyInterface.h" #include "VisibilityInfo.h" #include "VisibilityVector3.h" namespace GtpVisibility { /** This class defines an interface to the external visibility preprocessor. It allows to export the static part of the scene to a file in the XML format understood by the preprocessor. By default all the exported meshes are considered as scene occluders, whereas occludees are formed by their bounding boxes, and bounding boxes of the scene hierarchy. This class also allows to import the preprocessed data with PVS information for the viewcells (note that the viewcells are either generated automatically by the preprocessor or loaded from a polyhedral definition stored in a file (see documentation for the Preprocessor class). */ class PreprocessingManager { public: /** Constructor taking a HierarchyInterface as argument. The HierarchyInterface makes the PreprocessingManager independent from the actual scene representation as long as it supports a required set of methods. */ PreprocessingManager(HierarchyInterface *hierarchyInterface); /** Destructor which deletes all data describing static scene visibility. */ virtual ~PreprocessingManager(); /** Export the scene for visibility preprocessing. Exports the hierarchyInterface including its bounding boxes + mesh data. Note that the bounding boxes can be used as occludees by the extrenal preprocessor. The viewcell data will either be supplied directly to the visibility preprocessing standalone module. @param filename name of the file to export. @return true if the export was succesful. */ virtual bool ExportScene(const string filename) = 0; /** Load preprocessed visibility information. The loaded data is matched with the current scene graph. The topology of the current scene graph has to match with the loaded data. There is also geometrical check of the bounding boxes. Once loading is succesful the PreprocessingManager establishes links from its internal visibility representation to the scene graph: no change of this part of the scene graph is allowed; this would violate the static scene assumption! @param filename name of the file to load. @return true if the loading was succesful. */ virtual bool LoadPreprocessedData(const string filename) = 0; /** Retrieve a PVS corresponding to the given spherical neighborhood of the point. Typically the implementation of this method will firs locate all viewcells intersecting the sphere using efficient logarithmic search enhanced with caching the last query. Then it computes a union of the PVS for the found viewcells. @param point the center point of the spherical neighborhood @param radius the radius of the spherical neighborhood. Note that if radius==0 a more efficient implementation of the method for this special case can be used. @param visibleNodes of not NULL a set of visible hierarchy nodes is added to the visibleNodes container. This set is formed of visible leafs or fully visible interior nodes. @param visibleMeshes if not NULL the set of visible meshes is added to the container. Returns true if the corresponding PVS exists. */ virtual bool GetPVS(const Vector3 &point, const float radius, NodeInfoContainer *visibleNodes, MeshInfoContainer *visibleMeshes); /** Sets the scene traverser. @remark the scene traverser is dependent on the type of hierarchyInterface the scene consists of. */ virtual void SetSceneTraverser(HierarchyInterface *hierarchyInterface) { mSceneTraverser = hierarchyInterface; } protected: /** Get checksum of the current occluder set in the scene graph. This method is used to check if the preprocessed data matches the current scene graph -> $$ could be moved to VisibilitySceneTraverser */ long GetOccluderChecksum() const { return 0; } /** Get checksum of the current occludee set in the scene graph. This method is used to check if the preprocessed data matches the current scene graph -> $$ could be moved to VisibilitySceneTraverser */ long GetOccludeeChecksum() const { return 0; } /** Find viewcells intersecting a spherical neighborhood of a point. Returns false if no viewcell was found. */ virtual bool LocateViewCellIds(const Vector3 ¢er, const float radius, vector *viewCellIds ) = 0; /** Add a PVS of the given viewcell to the already evaluated PVS by computing a union with visibleNodes and visibleMeshes. Returns the number of added entries. */ virtual int AddViewCellPVS(const int cellID, NodeInfoContainer *visibleNodes, MeshInfoContainer *visibleMeshes ) = 0; HierarchyInterface *mSceneTraverser; }; }; #endif // VisibilityPreprocessingInterafce