Renamed osgViewer::Config osgViewer::ViewConfig and moved it's declaration into include/osgViewer.

This commit is contained in:
Robert Osfield
2013-05-16 10:11:06 +00:00
parent e3ed763c15
commit 3b6c2b636a
19 changed files with 113 additions and 3892 deletions

View File

@@ -1,276 +0,0 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGVIEWER_CONFIG
#define OSGVIEWER_CONFIG 1
#include <osg/DisplaySettings>
#include <osg/Geometry>
#include <osg/Image>
#include <osgViewer/Export>
namespace osgViewer {
// forward declare
class View;
/** Config base class for encapsulating view configuration.*/
class OSGVIEWER_EXPORT Config : public osg::Object
{
public:
Config() {}
Config(const Config& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : osg::Object(rhs,copyop) {}
META_Object(osgViewer,Config);
/** configure method that is overridden by Config subclasses.*/
virtual void configure(osgViewer::View& /*view*/) const {}
virtual osg::DisplaySettings* getActiveDisplaySetting(osgViewer::View& view) const;
};
#if 0
class OSGVIEWER_EXPORT ViewAcrossAllScreens : public Config
{
public:
ViewAcrossAllScreens() {}
ViewAcrossAllScreens(const ViewAcrossAllScreens& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY): Config(rhs,copyop) {}
META_Object(osgViewer,ViewAcrossAllScreens);
virtual void configure(osgViewer::View& view) const;
};
/** single camera on a single window.*/
class OSGVIEWER_EXPORT ViewInWindow : public Config
{
public:
ViewInWindow():_x(0),_y(0),_width(-1),_height(-1),_screenNum(0) {}
ViewInWindow(int x, int y, int width, int height, unsigned int screenNum=0):_x(x),_y(y),_width(width),_height(height),_screenNum(screenNum) {}
ViewInWindow(const ViewInWindow& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):Config(rhs,copyop), _x(rhs._x),_y(rhs._y),_width(rhs._width),_height(rhs._height),_screenNum(rhs._screenNum) {}
META_Object(osgViewer,ViewInWindow);
virtual void configure(osgViewer::View& view) const;
void setX(int x) { _x = x; }
int getX() const { return _x; }
void setY(int y) { _y = y; }
int getY() const { return _y; }
void setWidth(int w) { _width = w; }
int getWidth() const { return _width; }
void setHeight(int h) { _height = h; }
int getHeight() const { return _height; }
void setScreenNum(unsigned int sn) { _screenNum = sn; }
unsigned int getScreenNum() const { return _screenNum; }
protected:
int _x, _y, _width, _height;
unsigned int _screenNum;
};
/** single camera associated with a single full screen GraphicsWindow.*/
class OSGVIEWER_EXPORT ViewOnSingleScreen : public Config
{
public:
ViewOnSingleScreen(unsigned int screenNum=0) : _screenNum(screenNum) {}
ViewOnSingleScreen(const ViewOnSingleScreen& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : Config(rhs,copyop), _screenNum(rhs._screenNum) {}
META_Object(osgViewer,ViewOnSingleScreen);
virtual void configure(osgViewer::View& view) const;
void setScreenNum(unsigned int sn) { _screenNum = sn; }
unsigned int getScreenNum() const { return _screenNum; }
protected:
unsigned int _screenNum;
};
/** spherical display using 6 slave cameras rendering the 6 sides of a cube map, and 7th camera doing distortion correction to present on a spherical display.*/
class OSGVIEWER_EXPORT ViewFor3DSphericalDisplay : public Config
{
public:
ViewFor3DSphericalDisplay(double radius=1.0, double collar=0.45, unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd()):
_radius(radius),
_collar(collar),
_screenNum(screenNum),
_intensityMap(intensityMap),
_projectorMatrix(projectorMatrix) {}
ViewFor3DSphericalDisplay(const ViewFor3DSphericalDisplay& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
Config(rhs,copyop),
_radius(rhs._radius),
_collar(rhs._collar),
_screenNum(rhs._screenNum),
_intensityMap(rhs._intensityMap),
_projectorMatrix(rhs._projectorMatrix) {}
META_Object(osgViewer,ViewFor3DSphericalDisplay);
virtual void configure(osgViewer::View& view) const;
void setRadius(double r) { _radius = r; }
double getRadius() const { return _radius; }
void setCollar(double r) { _collar = r; }
double getCollar() const { return _collar; }
void setScreenNum(unsigned int n) { _screenNum = n; }
unsigned int getScreenNum() const { return _screenNum; }
void setIntensityMap(osg::Image* im) { _intensityMap = im; }
const osg::Image* getIntensityMap() const { return _intensityMap.get(); }
void setProjectionMatrix(const osg::Matrixd& m) { _projectorMatrix = m; }
const osg::Matrixd& getProjectionMatrix() const { return _projectorMatrix; }
protected:
osg::Geometry* create3DSphericalDisplayDistortionMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector, double sphere_radius, double collar_radius,osg::Image* intensityMap, const osg::Matrix& projectorMatrix) const;
double _radius;
double _collar;
unsigned int _screenNum;
osg::ref_ptr<osg::Image> _intensityMap;
osg::Matrixd _projectorMatrix;
};
/** spherical display by rendering main scene to a panoramic 2:1 texture and then doing distortion correction to present onto a spherical display.*/
class OSGVIEWER_EXPORT ViewForPanoramicSphericalDisplay : public Config
{
public:
ViewForPanoramicSphericalDisplay(double radius=1.0, double collar=0.45, unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd());
ViewForPanoramicSphericalDisplay(const ViewForPanoramicSphericalDisplay& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgViewer,ViewOnSingleScreen);
virtual void configure(osgViewer::View& view) const;
void setRadius(double r) { _radius = r; }
double getRadius() const { return _radius; }
void setCollar(double r) { _collar = r; }
double getCollar() const { return _collar; }
void setScreenNum(unsigned int n) { _screenNum = n; }
unsigned int getScreenNum() const { return _screenNum; }
void setIntensityMap(osg::Image* im) { _intensityMap = im; }
const osg::Image* getIntensityMap() const { return _intensityMap; }
void setProjectionMatrix(const osg::Matrixd& m) { _projectorMatrix = m; }
const osg::Matrixd& getProjectionMatrix() const { return _projectorMatrix; }
protected:
double _radius;
double _collar;
unsigned int _screenNum;
osg::ref_ref<osg::Image> _intensityMap;
osg::Matrixd _projectorMatrix;
};
/** autostereoscopic Philips WoWvx display.*/
class OSGVIEWER_EXPORT ViewForWoWVxDisplay : public Config
{
public:
ViewForWoWVxDisplay();
ViewForWoWVxDisplay(unsigned int screenNum, unsigned char wow_content, unsigned char wow_factor, unsigned char wow_offset, float wow_disparity_Zd, float wow_disparity_vz, float wow_disparity_M, float wow_disparity_C);
ViewForWoWVxDisplay(const ViewForWoWVxDisplay& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgViewer,ViewForWoWVxDisplay);
virtual void configure(osgViewer::View& view) const;
void setScreenNum(unsigned int n) { _screenNum = n; }
unsigned int getScreenNum() const { return _screenNum; }
void set(unsigned char c) { _wow_content = c; }
double get() const { return _wow_content; }
void set(unsigned char c) { _wow_factor = c; }
double get() const { return _wow_factor; }
void set(unsigned char c) { _wow_offset = c; }
double get() const { return _wow_offset; }
void setWowDisparityZD(float c) { _wow_disparity_Zd = c; }
float getWowDisparityZD() const { return _wow_disparity_Zd; }
void setWowDisparityVZ(float c) { _wow_disparity_vz = c; }
float getWowDisparityVZ() const { return _wow_disparity_vz; }
void setWowDisparityM(float c) { _wow_disparity_M = c; }
float getWowDisparityM() const { return _wow_disparity_M; }
void setWowDisparityC(float c) { _wow_disparity_C = c; }
float getWowDisparityC() const { return _wow_disparity_C; }
protected:
unsigned int _screenNum;
unsigned char _wow_content;
unsigned char _wow_factor;
unsigned char _wow_offset;
float _wow_disparity_Zd;
float _wow_disparity_vz;
float _wow_disparity_M;
float _wow_disparity_C;
};
/** Configure view with DepthPartition.*/
class OSGVIEWER_EXPORT DepthPartition : public Config
{
public:
DepthPartition(DepthPartitionSettings* dsp=0);
DepthPartition(const ViewForWoWVxDisplay& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgViewer,DepthPartition);
void setDepthPartionSettings(DepthPartitionSettings* dsp) const { _dps = dps; }
const DepthPartitionSettings* getDepthPartionSettings() const { return _dps; }
/** for setting up depth partitioning on the specified camera.*/
bool setUpDepthPartitionForCamera(osg::Camera* cameraToPartition, DepthPartitionSettings* dps=0);
virtual void configure(osgViewer::View& view) const;
protected:
};
#endif
}
#endif

View File

@@ -33,6 +33,25 @@
namespace osgViewer {
/** Base class for View configurations for setting up Camera and Windowing.*/
class OSGVIEWER_EXPORT ViewConfig : public osg::Object
{
public:
ViewConfig() {}
ViewConfig(const ViewConfig& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : osg::Object(rhs,copyop) {}
META_Object(osgViewer,ViewConfig);
/** configure method that is overridden by Config subclasses.*/
virtual void configure(osgViewer::View& /*view*/) const {}
/** convinience method for getting the relavent display settings to use.*/
virtual osg::DisplaySettings* getActiveDisplaySetting(osgViewer::View& view) const;
};
struct OSGVIEWER_EXPORT DepthPartitionSettings : public osg::Referenced
{
enum DepthMode
@@ -197,26 +216,33 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
/** Get the FusionDistanceValue. Note, only used for USE_FUSION_DISTANCE_VALUE & PROPORTIONAL_TO_SCREEN_DISTANCE modes.*/
float getFusionDistanceValue() const { return _fusionDistanceValue; }
/** Convenience method for creating slave Cameras and associated GraphicsWindows across all screens.*/
/** Apply a viewer configuration to set up Cameras and Windowing. */
void apply(ViewConfig* config);
ViewConfig* getLastAppliedViewConfig() { return _lastAppliedViewConfig.get(); }
const ViewConfig* getLastAppliedViewConfig() const { return _lastAppliedViewConfig.get(); }
/** deprecated, use view.apply(new osgViewer::AcrossAllWindows()). */
void setUpViewAcrossAllScreens();
/** Convenience method for a single camera on a single window.*/
/** depreacted, use view.apply(new osgViewer::SingleWindow(x,y,width,screenNum)). */
void setUpViewInWindow(int x, int y, int width, int height, unsigned int screenNum=0);
/** Convenience method for a single camera associated with a single full screen GraphicsWindow.*/
/** deprecated, use view.apply(new osgViewer::SingleScreen(screenNum)). */
void setUpViewOnSingleScreen(unsigned int screenNum=0);
/** Convenience method for spherical display using 6 slave cameras rendering the 6 sides of a cube map, and 7th camera doing distortion correction to present on a spherical display.*/
/** deprecated, use view.apply(new osgViewer::SphericalDisplay(radius, collar, screenNum, intensityMap, projectorMatrix)). */
void setUpViewFor3DSphericalDisplay(double radius=1.0, double collar=0.45, unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd());
/** Convenience method for spherical display by rendering main scene to a panoramic 2:1 texture and then doing distortion correction to present onto a spherical display.*/
/** depreacted, use view.apply(new osgViewer::PanoramicSphericalDisplay(radius, collar, screenNum, intensityMap, projectorMatrix)). */
void setUpViewForPanoramicSphericalDisplay(double radius=1.0, double collar=0.45, unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd());
/** Convenience method for autostereoscopic Philips WoWvx display.*/
/** deprecated. use view.apply(new osgViewer::WoWVxDisplay(type (20 to 42), screenNum). */
void setUpViewForWoWVxDisplay(unsigned int screenNum, unsigned char wow_content, unsigned char wow_factor, unsigned char wow_offset, float wow_disparity_Zd, float wow_disparity_vz, float wow_disparity_M, float wow_disparity_C);
/** Convenience method for setting up depth partitioning on the specified camera.*/
bool setUpDepthPartitionForCamera(osg::Camera* cameraToPartition, DepthPartitionSettings* dps=0);
@@ -307,6 +333,9 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
osg::ref_ptr<osg::DisplaySettings> _displaySettings;
osgUtil::SceneView::FusionDistanceMode _fusionDistanceMode;
float _fusionDistanceValue;
osg::ref_ptr<ViewConfig> _lastAppliedViewConfig;
};
}

View File

@@ -14,16 +14,16 @@
#ifndef OSGVIEWER_AcrossAllScreens
#define OSGVIEWER_AcrossAllScreens 1
#include <osgViewer/Config>
#include <osgViewer/View>
namespace osgViewer {
class OSGVIEWER_EXPORT AcrossAllScreens : public Config
class OSGVIEWER_EXPORT AcrossAllScreens : public ViewConfig
{
public:
AcrossAllScreens() {}
AcrossAllScreens(const AcrossAllScreens& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY): Config(rhs,copyop) {}
AcrossAllScreens(const AcrossAllScreens& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY): ViewConfig(rhs,copyop) {}
META_Object(osgViewer, AcrossAllScreens);

View File

@@ -14,12 +14,12 @@
#ifndef OSGVIEWER_PanoramicSphericalDisplay
#define OSGVIEWER_PanoramicSphericalDisplay 1
#include <osgViewer/Config>
#include <osgViewer/View>
namespace osgViewer {
/** spherical display by rendering main scene to a panoramic 2:1 texture and then doing distortion correction to present onto a spherical display.*/
class OSGVIEWER_EXPORT PanoramicSphericalDisplay : public Config
class OSGVIEWER_EXPORT PanoramicSphericalDisplay : public ViewConfig
{
public:
@@ -31,7 +31,7 @@ class OSGVIEWER_EXPORT PanoramicSphericalDisplay : public Config
_projectorMatrix(projectorMatrix) {}
PanoramicSphericalDisplay(const PanoramicSphericalDisplay& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
Config(rhs, copyop),
ViewConfig(rhs, copyop),
_radius(rhs._radius),
_collar(rhs._collar),
_screenNum(rhs._screenNum),

View File

@@ -14,17 +14,17 @@
#ifndef OSGVIEWER_SingleScreen
#define OSGVIEWER_SingleScreen 1
#include <osgViewer/Config>
#include <osgViewer/View>
namespace osgViewer {
/** single camera associated with a single full screen GraphicsWindow.*/
class OSGVIEWER_EXPORT SingleScreen : public Config
class OSGVIEWER_EXPORT SingleScreen : public ViewConfig
{
public:
SingleScreen(unsigned int screenNum=0) : _screenNum(screenNum) {}
SingleScreen(const SingleScreen& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : Config(rhs,copyop), _screenNum(rhs._screenNum) {}
SingleScreen(const SingleScreen& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : ViewConfig(rhs,copyop), _screenNum(rhs._screenNum) {}
META_Object(osgViewer, SingleScreen);

View File

@@ -14,18 +14,18 @@
#ifndef OSGVIEWER_SingleWindow
#define OSGVIEWER_SingleWindow 1
#include <osgViewer/Config>
#include <osgViewer/View>
namespace osgViewer {
/** single camera on a single window.*/
class OSGVIEWER_EXPORT SingleWindow : public Config
class OSGVIEWER_EXPORT SingleWindow : public ViewConfig
{
public:
SingleWindow():_x(0),_y(0),_width(-1),_height(-1),_screenNum(0) {}
SingleWindow(int x, int y, int width, int height, unsigned int screenNum=0):_x(x),_y(y),_width(width),_height(height),_screenNum(screenNum) {}
SingleWindow(const SingleWindow& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):Config(rhs,copyop), _x(rhs._x),_y(rhs._y),_width(rhs._width),_height(rhs._height),_screenNum(rhs._screenNum) {}
SingleWindow(const SingleWindow& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):ViewConfig(rhs,copyop), _x(rhs._x),_y(rhs._y),_width(rhs._width),_height(rhs._height),_screenNum(rhs._screenNum) {}
META_Object(osgViewer,SingleWindow);

View File

@@ -14,12 +14,12 @@
#ifndef OSGVIEWER_SphericalDisplay
#define OSGVIEWER_SphericalDisplay 1
#include <osgViewer/Config>
#include <osgViewer/View>
namespace osgViewer {
/** spherical display using 6 slave cameras rendering the 6 sides of a cube map, and 7th camera doing distortion correction to present on a spherical display.*/
class OSGVIEWER_EXPORT SphericalDisplay : public Config
class OSGVIEWER_EXPORT SphericalDisplay : public ViewConfig
{
public:
@@ -31,7 +31,7 @@ class OSGVIEWER_EXPORT SphericalDisplay : public Config
_projectorMatrix(projectorMatrix) {}
SphericalDisplay(const SphericalDisplay& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
Config(rhs,copyop),
ViewConfig(rhs,copyop),
_radius(rhs._radius),
_collar(rhs._collar),
_screenNum(rhs._screenNum),

View File

@@ -11,15 +11,15 @@
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGVIEWER_PanoramicSphericalDisplay
#define OSGVIEWER_PanoramicSphericalDisplay 1
#ifndef OSGVIEWER_WoWVxDisplay
#define OSGVIEWER_WoWVxDisplay 1
#include <osgViewer/Config>
#include <osgViewer/View>
namespace osgViewer {
/** autostereoscopic Philips WoWvx display.*/
class OSGVIEWER_EXPORT WoWVxDisplay : public Config
class OSGVIEWER_EXPORT WoWVxDisplay : public ViewConfig
{
public:
@@ -45,7 +45,7 @@ class OSGVIEWER_EXPORT WoWVxDisplay : public Config
_wow_disparity_C(wow_disparity_C) {}
WoWVxDisplay(const WoWVxDisplay& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
Config(rhs, copyop),
ViewConfig(rhs, copyop),
_screenNum(rhs._screenNum),
_wow_content(rhs._wow_content),
_wow_factor(rhs._wow_factor),