zoukankan      html  css  js  c++  java
  • UE4-动画/蒙太奇/融合(Animation/montage/blend)相关笔记

    Q.定义状态机动画蓝图事件:

     

    Q.Animation/Montage指定帧触发事件(Event):

    (注意:单帧动画需要取消勾选Teleport to Explicit Time,否则无法触发帧事件)

    Q.C++自定义 Animation Blueprint(动画蓝图)

    自己很少用C++写Skeleton动画相关的逻辑,通常Anim的BP满足大部分需求,最多继承一个UAnimInstance封装一个通用基类,很少去自定义anim节点

    故留个C++实现备查.

    Note:AnimGraph属于Edtior模块,如果需要打包,需要注意下build.cs:

    https://github.com/Hethger/UE4_AnimGraphNode_Project_Template 

    build.cs主要片段:

            if (Target.Type == TargetType.Editor)
            {
                PublicDependencyModuleNames.AddRange(
                    new string[] 
                    {
                        "UnrealED",
                        "BlueprintGraph",
                        "AnimGraph"
                    });
            }

    AnimInstance 栗子:

    .h

    UCLASS(transient, Blueprintable , hideCategories = AnimInstance, BlueprintType )
    class BJ_3DDESIGNAPP_API UCppAnimation_Demonstrate : public UAnimInstance
    {
        GENERATED_BODY()
    public:
        //初始化虚函数
        virtual void NativeInitializeAnimation() override;
        //tick event 
        virtual void NativeUpdateAnimation(float DeltaTimeX) override;
    protected:
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CppVariant")
            float Speed = 0.0f;
    };

     .cpp

    void UCppAnimation_Demonstrate::NativeInitializeAnimation()
    { Super::NativeInitializeAnimation(); }
    void UCppAnimation_Demonstrate::NativeUpdateAnimation(float DeltaTimeX) { Super::NativeUpdateAnimation(DeltaTimeX);
      //你的逻辑
    }

    Q.C++自定义 Animation Graph Node (动画节点)

      需要C++自定义动画节点的话,需要分别实现UAnimGraphNode_Base,和FAnimNode_Base的子类;

      UAnimGraphNode_Base用于在Editor里的定义一些节点的属性(如颜色/Category 名称/节点名等)

      FAnimNode_Base 里实现我们自己的动画逻辑

     栗子(PS:例子是没有实现任何功能的):

    AnimNode:

    .h

    
    

    #pragma once

    
    

    #include "CoreMinimal.h"
    #include "Animation/AnimNodeBase.h"
    #include "CppAnimNode_Demonstrate.generated.h"


    USTRUCT(BlueprintType)
    struct BJ_3DDESIGNAPP_API FCppAnimNode_Demonstrate : public FAnimNode_Base { GENERATED_USTRUCT_BODY() public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Links) FPoseLink BasePose; public: virtual void Initialize_AnyThread(const FAnimationInitializeContext& Context) override; virtual void CacheBones_AnyThread(const FAnimationCacheBonesContext& Context) override; virtual void Update_AnyThread(const FAnimationUpdateContext& Context) override; virtual void Evaluate_AnyThread(FPoseContext& Output) override; virtual void GatherDebugData(FNodeDebugData& DebugData) override; // Constructor public: FCppAnimNode_Demonstrate(); };

    .cpp

    #include "CppAnimNode_Demonstrate.h"

    FCppAnimNode_Demonstrate::FCppAnimNode_Demonstrate() { }
    void FCppAnimNode_Demonstrate::Initialize_AnyThread(const FAnimationInitializeContext & Context) { BasePose.Initialize(Context); } void FCppAnimNode_Demonstrate::CacheBones_AnyThread(const FAnimationCacheBonesContext & Context) { BasePose.CacheBones(Context); } void FCppAnimNode_Demonstrate::Update_AnyThread(const FAnimationUpdateContext & Context) { EvaluateGraphExposedInputs.Execute(Context); BasePose.Update(Context); } void FCppAnimNode_Demonstrate::Evaluate_AnyThread(FPoseContext & Output) { BasePose.Evaluate(Output); } void FCppAnimNode_Demonstrate::GatherDebugData(FNodeDebugData & DebugData) { FString DebugLine = DebugData.GetNodeName(this); DebugData.AddDebugItem(DebugLine); BasePose.GatherDebugData(DebugData); }

    AnimGraphNode:

    .h

    #pragma once

    #include "CoreMinimal.h"
    #include "AnimGraphNode_Base.h"
    #include "CppAnimNode_Demonstrate.h"
    #include "CppAnimGraphNode_Demonstrate.generated.h"


    UCLASS() class BJ_3DDESIGNAPP_API UCppAnimGraphNode_Demonstrate : public UAnimGraphNode_Base { GENERATED_UCLASS_BODY() private: //注意,自定义的Anim Node类,逻辑都在里面 UPROPERTY(EditAnywhere, Category = "Settings") FCppAnimNode_Demonstrate Node; public: //节点颜色 virtual FLinearColor GetNodeTitleColor() const override; //提示内容 virtual FText GetTooltipText() const override; //节点名称 virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override; //Category 分类名称 virtual FString GetNodeCategory() const override; };

    .cpp

    #include "CppAnimGraphNode_Demonstrate.h"

    #define LOCTEXT_NAMESPACE "LQ" UCppAnimGraphNode_Demonstrate::UCppAnimGraphNode_Demonstrate(const FObjectInitializer& ObjectInitializer) :Super(ObjectInitializer) { } FLinearColor UCppAnimGraphNode_Demonstrate::GetNodeTitleColor() const { return FLinearColor::Green; } FText UCppAnimGraphNode_Demonstrate::GetTooltipText() const { return LOCTEXT("hello_ue4_animation ", "hello_ue4_animation "); } FText UCppAnimGraphNode_Demonstrate::GetNodeTitle(ENodeTitleType::Type TitleType) const { return LOCTEXT("HandleCharacterHeight", "HandleCharacterHeight"); } FString UCppAnimGraphNode_Demonstrate::GetNodeCategory() const { return TEXT("CppCustomNode"); } #undef LOCTEXT_NAMESPACE

     

    Q.C++ 自定义State machine状态机

      wait

  • 相关阅读:
    2018暑假假期周进度报告——第八周
    zf-关于评价器的开关所在的配置文件,与代码如何修改。
    不要点击一个功能就创建一个新的网页,要尽量少的新创建页面(例如:办事指南,点击一个部门创建一个网页,选择具体事项时,又创建一个网页,这样创建的网页太多)
    实现jsp页面显示用户登录信息,利用session保存。
    zf-关于更换页面,的各种问题。
    报错 BeanFactory not initialized or already closed
    Server Tomcat v6.0 Server at localhost was unable to start within 45 seconds
    如果在一个实现类中改变另外一个类中的变量,但是怎么改网页上都没变化的问题。
    如果更新包更新包现场,class文件更新过去,没有改变,及时删掉,照样能进那个模块的问题。
    使用内链接(A a inner join B b on a.xx = b.xx)查询2个表中某一列的相同的字段。
  • 原文地址:https://www.cnblogs.com/linqing/p/10233861.html
Copyright © 2011-2022 走看看