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 *
RevLine 
[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]8using namespace std;
9
10class KdNode;
11class Intersectable;
[540]12class Mesh;
[504]13
[531]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 
[512]56class Beam {
[504]57 
58public:                 
[532]59  enum {STORE_KD_NODES=1, STORE_OBJECTS=2, STORE_VIEW_CELLS, VALID=8};
[504]60  int mFlags;
61 
62  // list of nodes intersected by the frustum
63  vector<KdNode *> mKdNodes;
[513]64  // list of objects intersected by the frustum
65  ObjectContainer mObjects;
66  // view cells intersected by frustum
67  ViewCellContainer mViewCells;
[504]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;
[507]76
[540]77  Mesh *mMesh;
[511]78   
[540]79  /** Constructs a beam from a spatial and a directional box.
80  */
[511]81  void Construct(const AxisAlignedBox3 &box,
[540]82                             const AxisAlignedBox3 &dBox);
[511]83 
[540]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;
[511]90
[542]91  /** Computes parameters for glOrtho.
[540]92  */
93  void ComputeOrthoFrustum(float &left, float &right,
94                                                   float &bottom, float &top,
95                                                   float &near, float &far,
96                                                   const AxisAlignedBox3 &sceneBBox) const;
97
[522]98  int ComputeIntersection(const AxisAlignedBox3 &box);
99
[525]100  Vector3 GetMainDirection() const;
101
[507]102  bool IsValid() { return mFlags & VALID; }
103  bool SetValid() { return mFlags |= VALID; }
104
[540]105  Beam():mFlags(STORE_KD_NODES+STORE_OBJECTS), mKdNodes(0), mObjects(0), mViewCells(0), mMesh(NULL)
[504]106  {
107  }
[540]108
[542]109  ~Beam();
110
111  /** Creates beam mesh bounded at zfar.
112  */
[540]113  void CreateMesh(const float zfar);
[504]114};
115
116
117#endif
Note: See TracBrowser for help on using the repository browser.