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 );