#ifndef _Preprocessor_H__ #define _Preprocessor_H__ #include using namespace std; #include "Containers.h" #include "Mesh.h" #include "KdTree.h" namespace GtpVisibilityPreprocessor { class RenderSimulator; class SceneGraph; class Exporter; class ViewCellsManager; class BspTree; class VspOspTree; class VspBspTree; class RenderSimulator; struct VssRayContainer; class SamplingStrategy; class GlRendererBuffer; class VspTree; class HierarchyManager; class BvHierarchy; class Intersectable; class VssRay; class RayCaster; /** Namespace for the external visibility preprocessor This namespace includes all classes which are created by the VUT (Vienna University of Technology) for the External Visibility Preprocessor of the GTP (GameTools Project) (www.gametools.org). */ /** Main class of the visibility preprocessor. Responsible for loading and saving of the input and output files. Initiates construction of the kD-tree, viewcell loading/generation and the visibility computation itself. */ class Preprocessor { friend class RayCaster; friend class IntelRayCaster; friend class InternalRayCaster; public: /** Default constructor initialising e.g., KD tree and BSP tree. */ Preprocessor(); virtual ~Preprocessor(); /** Load the input scene. @param filename file to load @return true on success */ virtual bool LoadScene(const string filename); /** Export all preprocessed data in a XML format understandable by the PreprocessingInterface of the GtpVisibilityPreprocessor Module. The file can be compressed depending on the environement settings. @return true on successful export */ virtual bool ExportPreprocessedData(const string filename); /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction is driven by the environment settings, which also sais which of the three types of entities should be used to drive the heuristical construction (only occluders by default) */ virtual bool BuildKdTree(); /** Compute visibility method. This method has to be reimplemented by the actual Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor, GlobalSamplingpreprocessor) */ virtual bool ComputeVisibility() = 0; /** Post Process the computed visibility. By default applys the visibility filter (if specified in the environment and export the preprocessed data */ virtual bool PostProcessVisibility(); /** View cells are either loaded or prepared for generation, according to the chosen environment object. Important evironment options are, e.g, the view cell type. Should be done after scene loading (i.e., some options are based on scene type). */ bool PrepareViewCells(); /** Construct viewcells from the scratch */ bool ConstructViewCells(); /** Returns the specified sample strategy, NULL if no valid strategy. */ SamplingStrategy *GenerateSamplingStrategy(const int strategyId) const; /** Export preprocessor data. */ bool Export( const string filename, const bool scene, const bool kdtree); virtual void KdTreeStatistics(ostream &s); virtual void BspTreeStatistics(ostream &s); /** Loads samples from file. @param samples returns the stored sample rays @param objects needed to associate the objects ids @returns true if samples were loaded successfully */ bool LoadSamples(VssRayContainer &samples, ObjectContainer &objects) const; /** Exports samples to file. @returns true if samples were written successfully */ bool ExportSamples(const VssRayContainer &samples) const; bool LoadKdTree(const string filename); bool ExportKdTree(const string filename); virtual bool GenerateRays( const int number, const int raysType, SimpleRayContainer &rays ); bool GenerateRayBundle( SimpleRayContainer &rayBundle, const SimpleRay &mainRay, const int number, const int shuffleType) const; virtual void CastRays(SimpleRayContainer &rays, VssRayContainer &vssRays, const bool castDoubleRays, const bool pruneInvalidRays = true); /** Returns a view cells manager of the given name. */ ViewCellsManager *CreateViewCellsManager(const char *name); /** Returns a hierarchy manager of the given name. */ HierarchyManager *CreateHierarchyManager(const char *name); GlRendererBuffer *GetRenderer(); bool InitRayCast(const string externKdTree, const string internKdTree); //////////////////////////////////////////////// /// scene graph loaded from file SceneGraph *mSceneGraph; /// raw array of objects ObjectContainer mObjects; /// kD-tree organizing the scene graph (occluders + occludees) + viewcells KdTree *mKdTree; /// View space partition bsp tree VspBspTree *mVspBspTree; /// Hierarchy manager handling view space and object space partition HierarchyManager *mHierarchyManager; /// BSP tree representing the viewcells BspTree *mBspTree; /// list of all loaded occluders ObjectContainer mOccluders; /// list of all loaded occludees ObjectContainer mOccludees; ViewCellsManager *mViewCellsManager; /// greedy optimized hierarchy for both objects and view cells VspOspTree *mVspOspTree; bool mUseGlRenderer; bool mUseGlDebugger; bool mLoadViewCells; bool mDetectEmptyViewSpace; bool mQuitOnFinish; bool mLoadMeshes; bool mComputeVisibility; bool mExportVisibility; string mVisibilityFileName; bool mApplyVisibilityFilter; bool mApplyVisibilitySpatialFilter; float mVisibilityFilterWidth; int mPass; protected: void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction) const; // matt: previously was a signal void EvalPvsStat(); ///////////////////////// RayCaster *mRayCaster; /// samples used for construction of the BSP view cells tree. int mBspConstructionSamples; /// samples used for construction of the VSP OSP tree. int mVspOspConstructionSamples; /** Simulates rendering of the scene. */ RenderSimulator *mRenderSimulator; vector mFaceParents; GlRendererBuffer *renderer; }; } #endif