Further work on improving stereo support in the OSG.
Renamed the osg::VisualsSettings to osg::DisplaySettings, and osgUtil::VisualsRequirementsVisitor to osgUtil::DisplayRequirementsVisitor. Added support for OSG_SCREEN_HEIGHT into osg::DisplaySettings, and added a DisplaySettings* to the constructors of osg::SceneView and osg::Camera.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <osg/Quat>
|
||||
#include <osg/ClippingVolume>
|
||||
#include <osg/Viewport>
|
||||
#include <osg/DisplaySettings>
|
||||
|
||||
namespace osg {
|
||||
|
||||
@@ -24,7 +25,8 @@ class SG_EXPORT Camera: public osg::Referenced
|
||||
|
||||
public:
|
||||
|
||||
Camera();
|
||||
Camera(DisplaySettings* ds=NULL);
|
||||
|
||||
Camera(const Camera&);
|
||||
Camera& operator=(const Camera&);
|
||||
virtual ~Camera();
|
||||
@@ -275,26 +277,26 @@ class SG_EXPORT Camera: public osg::Referenced
|
||||
PROPORTIONAL_TO_SCREEN_DISTANCE
|
||||
};
|
||||
|
||||
/** Set the fusion distance function which in use to calculate the
|
||||
/** Set the mode of the fusion distance function which in use to calculate the
|
||||
* fusion distance used in stereo rendering. Default value is
|
||||
* PROPORTIONAL_TO_LOOK_DISTANCE, 1.0f.*/
|
||||
void setFusionDistanceFunction(FusionDistanceMode mode, float ratio=1.0f)
|
||||
{
|
||||
_fusionDistanceMode = mode;
|
||||
_fusionDistanceRatio = ratio;
|
||||
_dirty = true;
|
||||
}
|
||||
* PROPORTIONAL_TO_LOOK_DISTANCE. Use in conjunction with setFusionDistanceRatio(float).*/
|
||||
void setFusionDistanceMode(FusionDistanceMode mode) { _fusionDistanceMode = mode; _dirty = true; }
|
||||
|
||||
/** Get the fusion distance function.*/
|
||||
void getFusionDistanceFunction(FusionDistanceMode& mode, float& ratio)
|
||||
{
|
||||
mode = _fusionDistanceMode;
|
||||
ratio = _fusionDistanceRatio;
|
||||
}
|
||||
/** Get the mode of the fusion distance function.*/
|
||||
FusionDistanceMode getFusionDistanceMode() const { return _fusionDistanceMode; }
|
||||
|
||||
/** Set the ratio of the fusion distance function which in use to calculate the
|
||||
* fusion distance used in stereo rendering. Default value is 1.0f
|
||||
* Use in conjunction with setFusionDistanceMode(..).*/
|
||||
void setFusionDistanceRatio(float ratio) { _fusionDistanceRatio = ratio; _dirty = true; }
|
||||
|
||||
/** Get the ratio of the fusion distance function.*/
|
||||
float getFusionDistanceRatio() const { return _fusionDistanceRatio; }
|
||||
|
||||
/** Calculate and return the fusion distance, using the FusionDistanceFunction.*/
|
||||
const float getFusionDistance() const;
|
||||
|
||||
|
||||
/** Set the physical distance between the viewers eyes and the display system.
|
||||
* Note, only used when rendering in stereo.*/
|
||||
void setScreenDistance(float screenDistance) { _screenDistance = screenDistance; _dirty = true; }
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
#ifndef OSG_VISUALSSETTINGS
|
||||
#define OSG_VISUALSSETTINGS 1
|
||||
#ifndef OSG_DisplaySettings
|
||||
#define OSG_DisplaySettings 1
|
||||
|
||||
#include <osg/Referenced>
|
||||
|
||||
@@ -12,33 +12,33 @@
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** VisualsSettings class for encapsulating what visuals are required and
|
||||
/** DisplaySettings class for encapsulating what visuals are required and
|
||||
* have been set up, and the status of stereo viewing.*/
|
||||
class SG_EXPORT VisualsSettings : public osg::Referenced
|
||||
class SG_EXPORT DisplaySettings : public osg::Referenced
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
VisualsSettings()
|
||||
DisplaySettings()
|
||||
{
|
||||
setDefaults();
|
||||
readEnvironmentalVariables();
|
||||
}
|
||||
|
||||
VisualsSettings(std::vector<std::string>& commandLine)
|
||||
DisplaySettings(std::vector<std::string>& commandLine)
|
||||
{
|
||||
setDefaults();
|
||||
readEnvironmentalVariables();
|
||||
readCommandLine(commandLine);
|
||||
}
|
||||
|
||||
VisualsSettings(const VisualsSettings& vs);
|
||||
DisplaySettings(const DisplaySettings& vs);
|
||||
|
||||
virtual ~VisualsSettings();
|
||||
virtual ~DisplaySettings();
|
||||
|
||||
VisualsSettings& operator = (const VisualsSettings& vs);
|
||||
DisplaySettings& operator = (const DisplaySettings& vs);
|
||||
|
||||
void merge(const VisualsSettings& vs);
|
||||
void merge(const DisplaySettings& vs);
|
||||
|
||||
void setDefaults();
|
||||
|
||||
@@ -70,6 +70,9 @@ class SG_EXPORT VisualsSettings : public osg::Referenced
|
||||
const float getScreenDistance() const { return _screenDistance; }
|
||||
|
||||
|
||||
void setScreenHeight(const float height) { _screenHeight = height; }
|
||||
const float getScreenHeight() const { return _screenHeight; }
|
||||
|
||||
|
||||
void setDoubleBuffer(const bool flag) { _doubleBuffer = flag; }
|
||||
const bool getDoubleBuffer() const { return _doubleBuffer; }
|
||||
@@ -94,12 +97,13 @@ class SG_EXPORT VisualsSettings : public osg::Referenced
|
||||
|
||||
protected:
|
||||
|
||||
void copy(const VisualsSettings& vs);
|
||||
void copy(const DisplaySettings& vs);
|
||||
|
||||
bool _stereo;
|
||||
StereoMode _stereoMode;
|
||||
float _eyeSeperation;
|
||||
float _screenDistance;
|
||||
float _screenHeight;
|
||||
|
||||
bool _doubleBuffer;
|
||||
bool _RGB;
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <osg/FrameStamp>
|
||||
#include <osg/Camera>
|
||||
#include <osg/VisualsSettings>
|
||||
#include <osg/DisplaySettings>
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
@@ -108,20 +108,20 @@ class SG_EXPORT State : public Referenced
|
||||
/** Get the camera */
|
||||
inline const Camera* getCamera() const { return _camera.get(); }
|
||||
|
||||
/** Set the VisualsSettings. Note, nothing is applied, the visual settings are just used
|
||||
/** Set the DisplaySettings. Note, nothing is applied, the visual settings are just used
|
||||
* used in the State object to pass the current visual settings to Drawables
|
||||
* during rendering. */
|
||||
inline void setVisualsSettings(VisualsSettings* vs) { _visualsSettings = vs; }
|
||||
inline void setDisplaySettings(DisplaySettings* vs) { _displaySettings = vs; }
|
||||
|
||||
/** Get the VisualsSettings */
|
||||
inline const VisualsSettings* getVisualsSettings() const { return _visualsSettings.get(); }
|
||||
/** Get the DisplaySettings */
|
||||
inline const DisplaySettings* getDisplaySettings() const { return _displaySettings.get(); }
|
||||
|
||||
private:
|
||||
|
||||
unsigned int _contextID;
|
||||
ref_ptr<FrameStamp> _frameStamp;
|
||||
ref_ptr<Camera> _camera;
|
||||
ref_ptr<VisualsSettings> _visualsSettings;
|
||||
ref_ptr<DisplaySettings> _displaySettings;
|
||||
|
||||
typedef std::vector<StateAttribute::GLModeValue> ValueVec;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Timer>
|
||||
#include <osg/VisualsSettings>
|
||||
#include <osg/DisplaySettings>
|
||||
|
||||
#include <osgUtil/GUIEventAdapter>
|
||||
#include <osgUtil/CameraManipulator>
|
||||
@@ -178,7 +178,7 @@ class OSGGLUT_EXPORT Viewer : public osgUtil::GUIActionAdapter
|
||||
|
||||
|
||||
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
||||
osg::ref_ptr<osg::VisualsSettings> _visualsSettings;
|
||||
osg::ref_ptr<osg::DisplaySettings> _displaySettings;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
#ifndef OSGUTIL_VISUALSREQUIREMENTSVISITOR
|
||||
#define OSGUTIL_VISUALSREQUIREMENTSVISITOR 1
|
||||
#ifndef OSGUTIL_DISPLAYEQUIREMENTSVISITOR
|
||||
#define OSGUTIL_DISPLAYREQUIREMENTSVISITOR 1
|
||||
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/Geode>
|
||||
#include <osg/VisualsSettings>
|
||||
#include <osg/DisplaySettings>
|
||||
|
||||
#include <osgUtil/Export>
|
||||
|
||||
@@ -18,21 +18,21 @@ namespace osgUtil {
|
||||
* applications to set up there windows with the correct visuals. Have a look at
|
||||
* src/osgGLUT/Viewer.cpp's Viewer::open() method for an example how to use it.
|
||||
*/
|
||||
class OSGUTIL_EXPORT VisualsRequirementsVisitor : public osg::NodeVisitor
|
||||
class OSGUTIL_EXPORT DisplayRequirementsVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
/** Default to traversing all children, and reqiresDoubleBuffer,
|
||||
* requiresRGB and requiresDepthBuffer to true and with
|
||||
* alpha and stencil off.*/
|
||||
VisualsRequirementsVisitor();
|
||||
DisplayRequirementsVisitor();
|
||||
|
||||
|
||||
/** Set the VisualsSettings. */
|
||||
inline void setVisualsSettings(osg::VisualsSettings* vs) { _vs = vs; }
|
||||
/** Set the DisplaySettings. */
|
||||
inline void setDisplaySettings(osg::DisplaySettings* ds) { _ds = ds; }
|
||||
|
||||
/** Get the VisualsSettings */
|
||||
inline const osg::VisualsSettings* getVisualsSettings() const { return _vs.get(); }
|
||||
/** Get the DisplaySettings */
|
||||
inline const osg::DisplaySettings* getDisplaySettings() const { return _ds.get(); }
|
||||
|
||||
virtual void applyStateSet(osg::StateSet& stateset);
|
||||
|
||||
@@ -44,7 +44,7 @@ class OSGUTIL_EXPORT VisualsRequirementsVisitor : public osg::NodeVisitor
|
||||
|
||||
protected:
|
||||
|
||||
osg::ref_ptr<osg::VisualsSettings> _vs;
|
||||
osg::ref_ptr<osg::DisplaySettings> _ds;
|
||||
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <osg/Light>
|
||||
#include <osg/Camera>
|
||||
#include <osg/FrameStamp>
|
||||
#include <osg/VisualsSettings>
|
||||
#include <osg/DisplaySettings>
|
||||
|
||||
#include <osgUtil/CullVisitor>
|
||||
|
||||
@@ -26,7 +26,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
public:
|
||||
|
||||
/** Construct a default scene view.*/
|
||||
SceneView();
|
||||
SceneView(osg::DisplaySettings* ds=NULL);
|
||||
|
||||
/** Set scene view to use default global state, light, camera
|
||||
* and render visitor.
|
||||
@@ -77,11 +77,11 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
_viewport->getViewport(x,y,width,height);
|
||||
}
|
||||
|
||||
/** Set the VisualsSettings. */
|
||||
inline void setVisualsSettings(osg::VisualsSettings* vs) { _visualsSettings = vs; }
|
||||
/** Set the DisplaySettings. */
|
||||
inline void setDisplaySettings(osg::DisplaySettings* vs) { _displaySettings = vs; }
|
||||
|
||||
/** Get the VisualsSettings */
|
||||
inline const osg::VisualsSettings* getVisualsSettings() const { return _visualsSettings.get(); }
|
||||
/** Get the DisplaySettings */
|
||||
inline const osg::DisplaySettings* getDisplaySettings() const { return _displaySettings.get(); }
|
||||
|
||||
|
||||
/** Set the background color used in glClearColor().
|
||||
@@ -218,7 +218,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
osg::ref_ptr<osg::StateSet> _globalState;
|
||||
osg::ref_ptr<osg::Light> _light;
|
||||
osg::ref_ptr<osg::Camera> _camera;
|
||||
osg::ref_ptr<osg::VisualsSettings> _visualsSettings;
|
||||
osg::ref_ptr<osg::DisplaySettings> _displaySettings;
|
||||
osg::ref_ptr<osg::State> _state;
|
||||
|
||||
bool _initCalled;
|
||||
|
||||
Reference in New Issue
Block a user