#ifndef _SamplingPreprocessor_H__ #define _SamplingPreprocessor_H__ #include using namespace std; #include "Preprocessor.h" #include "VssRay.h" namespace GtpVisibilityPreprocessor { class Exporter; /** Sampling based visibility preprocessing. The implementation is based on heuristical sampling of view space */ class SamplingPreprocessor : public Preprocessor { public: SamplingPreprocessor(); ~SamplingPreprocessor(); virtual bool ComputeVisibility(); protected: /** Sets up ray for sampling. */ void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction, const int type, const Ray::Intersection &source); /** Refined sampling for finding "holes", i.e., difficult visibility. */ void HoleSamplingPass(); /** Casts a bundle of sample rays into the scene. @param sampleContributions the number of sample contributions @param contributingSamples the number of samples contributing */ void CastRays(const RayContainer &rays); /** Casts a single ray into the scene. @returns sample contributions */ int CastRay(Ray &ray); /** Verify if the exact visibility for this object was established. */ void VerifyVisibility(Intersectable *object); /** Sample the shiluette of objects in order to find visibility changes along the visibility skeleton. */ int CastEdgeSamples( Intersectable *object, const Vector3 &point, MeshInstance *mi, const int samples ); /** Processes the view cells during a pass. @param newRays the newly cast rays @param sampleContributions returns the accumulated contribution of the samples @param contributingSamples returns the samples contributing to pvs */ void ProcessViewCells(const RayContainer &newRays, const ObjectContainer &objects, int &sampleContributions, int &contributingSamples); /** Returns random node as target for the current sample ray. */ KdNode *GetNodeToSample(Intersectable *object); protected: int mPass; int mSamplesPerPass; int mTotalSamples; ofstream mStats; ObjectContainer mObjects; RayContainer mSampleRays; VssRayContainer mVssSampleRays; }; } #endif