diff --git a/src/osgPresentation/SlideEventHandler.cpp b/src/osgPresentation/SlideEventHandler.cpp index 04559e28f..e7064c391 100644 --- a/src/osgPresentation/SlideEventHandler.cpp +++ b/src/osgPresentation/SlideEventHandler.cpp @@ -503,83 +503,42 @@ public: void apply(osg::Node& node) { - if (node.getStateSet()) - { - apply(*node.getStateSet()); - } - traverse(node); } void apply(osg::LightSource& lightsource) { - if (lightsource.getStateSet()) - { - apply(*lightsource.getStateSet()); - } - if (lightsource.getLight()) { - OSG_INFO<<"Adjusting light"<setPosition(osg::Vec4(direction,0.0f)); - } traverse(lightsource); } - void apply(osg::StateSet& stateset) + void apply(const osg::Matrixd& matrix, osg::Light* light) { - osg::TexEnvCombine* texenvcombine = dynamic_cast(stateset.getTextureAttribute(0,osg::StateAttribute::TEXENV)); - if (texenvcombine) - { - apply(*texenvcombine); - } - } - - void apply(osg::TexEnvCombine& texenv) - { - OSG_INFO<<"Adjusting tex env combine"<setPosition(osg::Vec4(direction,0.0f)); } - osg::Matrixd _viewMatrix; float _currentX, _currentY; @@ -975,17 +934,17 @@ bool SlideEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction */ else if (ea.getKey()=='u') { - updateAlpha(true,false,ea.getX(),ea.getY()); + updateAlpha(true,false,ea.getXnormalized(),ea.getYnormalized()); return true; } else if (ea.getKey()=='i') { - updateAlpha(false,true,ea.getX(),ea.getY()); + updateAlpha(false,true,ea.getXnormalized(),ea.getYnormalized()); return true; } else if (ea.getKey()=='k') { - updateLight(ea.getX(),ea.getY()); + updateLight(ea.getXnormalized(),ea.getYnormalized()); return true; } @@ -1232,8 +1191,7 @@ void SlideEventHandler::updateOperators() if (_viewer.valid()) { - UpdateLightVisitor uav(_viewer->getCamera()->getViewMatrix(),0.0f,0.0f); - _viewer->getSceneData()->accept(uav); + updateLight(0.0f,0.0f); } } @@ -1288,6 +1246,19 @@ void SlideEventHandler::updateLight(float x, float y) UpdateLightVisitor uav(_viewer->getCamera()->getViewMatrix(),x,y); _viewer->getSceneData()->accept(uav); + + if (_viewer->getLightingMode()!= osg::View::NO_LIGHT && _viewer->getLight()) + { + if (_viewer->getLightingMode()== osg::View::SKY_LIGHT) + { + uav.apply(_viewer->getCamera()->getViewMatrix(), _viewer->getLight()); + } + else if (_viewer->getLightingMode()== osg::View::HEADLIGHT) + { + uav.apply(osg::Matrix::identity(), _viewer->getLight()); + } + } + } void SlideEventHandler::compileSlide(unsigned int slideNum)