|
发表于 2010-5-16 03:46:54
|
显示全部楼层
稍微看了用一下,,下面的应该是正确的,具体原因就不解析了~~~给您一个建议,,请您从C++初级教程入手,一步一步慢慢来~~~
- #include <osg/AnimationPath>
- #include <osg/MatrixTransform>
- #include <osgDB/ReadFile>
- #include <osgViewer/Viewer>
- #include <osg/Math>
- osg::AnimationPath* createPath()
- {
- typedef osg::AnimationPath::ControlPoint ControlPoint;
- osg::Vec3 yoz(1.0,0.0,0.0),xoz(0.0,1.0,0.0),xoy(0.0,0.0,1.0);
- osg::ref_ptr<osg::AnimationPath> path =new osg::AnimationPath ;
- path->insert(0.0,ControlPoint(osg::Vec3 (0.0,0.0,0.0),osg:uat(0.0,yoz,0.0,xoz,0.0,xoy)));
- path->insert(2.0,ControlPoint(osg::Vec3 (5.0,0.0,0.0),osg:uat(osg:I,yoz,0.0,xoz,0.0,xoy)));
- path->insert(4.0,ControlPoint(osg::Vec3 (5.0,0.0,5.0),osg:uat(osg:I,yoz,0.0,xoz,osg:I,xoy)));
- path->insert(6.0,ControlPoint(osg::Vec3 (0.0,0.0,5.0),osg:uat(0.0,yoz,0.0,xoz,osg:I,xoy)));
- path->insert(8.0,ControlPoint(osg::Vec3 (0.0,0.0,0.0),osg:uat(0.0,yoz,0.0,xoz,0.0,xoy)));
- return path.release();
- }
- int main(int argc, char** argv )
- {
- osg::ArgumentParser arguments(&argc,argv);
- osg::Node* model=osgDB::readNodeFiles(arguments);
- if (!model)model=osgDB::readNodeFile("glider.osg");
- osg::AnimationPath* path=createPath();
- path->setLoopMode(osg::AnimationPath:OOP );
- osg::ref_ptr<osg::MatrixTransform> root=new osg::MatrixTransform;
- root->addChild(model);
- root->setUpdateCallback (new osg::AnimationPathCallback(path));
- osgViewer::Viewer viewer;
- viewer.setSceneData(root.get());
- return viewer.run();
- }
复制代码 |
|