osg.AnimationPath
是OpenSceneGraph中管理动画路径的类。动画路径表示模型或者相机的运动过程及动画。
osg.AnimationPath
osg::ref_ptr<osg::AnimationPath> animationPath = new osg::AnimationPath;
double timeInSeconds = 0.0;
osg::Vec3 position(0.0f, 0.0f, 0.0f);
osg::Quat rotation(0.0f, 0.0f, 0.0f, 1.0f);
osg::Vec3 scale(1.0f, 1.0f, 1.0f);
animationPath->insert(timeInSeconds, osg::AnimationPath::ControlPoint(position, rotation, scale));
double pathLength = animationPath->getPeriod();
osg::Vec3 position = animationPath->getPosition(timeInSeconds);
osg::Quat rotation = animationPath->getRotation(timeInSeconds);
使用 osg::AnimationPathCallback
类可以让动画路径自动更新。
osg::ref_ptr<osg::MatrixTransform> transformNode = new osg::MatrixTransform;
transformNode->setUpdateCallback(new osg::AnimationPathCallback(animationPath));