[ue4] Closes #2234, add SpineWidget::GetBonePosition in the skeleton coordinate system.

This commit is contained in:
badlogic 2023-02-07 15:26:10 +01:00
parent 0f595e7fbe
commit 39d544ce86
3 changed files with 22 additions and 0 deletions

View File

@ -331,6 +331,25 @@ bool USpineWidget::HasBone(const FString BoneName) {
return false; return false;
} }
FTransform USpineWidget::GetBoneTransform(const FString& BoneName) {
CheckState();
if (skeleton) {
Bone *bone = skeleton->findBone(TCHAR_TO_UTF8(*BoneName));
if (!bone) return FTransform();
FMatrix localTransform;
localTransform.SetIdentity();
localTransform.SetAxis(2, FVector(bone->getA(), 0, bone->getC()));
localTransform.SetAxis(0, FVector(bone->getB(), 0, bone->getD()));
localTransform.SetOrigin(FVector(bone->getWorldX(), 0, bone->getWorldY()));
FTransform result;
result.SetFromMatrix(localTransform);
return result;
}
return FTransform();
}
void USpineWidget::GetSlots(TArray<FString> &Slots) { void USpineWidget::GetSlots(TArray<FString> &Slots) {
CheckState(); CheckState();
if (skeleton) { if (skeleton) {

View File

@ -132,6 +132,9 @@ public:
UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton") UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton")
bool HasBone(const FString BoneName); bool HasBone(const FString BoneName);
UFUNCTION(BlueprintCallable, Category = "Components|Spine|Skeleton")
FTransform GetBoneTransform(const FString &BoneName);
UFUNCTION(BlueprintPure, Category = "Components|Spine|Skeleton") UFUNCTION(BlueprintPure, Category = "Components|Spine|Skeleton")
void GetSlots(TArray<FString> &Slots); void GetSlots(TArray<FString> &Slots);