OpenWalnut  1.5.0dev
WGEViewerEffectHorizon.cpp
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 #include "../common/WProperties.h"
26 
27 #include "shaders/WGEShader.h"
28 #include "shaders/WGEPropertyUniform.h"
29 
30 #include "WGEViewerEffectHorizon.h"
31 
33  WGEViewerEffect( "Horizon Background", "Configurable horizon background effect." )
34 {
35  WPropColor bottom1Color = m_properties->addProperty( "First Bottom Color", "Bottom color gradient: first color.",
36  WColor( 1.00, 1.00, 1.00, 1.00 ) );
37  WPropColor bottom2Color = m_properties->addProperty( "Second Bottom Color", "Bottom color gradient: second color.",
38  WColor( 0.82, 0.82, 0.82, 1.00 ) );
39  WPropColor top1Color = m_properties->addProperty( "First Top Color", "Top color gradient: first color.",
40  WColor( 0.85, 0.85, 0.85, 1.0 ) );
41  WPropColor top2Color = m_properties->addProperty( "Second Top Color", "Top color gradient: second color.",
42  WColor( 0.95, 0.95, 0.95, 0.95 ) );
43 
44  WPropDouble horizonLine = m_properties->addProperty( "Horizon in %", "Horizon line in percent.", 33.0 );
45  horizonLine->setMin( 0.0 );
46  horizonLine->setMax( 100.0 );
47 
48  m_state->addUniform( new WGEPropertyUniform< WPropDouble >( "u_horizon", horizonLine ) );
49  m_state->addUniform( new WGEPropertyUniform< WPropColor >( "u_bottom1Color", bottom1Color ) );
50  m_state->addUniform( new WGEPropertyUniform< WPropColor >( "u_bottom2Color", bottom2Color ) );
51  m_state->addUniform( new WGEPropertyUniform< WPropColor >( "u_top1Color", top1Color ) );
52  m_state->addUniform( new WGEPropertyUniform< WPropColor >( "u_top2Color", top2Color ) );
53 
54  // default cam is a post render cam. The Horizon needs to be done BEFORE everything else
55  setRenderOrder( WGECamera::NESTED_RENDER, -1000 );
56 
57  osg::ref_ptr< WGEShader > horizonShader = new WGEShader( "WGECameraHorizon" );
58  horizonShader->apply( m_geode );
59 }
60 
62 {
63  // cleanup
64 }
65 
Class implementing a uniform which can be controlled by a property instance.
Class encapsulating the OSG Program class for a more convenient way of adding and modifying shader.
Definition: WGEShader.h:48
WGEViewerEffectHorizon()
Default constructor.
virtual ~WGEViewerEffectHorizon()
Destructor.
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.
WProperties::SPtr m_properties
the properties of the object.
Definition: WObjectNDIP.h:99