本文整理汇总了C++中AnimationTarget类的典型用法代码示例。如果您正苦于以下问题:C++ AnimationTarget类的具体用法?C++ AnimationTarget怎么用?C++ AnimationTarget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AnimationTarget类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lua_AnimationTarget_destroyAnimation
int lua_AnimationTarget_destroyAnimation(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 1:
{
if ((lua_type(state, 1) == LUA_TUSERDATA))
{
AnimationTarget* instance = getInstance(state);
instance->destroyAnimation();
return 0;
}
lua_pushstring(state, "lua_AnimationTarget_destroyAnimation - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
case 2:
{
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
(lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
{
// Get parameter 1 off the stack.
const char* param1 = gameplay::ScriptUtil::getString(2, false);
AnimationTarget* instance = getInstance(state);
instance->destroyAnimation(param1);
return 0;
}
lua_pushstring(state, "lua_AnimationTarget_destroyAnimation - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
default:
{
lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
lua_error(state);
break;
}
}
return 0;
}
示例2: lua_AnimationTarget_getAnimationPropertyValue
int lua_AnimationTarget_getAnimationPropertyValue(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->getAnimationPropertyValue(param1, param2);
return 0;
}
lua_pushstring(state, "lua_AnimationTarget_getAnimationPropertyValue - 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).");
lua_error(state);
break;
}
}
return 0;
}
示例3: lua_AnimationTarget_getAnimationPropertyComponentCount
int lua_AnimationTarget_getAnimationPropertyComponentCount(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 2:
{
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
lua_type(state, 2) == LUA_TNUMBER)
{
// Get parameter 1 off the stack.
int param1 = (int)luaL_checkint(state, 2);
AnimationTarget* instance = getInstance(state);
unsigned int result = instance->getAnimationPropertyComponentCount(param1);
// Push the return value onto the stack.
lua_pushunsigned(state, result);
return 1;
}
lua_pushstring(state, "lua_AnimationTarget_getAnimationPropertyComponentCount - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
default:
{
lua_pushstring(state, "Invalid number of parameters (expected 2).");
lua_error(state);
break;
}
}
return 0;
}
示例4: lua_AnimationTarget_getAnimation
int lua_AnimationTarget_getAnimation(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 1:
{
if ((lua_type(state, 1) == LUA_TUSERDATA))
{
AnimationTarget* instance = getInstance(state);
void* returnPtr = ((void*)instance->getAnimation());
if (returnPtr)
{
gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
object->instance = returnPtr;
object->owns = false;
luaL_getmetatable(state, "Animation");
lua_setmetatable(state, -2);
}
else
{
lua_pushnil(state);
}
return 1;
}
lua_pushstring(state, "lua_AnimationTarget_getAnimation - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
case 2:
{
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
(lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
{
// Get parameter 1 off the stack.
const char* param1 = gameplay::ScriptUtil::getString(2, false);
AnimationTarget* instance = getInstance(state);
void* returnPtr = ((void*)instance->getAnimation(param1));
if (returnPtr)
{
gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
object->instance = returnPtr;
object->owns = false;
luaL_getmetatable(state, "Animation");
lua_setmetatable(state, -2);
}
else
{
lua_pushnil(state);
}
return 1;
}
lua_pushstring(state, "lua_AnimationTarget_getAnimation - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
default:
{
lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
lua_error(state);
break;
}
}
return 0;
}
示例5: lua_AnimationTarget_createAnimation
int lua_AnimationTarget_createAnimation(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:
{
do
{
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
(lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
(lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
{
// Get parameter 1 off the stack.
const char* param1 = gameplay::ScriptUtil::getString(2, false);
// Get parameter 2 off the stack.
const char* param2 = gameplay::ScriptUtil::getString(3, false);
AnimationTarget* instance = getInstance(state);
void* returnPtr = ((void*)instance->createAnimation(param1, param2));
if (returnPtr)
{
gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
object->instance = returnPtr;
object->owns = false;
luaL_getmetatable(state, "Animation");
lua_setmetatable(state, -2);
}
else
{
lua_pushnil(state);
}
return 1;
}
} while (0);
do
{
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
(lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
(lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
{
// Get parameter 1 off the stack.
const char* param1 = gameplay::ScriptUtil::getString(2, false);
// Get parameter 2 off the stack.
bool param2Valid;
gameplay::ScriptUtil::LuaArray<Properties> param2 = gameplay::ScriptUtil::getObjectPointer<Properties>(3, "Properties", false, ¶m2Valid);
if (!param2Valid)
break;
AnimationTarget* instance = getInstance(state);
void* returnPtr = ((void*)instance->createAnimation(param1, param2));
if (returnPtr)
{
gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
object->instance = returnPtr;
object->owns = false;
luaL_getmetatable(state, "Animation");
lua_setmetatable(state, -2);
}
else
{
lua_pushnil(state);
}
return 1;
}
} while (0);
lua_pushstring(state, "lua_AnimationTarget_createAnimation - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
case 7:
{
do
{
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
(lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
lua_type(state, 3) == LUA_TNUMBER &&
lua_type(state, 4) == LUA_TNUMBER &&
(lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TLIGHTUSERDATA) &&
(lua_type(state, 6) == LUA_TTABLE || lua_type(state, 6) == LUA_TLIGHTUSERDATA) &&
lua_type(state, 7) == LUA_TNUMBER)
{
// Get parameter 1 off the stack.
const char* param1 = gameplay::ScriptUtil::getString(2, false);
// Get parameter 2 off the stack.
int param2 = (int)luaL_checkint(state, 3);
// Get parameter 3 off the stack.
unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
//.........这里部分代码省略.........
示例6: lua_AnimationTarget_createAnimationFromTo
int lua_AnimationTarget_createAnimationFromTo(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 7:
{
if ((lua_type(state, 1) == LUA_TUSERDATA) &&
(lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
lua_type(state, 3) == LUA_TNUMBER &&
(lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TLIGHTUSERDATA) &&
(lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TLIGHTUSERDATA) &&
lua_type(state, 6) == LUA_TNUMBER &&
lua_type(state, 7) == LUA_TNUMBER)
{
// Get parameter 1 off the stack.
const char* param1 = gameplay::ScriptUtil::getString(2, false);
// Get parameter 2 off the stack.
int param2 = (int)luaL_checkint(state, 3);
// Get parameter 3 off the stack.
gameplay::ScriptUtil::LuaArray<float> param3 = gameplay::ScriptUtil::getFloatPointer(4);
// Get parameter 4 off the stack.
gameplay::ScriptUtil::LuaArray<float> param4 = gameplay::ScriptUtil::getFloatPointer(5);
// Get parameter 5 off the stack.
Curve::InterpolationType param5 = (Curve::InterpolationType)luaL_checkint(state, 6);
// Get parameter 6 off the stack.
unsigned long param6 = (unsigned long)luaL_checkunsigned(state, 7);
AnimationTarget* instance = getInstance(state);
void* returnPtr = ((void*)instance->createAnimationFromTo(param1, param2, param3, param4, param5, param6));
if (returnPtr)
{
gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
object->instance = returnPtr;
object->owns = false;
luaL_getmetatable(state, "Animation");
lua_setmetatable(state, -2);
}
else
{
lua_pushnil(state);
}
return 1;
}
lua_pushstring(state, "lua_AnimationTarget_createAnimationFromTo - Failed to match the given parameters to a valid function signature.");
lua_error(state);
break;
}
default:
{
lua_pushstring(state, "Invalid number of parameters (expected 7).");
lua_error(state);
break;
}
}
return 0;
}
示例7: onEnd
//.........这里部分代码省略.........
(**_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;
}
示例8: if
//.........这里部分代码省略.........
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;
}