OpenWalnut  1.4.0
WGEViewerEffectImageOverlay.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WGEVIEWEREFFECTIMAGEOVERLAY_H
26 #define WGEVIEWEREFFECTIMAGEOVERLAY_H
27 
28 #include "core/common/WLogger.h"
29 
30 #include "WGEViewerEffect.h"
31 
32 class WGEViewer;
33 
34 /**
35  * Image Overlay Effect.
36  */
38 {
39 public:
40  /**
41  * Convenience typedef for a boost::shared_ptr< WGEViewerEffectImageOverlay >.
42  */
43  typedef osg::ref_ptr< WGEViewerEffectImageOverlay > SPtr;
44 
45  /**
46  * Convenience typedef for a boost::shared_ptr< const WGEViewerEffectImageOverlay >.
47  */
48  typedef osg::ref_ptr< const WGEViewerEffectImageOverlay > ConstSPtr;
49 
50  /**
51  * Default constructor.
52  */
54 
55  /**
56  * Destructor.
57  */
59 
60  /**
61  * Set the reference viewer. Needed as the effect itself is not able to query important camera states. This can be the viewer on which the
62  * effect is applied but does not have to. Important is a valid WGECamera, including a properly setup viewport.
63  *
64  * \param viewer the viewer in which the effect is used.
65  */
66  void setReferenceViewer( boost::shared_ptr< WGEViewer > viewer );
67 
68  /**
69  * Query current reference viewer.
70  *
71  * \return the reference viewer or NULL if none has been set.
72  */
73  const boost::shared_ptr< WGEViewer > getReferenceViewer() const;
74 
75 protected:
76  /**
77  * Width of the image in pixels.
78  */
79  osg::ref_ptr< osg::Uniform > m_overlayWidth;
80 
81  /**
82  * Height of the image in pixels.
83  */
84  osg::ref_ptr< osg::Uniform > m_overlayHeight;
85 
86  /**
87  * Width of the viewport in pixels.
88  */
89  osg::ref_ptr< osg::Uniform > m_viewportWidth;
90 
91  /**
92  * Height of the viewport in pixels.
93  */
94  osg::ref_ptr< osg::Uniform > m_viewportHeight;
95 
96  /**
97  * The viewer used to query the current reference cam.
98  */
99  boost::shared_ptr< WGEViewer > m_viewer;
100 
101  /**
102  * The filename to load.
103  */
104  WPropFilename m_image;
105 
106  /**
107  * The texture.
108  */
109  osg::ref_ptr< osg::Texture2D > m_logoTexture;
110 
111  /**
112  * If true, the update callback is forced to reload the image.
113  */
115 
116 private:
117  /**
118  * Update the uniforms and textures if needed
119  */
120  class Updater: public osg::NodeCallback
121  {
122  public:
123  /**
124  * Called before draw on update
125  *
126  * \param node the node
127  * \param nv the visitor calling this.
128  */
129  virtual void operator() ( osg::Node* node, osg::NodeVisitor* nv );
130  };
131  /**
132  * Update callback for the viewport.
133  */
134  osg::ref_ptr< Updater > m_updater;
135 };
136 
137 #endif // WGEVIEWEREFFECTIMAGEOVERLAY_H
138 
Base class for implementing basic fullscreen effects for the WGEViewer.
WGEViewerEffectImageOverlay()
Default constructor.
osg::ref_ptr< Updater > m_updater
Update callback for the viewport.
osg::ref_ptr< const WGEViewerEffectImageOverlay > ConstSPtr
Convenience typedef for a boost::shared_ptr< const WGEViewerEffectImageOverlay >. ...
virtual ~WGEViewerEffectImageOverlay()
Destructor.
osg::ref_ptr< osg::Uniform > m_viewportHeight
Height of the viewport in pixels.
boost::shared_ptr< WGEViewer > m_viewer
The viewer used to query the current reference cam.
osg::ref_ptr< osg::Uniform > m_viewportWidth
Width of the viewport in pixels.
const boost::shared_ptr< WGEViewer > getReferenceViewer() const
Query current reference viewer.
Update the uniforms and textures if needed.
Class for managing one view to the scene.
Definition: WGEViewer.h:75
void setReferenceViewer(boost::shared_ptr< WGEViewer > viewer)
Set the reference viewer.
virtual void operator()(osg::Node *node, osg::NodeVisitor *nv)
Called before draw on update.
osg::ref_ptr< osg::Uniform > m_overlayHeight
Height of the image in pixels.
WPropFilename m_image
The filename to load.
osg::ref_ptr< WGEViewerEffectImageOverlay > SPtr
Convenience typedef for a boost::shared_ptr< WGEViewerEffectImageOverlay >.
osg::ref_ptr< osg::Uniform > m_overlayWidth
Width of the image in pixels.
osg::ref_ptr< osg::Texture2D > m_logoTexture
The texture.
bool m_forceReload
If true, the update callback is forced to reload the image.