查看: 1082|回复: 3

新人求助!在线等急,高位老大请进

[复制链接]

该用户从未签到

发表于 2010-5-15 23:29:00 | 显示全部楼层 |阅读模式

  1. #include <osg/AnimationPath>
  2. #include <osg/MatrixTransform>
  3. #include <osgDB/ReadFile>
  4. #include <osgViewer/Viewer>
  5. #include <osg/Math>
  6. osg::AnimationPath* createPath()
  7. {
  8. typedef osg::PI PI; \\这里提示有错误
  9. typedef osg::AnimationPath::ControlPoint ControlPoint;
  10. osg::Vec3 yoz(1.0,0.0,0.0),xoz(0.0,1.0,0.0),xoy(0.0,0.0,1.0);
  11. osg::ref_ptr <osg::AnimationPath>path =new osg::AnimationPath  
  12.   path->insert(0.0,ControlPoint(osg::Vec3 (0.0,0.0,0.0),osg::Quat(0.0,yoz,0.0,xoz,0.0,xoy)));  \\这里提示也有错误
  13.   path->insert(2.0,ControlPoint(osg::Vec3 (5.0,0.0,0.0),osg::Quat(PI,yoz,0.0,xoz,0.0,xoy)));
  14.   path->insert(4.0,ControlPoint(osg::Vec3 (5.0,0.0,5.0),osg::Quat(PI,yoz,0.0,xoz,PI,xoy)));
  15.   path->insert(6.0,ControlPoint(osg::Vec3 (0.0,0.0,5.0),osg::Quat(0.0,yoz,0.0,xoz,PI,xoy)));
  16.   path->insert(8.0,ControlPoint(osg::Vec3 (0.0,0.0,0.0),osg::Quat(0.0,yoz,0.0,xoz,0.0,xoy)));
  17.   return path.release();
  18. }
  19. int main(int argc, char** argv )
  20. {
  21. osg::ArgumentParser arguments(&argc,argv);
  22. osg::Node* model=osgDB::readNodeFile(arguments);
  23. if (!model)model=osgDB::readNodeFile("glider.osg");

  24. osg::AnimationPath* path=createPath();
  25. path->setLoopMode(osg::AnimationPath::LOOP );
  26. osg::ref_ptr <osg::MatrixTransform>root=new osg::MatrixTransform;
  27. root->addChild(model);
  28. root->setUpdateCallback (new osg::AnimationPathCallback(path));
  29. osgViewer::Viewer Viewer;
  30. viewer.setSceneData(root.get()); \\还有这提示也有错误
  31. return viewer.run();  \\这提示也有错误

  32. }
复制代码
代码提示 提示有问题请教如何更改    谢谢个位老大了!!万分火急啊

该用户从未签到

 楼主| 发表于 2010-5-15 23:30:08 | 显示全部楼层
十分抱歉 黏贴的代码 都变符号了

该用户从未签到

发表于 2010-5-16 03:46:54 | 显示全部楼层
稍微看了用一下,,下面的应该是正确的,具体原因就不解析了~~~给您一个建议,,请您从C++初级教程入手,一步一步慢慢来~~~



  1. #include <osg/AnimationPath>
  2. #include <osg/MatrixTransform>
  3. #include <osgDB/ReadFile>
  4. #include <osgViewer/Viewer>
  5. #include <osg/Math>
  6. osg::AnimationPath* createPath()
  7. {

  8.         typedef osg::AnimationPath::ControlPoint ControlPoint;
  9.         osg::Vec3 yoz(1.0,0.0,0.0),xoz(0.0,1.0,0.0),xoy(0.0,0.0,1.0);
  10.         osg::ref_ptr<osg::AnimationPath> path =new osg::AnimationPath ;  
  11.                 path->insert(0.0,ControlPoint(osg::Vec3 (0.0,0.0,0.0),osg:uat(0.0,yoz,0.0,xoz,0.0,xoy)));  
  12.         path->insert(2.0,ControlPoint(osg::Vec3 (5.0,0.0,0.0),osg:uat(osg:I,yoz,0.0,xoz,0.0,xoy)));
  13.         path->insert(4.0,ControlPoint(osg::Vec3 (5.0,0.0,5.0),osg:uat(osg:I,yoz,0.0,xoz,osg:I,xoy)));
  14.         path->insert(6.0,ControlPoint(osg::Vec3 (0.0,0.0,5.0),osg:uat(0.0,yoz,0.0,xoz,osg:I,xoy)));
  15.         path->insert(8.0,ControlPoint(osg::Vec3 (0.0,0.0,0.0),osg:uat(0.0,yoz,0.0,xoz,0.0,xoy)));
  16.         return path.release();
  17. }
  18. int main(int argc, char** argv )
  19. {
  20.         osg::ArgumentParser arguments(&argc,argv);
  21.         osg::Node* model=osgDB::readNodeFiles(arguments);
  22.         if (!model)model=osgDB::readNodeFile("glider.osg");

  23.         osg::AnimationPath* path=createPath();
  24.         path->setLoopMode(osg::AnimationPath:OOP );
  25.         osg::ref_ptr<osg::MatrixTransform> root=new osg::MatrixTransform;
  26.         root->addChild(model);
  27.         root->setUpdateCallback (new osg::AnimationPathCallback(path));
  28.         osgViewer::Viewer viewer;
  29.         viewer.setSceneData(root.get());
  30.         return viewer.run();  

  31. }

复制代码

该用户从未签到

 楼主| 发表于 2010-5-23 11:09:49 | 显示全部楼层
多谢管理员建议我一定努力!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

OSG中国官方论坛-有您OSG在中国才更好

网站简介:osgChina是国内首个三维相关技术开源社区,旨在为国内更多的技术开发人员提供最前沿的技术资讯,为更多的三维从业者提供一个学习、交流的技术平台。

联系我们

  • 工作时间:09:00--18:00
  • 反馈邮箱:1315785073@qq.com
快速回复 返回顶部 返回列表