Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
VisualImpactCalculatorOSG.h
1 #pragma once
2 //
3 // VisualImpactCalculatorOSG.h
4 //
5 // Framework for calculating visual impact of selected geometry in a scene.
6 // This code calculates the position of all the pixels that a particular set of
7 // drawing primitives has contributed to the frame buffer at the end of a rendering pass.
8 // i.e. All the pixels of a particular geometry or geometries that are visible in the current view.
9 // It then summates the solid angle that these pixels represent using Gauss Bonnett.
10 // This data can be used to give a quantatative assessment of the visual impact of the geometry.
11 //
12 // Contributed by Roger James (roger@beardandsandals.co.uk) and Virtual Outlooks Limited.
13 //
14 // Copyright (c) 2001-2012 Virtual Terrain Project
15 // Free for all uses, see license.txt for details.
16 //
17 
18 
19 class GDALRasterBand;
20 
22 {
23 public:
24  CVisualImpactCalculatorOSG() : m_bInitialised(false) {};
25  void AddVisualImpactContributor(osg::Node *pOsgNode);
26  void RemoveVisualImpactContributor(osg::Node *pOsgNode);
27  void SetVisualImpactTarget(const FPoint3 Target);
28  const FPoint3& GetVisualImpactTarget() const;
29  osg::Image* GetIntermediateImage() { return m_pIntermediateImage.get(); }
30  osg::Image* GetFinalImage() { return m_pFinalImage.get(); }
31  bool UsingLiveFrameBuffer();
32  float Calculate();
33  bool Plot(GDALRasterBand *pRasterBand, float fScaleFactor, double dXSampleInterval, double dYSampleInterval, bool progress_callback(int));
34  bool Initialise();
35 
36 protected:
37  float Implementation(bool bOneOffMode, GDALRasterBand *pRasterBand = NULL, float fScaleFactor = 1.0f, double dXSampleInterval = 1.0f, double dYSampleInterval = 1.0f, bool progress_callback(int) = NULL);
38  float InnerImplementation() const;
39  FPoint3 m_Target;
40  osg::Matrix m_ViewMatrix;
41  mutable osg::Matrix m_ProjectionMatrix;
42  mutable bool m_bUsingLiveFrameBuffer;
43  mutable bool m_bInitialised;
44  osg::ref_ptr<osg::Image> m_pIntermediateImage;
45  osg::ref_ptr<osg::Image> m_pFinalImage;
46  osg::ref_ptr<osg::Camera> m_pVisualImpactCamera;
47  typedef std::set<osg::Node*> VisualImpactContributors;
48  VisualImpactContributors m_VisualImpactContributors;
49 };