28 #include <osg/ShapeDrawable>
32 #include <osgGA/FlightManipulator>
33 #include <osgGA/DriveManipulator>
34 #include <osgGA/UFOManipulator>
35 #include <osgGA/KeySwitchMatrixManipulator>
36 #include <osgGA/StateSetManipulator>
37 #include <osgGA/AnimationPathManipulator>
38 #include <osgGA/TerrainManipulator>
39 #include <osgViewer/ViewerEventHandlers>
40 #include <osgViewer/View>
42 #include <osgDB/ReadFile>
44 #include "exceptions/WGEInitFailed.h"
45 #include "WGE2DManipulator.h"
46 #include "WGEGroupNode.h"
47 #include "WGENoOpManipulator.h"
48 #include "WGEZoomTrackballManipulator.h"
49 #include "WPickHandler.h"
51 #include "../common/WConditionOneShot.h"
52 #include "../common/WThreadedRunner.h"
54 #include "WGEViewer.h"
56 WGEViewer::WGEViewer( std::string name, osg::ref_ptr<osg::Referenced> wdata,
int x,
int y,
int width,
int height,
59 boost::enable_shared_from_this<
WGEViewer >(),
64 m_inAnimationMode( false ),
71 #ifdef WGEMODE_MULTITHREADED
72 m_View = osg::ref_ptr<osgViewer::View>(
new osgViewer::View );
75 m_View = osg::ref_ptr<osgViewer::Viewer>(
new osgViewer::Viewer );
78 osg::ref_ptr< WGECamera > cam(
new WGECamera( width, height, projectionMode ) );
79 m_View->setCamera( cam );
84 #ifdef WGEMODE_MULTITHREADED
90 switch( projectionMode )
92 case( WGECamera::ORTHOGRAPHIC ):
95 if( name != std::string(
"Main View" ) )
97 case( WGECamera::PERSPECTIVE ):
101 m_View->setLightingMode( osg::View::HEADLIGHT );
104 case( WGECamera::TWO_D ):
107 case( WGECamera::TWO_D_UNIT ):
112 throw WGEInitFailed( std::string(
"Unknown projection mode" ) );
116 m_View->addEventHandler(
new osgViewer::StatsHandler );
120 m_bgColor =
m_properties->addProperty(
"Background Color",
"Default background color if not overwritten by a camera effect.",
123 m_throwing =
m_properties->addProperty(
"Throwing",
"If checked, you can grab the scene and throw it. It will keep the rotation impulse.",
127 WPropGroup effects =
m_properties->addPropertyGroup(
"Camera Effects",
"Several effects that to not depend on any scene content." );
133 m_View->setSceneData(
m_scene );
145 throw WGEInitFailed( std::string(
"Initialization of WGEViewer failed" ) );
155 #ifdef WGEMODE_SINGLETHREADED
156 osg::ref_ptr<osgViewer::Viewer>
158 osg::ref_ptr<osgViewer::View>
169 m_View->setCameraManipulator( manipulator );
175 return m_View->getCameraManipulator();
180 m_View->setCamera( camera );
234 #ifdef WGEMODE_SINGLETHREADED
241 m_View->getEventQueue()->windowResize( 0, 0, width, height );
246 m_View->getCamera()->setViewport( 0, 0, width, height );
305 const GLubyte* vendor = glGetString( GL_VENDOR );
306 m_vendor =
reinterpret_cast< const char*
>( vendor );
309 m_camera->setInitialDrawCallback( NULL );
337 m_View->setCameraManipulator( anim );
393 getVignette()->setEnabledByDefault( activeByDefault );