osgAnimation.TemplateInterpolatorBase是OpenSceneGraph的osgAnimation库中一种模板化的插值器基类,用于计算两个值之间的插值。它包含一些基本的插值函数和成员变量,供继承类使用。
double _startTime:插值器的起始时间。double _endTime:插值器的结束时间。virtual void setStartTime(double t):设置插值器的起始时间。virtual double getStartTime() const:获取插值器的起始时间。virtual void setEndTime(double t):设置插值器的结束时间。virtual double getEndTime() const:获取插值器的结束时间。virtual bool getFirst(double &value):获取插值器的第一个插值值,并将其赋值给value变量。如果插值器中没有可用的插值值,返回false。virtual bool getNext(double &value):获取插值器的下一个插值值,并将其赋值给value变量。如果插值器中没有可用的插值值,返回false。osgAnimation.FloatInterpolator:基于osgAnimation.TemplateInterpolatorBase实现的浮点数插值器。osgAnimation.DoubleInterpolator:基于osgAnimation.TemplateInterpolatorBase实现的双精度浮点数插值器。osgAnimation.Vec3Interpolator:基于osgAnimation.TemplateInterpolatorBase实现的三维向量插值器。osgAnimation.QuatInterpolator:基于osgAnimation.TemplateInterpolatorBase实现的四元数插值器。osgAnimation.QuatSlerpInterpolator:基于osgAnimation.QuatInterpolator实现的四元数插值器,使用球面线性插值算法(Slerp)。osgAnimation.QuatSquadInterpolator:基于osgAnimation.QuatInterpolator实现的四元数插值器,使用Squad算法(四元数样条)。osgAnimation.MatrixInterpolator:基于osgAnimation.TemplateInterpolatorBase实现的矩阵插值器。osgAnimation.VertexAttributeInterpolator:基于osgAnimation.TemplateInterpolatorBase实现的顶点属性插值器。// 创建一个从0到10秒之间插值的FloatInterpolator对象
osg::ref_ptr<osgAnimation::FloatInterpolator> interpolator = new osgAnimation::FloatInterpolator();
interpolator->setStartTime(0.0);
interpolator->setEndTime(10.0);
// 输出插值器中的所有插值值
double value;
while (interpolator->getNext(value))
{
std::cout << value << std::endl;
}