diff --git a/examples/osgshadow/osgshadow.cpp b/examples/osgshadow/osgshadow.cpp index 2967cea26..ed11621c7 100644 --- a/examples/osgshadow/osgshadow.cpp +++ b/examples/osgshadow/osgshadow.cpp @@ -582,6 +582,63 @@ namespace ModelThree } +namespace ModelFive +{ + osg::AnimationPathCallback* createAnimationPathCallback( float radius, float time ) + { + osg::ref_ptr path = new osg::AnimationPath; + path->setLoopMode( osg::AnimationPath::LOOP ); + + unsigned int numSamples = 32; + float delta_yaw = 2.0f * osg::PI/((float)numSamples - 1.0f); + float delta_time = time / (float)numSamples; + for ( unsigned int i=0; iinsert( delta_time * (float)i, osg::AnimationPath::ControlPoint(pos, rot) ); + } + + osg::ref_ptr apcb = new osg::AnimationPathCallback; + apcb->setAnimationPath( path.get() ); + return apcb.release(); + } + + osg::Group* createModel(osg::ArgumentParser& arguments) + { + unsigned int rcvShadowMask = 0x1; + unsigned int castShadowMask = 0x2; + + // Set the ground (only receives shadow) + osg::ref_ptr groundNode = new osg::MatrixTransform; + groundNode->addChild( osgDB::readNodeFile("lz.osg") ); + groundNode->setMatrix( osg::Matrix::translate(200.0f, 200.0f,-200.0f) ); + //groundNode->setNodeMask( rcvShadowMask ); + + // Set the cessna (only casts shadow) + osg::ref_ptr cessnaNode = new osg::MatrixTransform; + cessnaNode->addChild( osgDB::readNodeFile("cessna.osg.0,0,90.rot") ); + cessnaNode->addUpdateCallback( createAnimationPathCallback(50.0f, 6.0f) ); + //cessnaNode->setNodeMask( castShadowMask ); + + osg::ref_ptr shadowRoot = new osg::Group; + shadowRoot->addChild( groundNode.get() ); + for ( unsigned int i=0; i<10; ++i ) + { + for ( unsigned int j=0; j<10; ++j ) + { + osg::ref_ptr cessnaInstance = new osg::MatrixTransform; + cessnaInstance->setMatrix( osg::Matrix::translate((float)i*50.0f-25.0f, (float)j*50.0f-25.0f, 0.0f) ); + cessnaInstance->addChild( cessnaNode.get() ); + shadowRoot->addChild( cessnaInstance.get() ); + } + } + + return shadowRoot.release(); + } +} + osg::Node* createTestModel(osg::ArgumentParser& arguments) { if (arguments.read("-1")) @@ -596,6 +653,10 @@ osg::Node* createTestModel(osg::ArgumentParser& arguments) { return ModelFour::createModel(arguments); } + else if (arguments.read("-5")) + { + return ModelFive::createModel(arguments); + } else /*if (arguments.read("-3"))*/ { return ModelThree::createModel(arguments);