[1941] | 1 | #ifndef __GLOBALLINESRENDERER_H
|
---|
| 2 | #define __GLOBALLINESRENDERER_H
|
---|
| 3 |
|
---|
| 4 | #include "common.h"
|
---|
| 5 | #include "Containers.h"
|
---|
[1953] | 6 | #include "Vector3.h"
|
---|
[1941] | 7 |
|
---|
[1953] | 8 |
|
---|
[1941] | 9 | class RenderTexture;
|
---|
| 10 |
|
---|
| 11 | namespace GtpVisibilityPreprocessor {
|
---|
| 12 |
|
---|
| 13 | class Beam;
|
---|
| 14 | class Intersectable;
|
---|
| 15 | class Preprocessor;
|
---|
| 16 | class GlRenderer;
|
---|
[1968] | 17 | struct SimpleRay;
|
---|
[1941] | 18 |
|
---|
| 19 | struct VssRayContainer;
|
---|
| 20 |
|
---|
| 21 | class GlobalLinesRenderer
|
---|
| 22 | {
|
---|
| 23 | public:
|
---|
[1964] | 24 |
|
---|
| 25 | GlobalLinesRenderer(Preprocessor *preprocessor,
|
---|
[1968] | 26 | const int texHeight,
|
---|
| 27 | const int mTexWidth,
|
---|
| 28 | const float eps,
|
---|
| 29 | const int maxDepth,
|
---|
| 30 | const bool sampleReverse);
|
---|
[1964] | 31 |
|
---|
[1968] | 32 | GlobalLinesRenderer(Preprocessor *preprocessor);
|
---|
[1941] | 33 |
|
---|
| 34 | ~GlobalLinesRenderer();
|
---|
| 35 |
|
---|
[1964] | 36 | /** Casts global lines in the angle specified by alpha and
|
---|
| 37 | beta.
|
---|
| 38 | @returns Computed samples in the container rays
|
---|
| 39 | */
|
---|
| 40 | void CastGlobalLines(const float alpha,
|
---|
| 41 | const float beta,
|
---|
| 42 | VssRayContainer &rays);
|
---|
[1941] | 43 |
|
---|
[1968] | 44 | /** Casts global lines using the given ray as origin and
|
---|
| 45 | direction vector.
|
---|
| 46 | @returns Computed samples in the container rays
|
---|
| 47 | */
|
---|
| 48 | void CastGlobalLines(const SimpleRay &ray,
|
---|
| 49 | VssRayContainer &rays);
|
---|
| 50 |
|
---|
| 51 |
|
---|
[1941] | 52 | void InitGl();
|
---|
| 53 |
|
---|
| 54 | /** Computes rays from information gained with hw sampling
|
---|
| 55 | */
|
---|
| 56 | void ComputeRays(Intersectable *sourceObj, VssRayContainer &rays);
|
---|
| 57 |
|
---|
| 58 | float GetPixelError(int &pvsSize);
|
---|
| 59 |
|
---|
| 60 | int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const;
|
---|
| 61 |
|
---|
| 62 | void RenderObject(Intersectable *obj);
|
---|
[1953] | 63 |
|
---|
| 64 |
|
---|
| 65 | /** Draws the geometry for one pass.
|
---|
| 66 | */
|
---|
| 67 | void DrawGeometry();
|
---|
[1960] | 68 | void Run();
|
---|
| 69 | void GrabDepthBuffer(float *data, RenderTexture *rt);
|
---|
| 70 | void GrabItemBuffer(unsigned char *data, RenderTexture *rt);
|
---|
[1964] | 71 | void ApplyDepthPeeling(VssRayContainer &rays);
|
---|
[1960] | 72 | void ExportDepthBuffer();
|
---|
| 73 | void ExportItemBuffer();
|
---|
[1968] | 74 | bool ProcessDepthBuffer(VssRayContainer &vssRays,
|
---|
[1964] | 75 | const bool oldBufferInitialised,
|
---|
| 76 | const int pass);
|
---|
| 77 |
|
---|
[1960] | 78 | void DisplayBuffer(const bool isDepth);
|
---|
| 79 |
|
---|
[1963] | 80 | bool ClipToViewSpaceBox(const Vector3 &origin,
|
---|
| 81 | const Vector3 &termination,
|
---|
| 82 | Vector3 &clippedOrigin,
|
---|
| 83 | Vector3 &clippedTermination);
|
---|
| 84 |
|
---|
[1960] | 85 | Intersectable *ExtractSamplePoint(float *depthBuffer,
|
---|
| 86 | unsigned char *itemBuffer,
|
---|
| 87 | const int x,
|
---|
| 88 | const int y,
|
---|
| 89 | Vector3 &hitPoint,
|
---|
| 90 | const bool isFrontBuffer) const;
|
---|
[1953] | 91 |
|
---|
[1960] | 92 | void Visualize(const VssRayContainer &vssRays);
|
---|
| 93 |
|
---|
[1953] | 94 | int mMaxDepth;
|
---|
[1968] | 95 |
|
---|
[1953] | 96 | Vector3 mEyeVec;
|
---|
| 97 | Vector3 mLeftVec;
|
---|
| 98 | Vector3 mUpVec;
|
---|
[1968] | 99 | Vector3 mTermination;
|
---|
| 100 |
|
---|
[1953] | 101 | float mFar;
|
---|
| 102 | float mNear;
|
---|
[1960] | 103 | float mWidth;
|
---|
[1953] | 104 |
|
---|
[1958] | 105 | Vector3 mViewPoint;
|
---|
| 106 |
|
---|
[1953] | 107 | float *mNewDepthBuffer;
|
---|
| 108 | float *mOldDepthBuffer;
|
---|
[1968] | 109 |
|
---|
[1960] | 110 | unsigned char *mNewItemBuffer;
|
---|
| 111 | unsigned char *mOldItemBuffer;
|
---|
| 112 |
|
---|
| 113 | RenderTexture *mNewTexture;
|
---|
[1953] | 114 | RenderTexture *mOldTexture;
|
---|
[1958] | 115 |
|
---|
| 116 | void ComputeLookAt(const float alpha,
|
---|
| 117 | const float beta,
|
---|
| 118 | Vector3 &eye,
|
---|
| 119 | Vector3 &up,
|
---|
[1964] | 120 | Vector3 &left);
|
---|
[1968] | 121 |
|
---|
[1941] | 122 | protected:
|
---|
| 123 |
|
---|
| 124 | void SwitchRenderTextures();
|
---|
| 125 |
|
---|
[1964] | 126 | void InitScene(const float alpha, const float beta);
|
---|
[1968] | 127 | void InitScene(const SimpleRay &ray);
|
---|
[1941] | 128 |
|
---|
[1968] | 129 | void InitRenderTexture(RenderTexture *rt);
|
---|
| 130 |
|
---|
[1941] | 131 | Preprocessor *mPreprocessor;
|
---|
| 132 |
|
---|
| 133 | GlRenderer *mRenderer;
|
---|
[1964] | 134 |
|
---|
| 135 | int mTexWidth;
|
---|
| 136 | int mTexHeight;
|
---|
| 137 | float mEpsilon;
|
---|
[1968] | 138 |
|
---|
| 139 | bool mSampleReverse;
|
---|
[1941] | 140 | };
|
---|
| 141 |
|
---|
| 142 | extern GlobalLinesRenderer *globalLinesRenderer;
|
---|
| 143 |
|
---|
| 144 | };
|
---|
| 145 |
|
---|
| 146 | #endif
|
---|
| 147 |
|
---|