2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-05-08 22:19:16 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "AnimNode_SkeletalControlBase.h"
|
|
|
|
|
#include "AnimNode_LookAt.generated.h"
|
|
|
|
|
|
|
|
|
|
UENUM()
|
|
|
|
|
namespace EAxisOption
|
|
|
|
|
{
|
|
|
|
|
enum Type
|
|
|
|
|
{
|
|
|
|
|
X,
|
|
|
|
|
Y,
|
|
|
|
|
Z,
|
|
|
|
|
X_Neg,
|
|
|
|
|
Y_Neg,
|
|
|
|
|
Z_Neg
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-22 14:58:29 -05:00
|
|
|
|
|
|
|
|
UENUM()
|
|
|
|
|
/** Various ways to interpolate TAlphaBlend. */
|
|
|
|
|
namespace EInterpolationBlend
|
|
|
|
|
{
|
|
|
|
|
enum Type
|
|
|
|
|
{
|
|
|
|
|
Linear,
|
|
|
|
|
Cubic,
|
|
|
|
|
Sinusoidal,
|
|
|
|
|
EaseInOutExponent2,
|
|
|
|
|
EaseInOutExponent3,
|
|
|
|
|
EaseInOutExponent4,
|
|
|
|
|
EaseInOutExponent5,
|
|
|
|
|
MAX
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 22:19:16 -04:00
|
|
|
/**
|
|
|
|
|
* Simple controller that make a bone to look at the point or another bone
|
|
|
|
|
*/
|
|
|
|
|
USTRUCT()
|
2015-06-10 10:57:15 -04:00
|
|
|
struct ANIMGRAPHRUNTIME_API FAnimNode_LookAt : public FAnimNode_SkeletalControlBase
|
2014-05-08 22:19:16 -04:00
|
|
|
{
|
2015-03-17 05:38:32 -04:00
|
|
|
GENERATED_USTRUCT_BODY()
|
2014-05-08 22:19:16 -04:00
|
|
|
|
|
|
|
|
/** Name of bone to control. This is the main bone chain to modify from. **/
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SkeletalControl)
|
|
|
|
|
FBoneReference BoneToModify;
|
|
|
|
|
|
|
|
|
|
/** Target Bone to look at - you can't use LookAtLocation as alternative as you'll get a delay on bone location if you query directly **/
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SkeletalControl)
|
|
|
|
|
FBoneReference LookAtBone;
|
|
|
|
|
|
|
|
|
|
/** Target Location in world space if LookAtBone is empty */
|
2014-08-19 17:38:03 -04:00
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SkeletalControl, meta=(PinHiddenByDefault))
|
2014-05-08 22:19:16 -04:00
|
|
|
FVector LookAtLocation;
|
|
|
|
|
|
|
|
|
|
/** Look at axis, which axis to align to look at point */
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SkeletalControl)
|
|
|
|
|
TEnumAsByte<EAxisOption::Type> LookAtAxis;
|
|
|
|
|
|
2015-06-15 10:53:37 -04:00
|
|
|
/** Whether or not to use Look up axis */
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SkeletalControl)
|
|
|
|
|
bool bUseLookUpAxis;
|
|
|
|
|
|
|
|
|
|
/** Look up axis in local space */
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SkeletalControl)
|
|
|
|
|
TEnumAsByte<EAxisOption::Type> LookUpAxis;
|
|
|
|
|
|
2015-01-22 14:58:29 -05:00
|
|
|
/** Look at Clamp value in degree - if you're look at axis is Z, only X, Y degree of clamp will be used*/
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SkeletalControl, meta=(PinHiddenByDefault))
|
|
|
|
|
float LookAtClamp;
|
|
|
|
|
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SkeletalControl, meta=(PinHiddenByDefault))
|
|
|
|
|
TEnumAsByte<EInterpolationBlend::Type> InterpolationType;
|
|
|
|
|
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SkeletalControl, meta=(PinHiddenByDefault))
|
|
|
|
|
float InterpolationTime;
|
|
|
|
|
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SkeletalControl, meta=(PinHiddenByDefault))
|
|
|
|
|
float InterpolationTriggerThreashold;
|
|
|
|
|
|
|
|
|
|
UPROPERTY(EditAnywhere, Category=SkeletalControl)
|
|
|
|
|
bool bEnableDebug;
|
|
|
|
|
|
2014-05-08 22:19:16 -04:00
|
|
|
/** Debug transient data */
|
|
|
|
|
FVector CurrentLookAtLocation;
|
|
|
|
|
|
2015-01-22 14:58:29 -05:00
|
|
|
/** Current Target Location */
|
|
|
|
|
FVector CurrentTargetLocation;
|
|
|
|
|
FVector PreviousTargetLocation;
|
|
|
|
|
|
|
|
|
|
/** Current Alpha */
|
|
|
|
|
float AccumulatedInterpoolationTime;
|
|
|
|
|
|
2014-05-08 22:19:16 -04:00
|
|
|
// in the future, it would be nice to have more options, -i.e. lag, interpolation speed
|
|
|
|
|
FAnimNode_LookAt();
|
|
|
|
|
|
|
|
|
|
// FAnimNode_Base interface
|
2014-06-13 06:14:46 -04:00
|
|
|
virtual void GatherDebugData(FNodeDebugData& DebugData) override;
|
2015-01-22 14:58:29 -05:00
|
|
|
virtual void Update(const FAnimationUpdateContext& Context) override;
|
2014-05-08 22:19:16 -04:00
|
|
|
// End of FAnimNode_Base interface
|
|
|
|
|
|
|
|
|
|
// FAnimNode_SkeletalControlBase interface
|
2015-05-19 06:19:22 -04:00
|
|
|
virtual void EvaluateBoneTransforms(USkeletalMeshComponent* SkelComp, FCSPose<FCompactPose>& MeshBases, TArray<FBoneTransform>& OutBoneTransforms) override;
|
2014-10-01 14:45:04 -04:00
|
|
|
virtual bool IsValidToEvaluate(const USkeleton* Skeleton, const FBoneContainer& RequiredBones) override;
|
2014-05-08 22:19:16 -04:00
|
|
|
// End of FAnimNode_SkeletalControlBase interface
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// FAnimNode_SkeletalControlBase interface
|
2014-10-01 14:45:04 -04:00
|
|
|
virtual void InitializeBoneReferences(const FBoneContainer& RequiredBones) override;
|
2014-05-08 22:19:16 -04:00
|
|
|
// End of FAnimNode_SkeletalControlBase interface
|
|
|
|
|
|
2015-05-19 06:19:22 -04:00
|
|
|
FVector GetAlignVector(const FTransform& Transform, EAxisOption::Type AxisOption);
|
2015-01-22 14:58:29 -05:00
|
|
|
|
|
|
|
|
EAlphaBlendType GetInterpolationType()
|
|
|
|
|
{
|
|
|
|
|
switch (InterpolationType)
|
|
|
|
|
{
|
|
|
|
|
case EInterpolationBlend::Cubic:
|
|
|
|
|
return ABT_Cubic;
|
|
|
|
|
case EInterpolationBlend::Sinusoidal:
|
|
|
|
|
return ABT_Cubic;
|
|
|
|
|
case EInterpolationBlend::EaseInOutExponent2:
|
|
|
|
|
return ABT_EaseInOutExponent2;
|
|
|
|
|
case EInterpolationBlend::EaseInOutExponent3:
|
|
|
|
|
return ABT_EaseInOutExponent3;
|
|
|
|
|
case EInterpolationBlend::EaseInOutExponent4:
|
|
|
|
|
return ABT_EaseInOutExponent4;
|
|
|
|
|
case EInterpolationBlend::EaseInOutExponent5:
|
|
|
|
|
return ABT_EaseInOutExponent5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ABT_Linear;
|
|
|
|
|
}
|
2014-05-08 22:19:16 -04:00
|
|
|
};
|