查看: 1458|回复: 1

osg2.99 版本中"euler"运动怎么实现?

[复制链接]

该用户从未签到

发表于 2011-1-7 16:47:04 | 显示全部楼层 |阅读模式
osg2.99 版本中"euler"运动怎么实现?2.99版本examples中的osganimationsolid程序中有平移和旋转的代码(绿色部分),但编译出来的exe中只有平移功能,没有旋转功能。

以下是osganimationsolid.cpp中的部分程序代码:


osg::ref_ptr<osg::MatrixTransform> trans = new osg::MatrixTransform();

trans->setName("AnimatedNode");

trans->setDataVariance(osg::Object:YNAMIC);

osgAnimation::UpdateMatrixTransform* updatecb = new osgAnimation::UpdateMatrixTransform("AnimatedCallback");


updatecb->getStackedTransforms().push_back(new osgAnimation::StackedTranslateElement("position"));


trans->setUpdateCallback(updatecb);

    trans->setMatrix(osg::Matrix::identity());
    trans->addChild (geode.get());

    root->addChild (axe.get());
    root->addChild (trans.get());

    // Define a scheduler for our animations
    osg::Group* grp = new osg::Group;
    osgAnimation::BasicAnimationManager* mng = new osgAnimation::BasicAnimationManager();
    grp->setUpdateCallback(mng);

    grp->addChild(root);

    // And we finaly define our channel
    osgAnimation::Vec3LinearChannel* channelAnimation1 = new osgAnimation::Vec3LinearChannel;
    channelAnimation1->setTargetName("AnimatedCallback");
    channelAnimation1->setName("position");
    channelAnimation1->getOrCreateSampler()->getOrCreateKeyframeContainer()->push_back(osgAnimation::Vec3Keyframe(0, osg::Vec3(0,0,0)));
    channelAnimation1->getOrCreateSampler()->getOrCreateKeyframeContainer()->push_back(osgAnimation::Vec3Keyframe(2, osg::Vec3(1,1,0)));
    osgAnimation::Animation* anim1 = new osgAnimation::Animation;
    anim1->addChannel(channelAnimation1);
    anim1->setPlayMode(osgAnimation::Animation:PONG);


    osgAnimation::Vec3LinearChannel* channelAnimation2 = new osgAnimation::Vec3LinearChannel;
    channelAnimation2->setTargetName("AnimatedCallback");
    channelAnimation2->setName("euler");
    channelAnimation2->getOrCreateSampler()->getOrCreateKeyframeContainer()->push_back(osgAnimation::Vec3Keyframe(0, osg::Vec3(0,0,0)));
    channelAnimation2->getOrCreateSampler()->getOrCreateKeyframeContainer()->push_back(osgAnimation::Vec3Keyframe(1.5, osg::Vec3(2*osg::PI,0,0)));
    osgAnimation::Animation* anim2 = new osgAnimation::Animation;
    anim2->addChannel(channelAnimation2);

求助!osg2.99中怎么实现旋转功能?
    anim2->setPlayMode(osgAnimation::Animation:OOP);

该用户从未签到

发表于 2011-1-10 08:43:03 | 显示全部楼层
就是osganimationsolid例子,它很明显地同时实现了平移和旋转
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

联系我们

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