From e096a5f44ab4e05d8446e2d232fadab115242571 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 16 Feb 2007 06:39:23 +0000 Subject: [PATCH] Added enabling of the stencil buffer when setting up ShadowVolume path --- examples/osgshadowtexture/osgshadowtexture.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/osgshadowtexture/osgshadowtexture.cpp b/examples/osgshadowtexture/osgshadowtexture.cpp index e6c07af6a..10103b14a 100644 --- a/examples/osgshadowtexture/osgshadowtexture.cpp +++ b/examples/osgshadowtexture/osgshadowtexture.cpp @@ -135,7 +135,7 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius) positioned->addChild(cessna); osg::MatrixTransform* xform = new osg::MatrixTransform; - //xform->setUpdateCallback(new osg::AnimationPathCallback(animationPath,0.0f,2.0)); + xform->setUpdateCallback(new osg::AnimationPathCallback(animationPath,0.0f,2.0)); xform->addChild(positioned); model->addChild(xform); @@ -159,8 +159,11 @@ osg::Node* createModel(osg::ArgumentParser& arguments) // the shadowed model osg::Node* shadowed = createBase(center-osg::Vec3(0.0f,0.0f,radius*0.25),radius); - if (arguments.read("--osgShadow")) + if (arguments.read("--sv")) { + // hint to tell viewer to request stencil buffer when setting up windows + osg::DisplaySettings::instance()->setMinimumNumStencilBits(8); + osgShadow::ShadowedScene* shadowedScene = new osgShadow::ShadowedScene; osg::ref_ptr shadowVolume = new osgShadow::ShadowVolume; @@ -168,9 +171,7 @@ osg::Node* createModel(osg::ArgumentParser& arguments) shadowVolume->setDynamicShadowVolumes(true); osg::ref_ptr ls = new osg::LightSource; - ls->getLight()->setPosition(osg::Vec4(0,1,1,0.0)); - ls->getLight()->setAmbient(osg::Vec4(0.0,0.0,1.0,1.0)); - ls->getLight()->setDiffuse(osg::Vec4(0.0,1.0,0.0,1.0)); + ls->getLight()->setPosition(osg::Vec4(lightPosition,1.0)); shadowedScene->addChild(shadower); shadowedScene->addChild(shadowed);