Browse Source

AniamtionCotrol supports animation blending

Ivan K 9 years ago
parent
commit
4e1eb4df74

+ 2 - 0
Source/Urho3D/AngelScript/GraphicsAPI.cpp

@@ -1327,6 +1327,7 @@ static void RegisterAnimationController(asIScriptEngine* engine)
     engine->RegisterObjectMethod("AnimationController", "bool SetTime(const String&in, float)", asMETHOD(AnimationController, SetTime), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "bool SetWeight(const String&in, float)", asMETHOD(AnimationController, SetWeight), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "bool SetLooped(const String&in, bool)", asMETHOD(AnimationController, SetLooped), asCALL_THISCALL);
+    engine->RegisterObjectMethod("AnimationController", "bool SetBlendingMode(const String&in, AnimationBlendingMode)", asMETHOD(AnimationController, SetBlendingMode), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "bool SetSpeed(const String&in, float)", asMETHOD(AnimationController, SetSpeed), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "bool SetAutoFade(const String&in, float)", asMETHOD(AnimationController, SetAutoFade), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "bool SetRemoveOnCompletion(const String&in, bool)", asMETHOD(AnimationController, SetRemoveOnCompletion), asCALL_THISCALL);
@@ -1339,6 +1340,7 @@ static void RegisterAnimationController(asIScriptEngine* engine)
     engine->RegisterObjectMethod("AnimationController", "float GetTime(const String&in) const", asMETHOD(AnimationController, GetTime), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "float GetWeight(const String&in) const", asMETHOD(AnimationController, GetWeight), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "bool GetLooped(const String&in) const", asMETHOD(AnimationController, IsLooped), asCALL_THISCALL);
+    engine->RegisterObjectMethod("AnimationController", "AnimationBlendingMode GetBlendingMode(const String&in) const", asMETHOD(AnimationController, GetBlendingMode), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "float GetLength(const String&in) const", asMETHOD(AnimationController, GetLength), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "float GetSpeed(const String&in) const", asMETHOD(AnimationController, GetSpeed), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimationController", "float GetFadeTarget(const String&in) const", asMETHOD(AnimationController, GetFadeTarget), asCALL_THISCALL);

+ 17 - 0
Source/Urho3D/Graphics/AnimationController.cpp

@@ -393,6 +393,17 @@ bool AnimationController::SetLooped(const String& name, bool enable)
     return true;
 }
 
+bool AnimationController::SetBlendingMode(const String& name, AnimationBlendingMode mode)
+{
+    AnimationState* state = GetAnimationState(name);
+    if (!state)
+        return false;
+
+    state->SetBlendingMode(mode);
+    MarkNetworkUpdate();
+    return true;
+}
+
 bool AnimationController::SetAutoFade(const String& name, float fadeOutTime)
 {
     unsigned index;
@@ -484,6 +495,12 @@ bool AnimationController::IsLooped(const String& name) const
     return state ? state->IsLooped() : false;
 }
 
+AnimationBlendingMode AnimationController::GetBlendingMode(const String& name) const
+{
+    AnimationState* state = GetAnimationState(name);
+    return state ? state->GetBlendingMode() : ABM_OVERRIDE;
+}
+
 float AnimationController::GetLength(const String& name) const
 {
     AnimationState* state = GetAnimationState(name);

+ 5 - 1
Source/Urho3D/Graphics/AnimationController.h

@@ -24,13 +24,13 @@
 
 #include "../IO/VectorBuffer.h"
 #include "../Scene/Component.h"
+#include "../Graphics/AnimationState.h"
 
 namespace Urho3D
 {
 
 class AnimatedModel;
 class Animation;
-class AnimationState;
 struct Bone;
 
 /// Control data for an animation.
@@ -129,6 +129,8 @@ public:
     bool SetAutoFade(const String& name, float fadeOutTime);
     /// Set whether an animation auto-removes on completion.
     bool SetRemoveOnCompletion(const String& name, bool removeOnCompletion);
+    /// Set animation blending mode. Return true on success.
+    bool SetBlendingMode(const String& name, AnimationBlendingMode mode);
 
     /// Return whether an animation is active. Note that non-looping animations that are being clamped at the end also return true.
     bool IsPlaying(const String& name) const;
@@ -150,6 +152,8 @@ public:
     float GetWeight(const String& name) const;
     /// Return animation looping.
     bool IsLooped(const String& name) const;
+    /// Return animation blending mode.
+    AnimationBlendingMode GetBlendingMode(const String& name) const;
     /// Return animation length.
     float GetLength(const String& name) const;
     /// Return animation speed.

+ 2 - 0
Source/Urho3D/LuaScript/pkgs/Graphics/AnimationController.pkg

@@ -32,6 +32,7 @@ class AnimationController : public Component
     bool SetTime(const String name, float time);
     bool SetWeight(const String name, float weight);
     bool SetLooped(const String name, bool enable);
+    bool SetBlendingMode(const String name, AnimationBlendingMode mode);
     bool SetSpeed(const String name, float speed);
     bool SetAutoFade(const String name, float fadeOutTime);
     bool SetRemoveOnCompletion(const String name, bool removeOnCompletion);
@@ -46,6 +47,7 @@ class AnimationController : public Component
     float GetTime(const String name) const;
     float GetWeight(const String name) const;
     bool IsLooped(const String name) const;
+    AnimationBlendingMode GetBlendingMode(const String name) const;
     float GetLength(const String name) const;
     float GetSpeed(const String name) const;
     float GetFadeTarget(const String name) const;