28 #include "exceptions/WGEInitFailed.h"
29 #include "WGECamera.h"
33 m_DefProjMode( projectionMode )
36 getOrCreateStateSet()->setGlobalDefaults();
38 setViewport( 0, 0, width, height );
39 setClearColor( osg::Vec4( 0.9, 0.9, 0.9, 1.0 ) );
42 setCullingActive(
false );
43 setCullingMode( osg::CullSettings::NO_CULLING );
46 setComputeNearFarMode(
47 osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES
56 m_DefProjMode( ORTHOGRAPHIC )
59 getOrCreateStateSet()->setGlobalDefaults();
62 setCullingActive(
false );
63 setCullingMode( osg::CullSettings::NO_CULLING );
66 setComputeNearFarMode(
67 osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES
93 setProjectionMatrixAsOrtho( -120.0 * getViewport()->aspectRatio(), 120.0 * getViewport()->aspectRatio(),
94 -120.0, 120.0, -1000.0, +1000.0 );
95 setProjectionResizePolicy( HORIZONTAL );
98 setProjectionMatrixAsPerspective( 30.0, getViewport()->aspectRatio(), 1.0, 1000.0 );
99 setProjectionResizePolicy( WGECamera::HORIZONTAL );
103 setProjectionResizePolicy( WGECamera::FIXED );
107 setProjectionResizePolicy( WGECamera::FIXED );
110 throw WGEInitFailed( std::string(
"Unknown projection mode." ) );
118 setProjectionMatrixAsOrtho2D( 0.0, getViewport()->width(), 0.0, getViewport()->height() );
122 double aspectWH =
static_cast< double >( getViewport()->width() ) /
static_cast< double >( getViewport()->height() );
123 double aspectHW = 1.0 / aspectWH;
125 double w = aspectWH > aspectHW ? aspectWH : 1.0;
126 double h = aspectWH > aspectHW ? 1.0 : aspectHW;
130 setProjectionMatrixAsOrtho( -w, w, -h, h, 0.0, 1.0 );
void reset()
Resets the camera and activates the prior set defaults.
virtual ~WGECamera()
Destructor.
ProjectionMode m_DefProjMode
The projection mode used as default.
void setDefaultProjectionMode(ProjectionMode mode)
Sets the default projection mode used for cameras getting reset.
ProjectionMode
List of possible camera modes.
void resize()
Change camera parameters which should be changed on a resize.
WGECamera()
Constructor which sets defaults.
ProjectionMode getDefaultProjectionMode()
Returns the current default projection mode.
Exception thrown if initialization of the graphics engine fails.