[505] | 1 | #ifndef __BEAM_H
|
---|
| 2 | #define __BEAM_H
|
---|
[504] | 3 |
|
---|
| 4 | #include <vector>
|
---|
[511] | 5 | #include "AxisAlignedBox3.h"
|
---|
[531] | 6 | #include "Statistics.h"
|
---|
[511] | 7 |
|
---|
[504] | 8 | using namespace std;
|
---|
| 9 |
|
---|
[863] | 10 | namespace GtpVisibilityPreprocessor {
|
---|
| 11 |
|
---|
[504] | 12 | class KdNode;
|
---|
| 13 | class Intersectable;
|
---|
[540] | 14 | class Mesh;
|
---|
[504] | 15 |
|
---|
[860] | 16 |
|
---|
[531] | 17 | // the values need for rss tree update computed already inside the glrendererbuffer
|
---|
| 18 | // not all of them need to be computed
|
---|
| 19 | class BeamSampleStatistics: public StatisticsBase
|
---|
| 20 | {
|
---|
| 21 | public:
|
---|
| 22 | enum {COMPUTE_PVS_SIZE, COMPUTE_RAY_CONTRIBUTIONS, COMPUTE_PVS_ENTROPY};
|
---|
| 23 | int flags;
|
---|
| 24 |
|
---|
| 25 | BeamSampleStatistics(): flags(COMPUTE_RAY_CONTRIBUTIONS)
|
---|
| 26 | {
|
---|
| 27 | Reset();
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | float pvsSize;
|
---|
| 31 | float rays;
|
---|
| 32 | float rayContributions;
|
---|
| 33 | float pvsEntropy;
|
---|
| 34 | float rayLengthEntropy;
|
---|
| 35 | float importance;
|
---|
| 36 |
|
---|
| 37 | float weightedRayContribution;
|
---|
| 38 |
|
---|
| 39 | void Reset()
|
---|
| 40 | {
|
---|
| 41 | pvsSize = 0;
|
---|
| 42 | rays = 0;
|
---|
| 43 | rayContributions = 0;
|
---|
| 44 | pvsEntropy = 0;
|
---|
| 45 | rayLengthEntropy = 0;
|
---|
| 46 | importance = 0;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | void Print(ostream &app) const;
|
---|
| 50 |
|
---|
| 51 | friend ostream &operator<<(ostream &s, const BeamSampleStatistics &stat)
|
---|
| 52 | {
|
---|
| 53 | stat.Print(s);
|
---|
| 54 | return s;
|
---|
| 55 | }
|
---|
| 56 | };
|
---|
| 57 |
|
---|
| 58 |
|
---|
[512] | 59 | class Beam {
|
---|
[504] | 60 |
|
---|
| 61 | public:
|
---|
[532] | 62 | enum {STORE_KD_NODES=1, STORE_OBJECTS=2, STORE_VIEW_CELLS, VALID=8};
|
---|
[504] | 63 | int mFlags;
|
---|
| 64 |
|
---|
| 65 | // list of nodes intersected by the frustum
|
---|
| 66 | vector<KdNode *> mKdNodes;
|
---|
[513] | 67 | // list of objects intersected by the frustum
|
---|
| 68 | ObjectContainer mObjects;
|
---|
| 69 | // view cells intersected by frustum
|
---|
| 70 | ViewCellContainer mViewCells;
|
---|
[504] | 71 |
|
---|
| 72 | // spatial box
|
---|
| 73 | AxisAlignedBox3 mBox;
|
---|
| 74 | // directional box (it is actually a 2D box - only x and y ranges are valid)
|
---|
| 75 | // directional parametrization according to VssRay::GetDirParametrization
|
---|
| 76 | AxisAlignedBox3 mDirBox;
|
---|
| 77 |
|
---|
| 78 | vector<Plane3> mPlanes;
|
---|
[507] | 79 |
|
---|
[540] | 80 | Mesh *mMesh;
|
---|
[511] | 81 |
|
---|
[540] | 82 | /** Constructs a beam from a spatial and a directional box.
|
---|
| 83 | */
|
---|
[511] | 84 | void Construct(const AxisAlignedBox3 &box,
|
---|
[540] | 85 | const AxisAlignedBox3 &dBox);
|
---|
[511] | 86 |
|
---|
[540] | 87 | /** Computes parameters for glFrustum.
|
---|
| 88 | */
|
---|
| 89 | void ComputePerspectiveFrustum(float &left, float &right,
|
---|
| 90 | float &bottom, float &top,
|
---|
| 91 | float &near, float &far,
|
---|
| 92 | const AxisAlignedBox3 &sceneBBox) const;
|
---|
[511] | 93 |
|
---|
[542] | 94 | /** Computes parameters for glOrtho.
|
---|
[540] | 95 | */
|
---|
| 96 | void ComputeOrthoFrustum(float &left, float &right,
|
---|
| 97 | float &bottom, float &top,
|
---|
| 98 | float &near, float &far,
|
---|
| 99 | const AxisAlignedBox3 &sceneBBox) const;
|
---|
| 100 |
|
---|
[522] | 101 | int ComputeIntersection(const AxisAlignedBox3 &box);
|
---|
| 102 |
|
---|
[525] | 103 | Vector3 GetMainDirection() const;
|
---|
| 104 |
|
---|
[507] | 105 | bool IsValid() { return mFlags & VALID; }
|
---|
| 106 | bool SetValid() { return mFlags |= VALID; }
|
---|
| 107 |
|
---|
[540] | 108 | Beam():mFlags(STORE_KD_NODES+STORE_OBJECTS), mKdNodes(0), mObjects(0), mViewCells(0), mMesh(NULL)
|
---|
[504] | 109 | {
|
---|
| 110 | }
|
---|
[540] | 111 |
|
---|
[542] | 112 | ~Beam();
|
---|
| 113 |
|
---|
| 114 | /** Creates beam mesh bounded at zfar.
|
---|
| 115 | */
|
---|
[540] | 116 | void CreateMesh(const float zfar);
|
---|
[504] | 117 | };
|
---|
| 118 |
|
---|
[860] | 119 | }
|
---|
[504] | 120 |
|
---|
| 121 | #endif
|
---|