#ifndef _Preprocessor_H__ #define _Preprocessor_H__ #include using namespace std; #include "Containers.h" #include "Mesh.h" #include "KdTree.h" // matt: remove qt dependencies //#include 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; /** 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. */ // matt: remove qt dependencies class Preprocessor// : public QObject { //Q_OBJECT 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 (if not already loaded) */ bool ConstructViewCells(); /** Returns the specified sample strategy, NULL if no valid strategy. */ SamplingStrategy *GenerateSamplingStrategy(const int strategyId) const; bool Export( const string filename, const bool scene, const bool kdtree, const bool bsptree ); 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); /** Get Sample rays of particular type, returns false if this type of rays is not supported by the preprocessor */ enum { OBJECT_BASED_DISTRIBUTION, DIRECTION_BASED_DISTRIBUTION, DIRECTION_BOX_BASED_DISTRIBUTION, SPATIAL_BOX_BASED_DISTRIBUTION, RSS_BASED_DISTRIBUTION, RSS_SILHOUETTE_BASED_DISTRIBUTION, VSS_BASED_DISTRIBUTION, OBJECT_DIRECTION_BASED_DISTRIBUTION, OBJECTS_INTERIOR_DISTRIBUTION }; enum { INTERNAL_RAYCASTER = 0, INTEL_RAYCASTER }; 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); /** 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() { return renderer;} bool InitRayCast(const string externKdTree); int CastRay( const Vector3 &viewPoint, const Vector3 &direction, const float probability, VssRayContainer &vssRays, const AxisAlignedBox3 &box ); Intersectable * CastSimpleRay( const Vector3 &viewPoint, const Vector3 &direction, const AxisAlignedBox3 &box, Vector3 &point, Vector3 &normal ); //////////////////////////////////////////////// /// 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; // view space partition tree VspTree *mVspTree; 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 GetRayCastMethod() { return mRayCastMethod; } void SetRayCastMethod(int rayCastMethod) { mRayCastMethod = rayCastMethod; } int mPass; protected: void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction); int ProcessRay( const Vector3 &viewPoint, const Vector3 &direction, Intersectable *objectA, Vector3 &pointA, const Vector3 &normalA, Intersectable *objectB, Vector3 &pointB, const Vector3 &normalB, const float probability, VssRayContainer &vssRays, const AxisAlignedBox3 &box); int CastInternalRay( const Vector3 &viewPoint, const Vector3 &direction, const float probability, VssRayContainer &vssRays, const AxisAlignedBox3 &box); int CastIntelDoubleRay( const Vector3 &viewPoint, const Vector3 &direction, const float probability, VssRayContainer &vssRays, const AxisAlignedBox3 &box); Intersectable *CastIntelSingleRay( const Vector3 &viewPoint, const Vector3 &direction, Vector3 &tPoint, const AxisAlignedBox3 &box); ///////////////////////// int mRayCastMethod; /// 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; // matt: remove qt dependencies //signals: void EvalPvsStat(); protected: void CastRays16(const int i, SimpleRayContainer &rays, VssRayContainer &vssRays, const AxisAlignedBox3 &sbox); }; //extern Preprocessor *preprocessor; } #endif