osg/View
Go to the documentation of this file.
/* -*-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 OSG_VIEW
#define OSG_VIEW 1
#include <osg/Camera>
#include <osg/Light>
#include <osg/Stats>
#include <OpenThreads/Mutex>
namespace osg {
class OSG_EXPORT View : public virtual osg::Object
{
public :
View();
View(const osg::View& view, const osg::CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_Object(osg,View);
virtual void take(View& rhs);
void setStats(osg::Stats* stats) { _stats = stats; }
osg::Stats* getStats() { return _stats.get(); }
const osg::Stats* getStats() const { return _stats.get(); }
enum LightingMode
{
NO_LIGHT,
HEADLIGHT,
SKY_LIGHT
};
void setLightingMode(LightingMode lightingMode);
LightingMode getLightingMode() const { return _lightingMode; }
void setLight(osg::Light* light) { _light = light; }
osg::Light* getLight() { return _light.get(); }
const osg::Light* getLight() const { return _light.get(); }
void setCamera(osg::Camera* camera);
osg::Camera* getCamera() { return _camera.get(); }
const osg::Camera* getCamera() const { return _camera.get(); }
void setFrameStamp(osg::FrameStamp* fs) { _frameStamp = fs; }
osg::FrameStamp* getFrameStamp() { return _frameStamp.get(); }
const osg::FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
struct OSG_EXPORT Slave
{
Slave(bool useMastersSceneData=true):
_useMastersSceneData(useMastersSceneData) {}
Slave(osg::Camera* camera, const osg::Matrixd& projectionOffset, const osg::Matrixd& viewOffset, bool useMastersSceneData=true):
_camera(camera),
_projectionOffset(projectionOffset),
_viewOffset(viewOffset),
_useMastersSceneData(useMastersSceneData) {}
Slave(const Slave& rhs) :
_camera(rhs._camera),
_projectionOffset(rhs._projectionOffset),
_viewOffset(rhs._viewOffset),
_useMastersSceneData(rhs._useMastersSceneData),
_updateSlaveCallback(rhs._updateSlaveCallback) {}
virtual ~Slave() {}
Slave& operator = (const Slave& rhs)
{
_camera = rhs._camera;
_projectionOffset = rhs._projectionOffset;
_viewOffset = rhs._viewOffset;
_useMastersSceneData = rhs._useMastersSceneData;
_updateSlaveCallback = rhs._updateSlaveCallback;
return *this;
}
struct UpdateSlaveCallback : public virtual Referenced
{
virtual void updateSlave(osg::View& view, osg::View::Slave& slave) = 0;
};
void updateSlave(View& view)
{
if (_updateSlaveCallback.valid()) _updateSlaveCallback->updateSlave(view, *this);
else updateSlaveImplementation(view);
}
virtual void updateSlaveImplementation(View& view);
osg::ref_ptr<osg::Camera> _camera;
osg::Matrixd _projectionOffset;
osg::Matrixd _viewOffset;
bool _useMastersSceneData;
osg::ref_ptr<UpdateSlaveCallback> _updateSlaveCallback;
};
bool addSlave(osg::Camera* camera, bool useMastersSceneData=true) { return addSlave(camera, osg::Matrix::identity(), osg::Matrix::identity(), useMastersSceneData); }
bool addSlave(osg::Camera* camera, const osg::Matrix& projectionOffset, const osg::Matrix& viewOffset, bool useMastersSceneData=true);
bool removeSlave(unsigned int pos);
unsigned int getNumSlaves() const { return static_cast<unsigned int>(_slaves.size()); }
Slave& getSlave(unsigned int pos) { return _slaves[pos]; }
const Slave& getSlave(unsigned int pos) const { return _slaves[pos]; }
unsigned int findSlaveIndexForCamera(osg::Camera* camera) const;
Slave * findSlaveForCamera(osg::Camera* camera);
void updateSlaves();
virtual void resizeGLObjectBuffers(unsigned int maxSize);
virtual void releaseGLObjects(osg::State* = 0) const;
protected :
virtual ~View();
virtual osg::GraphicsOperation* createRenderer(osg::Camera*) { return 0; }
osg::ref_ptr<osg::Stats> _stats;
LightingMode _lightingMode;
osg::ref_ptr<osg::Light> _light;
osg::ref_ptr<osg::Camera> _camera;
typedef std::vector<Slave> Slaves;
Slaves _slaves;
osg::ref_ptr<osg::FrameStamp> _frameStamp;
};
}
#endif
Camera
Light
Mutex
Stats
osg::Camera
Definition Camera:45
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::FrameStamp
Definition FrameStamp:35
osg::Light
Definition Light:40
osg::Matrixd
Definition Matrixd:27
osg::Matrixd::identity
static Matrixd identity(void)
Definition Matrixd:444
osg::Object
Definition Object:61
osg::Referenced::Referenced
Referenced()
osg::State
Definition State:80
osg::Stats
Definition Stats:29
osg::View
Definition osg/View:30
osg::View::getNumSlaves
unsigned int getNumSlaves() const
Definition osg/View:153
osg::View::getCamera
const osg::Camera * getCamera() const
Definition osg/View:84
osg::View::findSlaveIndexForCamera
unsigned int findSlaveIndexForCamera(osg::Camera *camera) const
osg::View::getStats
const osg::Stats * getStats() const
Definition osg/View:50
osg::View::getSlave
Slave & getSlave(unsigned int pos)
Definition osg/View:155
osg::View::createRenderer
virtual osg::GraphicsOperation * createRenderer(osg::Camera *)
Definition osg/View:171
osg::View::take
virtual void take(View &rhs)
osg::View::getLightingMode
LightingMode getLightingMode() const
Definition osg/View:66
osg::View::setFrameStamp
void setFrameStamp(osg::FrameStamp *fs)
Definition osg/View:87
osg::View::getStats
osg::Stats * getStats()
Definition osg/View:47
osg::View::LightingMode
LightingMode
Definition osg/View:55
osg::View::HEADLIGHT
@ HEADLIGHT
Definition osg/View:57
osg::View::SKY_LIGHT
@ SKY_LIGHT
Definition osg/View:58
osg::View::NO_LIGHT
@ NO_LIGHT
Definition osg/View:56
osg::View::_lightingMode
LightingMode _lightingMode
Definition osg/View:175
osg::View::addSlave
bool addSlave(osg::Camera *camera, const osg::Matrix &projectionOffset, const osg::Matrix &viewOffset, bool useMastersSceneData=true)
osg::View::getLight
osg::Light * getLight()
Definition osg/View:72
osg::View::_stats
osg::ref_ptr< osg::Stats > _stats
Definition osg/View:173
osg::View::getFrameStamp
const osg::FrameStamp * getFrameStamp() const
Definition osg/View:93
osg::View::releaseGLObjects
virtual void releaseGLObjects(osg::State *=0) const
osg::View::getLight
const osg::Light * getLight() const
Definition osg/View:75
osg::View::updateSlaves
void updateSlaves()
osg::View::addSlave
bool addSlave(osg::Camera *camera, bool useMastersSceneData=true)
Definition osg/View:147
osg::View::View
View(const osg::View &view, const osg::CopyOp &copyop=CopyOp::SHALLOW_COPY)
osg::View::removeSlave
bool removeSlave(unsigned int pos)
osg::View::findSlaveForCamera
Slave * findSlaveForCamera(osg::Camera *camera)
osg::View::View
View()
osg::View::setStats
void setStats(osg::Stats *stats)
Definition osg/View:44
osg::View::getSlave
const Slave & getSlave(unsigned int pos) const
Definition osg/View:156
osg::View::~View
virtual ~View()
osg::View::setCamera
void setCamera(osg::Camera *camera)
osg::View::_slaves
Slaves _slaves
Definition osg/View:181
osg::View::_frameStamp
osg::ref_ptr< osg::FrameStamp > _frameStamp
Definition osg/View:183
osg::View::getCamera
osg::Camera * getCamera()
Definition osg/View:81
osg::View::META_Object
META_Object(osg, View)
osg::View::setLightingMode
void setLightingMode(LightingMode lightingMode)
osg::View::_camera
osg::ref_ptr< osg::Camera > _camera
Definition osg/View:178
osg::View::resizeGLObjectBuffers
virtual void resizeGLObjectBuffers(unsigned int maxSize)
osg::View::setLight
void setLight(osg::Light *light)
Definition osg/View:69
osg::View::_light
osg::ref_ptr< osg::Light > _light
Definition osg/View:176
osg::View::Slaves
std::vector< Slave > Slaves
Definition osg/View:180
osg::View::getFrameStamp
osg::FrameStamp * getFrameStamp()
Definition osg/View:90
osg::ref_ptr
Definition ref_ptr:32
osg
Definition AlphaFunc:19
osg::Matrix
Matrixd Matrix
Definition Matrix:27
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39
osg::GraphicsOperation
Definition GraphicsThread:36
osg::View::Slave::UpdateSlaveCallback
Definition osg/View:128
osg::View::Slave::UpdateSlaveCallback::updateSlave
virtual void updateSlave(osg::View &view, osg::View::Slave &slave)=0
osg::View::Slave
Definition osg/View:98
osg::View::Slave::_useMastersSceneData
bool _useMastersSceneData
Definition osg/View:143
osg::View::Slave::_projectionOffset
osg::Matrixd _projectionOffset
Definition osg/View:141
osg::View::Slave::_camera
osg::ref_ptr< osg::Camera > _camera
Definition osg/View:140
osg::View::Slave::updateSlave
void updateSlave(View &view)
Definition osg/View:132
osg::View::Slave::Slave
Slave(bool useMastersSceneData=true)
Definition osg/View:99
osg::View::Slave::_viewOffset
osg::Matrixd _viewOffset
Definition osg/View:142
osg::View::Slave::Slave
Slave(osg::Camera *camera, const osg::Matrixd &projectionOffset, const osg::Matrixd &viewOffset, bool useMastersSceneData=true)
Definition osg/View:102
osg::View::Slave::_updateSlaveCallback
osg::ref_ptr< UpdateSlaveCallback > _updateSlaveCallback
Definition osg/View:144
osg::View::Slave::Slave
Slave(const Slave &rhs)
Definition osg/View:108
osg::View::Slave::~Slave
virtual ~Slave()
Definition osg/View:115
osg::View::Slave::updateSlaveImplementation
virtual void updateSlaveImplementation(View &view)