Hi hybr,

Thank you very much for your help.

I completed it and here I am giving complete code.


Code:
class ACPNodeVisitor : public osg::NodeVisitor
{
public:
        

        ACPNodeVisitor(  ) 
        {
                setTraversalMode(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN );
                
        }


        virtual void apply( osg::Transform& tranform );

        
        
protected:
        
        
};

void ACPNodeVisitor::apply(  osg::Transform& transform )
{
        
        osg::AnimationPathCallback* apc = 
dynamic_cast<osg::AnimationPathCallback*>(transform.getUpdateCallback()); 
        
        if (apc)
        {
                osg::AnimationPath *path= apc->getAnimationPath();
                
        
                int CuraniTime=apc->getAnimationTime();
                int AniTime=path->getPeriod();

                if(CuraniTime<=AniTime-1)
                {
                        std::cout<<path->getPeriod()<<std::endl;
                        std::cout<<path->getFirstTime()<<std::endl;
                        std::cout<<path->getLastTime()<<std::endl;
                        std::cout<<apc->getAnimationTime()<<std::endl;
                        std::cout<<"-------------"<<std::endl;
                        apc->setPause(false);
                }
                else
                {
                        apc->setPause(true);
                }

                
                
        } 
        
traverse( transform );
}




void main()
{
        osg::ref_ptr<osg::Node> model = osgDB::readNodeFile( "test.osg");
        
        osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform;
        mt->addChild( model.get() );

        osg::ref_ptr<osg::Group> root = new osg::Group;
        root->addChild( mt.get() );



osgViewer::Viewer viewer;
viewer.setUpViewInWindow (200, 200, 512, 512);
viewer.setCameraManipulator( new osgGA::TrackballManipulator );

viewer.setSceneData( root.get() );



while(!viewer.done())
{
        ACPNodeVisitor ftv;
        
        mt->accept( ftv );
                
        viewer.frame();
                
}

        
}



Is it the way of doing? If wrong can you please suggest the correct way of 
doing it.

... 

Thank you!

Cheers,
Koduri

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=48945#48945




_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to