void AnimationEffect::finished()
{
    AnimationUnrecPtr anim = getAnimation();
    anim->detachUpdateProducer();
    anim->removeAnimationListener(&theInternalAnimationListener);
    Inherited::finished();
}
void setupAnimation(void)
{
	//Read animation data from XML file
	FCFileType::FCPtrStore NewContainers;
	NewContainers = FCFileHandler::the()->read(BoostPath("./Data/15TestAnimations.xml"));

	FCFileType::FCPtrStore::iterator Itor;
    for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
    {
		if( (*Itor)->getType().isDerivedFrom(Animation::getClassType()))
		{
			//Set the animation to the one we just read in
			TheAnimation = (dynamic_pointer_cast<Animation>(*Itor));
		}
		else if( (*Itor)->getType() == (SimpleMaterial::getClassType()))
		{
			//Set torus material
			TheTorusMaterial = (dynamic_pointer_cast<SimpleMaterial>(*Itor));
			
			//Attach torus material to torus geometry
				TorusGeometry->setMaterial(TheTorusMaterial);
		}
    }

    TheAnimation->attachUpdateProducer(TutorialWindow->editEventProducer());
    TheAnimation->start();
}
void initAnimations(FieldContainerUnrecPtr AnimatedObject, std::string AnimatedField)
{
	//Main Animation
	TheAnimation = createColorAnimation(AnimatedObject, AnimatedField);

    TheAnimation->attachUpdateProducer(TutorialWindow->editEventProducer());
    TheAnimation->start();
}
void AnimationEffect::inheritedBegin()
{
    AnimationUnrecPtr anim = getAnimation();
    if(anim != NULL)
    { 
        anim->attachUpdateProducer(theUpdateProducer);
        anim->start();
        anim->addAnimationListener(&theInternalAnimationListener);
    }
    else
    {
          SWARNING << "AnimationEffect::inheritedBegin(): Null Animation. Not set yet?";
    }
}
void testAnim(void)
{
    AnimVec3fDataSourceUnrecPtr src0 = AnimVec3fDataSource::create();
    AnimVec3fDataSourceUnrecPtr src1 = AnimVec3fDataSource::create();

    src0->editMFInterpolationModes()->push_back(AnimKeyFrameDataSource::IM_Linear);

    src0->editMFInValues()->push_back(0.f);
    src0->editMFInValues()->push_back(1.f);
    src0->editMFInValues()->push_back(3.f);

    src0->editMFValues()->push_back(Vec3f(0.f, 0.f, 0.f));
    src0->editMFValues()->push_back(Vec3f(1.f, 0.f, 0.f));
    src0->editMFValues()->push_back(Vec3f(1.f, 2.f, 0.f));

    
    src1->editMFInterpolationModes()->push_back(AnimKeyFrameDataSource::IM_Linear);

    src1->editMFInValues()->push_back(1.f );
    src1->editMFInValues()->push_back(2.f );
    src1->editMFInValues()->push_back(2.5f);
    src1->editMFInValues()->push_back(4.f );

    src1->editMFValues()->push_back(Vec3f(0.f, 1.f, 0.f));
    src1->editMFValues()->push_back(Vec3f(0.f, 0.f, 1.f));
    src1->editMFValues()->push_back(Vec3f(1.f, 0.f, 1.f));
    src1->editMFValues()->push_back(Vec3f(2.f, 2.f, 2.f));


    AnimationUnrecPtr        a  = Animation::create();
    AnimVec3fChannelUnrecPtr c0 = AnimVec3fChannel::create();
    AnimVec3fChannelUnrecPtr c1 = AnimVec3fChannel::create();
    AnimTimeSensorUnrecPtr   t  = AnimTimeSensor::create();

    c0->setData(src0);
    c1->setData(src1);

    a->editMFChannels()->push_back(c0);
    a->editMFChannels()->push_back(c1);

    a->setTimeSensor(t);

    commitChanges();
}
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    OSG::preloadSharedObject("OSGFileIO");
    OSG::preloadSharedObject("OSGImageFileIO");
    // OSG init
    osgInit(argc,argv);
    {
        // Set up Window
        WindowEventProducerRecPtr TutorialWindow = createNativeWindow();

        //Initialize Window
        TutorialWindow->initWindow();

        SimpleSceneManager sceneManager;
        TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
        TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));

        // Tell the Manager what to manage
        sceneManager.setWindow(TutorialWindow);

        //Attach to events
        TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager));
        TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager));
        TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
        TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));
        TutorialWindow->connectKeyPressed(boost::bind(keyPressed, _1, TutorialWindow.get()));

        //Box Geometry
        GeometryUnrecPtr BoxGeometry = makeBoxGeo(1.0,1.0,1.0,1,1,1);
        ChunkMaterialUnrecPtr TheBoxMaterial = ChunkMaterial::create();
        BoxGeometry->setMaterial(TheBoxMaterial);

        NodeUnrecPtr BoxGeometryNode = Node::create();
        BoxGeometryNode->setCore(BoxGeometry);

        //Make Box Node
        NodeUnrecPtr BoxNode = Node::create();
        TransformUnrecPtr BoxNodeTrans;
        BoxNodeTrans = Transform::create();

        BoxNode->setCore(BoxNodeTrans);
        BoxNode->addChild(BoxGeometryNode);

        //Make Main Scene Node
        NodeUnrecPtr scene = Node::create();
        ComponentTransformUnrecPtr Trans;
        Trans = ComponentTransform::create();
        scene->setCore(Trans);

        // add the torus as a child
        scene->addChild(BoxNode);

        //Setup the Animation
        AnimationUnrecPtr TheAnimation = setupAnimation(TheBoxMaterial);
        TheAnimation->attachUpdateProducer(TutorialWindow);
        TheAnimation->start();

        // tell the manager what to manage
        sceneManager.setRoot  (scene);

        //Create the Documentation
        SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);

        // show the whole scene
        sceneManager.showAll();

        //Open Window
        Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
        Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);

        TutorialWindow->openWindow(WinPos,
                                   WinSize,
                                   "09TextureSelectAnimation");

        //Main Loop
        TutorialWindow->mainLoop();
    }

    osgExit();

    return 0;
}
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    {
        // Set up Window
        WindowEventProducerRecPtr TutorialWindow = createNativeWindow();

        //Initialize Window
        TutorialWindow->initWindow();

        SimpleSceneManager sceneManager;
        TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
        TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));

        // Tell the Manager what to manage
        sceneManager.setWindow(TutorialWindow);

        //Attach to events
        TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager));
        TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager));
        TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
        TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));
        TutorialWindow->connectKeyPressed(boost::bind(keyPressed, _1, TutorialWindow.get()));

        //Torus Node
        NodeUnrecPtr TorusGeometryNode = makeTorus(.5, 2, 32, 32);

        //Make Torus Node
        NodeUnrecPtr TorusNode = Node::create();
        TransformUnrecPtr TorusNodeTrans;
        TorusNodeTrans = Transform::create();

        TorusNode->setCore(TorusNodeTrans);
        TorusNode->addChild(TorusGeometryNode);

        //Make Main Scene Node
        NodeUnrecPtr scene = Node::create();
        ComponentTransformUnrecPtr Trans;
        Trans = ComponentTransform::create();
        scene->setCore(Trans);

        // add the torus as a child
        scene->addChild(TorusNode);

        //Make a gradient Background
        GradientBackgroundUnrecPtr TutorialBackground = GradientBackground::create();
        TutorialBackground->addLine(Color3f(1.0,0.0,0.0),0.0);
        TutorialBackground->addLine(Color3f(0.0,1.0,0.0),0.5);
        TutorialBackground->addLine(Color3f(0.0,0.0,1.0),1.0);
        setName(TutorialBackground, std::string("TutorialGradientBackground"));

        AnimationUnrecPtr TheAnimation = setupAnimation(TutorialBackground);
        TheAnimation->attachUpdateProducer(TutorialWindow);
        TheAnimation->start();

        // tell the manager what to manage
        sceneManager.setRoot  (scene);
        sceneManager.getWindow()->getPort(0)->setBackground(TutorialBackground);

        //Create the Documentation
        SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);

        // show the whole scene
        sceneManager.showAll();

        //Open Window
        Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
        Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
        TutorialWindow->openWindow(WinPos,
                                   WinSize,
                                   "03MFieldAnimation");

        //Main Loop
        TutorialWindow->mainLoop();
    }

    osgExit();

    return 0;
}
void setupAnimation(JointUnrecPtr TheJoint, JointUnrecPtr TheChildJoint)
{
	//Create an animation for TheJoint
	//TheJoint Transformation keyframes (we'll animate TheJoint's translation)
	Matrix transform = TheJoint->getJointTransformation();

	KeyframeTransformationSequenceUnrecPtr TheJointTranformationKeyframes = KeyframeTransformationSequenceMatrix4f::create();
	
	transform.setTranslate(0.0f,0.0f,0.0f);
	TheJointTranformationKeyframes->addKeyframe(transform, 0.0f);

	transform.setTranslate(2.0f,0.0f,0.0f);
	TheJointTranformationKeyframes->addKeyframe(transform, 2.0f);

	transform.setTranslate(1.0f,0.0f,0.0f);
	TheJointTranformationKeyframes->addKeyframe(transform, 4.0f);

	transform.setTranslate(3.0f,0.0f,0.0f);
	TheJointTranformationKeyframes->addKeyframe(transform, 6.0f);

	transform = TheJoint->getJointTransformation();
	transform.setTranslate(0.0f,0.0f,0.0f);
	TheJointTranformationKeyframes->addKeyframe(transform, 8.0f);

	//TheJoint Animator
    AnimatorUnrecPtr TheJointAnimator = KeyframeAnimator::create();
    dynamic_pointer_cast<KeyframeAnimator>(TheJointAnimator)->setKeyframeSequence(TheJointTranformationKeyframes);

    //TheJoint Animation
    TheJointAnimation = FieldAnimation::create();
    dynamic_pointer_cast<FieldAnimation>(TheJointAnimation)->setAnimator(TheJointAnimator);
    dynamic_pointer_cast<FieldAnimation>(TheJointAnimation)->setInterpolationType(Animator::CUBIC_INTERPOLATION);
    dynamic_pointer_cast<FieldAnimation>(TheJointAnimation)->setCycling(-1);
    dynamic_pointer_cast<FieldAnimation>(TheJointAnimation)->setAnimatedField(TheJoint, std::string("JointTransformation"));
	
    TheJointAnimation->attachUpdateProducer(TutorialWindow->editEventProducer());
    TheJointAnimation->start();

	//Create an animation for TheChildJoint
	//TheChildJoint Transformation keyframes (we'll animate TheChildJoint's rotation)
	transform = TheChildJoint->getJointTransformation();

	KeyframeTransformationSequenceUnrecPtr TheChildJointTransformationKeyframes = KeyframeTransformationSequenceMatrix4f::create();

	TheChildJointTransformationKeyframes->addKeyframe(transform, 0.0f);

	transform.setRotate(Quaternion(Vec3f(0.0,1.0,0.0),0.0));
	TheChildJointTransformationKeyframes->addKeyframe(transform, 2.0f);

	transform.setRotate(Quaternion(Vec3f(0.0,1.0,0.0),0.5*Pi));
	TheChildJointTransformationKeyframes->addKeyframe(transform, 4.0f);

	transform.setRotate(Quaternion(Vec3f(0.0,1.0,0.0),Pi));
	TheChildJointTransformationKeyframes->addKeyframe(transform, 6.0f);

	transform.setRotate(Quaternion(Vec3f(0.0,1.0,0.0),1.5*Pi));
	TheChildJointTransformationKeyframes->addKeyframe(transform, 8.0f);

	transform.setRotate(Quaternion(Vec3f(0.0,1.0,0.0),2.0*Pi));
	TheChildJointTransformationKeyframes->addKeyframe(transform, 10.0f);

	//TheChildJoint Animator
    AnimatorUnrecPtr TheChildJointAnimator = KeyframeAnimator::create();
    dynamic_pointer_cast<KeyframeAnimator>(TheChildJointAnimator)->setKeyframeSequence(TheChildJointTransformationKeyframes);

	//TheChildJoint Animation
    TheChildJointAnimation = FieldAnimation::create();
    dynamic_pointer_cast<FieldAnimation>(TheChildJointAnimation)->setAnimator(TheChildJointAnimator);
    dynamic_pointer_cast<FieldAnimation>(TheChildJointAnimation)->setInterpolationType(Animator::CUBIC_INTERPOLATION);
    dynamic_pointer_cast<FieldAnimation>(TheChildJointAnimation)->setCycling(-1);
    dynamic_pointer_cast<FieldAnimation>(TheChildJointAnimation)->setAnimatedField(TheChildJoint, std::string("JointTransformation"));

    TheChildJointAnimation->attachUpdateProducer(TutorialWindow->editEventProducer());
    TheChildJointAnimation->start();
}
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);
    {
        // Set up Window
        WindowEventProducerRecPtr TutorialWindow = createNativeWindow();

        //Initialize Window
        TutorialWindow->initWindow();

        SimpleSceneManager sceneManager;
        TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
        TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));

        // Tell the Manager what to manage
        sceneManager.setWindow(TutorialWindow);

        //Attach to events
        TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager));
        TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager));
        TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
        TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));
        TutorialWindow->connectKeyPressed(boost::bind(keyPressed, _1, TutorialWindow.get()));

        //Shader Chunk
        SimpleSHLChunkUnrecPtr TheSHLChunk = SimpleSHLChunk::create();
        TheSHLChunk->setVertexProgram(createSHLVertexProg());
        TheSHLChunk->setFragmentProgram(createSHLFragProg());
        //TheSHLChunk->addUniformVariable("Color1",Vec4f(0.0f,1.0f,0.0f,1.0f));
        //TheSHLChunk->addUniformVariable("Color2",Vec4f(1.0f,1.0f,1.0f,1.0f));

        //Shader Parameter Chunk
        SimpleSHLVariableChunkUnrecPtr SHLParameters = SimpleSHLVariableChunk::create();
        //Color Parameter
        SHLParameters->addUniformVariable("Color1",Vec4f(0.0f,1.0f,0.0f,1.0f));
        SHLParameters->addUniformVariable("Color2",Vec4f(1.0f,1.0f,1.0f,1.0f));

        ChunkMaterialUnrecPtr ShaderMaterial = ChunkMaterial::create();
        ShaderMaterial->addChunk(TheSHLChunk);
        ShaderMaterial->addChunk(SHLParameters);

        //Torus Node
        GeometryUnrecPtr TorusGeometry = makeTorusGeo(5.0f,20.0f, 32,32);

        TorusGeometry->setMaterial(ShaderMaterial);

        NodeUnrecPtr TorusNode = Node::create();
        TorusNode->setCore(TorusGeometry);

        // Make Main Scene Node
        NodeUnrecPtr scene = Node::create();
        scene->setCore(Group::create());
        scene->addChild(TorusNode);

        sceneManager.setRoot(scene);

        // Show the whole Scene
        sceneManager.showAll();

        //Create the Animations

        ShaderVariableVec4fUnrecPtr Color1Parameter;
        ShaderVariableVec4fUnrecPtr Color2Parameter;

        Color1Parameter = dynamic_cast<ShaderVariableVec4f*>(const_cast<ShaderVariable*>(SHLParameters->getVariables()->getVariable("Color1")));
        Color2Parameter = dynamic_cast<ShaderVariableVec4f*>(const_cast<ShaderVariable*>(SHLParameters->getVariables()->getVariable("Color2")));
        commitChanges();

        AnimationUnrecPtr TheAnimation = setupAnimation(Color1Parameter, "value");
        TheAnimation->attachUpdateProducer(TutorialWindow);
        TheAnimation->start();

        //Open Window
        Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
        Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
        TutorialWindow->openWindow(WinPos,
                                   WinSize,
                                   "04ShaderAnimation");

        //Main Loop
        TutorialWindow->mainLoop();
    }

    osgExit();

    return 0;
}
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);
    {
        // Set up Window
        WindowEventProducerRecPtr TutorialWindow = createNativeWindow();

        SimpleSceneManager sceneManager;
        TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
        TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));

        //Initialize Window
        TutorialWindow->initWindow();

        // Tell the Manager what to manage
        sceneManager.setWindow(TutorialWindow);

        //Attach to events
        TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager));
        TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager));
        TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager));
        TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager));

        //Print key command info
        std::cout << "\n\nKEY COMMANDS:" << std::endl;
        std::cout << "space   Play/Pause the animation" << std::endl;
        std::cout << "B       Show/Hide the bind pose skeleton" << std::endl;
        std::cout << "P       Show/Hide the current pose skeleton" << std::endl;
        //std::cout << "1       Play first example animation" << std::endl;
        //std::cout << "2       Play second example animation" << std::endl;
        std::cout << "CTRL-Q  Exit\n\n" << std::endl;


        //SkeletonDrawer System Material
        LineChunkUnrecPtr ExampleLineChunk = LineChunk::create();
        ExampleLineChunk->setWidth(2.0f);
        ExampleLineChunk->setSmooth(true);

        BlendChunkUnrecPtr ExampleBlendChunk = BlendChunk::create();
        ExampleBlendChunk->setSrcFactor(GL_SRC_ALPHA);
        ExampleBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);

        MaterialChunkUnrecPtr ExampleMaterialChunk = MaterialChunk::create();
        ExampleMaterialChunk->setAmbient(Color4f(1.0f,1.0f,1.0f,1.0f));
        ExampleMaterialChunk->setDiffuse(Color4f(0.0f,0.0f,0.0f,1.0f));
        ExampleMaterialChunk->setSpecular(Color4f(0.0f,0.0f,0.0f,1.0f));

        ChunkMaterialUnrecPtr ExampleMaterial = ChunkMaterial::create();
        ExampleMaterial->addChunk(ExampleLineChunk);
        ExampleMaterial->addChunk(ExampleMaterialChunk);
        ExampleMaterial->addChunk(ExampleBlendChunk);

        GeometryRefPtr SphereGeometry = makeSphereGeo(2, 0.25f);
        GeometryRefPtr BoxGeometry = makeBoxGeo(0.5f,0.5f,0.5f,1,1,1);

        //Skeleton
        SkeletonBlendedGeometryUnrecPtr ExampleSkeleton = SkeletonBlendedGeometry::create();

        //Joint
        TransformRecPtr ExampleRootJoint = Transform::create();

        NodeRecPtr ExampleRootJointNode = makeNodeFor(ExampleRootJoint);

        //Add this joint to the skeleton
        ExampleSkeleton->pushToJoints(ExampleRootJointNode, Matrix());

        NodeRecPtr TempRootJointNode = ExampleRootJointNode;
        NodeRefPtr GeoNode = makeNodeFor(BoxGeometry);
        TempRootJointNode->addChild(GeoNode);

        Matrix TempMat;
        //Create a set of randomly placed child joints
        for (Real32 i = 0.0f; i < 5.0f; ++i)
        {
            TransformRecPtr ExampleChildJoint = Transform::create();
            NodeRecPtr ExampleChildJointNode = makeNodeFor(ExampleChildJoint);

            GeoNode = makeNodeFor(SphereGeometry);
            ExampleChildJointNode->addChild(GeoNode);

            //TempMat.setTranslate(RandomPoolManager::getRandomReal32(0.0, 10.0f), RandomPoolManager::getRandomReal32(0.0f, 10.0f), RandomPoolManager::getRandomReal32(0.0f, 10.0f));
            switch((static_cast<UInt32>(i) % 3))
            {
                case 0:
                    TempMat.setTranslate(2.0f,0.0f,0.0f);
                    break;
                case 1:
                    TempMat.setTranslate(0.0f,2.0f,0.0f);
                    break;
                case 2:
                    TempMat.setTranslate(0.0f,0.0f,2.0f);
                    break;
            }

            //Set bind and current transformations to TempMat (calculated above)
            ExampleChildJoint->setMatrix(TempMat);

            //Add ExampleChildJoint as a child to the previous joint    
            TempRootJointNode->addChild(ExampleChildJointNode);//add a Child to the root joint

            //ExampleChildJoint will be the next parent joint
            TempRootJointNode = ExampleChildJointNode;

            //Add this joint to the skeleton
            Matrix InvBind(TempRootJointNode->getToWorld());
            InvBind.invert();
            ExampleSkeleton->pushToJoints(ExampleChildJointNode, InvBind);
        }

        //SkeletonDrawer
        SkeletonDrawableUnrecPtr ExampleSkeletonDrawable = SkeletonDrawable::create();
        ExampleSkeletonDrawable->setSkeleton(ExampleSkeleton);
        ExampleSkeletonDrawable->setMaterial(ExampleMaterial);
        ExampleSkeletonDrawable->setDrawBindPose(false);  //By default, we won't draw the skeleton's bind pose
        ExampleSkeletonDrawable->setBindPoseColor(Color4f(0.0, 1.0, 0.0, 1.0));  //When the skeleton's bind pose is rendered, it will be green
        ExampleSkeletonDrawable->setDrawPose(true);  //By default, we do draw the skeleton's current pose
        ExampleSkeletonDrawable->setPoseColor(Color4f(0.0, 0.0, 1.0, 1.0));  //The skeleton's current pose is rendered in blue

        //Skeleton Node
        NodeUnrecPtr SkeletonNode = Node::create();
        SkeletonNode->setCore(ExampleSkeletonDrawable);

        //Create scene
        NodeUnrecPtr scene = Node::create();
        scene->setCore(Group::create());
        scene->addChild(SkeletonNode);
        scene->addChild(ExampleRootJointNode);

        sceneManager.setRoot(scene);

        //Create the Documentation
        SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);

        //Setup the Animation
        AnimationUnrecPtr TheAnimation = setupAnimation(ExampleRootJoint,
                                                        dynamic_cast<Transform*>(ExampleRootJointNode->getChild(1)->getCore()));
        TheAnimation->attachUpdateProducer(TutorialWindow);
        TheAnimation->start();

        TutorialWindow->connectKeyPressed(boost::bind(keyPressed, _1,
                                                      TheAnimation.get(),
                                                      SkeletonNode.get(),
                                                      TutorialWindow.get()));

        // Show the whole Scene
        sceneManager.showAll();


        //Open Window
        Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
        Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
        TutorialWindow->openWindow(WinPos,
                                   WinSize,
                                   "11BoneAnimation");

        //Main Loop
        TutorialWindow->mainLoop();

    }
    osgExit();

    return 0;
}