Hi,

I have an OSG file contains some animation. The animation created in 3DS MAX. 
Now I want to control the animation of OSG. I controled the animation 
by using the simulation time. I gave the simulation time to the viewer->frame() 
function. This worked for me.

Here is the code for this


Code:
#include <osg/MatrixTransform>
#include <osgDB/ReadFile>
#include <osgGA/GUIEventHandler>
#include <osgViewer/Viewer>
#include <osgGA/TrackballManipulator>


int 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.getCamera()->setViewMatrixAsLookAt(osg::Vec3(0.0f,-100.0f,0.0f), 
osg::Vec3(), osg::Z_AXIS );
viewer.getCamera()->setAllowEventFocus( false );
viewer.setSceneData( root.get() );

double simulationTime1 = 0.0;
double simulationTime2 = 10.0;

while(!viewer.done())
{
        

        if(simulationTime1<=10)
        {
                simulationTime1 = simulationTime1+0.01;
                viewer.frame(simulationTime1);
                std::cout<<simulationTime1<<std::endl;
        }
        else
        {
                simulationTime2 =simulationTime2- 0.01;
                viewer.frame(simulationTime2);
                std::cout<<simulationTime2<<std::endl;
        }

                
}

        
}



Is this correct way of controling animations of OSG?

Now I have two OSG models. Both containing the animation. At a certain 
condition I want to stop the animation of the one of the model and I want to 
play the animation of the other model. This is not possible for me with 
simulation Time. 

Can any one please guide me how to control the animations of OSG models.



Thank you!

Cheers,
Koduri

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




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

Reply via email to