本文整理汇总了C++中Animation::GetNameHash方法的典型用法代码示例。如果您正苦于以下问题:C++ Animation::GetNameHash方法的具体用法?C++ Animation::GetNameHash怎么用?C++ Animation::GetNameHash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Animation
的用法示例。
在下文中一共展示了Animation::GetNameHash方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Play
bool AnimationController::Play(const String& name, unsigned char layer, bool looped, float fadeInTime)
{
// Check if already exists
unsigned index;
AnimationState* state;
FindAnimation(name, index, state);
if (!state)
{
Animation* newAnimation = GetSubsystem<ResourceCache>()->GetResource<Animation>(name);
state = AddAnimationState(newAnimation);
if (!state)
return false;
}
if (index == M_MAX_UNSIGNED)
{
AnimationControl newControl;
Animation* animation = state->GetAnimation();
newControl.name_ = animation->GetName();
newControl.hash_ = animation->GetNameHash();
animations_.Push(newControl);
index = animations_.Size() - 1;
}
state->SetLayer(layer);
state->SetLooped(looped);
animations_[index].targetWeight_ = 1.0f;
animations_[index].fadeTime_ = fadeInTime;
MarkNetworkUpdate();
return true;
}
示例2: GetAnimationState
AnimationState* AnimatedModel::GetAnimationState(StringHash animationNameHash) const
{
for (Vector<SharedPtr<AnimationState> >::ConstIterator i = animationStates_.Begin(); i != animationStates_.End(); ++i)
{
Animation* animation = (*i)->GetAnimation();
if (animation)
{
// Check both the animation and the resource name
if (animation->GetNameHash() == animationNameHash || animation->GetAnimationNameHash() == animationNameHash)
return *i;
}
}
return nullptr;
}
示例3: GetAnimationState
AnimationState* AnimationController::GetAnimationState(StringHash nameHash) const
{
// Model mode
AnimatedModel* model = GetComponent<AnimatedModel>();
if (model)
return model->GetAnimationState(nameHash);
// Node hierarchy mode
for (Vector<SharedPtr<AnimationState> >::ConstIterator i = nodeAnimationStates_.Begin(); i != nodeAnimationStates_.End(); ++i)
{
Animation* animation = (*i)->GetAnimation();
if (animation->GetNameHash() == nameHash || animation->GetAnimationNameHash() == nameHash)
return *i;
}
return 0;
}
示例4: GetAnimationState
AnimationState* AnimationController::GetAnimationState(StringHash nameHash) const
{
// Model mode
auto* model = GetComponent<AnimatedModel>();
if (model)
return model->GetAnimationState(nameHash);
// Node hierarchy mode
for (auto i = nodeAnimationStates_.begin(); i != nodeAnimationStates_.end(); ++i)
{
Animation* animation = (*i)->GetAnimation();
if (animation->GetNameHash() == nameHash || animation->GetAnimationNameHash() == nameHash)
return *i;
}
return nullptr;
}
示例5: RemoveAnimationState
void AnimatedModel::RemoveAnimationState(StringHash animationNameHash)
{
for (Vector<SharedPtr<AnimationState> >::Iterator i = animationStates_.Begin(); i != animationStates_.End(); ++i)
{
AnimationState* state = *i;
Animation* animation = state->GetAnimation();
if (animation)
{
// Check both the animation and the resource name
if (animation->GetNameHash() == animationNameHash || animation->GetAnimationNameHash() == animationNameHash)
{
animationStates_.Erase(i);
MarkAnimationDirty();
return;
}
}
}
}
示例6: GetAnimationStatesAttr
VariantVector AnimatedModel::GetAnimationStatesAttr() const
{
VariantVector ret;
ret.Reserve(animationStates_.Size() * 6 + 1);
ret.Push(animationStates_.Size());
for (Vector<SharedPtr<AnimationState> >::ConstIterator i = animationStates_.Begin(); i != animationStates_.End(); ++i)
{
AnimationState* state = *i;
Animation* animation = state->GetAnimation();
Bone* startBone = state->GetStartBone();
ret.Push(ResourceRef(Animation::GetTypeStatic(), animation ? animation->GetNameHash() : StringHash()));
ret.Push(startBone ? startBone->name_ : String::EMPTY);
ret.Push(state->IsLooped());
ret.Push(state->GetWeight());
ret.Push(state->GetTime());
ret.Push((int)state->GetLayer());
}
return ret;
}
示例7: Play
bool AnimationController::Play(const String& name, unsigned char layer, bool looped, float fadeInTime)
{
// Get the animation resource first to be able to get the canonical resource name
// (avoids potential adding of duplicate animations)
Animation* newAnimation = GetSubsystem<ResourceCache>()->GetResource<Animation>(name);
if (!newAnimation)
return false;
// Check if already exists
unsigned index;
AnimationState* state;
FindAnimation(newAnimation->GetName(), index, state);
if (!state)
{
state = AddAnimationState(newAnimation);
if (!state)
return false;
}
if (index == M_MAX_UNSIGNED)
{
AnimationControl newControl;
newControl.name_ = newAnimation->GetName();
newControl.hash_ = newAnimation->GetNameHash();
animations_.Push(newControl);
index = animations_.Size() - 1;
}
state->SetLayer(layer);
state->SetLooped(looped);
animations_[index].targetWeight_ = 1.0f;
animations_[index].fadeTime_ = fadeInTime;
MarkNetworkUpdate();
return true;
}
示例8: Play
bool AnimationController::Play(const String& name, unsigned char layer, bool looped, float fadeInTime)
{
// ATOMIC BEGIN
Animation* newAnimation = 0;
// Check if we're using attached animation resource
if (animation_.NotNull() && animation_->GetAnimationName() == name)
{
newAnimation = animation_;
}
else
{
for (unsigned i = 0; i < animationResources_.Size(); i++)
{
if (name == animationResources_[i]->GetAnimationName())
{
newAnimation = animationResources_[i];
break;
}
}
}
// Get the animation resource first to be able to get the canonical resource name
// (avoids potential adding of duplicate animations)
if (!newAnimation)
newAnimation = GetSubsystem<ResourceCache>()->GetResource<Animation>(name);
if (!newAnimation)
return false;
// ATOMIC END
// Check if already exists
unsigned index;
AnimationState* state;
FindAnimation(newAnimation->GetName(), index, state);
if (!state)
{
state = AddAnimationState(newAnimation);
if (!state)
return false;
}
if (index == M_MAX_UNSIGNED)
{
AnimationControl newControl;
newControl.name_ = newAnimation->GetName();
newControl.hash_ = newAnimation->GetNameHash();
animations_.Push(newControl);
index = animations_.Size() - 1;
}
state->SetLayer(layer);
state->SetLooped(looped);
animations_[index].targetWeight_ = 1.0f;
animations_[index].fadeTime_ = fadeInTime;
MarkNetworkUpdate();
return true;
}