From 8df5440a26e9ff18d68056707681ae2ee49ab713 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 7 Dec 2012 13:59:57 +0000 Subject: [PATCH] Added naming of root of presentation and used this in the setup of the position of the camera. --- examples/osgframerenderer/CameraProperty.cpp | 23 +++++++++++++------- src/osgPresentation/SlideShowConstructor.cpp | 1 + 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/examples/osgframerenderer/CameraProperty.cpp b/examples/osgframerenderer/CameraProperty.cpp index 25f8ad252..363233ded 100644 --- a/examples/osgframerenderer/CameraProperty.cpp +++ b/examples/osgframerenderer/CameraProperty.cpp @@ -6,17 +6,24 @@ void CameraProperty::setToModel(const osg::Node* node) { osg::BoundingSphere bs = node->getBound(); - double screenWidth = osg::DisplaySettings::instance()->getScreenWidth(); - double screenHeight = osg::DisplaySettings::instance()->getScreenHeight(); - double screenDistance = osg::DisplaySettings::instance()->getScreenDistance(); + double dist = osg::DisplaySettings::instance()->getScreenDistance(); + + OSG_NOTICE<<"Node name "<getName()<getName().find("Presentation")==std::string::npos) + { + double screenWidth = osg::DisplaySettings::instance()->getScreenWidth(); + double screenHeight = osg::DisplaySettings::instance()->getScreenHeight(); + double screenDistance = osg::DisplaySettings::instance()->getScreenDistance(); - double dist = bs.radius() / sin(viewAngle*0.5); + double vfov = atan2(screenHeight/2.0,screenDistance)*2.0; + double hfov = atan2(screenWidth/2.0,screenDistance)*2.0; + double viewAngle = vfovgetScreenDistance(); + dist = bs.radius() / sin(viewAngle*0.5); + } +#endif _center = bs.center(); _eye = _center - osg::Vec3d(0.0, dist, 0.0); diff --git a/src/osgPresentation/SlideShowConstructor.cpp b/src/osgPresentation/SlideShowConstructor.cpp index 380f885c1..beaf4762e 100644 --- a/src/osgPresentation/SlideShowConstructor.cpp +++ b/src/osgPresentation/SlideShowConstructor.cpp @@ -248,6 +248,7 @@ void SlideShowConstructor::createPresentation() _presentationSwitch->setName(std::string("Presentation_")+_presentationName); _root->addChild(_presentationSwitch.get()); + _root->setName(std::string("Presentation_")+_presentationName); osg::Vec3 slideCenter = _slideOrigin + osg::Vec3(_slideWidth*0.5f,0.0f,_slideHeight*0.5f);