查看: 1572|回复: 3

osg动画路径的问题

[复制链接]

该用户从未签到

发表于 2010-4-7 18:06:22 | 显示全部楼层 |阅读模式
我想做条物体移动的过程,但不用osgAnimation,还是用以前的osg::AnimationPath,但是做了个小程序测试,始终不见东西,不知道哪块出问题了,各位同仁能帮忙看下吗?折腾好久了,烦
    osgViewer::Viewer viewer;
    osg::Group* group = new osg::Group;

    osg::AnimationPath* animationPath_test = new osg::AnimationPath;;
    animationPath_test->setLoopMode(osg::AnimationPath:OOP);
    animationPath_test->insert( 0, osg::AnimationPath::ControlPoint(osg::Vec3(0.0, 0.0, 0.0), osg:uat(0.0,0.0,0.0,0.0)) );
    animationPath_test->insert( 2, osg::AnimationPath::ControlPoint(osg::Vec3(2.0, 0.0, 0.0), osg::Quat(0.0,0.0,0.0,0.0)) );
    animationPath_test->insert( 4, osg::AnimationPath::ControlPoint(osg::Vec3(4.0, 0.0, 0.0), osg::Quat(0.0,0.0,0.0,0.0)) );

    osg::ShapeDrawable* shape_test = new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0f, 0.0f, 0.0f), 2));
    shape_test->setColor( osg::Vec4(1.0f, 1.0f, 0.0f, 1.0f) );
    osg::Geode* geode_test = new osg::Geode();
    geode_test->addDrawable( shape_test );

    osg::MatrixTransform* xform_test = new osg::MatrixTransform;
    xform_test->setUpdateCallback( new osg::AnimationPathCallback( animationPath_test ) );
    xform_test->addChild ( geode_test );
    group->addChild ( xform_test );

    viewer.setSceneData( group );
    return viewer.run();

该用户从未签到

发表于 2010-4-8 09:02:32 | 显示全部楼层
animationPath_test->insert( 0, osg::AnimationPath::ControlPoint(osg::Vec3(0.0, 0.0, 0.0), osg:uat(0.0,0.0,0.0,0.0)) );
    animationPath_test->insert( 2, osg::AnimationPath::ControlPoint(osg::Vec3(2.0, 0.0, 0.0), osg::Quat(0.0,0.0,0.0,0.0)) );
    animationPath_test->insert( 4, osg::AnimationPath::ControlPoint(osg::Vec3(4.0, 0.0, 0.0), osg::Quat(0.0,0.0,0.0,0.0)) );


问题在osg:: Quat(0.0,0.0,0.0,0.0)!四元数的默认值是Quat(0,0,0,1),您这里的设置反而会使得旋转的计算出现问题

该用户从未签到

 楼主| 发表于 2010-4-8 09:18:39 | 显示全部楼层
呵呵 果然是这个问题,多谢array了,要不然这个问题又折腾我好久

该用户从未签到

发表于 2010-4-8 09:41:39 | 显示全部楼层
mark 下以后注意
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

联系我们

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