1
/* -*-c++-*- Producer - Copyright (C) 2001-2004 Don Burns
3
* This library is open source and may be redistributed and/or modified under
4
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5
* (at your option) any later version. The full license is in LICENSE file
6
* included with this distribution, and on the openscenegraph.org website.
8
* This library is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* OpenSceneGraph Public License for more details.
14
#ifndef PRODUCER_CAMERA_CONFIG
15
#define PRODUCER_CAMERA_CONFIG
19
#include <osg/Referenced>
21
#include <osgViewer/View>
31
#include "RenderSurface.h"
35
namespace osgProducer {
37
#define notImplemented {std::cout << __FILE__ << " " << __LINE__ << std::endl;}
38
class CameraGroup : public osg::Referenced {
42
ThreadPerRenderSurface,
45
static ThreadModel getDefaultThreadModel() { return SingleThreaded;}
49
class InputArea : public osg::Referenced {
51
void addRenderSurface(RenderSurface* s) { _rs.push_back(s); }
52
std::vector<osg::ref_ptr<RenderSurface> > _rs;
58
class CameraConfig : public osg::Referenced
63
void beginVisual( void );
65
void beginVisual( const char * name );
67
void setVisualSimpleConfiguration( void );
69
void setVisualByID( unsigned int id );
71
void addVisualAttribute( VisualChooser::AttributeName token, int param );
73
void addVisualAttribute( VisualChooser::AttributeName token );
75
void addVisualExtendedAttribute( unsigned int token );
77
void addVisualExtendedAttribute( unsigned int token, int param );
79
void endVisual( void );
81
VisualChooser *findVisual( const char *name );
83
bool parseFile( const std::string &file );
85
void beginRenderSurface( const char *name );
87
void setRenderSurfaceVisualChooser( const char *name );
89
void setRenderSurfaceVisualChooser( void );
91
void setRenderSurfaceWindowRectangle( int x, int y, unsigned int width, unsigned int height );
93
void setRenderSurfaceCustomFullScreenRectangle( int x, int y, unsigned int width, unsigned int height );
95
void setRenderSurfaceOverrideRedirect( bool flag );
97
void setRenderSurfaceHostName( const std::string &name );
99
void setRenderSurfaceDisplayNum( int n );
101
void setRenderSurfaceScreen( int n );
103
void setRenderSurfaceBorder( bool flag );
105
void setRenderSurfaceDrawableType( RenderSurface::DrawableType drawableType );
107
void setRenderSurfaceRenderToTextureMode( RenderSurface::RenderToTextureMode rttMode );
109
void setRenderSurfaceReadDrawable( const char *name );
111
void setRenderSurfaceInputRectangle( float x0, float x1, float y0, float y1 );
113
void endRenderSurface( void );
115
RenderSurface *findRenderSurface( const char *name );
117
unsigned int getNumberOfRenderSurfaces();
119
RenderSurface *getRenderSurface( unsigned int index );
121
void addCamera( std::string name, Camera *camera );
123
void beginCamera( std::string name );
125
void setCameraRenderSurface( const char *name );
127
void setCameraRenderSurface( void );
129
void setCameraProjectionRectangle( float x0, float x1, float y0, float y1 );
131
void setCameraProjectionRectangle( int x0, int x1, int y0, int y1 );
133
void setCameraOrtho( float left, float right, float bottom, float top, float nearClip, float farClip,
134
float xshear=0.0, float yshear=0.0 );
136
void setCameraPerspective( float hfov, float vfov, float nearClip, float farClip,
137
float xshear=0.0, float yshear=0.0 );
139
void setCameraFrustum( float left, float right, float bottom, float top, float nearClip, float farClip,
140
float xshear=0.0, float yshear=0.0 );
142
void setCameraLensShear( osg::Matrix::value_type xshear, osg::Matrix::value_type yshear );
144
void setCameraShareLens( bool shared );
146
void setCameraShareView( bool shared );
148
void setCameraClearColor( float r, float g, float b, float a );
150
void beginCameraOffset();
152
void rotateCameraOffset( osg::Matrix::value_type deg, osg::Matrix::value_type x, osg::Matrix::value_type y, osg::Matrix::value_type z );
154
void translateCameraOffset( osg::Matrix::value_type x, osg::Matrix::value_type y, osg::Matrix::value_type z );
156
void scaleCameraOffset( osg::Matrix::value_type x, osg::Matrix::value_type y, osg::Matrix::value_type z );
158
void shearCameraOffset( osg::Matrix::value_type shearx, osg::Matrix::value_type sheary );
160
void setCameraOffsetMultiplyMethod( Camera::Offset::MultiplyMethod method );
162
void endCameraOffset();
164
void endCamera( void );
166
Camera *findCamera( const char *name );
168
unsigned int getNumberOfCameras() const;
170
const Camera *getCamera( unsigned int n ) const;
172
Camera *getCamera( unsigned int n );
174
void beginInputArea();
176
void addInputAreaEntry( char *renderSurfaceName );
178
void endInputArea() ;
180
void setInputArea(InputArea *ia);
182
InputArea *getInputArea();
184
const InputArea *getInputArea() const;
186
void realize( void );
188
bool defaultConfig();
190
struct StereoSystemCommand
193
std::string _setStereoCommand;
194
std::string _restoreMonoCommand;
196
StereoSystemCommand(int screen, std::string setStereoCommand, std::string restoreMonoCommand ):
198
_setStereoCommand(setStereoCommand),
199
_restoreMonoCommand(restoreMonoCommand) {}
202
static std::string findFile( std::string );
204
void addStereoSystemCommand( int screen, std::string stereoCmd, std::string monoCmd );
206
const std::vector<StereoSystemCommand> &getStereoSystemCommands();
208
void setThreadModelDirective( CameraGroup::ThreadModel directive ) { _threadModelDirective = directive; }
209
CameraGroup::ThreadModel getThreadModelDirective() { return _threadModelDirective; }
213
virtual ~CameraConfig();
217
std::map <std::string, VisualChooser *> _visual_map;
218
osg::ref_ptr< VisualChooser >_current_visual_chooser;
219
bool _can_add_visual_attributes;
221
std::map <std::string, osg::ref_ptr<RenderSurface > > _render_surface_map;
222
osg::ref_ptr<RenderSurface> _current_render_surface;
223
bool _can_add_render_surface_attributes;
225
std::map <std::string, osg::ref_ptr< Camera > > _camera_map;
226
osg::ref_ptr<Camera> _current_camera;
227
bool _can_add_camera_attributes;
229
osg::ref_ptr< InputArea > _input_area;
230
bool _can_add_input_area_entries;
232
unsigned int getNumberOfScreens();
234
static bool fileExists(const std::string& );
236
osg::Matrix::value_type _offset_matrix[16];
237
osg::Matrix::value_type _offset_shearx, _offset_sheary;
239
std::vector<StereoSystemCommand> _stereoSystemCommands;
243
CameraGroup::ThreadModel _threadModelDirective;