source: trunk/VUT/GtpVisibilityPreprocessor/src/Beam.h @ 542

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