本文整理汇总了C++中AnimationTarget::setAnimationPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C++ AnimationTarget::setAnimationPropertyValue方法的具体用法?C++ AnimationTarget::setAnimationPropertyValue怎么用?C++ AnimationTarget::setAnimationPropertyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnimationTarget
的用法示例。
在下文中一共展示了AnimationTarget::setAnimationPropertyValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
//.........这里部分代码省略.........
(**_listenerItr)->_listener->animationEvent(this, Listener::TIME);
--*_listenerItr;
}
}
}
// Add back in start time, and divide by the total animation's duration to get the actual percentage complete
GP_ASSERT(_animation);
// Compute percentage complete for the current loop (prevent a divide by zero if _duration==0).
// Note that we don't use (currentTime/(_duration+_loopBlendTime)). That's because we want a
// % value that is outside the 0-1 range for loop smoothing/blending purposes.
float percentComplete = _duration == 0 ? 1 : currentTime / (float)_duration;
if (_loopBlendTime == 0.0f)
percentComplete = MATH_CLAMP(percentComplete, 0.0f, 1.0f);
// If we're cross fading, compute blend weights
if (isClipStateBitSet(CLIP_IS_FADING_OUT_BIT))
{
GP_ASSERT(_crossFadeToClip);
GP_ASSERT(_crossFadeOutDuration > 0);
if (isClipStateBitSet(CLIP_IS_FADING_OUT_STARTED_BIT)) // Calculate elapsed time since the fade out begin.
{
GP_ASSERT(_crossFadeToClip);
_crossFadeOutElapsed = (Game::getGameTime() - _crossFadeToClip->_timeStarted) * fabs(_speed);
resetClipStateBit(CLIP_IS_FADING_OUT_STARTED_BIT);
}
else
{
// continue tracking elapsed time.
_crossFadeOutElapsed += elapsedTime * fabs(_speed);
}
if (_crossFadeOutElapsed < _crossFadeOutDuration)
{
// Calculate this clip's blend weight.
float tempBlendWeight = ((float)_crossFadeOutDuration - _crossFadeOutElapsed) / (float)_crossFadeOutDuration;
// If this clip is fading in, adjust the crossfade clip's weight to be a percentage of your current blend weight
if (isClipStateBitSet(CLIP_IS_FADING_IN_BIT))
{
_crossFadeToClip->_blendWeight = (1.0f - tempBlendWeight) * _blendWeight;
_blendWeight -= _crossFadeToClip->_blendWeight;
}
else
{
// Just set the blend weight.
_crossFadeToClip->_blendWeight = (1.0f - tempBlendWeight);
_blendWeight = tempBlendWeight;
}
}
else
{
// Fade is done.
_crossFadeToClip->_blendWeight = 1.0f;
_blendWeight = 0.0f;
resetClipStateBit(CLIP_IS_STARTED_BIT);
resetClipStateBit(CLIP_IS_FADING_OUT_BIT);
_crossFadeToClip->resetClipStateBit(CLIP_IS_FADING_IN_BIT);
SAFE_RELEASE(_crossFadeToClip);
}
}
// Evaluate this clip.
Animation::Channel* channel = NULL;
AnimationValue* value = NULL;
AnimationTarget* target = NULL;
size_t channelCount = _animation->_channels.size();
float percentageStart = (float)_startTime / (float)_animation->_duration;
float percentageEnd = (float)_endTime / (float)_animation->_duration;
float percentageBlend = (float)_loopBlendTime / (float)_animation->_duration;
for (size_t i = 0; i < channelCount; i++)
{
channel = _animation->_channels[i];
GP_ASSERT(channel);
target = channel->_target;
GP_ASSERT(target);
value = _values[i];
GP_ASSERT(value);
// Evaluate the point on Curve
GP_ASSERT(channel->getCurve());
channel->getCurve()->evaluate(percentComplete, percentageStart, percentageEnd, percentageBlend, value->_value);
// Set the animation value on the target property.
target->setAnimationPropertyValue(channel->_propertyId, value, _blendWeight);
}
// When ended. Probably should move to it's own method so we can call it when the clip is ended early.
if (isClipStateBitSet(CLIP_IS_MARKED_FOR_REMOVAL_BIT) || !isClipStateBitSet(CLIP_IS_STARTED_BIT))
{
onEnd();
return true;
}
return false;
}
示例2: lua_AnimationTarget_setAnimationPropertyValue
int lua_AnimationTarget_setAnimationPropertyValue(lua_State* state)
{
// Get the number of parameters.
int paramCount = lua_gettop(state);
// Attempt to match the parameters to a valid binding.
switch (paramCount)
{
case 3:
{
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
lua_type(state, 2) == LUA_TNUMBER &&
(lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
{
// Get parameter 1 off the stack.
int param1 = (int)luaL_checkint(state, 2);
// Get parameter 2 off the stack.
bool param2Valid;
gameplay::ScriptUtil::LuaArray<AnimationValue> param2 = gameplay::ScriptUtil::getObjectPointer<AnimationValue>(3, "AnimationValue", false, ¶m2Valid);
if (!param2Valid)
{
lua_pushstring(state, "Failed to convert parameter 2 to type 'AnimationValue'.");
lua_error(state);
}
AnimationTarget* instance = getInstance(state);
instance->setAnimationPropertyValue(param1, param2);
return 0;
}
lua_pushstring(state, "lua_AnimationTarget_setAnimationPropertyValue - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
case 4:
{
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
lua_type(state, 2) == LUA_TNUMBER &&
(lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL) &&
lua_type(state, 4) == LUA_TNUMBER)
{
// Get parameter 1 off the stack.
int param1 = (int)luaL_checkint(state, 2);
// Get parameter 2 off the stack.
bool param2Valid;
gameplay::ScriptUtil::LuaArray<AnimationValue> param2 = gameplay::ScriptUtil::getObjectPointer<AnimationValue>(3, "AnimationValue", false, ¶m2Valid);
if (!param2Valid)
{
lua_pushstring(state, "Failed to convert parameter 2 to type 'AnimationValue'.");
lua_error(state);
}
// Get parameter 3 off the stack.
float param3 = (float)luaL_checknumber(state, 4);
AnimationTarget* instance = getInstance(state);
instance->setAnimationPropertyValue(param1, param2, param3);
return 0;
}
lua_pushstring(state, "lua_AnimationTarget_setAnimationPropertyValue - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
default:
{
lua_pushstring(state, "Invalid number of parameters (expected 3 or 4).");
lua_error(state);
break;
}
}
return 0;
}
示例3: update
//.........这里部分代码省略.........
else
{
while (*_listenerItr != _listeners->begin() && _elapsedTime <= (long) (**_listenerItr)->_eventTime)
{
GP_ASSERT(_listenerItr);
GP_ASSERT(**_listenerItr);
GP_ASSERT((**_listenerItr)->_listener);
(**_listenerItr)->_listener->animationEvent(this, Listener::TIME);
--*_listenerItr;
}
}
}
// Add back in start time, and divide by the total animation's duration to get the actual percentage complete
GP_ASSERT(_animation);
// If the animation duration is zero (start time == end time, such as when there is only a single keyframe),
// then prevent a divide by zero and set percentComplete = 1.
float percentComplete = _animation->_duration == 0 ? 1 : ((float)_startTime + currentTime) / (float)_animation->_duration;
percentComplete = MATH_CLAMP(percentComplete, 0.0f, 1.0f);
if (isClipStateBitSet(CLIP_IS_FADING_OUT_BIT))
{
GP_ASSERT(_crossFadeToClip);
GP_ASSERT(_crossFadeOutDuration > 0);
if (isClipStateBitSet(CLIP_IS_FADING_OUT_STARTED_BIT)) // Calculate elapsed time since the fade out begin.
{
GP_ASSERT(_crossFadeToClip);
_crossFadeOutElapsed = (Game::getGameTime() - _crossFadeToClip->_timeStarted) * fabs(_speed);
resetClipStateBit(CLIP_IS_FADING_OUT_STARTED_BIT);
}
else
{
// continue tracking elapsed time.
_crossFadeOutElapsed += elapsedTime * fabs(_speed);
}
if (_crossFadeOutElapsed < _crossFadeOutDuration)
{
// Calculate this clip's blend weight.
float tempBlendWeight = ((float)_crossFadeOutDuration - _crossFadeOutElapsed) / (float)_crossFadeOutDuration;
// If this clip is fading in, adjust the crossfade clip's weight to be a percentage of your current blend weight
if (isClipStateBitSet(CLIP_IS_FADING_IN_BIT))
{
_crossFadeToClip->_blendWeight = (1.0f - tempBlendWeight) * _blendWeight;
_blendWeight -= _crossFadeToClip->_blendWeight;
}
else
{
// Just set the blend weight.
_crossFadeToClip->_blendWeight = (1.0f - tempBlendWeight);
_blendWeight = tempBlendWeight;
}
}
else
{
// Fade is done.
_crossFadeToClip->_blendWeight = 1.0f;
_blendWeight = 0.0f;
resetClipStateBit(CLIP_IS_STARTED_BIT);
resetClipStateBit(CLIP_IS_FADING_OUT_BIT);
_crossFadeToClip->resetClipStateBit(CLIP_IS_FADING_IN_BIT);
SAFE_RELEASE(_crossFadeToClip);
}
}
// Evaluate this clip.
Animation::Channel* channel = NULL;
AnimationValue* value = NULL;
AnimationTarget* target = NULL;
size_t channelCount = _animation->_channels.size();
for (size_t i = 0; i < channelCount; i++)
{
channel = _animation->_channels[i];
GP_ASSERT(channel);
target = channel->_target;
GP_ASSERT(target);
value = _values[i];
GP_ASSERT(value);
// Evaluate the point on Curve
GP_ASSERT(channel->getCurve());
channel->getCurve()->evaluate(percentComplete, value->_value);
// Set the animation value on the target property.
target->setAnimationPropertyValue(channel->_propertyId, value, _blendWeight);
}
// When ended. Probably should move to it's own method so we can call it when the clip is ended early.
if (isClipStateBitSet(CLIP_IS_MARKED_FOR_REMOVAL_BIT) || !isClipStateBitSet(CLIP_IS_STARTED_BIT))
{
onEnd();
return true;
}
return false;
}