27 #include <osg/Texture2D>
28 #include <osgDB/ReadFile>
30 #include "../common/WPathHelper.h"
31 #include "../common/WProperties.h"
32 #include "../common/WLogger.h"
34 #include "WGEViewer.h"
36 #include "callbacks/WGEFunctorCallback.h"
37 #include "shaders/WGEShader.h"
38 #include "shaders/WGEPropertyUniform.h"
40 #include "WGEViewerEffectImageOverlay.h"
46 WPropDouble scale =
m_properties->addProperty(
"Scale",
"Scale the image in percent.", 50.0 );
48 scale->setMax( 200.0 );
50 WPropBool moveToTop =
m_properties->addProperty(
"Move to Top",
"Move the image to the top.",
false );
51 WPropBool moveToRight =
m_properties->addProperty(
"Move to Right",
"Move the image to the right.",
true );
53 WPropDouble opacity =
m_properties->addProperty(
"Opacity",
54 "Make the overlay transparent. Please be aware that the image itself might be transparent already.", 1.0 );
55 opacity->setMin( 0.0 );
56 opacity->setMax( 3.0 );
58 osg::ref_ptr< WGEShader > overlayShader =
new WGEShader(
"WGECameraOverlayTexture" );
59 overlayShader->apply(
m_geode );
67 m_logoTexture->setWrap( osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_BORDER );
68 m_logoTexture->setWrap( osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_BORDER );
71 m_overlayWidth =
new osg::Uniform(
"u_overlayWidth", static_cast< float >( 1 ) );
72 m_overlayHeight =
new osg::Uniform(
"u_overlayHeight", static_cast< float >( 1 ) );
76 m_viewportWidth =
new osg::Uniform(
"u_viewportWidth", static_cast< float >( 1024 ) );
77 m_viewportHeight =
new osg::Uniform(
"u_viewportHeight", static_cast< float >( 768 ) );
123 if( cam->getViewport() )
125 effect->
m_viewportWidth->set( static_cast< float >( cam->getViewport()->width() ) );
126 effect->
m_viewportHeight->set( static_cast< float >( cam->getViewport()->height() ) );
134 osg::Image* logoImage = osgDB::readImageFile( effect->
m_image->get(
true ).string() );
138 effect->
m_overlayWidth->set( static_cast< float >( logoImage->s() ) );
139 effect->
m_overlayHeight->set( static_cast< float >( logoImage->t() ) );
146 traverse( node, nv );
Base class for implementing basic fullscreen effects for the WGEViewer.
WGEViewerEffectImageOverlay()
Default constructor.
osg::ref_ptr< Updater > m_updater
Update callback for the viewport.
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.
Class encapsulating the OSG Program class for a more convenient way of adding and modifying shader...
Class for wrapping around the OSG Camera class.
Update the uniforms and textures if needed.
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.
static boost::filesystem::path getSharePath()
The path where shared files reside in.
osg::ref_ptr< osg::Geode > m_geode
The fullscreen quad.
WPropFilename m_image
The filename to load.
WProperties::SPtr m_properties
the properties of the object.
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.
osg::ref_ptr< osg::StateSet > m_state
The stateset of the cam.
boost::shared_ptr< WGEViewer > SPtr
Convenience typedef.