#ifndef __GLOBALLINESRENDERER_H #define __GLOBALLINESRENDERER_H #include "common.h" #include "Containers.h" #include "Vector3.h" class RenderTexture; namespace GtpVisibilityPreprocessor { class Beam; class Intersectable; class Preprocessor; class GlRenderer; struct SimpleRay; struct VssRayContainer; class GlobalLinesRenderer { public: GlobalLinesRenderer(Preprocessor *preprocessor, const int texHeight, const int mTexWidth, const float eps, const int maxDepth, const bool sampleReverse); GlobalLinesRenderer(Preprocessor *preprocessor); ~GlobalLinesRenderer(); /** Casts global lines in the angle specified by alpha and beta. The computed samples are stored in the ray container. @returns # of layers */ int CastGlobalLines(const float alpha, const float beta, VssRayContainer &rays); /** Casts global lines using the given ray as origin and direction vector. @returns Computed samples in the container rays */ int CastGlobalLines(const SimpleRay &ray, VssRayContainer &rays); void ComputeBoundingQuad(int &xMin, int &yMin, int &xMax, int &yMax); void InitGl(); /** Computes rays from information gained with hw sampling */ void ComputeRays(Intersectable *sourceObj, VssRayContainer &rays); float GetPixelError(int &pvsSize); int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; /** Draws the geometry for one pass. */ void DrawGeometry(); void Run(); void GrabDepthBuffer(float *data, RenderTexture *rt); void GrabItemBuffer(unsigned char *data, RenderTexture *rt); int ApplyDepthPeeling(VssRayContainer &rays); void ExportDepthBuffer(); void ExportItemBuffer(); bool ProcessDepthBuffer(VssRayContainer &vssRays, const bool oldBufferInitialised, const int pass); void DisplayBuffer(const bool isDepth); bool ClipToViewSpaceBox(const Vector3 &origin, const Vector3 &termination, Vector3 &clippedOrigin, Vector3 &clippedTermination); Intersectable *ExtractSamplePoint(float *depthBuffer, unsigned char *itemBuffer, const int x, const int y, Vector3 &hitPoint, const bool isFrontBuffer) const; void Visualize(const VssRayContainer &vssRays); int mMaxDepth; Vector3 mEyeVec; Vector3 mLeftVec; Vector3 mUpVec; Vector3 mTermination; float mFar; float mNear; float mWidth; Vector3 mViewPoint; float *mNewDepthBuffer; float *mOldDepthBuffer; unsigned char *mNewItemBuffer; unsigned char *mOldItemBuffer; RenderTexture *mNewTexture; RenderTexture *mOldTexture; void ComputeLookAt(const float alpha, const float beta, Vector3 &eye, Vector3 &up, Vector3 &left); Preprocessor *mPreprocessor; protected: void SwitchRenderTextures(); void InitScene(const float alpha, const float beta); void InitScene(const SimpleRay &ray); void InitRenderTexture(RenderTexture *rt); GlRenderer *mRenderer; int mTexWidth; int mTexHeight; float mEpsilon; bool mSampleReverse; }; extern GlobalLinesRenderer *globalLinesRenderer; }; #endif