source: GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h @ 1969

Revision 1969, 3.1 KB checked in by mattausch, 17 years ago (diff)

global lines nearly useable!

Line 
1#ifndef __GLOBALLINESRENDERER_H
2#define __GLOBALLINESRENDERER_H
3
4#include "common.h"
5#include "Containers.h"
6#include "Vector3.h"
7
8
9class RenderTexture;
10
11namespace GtpVisibilityPreprocessor {
12
13class Beam;
14class Intersectable;
15class Preprocessor;
16class GlRenderer;
17struct SimpleRay;
18
19struct VssRayContainer;
20
21class GlobalLinesRenderer
22{
23public:
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 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        /** Draws the geometry for one pass.
63        */
64        void DrawGeometry();
65        void Run();
66        void GrabDepthBuffer(float *data, RenderTexture *rt);
67        void GrabItemBuffer(unsigned char *data, RenderTexture *rt);
68        int ApplyDepthPeeling(VssRayContainer &rays);
69        void ExportDepthBuffer();
70        void ExportItemBuffer();
71        bool ProcessDepthBuffer(VssRayContainer &vssRays,
72                                                        const bool oldBufferInitialised,
73                                                        const int pass);
74
75        void DisplayBuffer(const bool isDepth);
76       
77        bool ClipToViewSpaceBox(const Vector3 &origin,
78                                                        const Vector3 &termination,
79                                                        Vector3 &clippedOrigin,
80                                                        Vector3 &clippedTermination);
81
82        Intersectable *ExtractSamplePoint(float *depthBuffer,
83                                                                          unsigned char *itemBuffer,
84                                                                          const int x,
85                                                                          const int y,
86                                                                          Vector3 &hitPoint,
87                                                                          const bool isFrontBuffer) const;
88
89        void Visualize(const VssRayContainer &vssRays);
90
91        int mMaxDepth;
92       
93        Vector3 mEyeVec;
94        Vector3 mLeftVec;
95        Vector3 mUpVec;
96        Vector3 mTermination;
97
98        float mFar;
99        float mNear;
100        float mWidth;
101
102        Vector3 mViewPoint;
103
104        float *mNewDepthBuffer;
105        float *mOldDepthBuffer;
106
107        unsigned char *mNewItemBuffer;
108        unsigned char *mOldItemBuffer;
109       
110        RenderTexture *mNewTexture;
111        RenderTexture *mOldTexture;
112
113        void ComputeLookAt(const float alpha,
114                                           const float beta,
115                                           Vector3 &eye,
116                                           Vector3 &up,
117                                           Vector3 &left);
118
119        Preprocessor *mPreprocessor;
120
121protected:
122
123        void SwitchRenderTextures();
124
125        void InitScene(const float alpha, const float beta);
126        void InitScene(const SimpleRay &ray);
127
128        void InitRenderTexture(RenderTexture *rt);
129
130       
131
132        GlRenderer *mRenderer;
133
134        int mTexWidth;
135        int mTexHeight;
136        float mEpsilon;
137
138        bool mSampleReverse;
139};
140
141extern GlobalLinesRenderer *globalLinesRenderer;
142
143};
144
145#endif
146
Note: See TracBrowser for help on using the repository browser.