osgAnimation.InSineFunction
是 OpenSceneGraph 中用于实现 Sine 动画函数的类。该函数用于生成一个在给定时间内逐步增加的正弦曲线。
osgAnimation.InSineFunction(start_time, end_time)
start_time
: 该函数的起始时间。end_time
: 该函数的结束时间。返回类型为 float,表示当前时刻的函数值。
#include <osgAnimation/Function>
#include <osg/MatrixTransform>
osg::ref_ptr<osg::MatrixTransform> createTransform()
{
osg::ref_ptr<osg::MatrixTransform> trans = new osg::MatrixTransform;
// 创建一个 InSineFunction 动画函数,并将其传递给 MatrixTransform 的动画属性。
osgAnimation::InSineFunction* animation = new osgAnimation::InSineFunction(0.0f, 2.0f);
osg::AnimationPath::ControlPoint controlPoint(osg::Vec3(0,0,0), osg::Quat(), osg::Vec3(1,1,1));
controlPoint.setInterpolator(animation);
osg::ref_ptr<osg::AnimationPath> animationPath = new osg::AnimationPath;
animationPath->insert(0.0f, controlPoint);
animationPath->insert(2.0f, osg::AnimationPath::ControlPoint(osg::Vec3(0,0,0), osg::Quat(), osg::Vec3(2,2,2)));
osg::ref_ptr<osg::AnimationPathCallback> apcb = new osg::AnimationPathCallback(animationPath);
trans->setUpdateCallback(apcb);
return trans;
}