本文整理汇总了C++中KeyFrame::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyFrame::getPosition方法的具体用法?C++ KeyFrame::getPosition怎么用?C++ KeyFrame::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyFrame
的用法示例。
在下文中一共展示了KeyFrame::getPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
//----------------------------------------------------------------------------//
void Affector::apply(AnimationInstance* instance)
{
PropertySet* target = instance->getTarget();
const float position = instance->getPosition();
// special case
if (d_keyFrames.empty())
{
return;
}
if (d_targetProperty.empty())
{
Logger::getSingleton().logEvent(
"Affector can't be applied when target property is set!", Warnings);
return;
}
if (!d_interpolator)
{
Logger::getSingleton().logEvent(
"Affector can't be applied when no interpolator is set!", Warnings);
return;
}
KeyFrame* left = 0;
KeyFrame* right = 0;
// find 2 neighbouring keyframes
for (KeyFrameMap::const_iterator it = d_keyFrames.begin();
it != d_keyFrames.end(); ++it)
{
KeyFrame* current = it->second;
if (current->getPosition() <= position)
{
left = current;
}
if (current->getPosition() >= position && !right)
{
right = current;
}
}
float leftDistance, rightDistance;
if (left)
{
leftDistance = position - left->getPosition();
}
else
// if no keyframe is suitable for left neighbour, pick the first one
{
left = d_keyFrames.begin()->second;
leftDistance = 0;
}
if (right)
{
rightDistance = right->getPosition() - position;
}
else
// if no keyframe is suitable for the right neighbour, pick the last one
{
right = d_keyFrames.rbegin()->second;
rightDistance = 0;
}
// if there is just one keyframe and we are right on it
if (leftDistance + rightDistance == 0)
{
leftDistance = rightDistance = 0.5;
}
// alter interpolation position using the right neighbours progression
// method
const float interpolationPosition =
right->alterInterpolationPosition(
leftDistance / (leftDistance + rightDistance));
// absolute application method
if (d_applicationMethod == AM_Absolute)
{
const String result = d_interpolator->interpolateAbsolute(
left->getValueForAnimation(instance),
right->getValueForAnimation(instance),
interpolationPosition);
target->setProperty(d_targetProperty, result);
}
// relative application method
else if (d_applicationMethod == AM_Relative)
{
const String& base = instance->getSavedPropertyValue(getTargetProperty());
const String result = d_interpolator->interpolateRelative(
base,
left->getValueForAnimation(instance),
//.........这里部分代码省略.........