#ifndef __BEAM_H #define __BEAM_H #include #include "AxisAlignedBox3.h" #include "Statistics.h" namespace GtpVisibilityPreprocessor { class KdNode; class Intersectable; class Mesh; // the values need for rss tree update computed already inside the glrendererbuffer // not all of them need to be computed class BeamSampleStatistics: public StatisticsBase { public: enum {COMPUTE_PVS_SIZE, COMPUTE_RAY_CONTRIBUTIONS, COMPUTE_PVS_ENTROPY}; int flags; BeamSampleStatistics(): flags(COMPUTE_RAY_CONTRIBUTIONS) { Reset(); } float pvsSize; float rays; float rayContributions; float pvsEntropy; float rayLengthEntropy; float importance; float weightedRayContribution; void Reset() { pvsSize = 0; rays = 0; rayContributions = 0; pvsEntropy = 0; rayLengthEntropy = 0; importance = 0; } void Print(std::ostream &app) const; friend std::ostream &operator<<(std::ostream &s, const BeamSampleStatistics &stat) { stat.Print(s); return s; } }; class Beam { public: enum {STORE_KD_NODES=1, STORE_OBJECTS=2, STORE_VIEW_CELLS, VALID=8}; int mFlags; // list of nodes intersected by the frustum vector mKdNodes; // list of objects intersected by the frustum ObjectContainer mObjects; // view cells intersected by frustum ViewCellContainer mViewCells; // spatial box AxisAlignedBox3 mBox; // directional box (it is actually a 2D box - only x and y ranges are valid) // directional parametrization according to VssRay::GetDirParametrization AxisAlignedBox3 mDirBox; vector mPlanes; Mesh *mMesh; /** Constructs a beam from a spatial and a directional box. */ void Construct(const AxisAlignedBox3 &box, const AxisAlignedBox3 &dBox); /** Computes parameters for glFrustum. */ void ComputePerspectiveFrustum(float &left, float &right, float &bottom, float &top, float &near, float &far, const AxisAlignedBox3 &sceneBBox) const; /** Computes parameters for glOrtho. */ void ComputeOrthoFrustum(float &left, float &right, float &bottom, float &top, float &near, float &far, const AxisAlignedBox3 &sceneBBox) const; int ComputeIntersection(const AxisAlignedBox3 &box); Vector3 GetMainDirection() const; bool IsValid() { return mFlags & VALID; } bool SetValid() { return mFlags |= VALID; } Beam():mFlags(STORE_KD_NODES+STORE_OBJECTS), mKdNodes(0), mObjects(0), mViewCells(0), mMesh(NULL) { } ~Beam(); /** Creates beam mesh bounded at zfar. */ void CreateMesh(const float zfar); }; } #endif