28 #include <osg/Texture2D>
29 #include <osgDB/ReadFile>
31 #include "../common/WLogger.h"
32 #include "../common/WPathHelper.h"
33 #include "../common/WProperties.h"
34 #include "WGEViewer.h"
35 #include "WGEViewerEffectImageOverlay.h"
36 #include "callbacks/WGEFunctorCallback.h"
37 #include "shaders/WGEPropertyUniform.h"
38 #include "shaders/WGEShader.h"
44 "Make the overlay blend out automatically after a given amount of time.",
true );
47 "Make the overlay blend out after this amount of time in seconds.", 4.0 );
52 WPropDouble scale =
m_properties->addProperty(
"Scale",
"Scale the image in percent.", 50.0 );
54 scale->setMax( 200.0 );
56 WPropBool moveToTop =
m_properties->addProperty(
"Move to Top",
"Move the image to the top.",
false );
57 WPropBool moveToRight =
m_properties->addProperty(
"Move to Right",
"Move the image to the right.",
true );
59 WPropDouble opacity =
m_properties->addProperty(
"Opacity",
60 "Make the overlay transparent. Please be aware that the image itself might be transparent already.", 1.0 );
61 opacity->setMin( 0.0 );
62 opacity->setMax( 3.0 );
64 osg::ref_ptr< WGEShader > overlayShader =
new WGEShader(
"WGECameraOverlayTexture" );
65 overlayShader->apply(
m_geode );
73 m_logoTexture->setWrap( osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_BORDER );
74 m_logoTexture->setWrap( osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_BORDER );
77 m_overlayWidth =
new osg::Uniform(
"u_overlayWidth",
static_cast< float >( 1 ) );
78 m_overlayHeight =
new osg::Uniform(
"u_overlayHeight",
static_cast< float >( 1 ) );
82 m_viewportWidth =
new osg::Uniform(
"u_viewportWidth",
static_cast< float >( 1024 ) );
83 m_viewportHeight =
new osg::Uniform(
"u_viewportHeight",
static_cast< float >( 768 ) );
101 osg::Uniform* animationTime(
112 m_geode->getOrCreateStateSet()->addUniform( animationTime );
146 if( cam->getViewport() )
148 effect->
m_viewportWidth->set(
static_cast< float >( cam->getViewport()->width() ) );
149 effect->
m_viewportHeight->set(
static_cast< float >( cam->getViewport()->height() ) );
157 osg::Image* logoImage = osgDB::readImageFile( effect->
m_image->get(
true ).string() );
161 effect->
m_overlayWidth->set(
static_cast< float >( logoImage->s() ) );
162 effect->
m_overlayHeight->set(
static_cast< float >( logoImage->t() ) );
169 traverse( node, nv );
Class for wrapping around the OSG Camera class.
This is a uniform callback setting the uniform to the current time in milliseconds,...
Class encapsulating the OSG Program class for a more convenient way of adding and modifying shader.
Update the uniforms and textures if needed.
virtual void operator()(osg::Node *node, osg::NodeVisitor *nv)
Called before draw on update.
WPropBool m_blendOutAuto
Enable to blend out the overlay.
osg::ref_ptr< osg::Uniform > m_overlayWidth
Width of the image in pixels.
osg::ref_ptr< osg::Uniform > m_viewportHeight
Height of the viewport in pixels.
osg::ref_ptr< osg::Texture2D > m_logoTexture
The texture.
const std::shared_ptr< WGEViewer > getReferenceViewer() const
Query current reference viewer.
osg::ref_ptr< osg::Uniform > m_viewportWidth
Width of the viewport in pixels.
WPropFilename m_image
The filename to load.
WPropDouble m_blendOutDuration
Time to blend out in seconds.
std::shared_ptr< WGEViewer > m_viewer
The viewer used to query the current reference cam.
WGEViewerEffectImageOverlay()
Default constructor.
virtual ~WGEViewerEffectImageOverlay()
Destructor.
osg::ref_ptr< osg::Uniform > m_overlayHeight
Height of the image in pixels.
osg::ref_ptr< Updater > m_updater
Update callback for the viewport.
osg::ref_ptr< WGEShaderAnimationCallback > m_animationCallback
Animate blend out sequence.
bool m_forceReload
If true, the update callback is forced to reload the image.
void setReferenceViewer(std::shared_ptr< WGEViewer > viewer)
Set the reference viewer.
Base class for implementing basic fullscreen effects for the WGEViewer.
osg::ref_ptr< osg::StateSet > m_state
The stateset of the cam.
osg::ref_ptr< osg::Geode > m_geode
The fullscreen quad.
std::shared_ptr< WGEViewer > SPtr
Convenience typedef.
WProperties::SPtr m_properties
the properties of the object.
static boost::filesystem::path getSharePath()
The path where shared files reside in.