Improved the set of the master + slave cameras

This commit is contained in:
Robert Osfield 2008-11-24 16:02:20 +00:00
parent 9addcc050d
commit 2517c1e77e

View File

@ -166,6 +166,8 @@ void singleWindowSideBySideCameras(osgViewer::Viewer& viewer)
unsigned int width, height; unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height);
// Not fullscreen // Not fullscreen
width /= 2; width /= 2;
height /= 2; height /= 2;
@ -194,19 +196,16 @@ void singleWindowSideBySideCameras(osgViewer::Viewer& viewer)
osg::notify(osg::NOTICE)<<" GraphicsWindow has not been created successfully."<<std::endl; osg::notify(osg::NOTICE)<<" GraphicsWindow has not been created successfully."<<std::endl;
} }
double aspectRatioScale = 1.0;
osg::Camera* master = viewer.getCamera(); osg::Camera* master = viewer.getCamera();
// get the default settings for the camera
double fovy, aspectRatio, zNear, zFar; double fovy, aspectRatio, zNear, zFar;
master->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar); master->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar);
master->setProjectionResizePolicy(osg::Camera::VERTICAL);
fovy = 90;
aspectRatio = 1;
master->setProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar);
double h = osg::absolute(tan(osg::DegreesToRadians(fovy / 2))); // reset this for the actual apsect ratio of out created window
double w = h * aspectRatio; double windowAspectRatio = double(width)/double(height);
double fovx = osg::absolute(osg::RadiansToDegrees(atan(w)) * 2); master->setProjectionMatrixAsPerspective(fovy, windowAspectRatio, 1.0, 10000.0);
master->setName("MasterCam"); master->setName("MasterCam");
@ -218,7 +217,7 @@ void singleWindowSideBySideCameras(osgViewer::Viewer& viewer)
GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT; GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
camera->setDrawBuffer(buffer); camera->setDrawBuffer(buffer);
camera->setReadBuffer(buffer); camera->setReadBuffer(buffer);
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd()); viewer.addSlave(camera.get(), osg::Matrixd::scale(1.0,0.5,1.0), osg::Matrixd());
camera = new osg::Camera; camera = new osg::Camera;
camera->setCullMask(2); camera->setCullMask(2);
@ -228,7 +227,7 @@ void singleWindowSideBySideCameras(osgViewer::Viewer& viewer)
buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT; buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
camera->setDrawBuffer(buffer); camera->setDrawBuffer(buffer);
camera->setReadBuffer(buffer); camera->setReadBuffer(buffer);
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd()); viewer.addSlave(camera.get(), osg::Matrixd::scale(1.0,0.5,1.0), osg::Matrixd());
} }
int main( int argc, char **argv ) int main( int argc, char **argv )