Added bool View::Slave::_useMastersSceneData to help manage HUD's and RTT

cameras that are embedded in the Viewer's View
This commit is contained in:
Robert Osfield 2007-02-23 11:53:45 +00:00
parent 67a9ac2055
commit 96f567eff3
4 changed files with 23 additions and 14 deletions

View File

@ -542,8 +542,6 @@ void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments
viewer.getCamera()->setProjectionMatrixAsPerspective(90.0f, 1.0, 1, 1000.0);
viewer.assignSceneDataToCameras();
// distortion correction set up.
{
@ -577,7 +575,7 @@ void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments
camera->setName("DistortionCorrectionCamera");
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd(), false);
}
viewer.getCamera()->setNearFarRatio(0.0001f);
@ -602,17 +600,17 @@ int main(int argc, char** argv)
if (arguments.read("--dome"))
{
viewer.setSceneData( loadedModel );
setDomeCorrection(viewer, arguments);
viewer.setSceneData( loadedModel );
}
else if (arguments.read("--faces"))
{
viewer.setSceneData( loadedModel );
setDomeFaces(viewer, arguments);
viewer.setSceneData( loadedModel );
}
else
{
@ -622,6 +620,7 @@ int main(int argc, char** argv)
viewer.setSceneData( distortionNode );
}
// set up the camera manipulators.
{
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;

View File

@ -54,29 +54,39 @@ class OSG_EXPORT View : public virtual osg::Referenced
/** Slave allows one to up a camera that follows the master with a local offset to the project and view matrices.*/
struct Slave
{
Slave() {}
Slave(osg::Camera* camera, const osg::Matrixd& projectionOffset, const osg::Matrixd& viewOffset):
_camera(camera), _projectionOffset(projectionOffset), _viewOffset(viewOffset) {}
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) {}
_camera(rhs._camera),
_projectionOffset(rhs._projectionOffset),
_viewOffset(rhs._viewOffset),
_useMastersSceneData(rhs._useMastersSceneData) {}
Slave& operator = (const Slave& rhs)
{
_camera = rhs._camera;
_projectionOffset = rhs._projectionOffset;
_viewOffset = rhs._viewOffset;
_useMastersSceneData = rhs._useMastersSceneData;
return *this;
}
osg::ref_ptr<osg::Camera> _camera;
osg::Matrixd _projectionOffset;
osg::Matrixd _viewOffset;
bool _useMastersSceneData;
};
bool addSlave(osg::Camera* camera) { return addSlave(camera, osg::Matrix::identity(), osg::Matrix::identity()); }
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& viewOffse);
bool addSlave(osg::Camera* camera, const osg::Matrix& projectionOffset, const osg::Matrix& viewOffse, bool useMastersSceneData=true);
bool removeSlave(unsigned int pos);

View File

@ -86,7 +86,7 @@ void View::updateSlave(unsigned int i)
if (slave._camera->getInheritanceMask() & osg::CullSettings::CLEAR_COLOR) slave._camera->setClearColor(_camera->getClearColor());
}
bool View::addSlave(osg::Camera* camera, const osg::Matrix& projectionOffset, const osg::Matrix& viewOffset)
bool View::addSlave(osg::Camera* camera, const osg::Matrix& projectionOffset, const osg::Matrix& viewOffset, bool useMastersSceneData)
{
if (!camera) return false;
@ -94,7 +94,7 @@ bool View::addSlave(osg::Camera* camera, const osg::Matrix& projectionOffset, co
unsigned int i = _slaves.size();
_slaves.push_back(Slave(camera, projectionOffset, viewOffset));
_slaves.push_back(Slave(camera, projectionOffset, viewOffset, useMastersSceneData));
updateSlave(i);

View File

@ -281,7 +281,7 @@ void View::assignSceneDataToCameras()
for(unsigned i=0; i<getNumSlaves(); ++i)
{
Slave& slave = getSlave(i);
if (slave._camera.valid())
if (slave._camera.valid() && slave._useMastersSceneData)
{
slave._camera->removeChildren(0,slave._camera->getNumChildren());
if (sceneData) slave._camera->addChild(sceneData);