haxis/Source/UnrealProject/Creatures/AnimationProxy.cpp

37 lines
1.3 KiB
C++

#include "UnrealProject.h"
#include "AnimationProxy.h"
bool FMainAnimProxy::Evaluate(FPoseContext& pose)
{
// Evalueate the animation pose according to the blueprint
if(GetRootNode() != NULL)
{
GetRootNode()->Evaluate(pose);
}
// Now set bone scales for character customizations
SetBoneScale(boneNames[0], FVector(charCustomization.headScale), pose);
SetBoneScale(boneNames[1], FVector(1, charCustomization.legThicknessYScale, charCustomization.legThicknessZScale), pose);
SetBoneScale(boneNames[2], FVector(1, charCustomization.legThicknessYScale, charCustomization.legThicknessZScale), pose);
SetBoneScale(boneNames[3], FVector(charCustomization.leftArmScale), pose);
SetBoneScale(boneNames[4], FVector(charCustomization.rightArmScale), pose);
SetBoneScale(boneNames[5], FVector(charCustomization.torsoScale), pose);
SetBoneScale(boneNames[6], FVector(charCustomization.overallScale), pose);
return true;
}
void FMainAnimProxy::SetBoneScale(const FName boneName, const FVector scale, FPoseContext& pose)
{
int32 boneIndex = this->GetSkelMeshComponent()->GetBoneIndex(boneName);
// Check if bone is in the skeleton.
if(boneIndex != INDEX_NONE)
{
FTransform& boneTransform = pose.Pose[FCompactPoseBoneIndex(boneIndex)];
boneTransform.SetScale3D(scale);
}
}