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