distinguish between virtual hand actor and component and animate the component

This commit is contained in:
Mamadou Babaei
2023-03-28 10:39:08 +02:00
parent f5750217da
commit 6a0b00b5d5
14 changed files with 594 additions and 1131 deletions
@@ -44,7 +44,7 @@
#include "Engine/SkeletalMesh.h"
#include "Math/Rotator.h"
#include "SenseGlove/GameFramework/SGVirtualHand.h"
#include "SenseGlove/Components/SGVirtualHandComponent.h"
FSGVirtualHandAnimInstanceProxy::FSGVirtualHandAnimInstanceProxy()
: FAnimInstanceProxy()
@@ -65,14 +65,14 @@ void FSGVirtualHandAnimInstanceProxy::PreEvaluateAnimation(UAnimInstance* InAnim
return;
}
ASGVirtualHand* Hand(Cast<ASGVirtualHand>(InAnimInstance->GetOwningActor()));
if (!IsValid(Hand))
USGVirtualHandComponent* VirtualHand{Cast<USGVirtualHandComponent>(GetSkelMeshComponent())};
if (!IsValid(VirtualHand))
{
return;
}
BonesRotations.Empty();
BonesRotations = Hand->GetFingersBonesRotations();
BonesRotations = VirtualHand->GetFingersBonesRotations();
}
bool FSGVirtualHandAnimInstanceProxy::Evaluate(FPoseContext& Output)
@@ -33,7 +33,7 @@
*/
#include "SenseGlove/Components/SGVirtualHandMeshComponent.h"
#include "SenseGlove/Components/SGVirtualHandComponent.h"
#include "Animation/Skeleton.h"
#include "Components/SkeletalMeshComponent.h"
@@ -45,7 +45,7 @@
#include "SGCore/SGHapticGlove.h"
#include "SGLog/SGLog.h"
struct USGVirtualHandMeshComponent::FImpl
struct USGVirtualHandComponent::FImpl
{
/************************
* Static methods
@@ -83,13 +83,13 @@ struct USGVirtualHandMeshComponent::FImpl
* Owner object
************************/
USGVirtualHandMeshComponent* Owner;
USGVirtualHandComponent* Owner;
/************************
* Constructor / Destructor
************************/
explicit FImpl(USGVirtualHandMeshComponent* InOwner);
explicit FImpl(USGVirtualHandComponent* InOwner);
~FImpl();
/************************
@@ -117,7 +117,7 @@ struct USGVirtualHandMeshComponent::FImpl
bool CheckGlove() const;
};
const TArray<TArray<FName>>& USGVirtualHandMeshComponent::GetLeftHandFingerBoneNames()
const TArray<TArray<FName>>& USGVirtualHandComponent::GetLeftHandFingerBoneNames()
{
static const TArray<TArray<FName>> BoneNames{
{FName(TEXT("thumb_01_l")), FName(TEXT("thumb_02_l")), FName(TEXT("thumb_03_l"))},
@@ -129,7 +129,7 @@ const TArray<TArray<FName>>& USGVirtualHandMeshComponent::GetLeftHandFingerBoneN
return BoneNames;
}
const TArray<TArray<FName>>& USGVirtualHandMeshComponent::GetRightHandFingerBoneNames()
const TArray<TArray<FName>>& USGVirtualHandComponent::GetRightHandFingerBoneNames()
{
static const TArray<TArray<FName>> BoneNames{
{FName(TEXT("thumb_01_r")), FName(TEXT("thumb_02_r")), FName(TEXT("thumb_03_r"))},
@@ -141,7 +141,7 @@ const TArray<TArray<FName>>& USGVirtualHandMeshComponent::GetRightHandFingerBone
return BoneNames;
}
const FName& USGVirtualHandMeshComponent::GetLeftHandFingerBoneName(const int32 Finger, const int32 Joint)
const FName& USGVirtualHandComponent::GetLeftHandFingerBoneName(const int32 Finger, const int32 Joint)
{
const TArray<TArray<FName>>& BoneNames{GetLeftHandFingerBoneNames()};
@@ -152,7 +152,7 @@ const FName& USGVirtualHandMeshComponent::GetLeftHandFingerBoneName(const int32
return BoneName;
}
const FName& USGVirtualHandMeshComponent::GetRightHandFingerBoneName(const int32 Finger, const int32 Joint)
const FName& USGVirtualHandComponent::GetRightHandFingerBoneName(const int32 Finger, const int32 Joint)
{
const TArray<TArray<FName>>& BoneNames{GetRightHandFingerBoneNames()};
@@ -163,7 +163,7 @@ const FName& USGVirtualHandMeshComponent::GetRightHandFingerBoneName(const int32
return BoneName;
}
USGVirtualHandMeshComponent::USGVirtualHandMeshComponent(const FObjectInitializer& ObjectInitializer)
USGVirtualHandComponent::USGVirtualHandComponent(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer),
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
{
@@ -205,7 +205,17 @@ USGVirtualHandMeshComponent::USGVirtualHandMeshComponent(const FObjectInitialize
Glove = nullptr;
}
void USGVirtualHandMeshComponent::SetAnimClass(UClass* NewClass)
void USGVirtualHandComponent::SetRight(const bool bInRight)
{
bRight = bInRight;
if (!Pimpl->IsUsingUserMesh())
{
Pimpl->SetDefaultMesh();
}
}
void USGVirtualHandComponent::SetAnimClass(UClass* NewClass)
{
ensureAlwaysMsgf(Cast<USGVirtualHandAnimInstance>(NewClass),
TEXT("The AnimInstance class must be a subclass of USGVirtualHandAnimInstance!"));
@@ -213,7 +223,25 @@ void USGVirtualHandMeshComponent::SetAnimClass(UClass* NewClass)
Super::SetAnimClass(NewClass);
}
void USGVirtualHandMeshComponent::InitializeComponent()
#if WITH_EDITOR
void USGVirtualHandComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
const FName PropertyName{PropertyChangedEvent.Property
? PropertyChangedEvent.Property->GetFName()
: NAME_None};
if (PropertyName == GET_MEMBER_NAME_CHECKED(USGVirtualHandComponent, bRight))
{
if (!Pimpl->IsUsingUserMesh())
{
Pimpl->SetDefaultMesh();
}
}
}
#endif /* WITH_EDITOR */
void USGVirtualHandComponent::InitializeComponent()
{
Super::InitializeComponent();
@@ -223,7 +251,7 @@ void USGVirtualHandMeshComponent::InitializeComponent()
}
}
void USGVirtualHandMeshComponent::TickComponent(
void USGVirtualHandComponent::TickComponent(
const float DeltaTime, const ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
#if WITH_EDITOR
@@ -239,7 +267,7 @@ void USGVirtualHandMeshComponent::TickComponent(
(void) Pimpl->CheckGlove();
}
void USGVirtualHandMeshComponent::SetSkeletalMesh(USkeletalMesh* NewMesh, const bool bReinitPose)
void USGVirtualHandComponent::SetSkeletalMesh(USkeletalMesh* NewMesh, const bool bReinitPose)
{
if (IsValid(NewMesh))
{
@@ -251,19 +279,19 @@ void USGVirtualHandMeshComponent::SetSkeletalMesh(USkeletalMesh* NewMesh, const
}
}
void USGVirtualHandMeshComponent::EditorTick(
void USGVirtualHandComponent::EditorTick(
const float DeltaTime, const ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
(void) Pimpl->CheckGlove();
}
bool USGVirtualHandMeshComponent::IsGloveConnected() const
bool USGVirtualHandComponent::IsGloveConnected() const
{
return Pimpl->CheckGlove();
}
USGHandPose* USGVirtualHandMeshComponent::GetHandPose()
USGHandPose* USGVirtualHandComponent::GetHandPose()
{
USGHandPose* HandPose = nullptr;
@@ -275,7 +303,7 @@ USGHandPose* USGVirtualHandMeshComponent::GetHandPose()
return HandPose;
}
const FName& USGVirtualHandMeshComponent::GetFingerBoneName(const int32 Finger, const int32 Joint) const
const FName& USGVirtualHandComponent::GetFingerBoneName(const int32 Finger, const int32 Joint) const
{
const FName& Name{IsRight()
? GetRightHandFingerBoneName(Finger, Joint)
@@ -283,7 +311,7 @@ const FName& USGVirtualHandMeshComponent::GetFingerBoneName(const int32 Finger,
return Name;
}
const FTransform& USGVirtualHandMeshComponent::GetFingerBoneRefTransform(const int32 Finger, const int32 Joint) const
const FTransform& USGVirtualHandComponent::GetFingerBoneRefTransform(const int32 Finger, const int32 Joint) const
{
const FName& BoneName{GetFingerBoneName(Finger, Joint)};
const FReferenceSkeleton& ReferenceSkeleton{Pimpl->GetRefSkeleton()};
@@ -296,14 +324,14 @@ const FTransform& USGVirtualHandMeshComponent::GetFingerBoneRefTransform(const i
return BoneTransform;
}
FRotator USGVirtualHandMeshComponent::GetFingerBoneRefRotation(const int32 Finger, const int32 Joint) const
FRotator USGVirtualHandComponent::GetFingerBoneRefRotation(const int32 Finger, const int32 Joint) const
{
const FTransform BoneTransform{GetFingerBoneRefTransform(Finger, Joint)};
FRotator BoneRotation{BoneTransform.GetRotation().Rotator()};
return MoveTemp(BoneRotation);
}
TMap<FName, FRotator> USGVirtualHandMeshComponent::GetFingersBonesRotations()
TMap<FName, FRotator> USGVirtualHandComponent::GetFingersBonesRotations()
{
TMap<FName, FRotator> Rotations;
@@ -337,14 +365,14 @@ TMap<FName, FRotator> USGVirtualHandMeshComponent::GetFingersBonesRotations()
return MoveTemp(Rotations);
}
USGVirtualHandMeshComponent::FImpl::FImpl(USGVirtualHandMeshComponent* InOwner)
USGVirtualHandComponent::FImpl::FImpl(USGVirtualHandComponent* InOwner)
: Owner(InOwner)
{
}
USGVirtualHandMeshComponent::FImpl::~FImpl() = default;
USGVirtualHandComponent::FImpl::~FImpl() = default;
bool USGVirtualHandMeshComponent::FImpl::IsEditor() const
bool USGVirtualHandComponent::FImpl::IsEditor() const
{
const UWorld* World = Owner->GetWorld();
if (World && World->WorldType == EWorldType::Editor)
@@ -355,7 +383,7 @@ bool USGVirtualHandMeshComponent::FImpl::IsEditor() const
return false;
}
FString USGVirtualHandMeshComponent::FImpl::GetDefaultMeshPath() const
FString USGVirtualHandComponent::FImpl::GetDefaultMeshPath() const
{
FString SkeletalMeshPath;
@@ -371,7 +399,7 @@ FString USGVirtualHandMeshComponent::FImpl::GetDefaultMeshPath() const
return MoveTemp(SkeletalMeshPath);
}
bool USGVirtualHandMeshComponent::FImpl::IsUsingUserMesh() const
bool USGVirtualHandComponent::FImpl::IsUsingUserMesh() const
{
const USkeletalMesh* SkeletalMesh{GetMesh()};
if (!IsValid(SkeletalMesh))
@@ -395,7 +423,7 @@ bool USGVirtualHandMeshComponent::FImpl::IsUsingUserMesh() const
return true;
}
USkeletalMesh* USGVirtualHandMeshComponent::FImpl::LoadDefaultMesh() const
USkeletalMesh* USGVirtualHandComponent::FImpl::LoadDefaultMesh() const
{
const FString SkeletalMeshPath(GetDefaultMeshPath());
USkeletalMesh* SkeletalMesh = Cast<USkeletalMesh>(
@@ -406,12 +434,12 @@ USkeletalMesh* USGVirtualHandMeshComponent::FImpl::LoadDefaultMesh() const
return SkeletalMesh;
}
void USGVirtualHandMeshComponent::FImpl::SetDefaultMesh() const
void USGVirtualHandComponent::FImpl::SetDefaultMesh() const
{
Owner->SetSkeletalMesh(LoadDefaultMesh(), true);
}
USkeletalMesh* USGVirtualHandMeshComponent::FImpl::GetMesh() const
USkeletalMesh* USGVirtualHandComponent::FImpl::GetMesh() const
{
return Owner->
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1
@@ -422,7 +450,7 @@ USkeletalMesh* USGVirtualHandMeshComponent::FImpl::GetMesh() const
;
}
USkeleton* USGVirtualHandMeshComponent::FImpl::GetSkeleton() const
USkeleton* USGVirtualHandComponent::FImpl::GetSkeleton() const
{
USkeletalMesh* SkeletalMesh{GetMesh()};
ensureAlwaysMsgf(IsValid(SkeletalMesh), TEXT("Invalid SkeletalMesh object!"));
@@ -436,7 +464,7 @@ USkeleton* USGVirtualHandMeshComponent::FImpl::GetSkeleton() const
;
}
const FReferenceSkeleton& USGVirtualHandMeshComponent::FImpl::GetRefSkeleton() const
const FReferenceSkeleton& USGVirtualHandComponent::FImpl::GetRefSkeleton() const
{
USkeletalMesh* SkeletalMesh{GetMesh()};
ensureAlwaysMsgf(IsValid(SkeletalMesh), TEXT("Invalid SkeletalMesh object!"));
@@ -450,7 +478,7 @@ const FReferenceSkeleton& USGVirtualHandMeshComponent::FImpl::GetRefSkeleton() c
;
}
bool USGVirtualHandMeshComponent::FImpl::CheckGlove() const
bool USGVirtualHandComponent::FImpl::CheckGlove() const
{
const bool bGloveWasPresent = IsValid(Owner->Glove);
const bool bFoundGlove = USGHapticGlove::GetGlove(Owner, Owner->IsRight(), Owner->Glove);
@@ -464,7 +492,7 @@ bool USGVirtualHandMeshComponent::FImpl::CheckGlove() const
return bFoundGlove;
}
void USGVirtualHandMeshComponent::FImplDeleter::operator()(const FImpl* P) const
void USGVirtualHandComponent::FImplDeleter::operator()(const FImpl* P) const
{
delete P;
}
@@ -1,478 +0,0 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2023 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#include "SenseGlove/GameFramework/SGVirtualHand.h"
#include "Animation/Skeleton.h"
#include "Components/SkeletalMeshComponent.h"
#include "Engine/SkeletalMesh.h"
#include "UObject/ConstructorHelpers.h"
#include "SenseGlove/Animation/SGVirtualHandAnimInstance.h"
#include "SGCore/SGHandPose.h"
#include "SGCore/SGHapticGlove.h"
#include "SGLog/SGLog.h"
struct ASGVirtualHand::FImpl
{
/************************
* Static methods
************************/
FORCEINLINE static const FString& GetDefaultLeftHandMeshPath()
{
static const FString Path{TEXT("SkeletalMesh'/SenseGlove/Meshes/"
"SK_SenseGlove_VirtualHand_Left.SK_SenseGlove_VirtualHand_Left'")};
return Path;
}
FORCEINLINE static const FString& GetDefaultLeftHandMeshPathOnly()
{
static const FString Path{TEXT("/SenseGlove/Meshes/"
"SK_SenseGlove_VirtualHand_Left.SK_SenseGlove_VirtualHand_Left")};
return Path;
}
FORCEINLINE static const FString& GetDefaultRightHandMeshPath()
{
static const FString Path{TEXT("SkeletalMesh'/SenseGlove/Meshes/"
"SK_SenseGlove_VirtualHand_Right.SK_SenseGlove_VirtualHand_Right'")};
return Path;
}
FORCEINLINE static const FString& GetDefaultRightHandMeshPathOnly()
{
static const FString Path{TEXT("/SenseGlove/Meshes/"
"SK_SenseGlove_VirtualHand_Right.SK_SenseGlove_VirtualHand_Right")};
return Path;
}
/************************
* Owner object
************************/
ASGVirtualHand* Owner;
/************************
* Constructor / Destructor
************************/
explicit FImpl(ASGVirtualHand* InOwner);
~FImpl();
/************************
* Default copy constructor & copy assignment operator
************************/
FImpl(const FImpl& Rhs) = default;
FImpl& operator=(const FImpl& Rhs) = default;
/************************
* Methods
************************/
bool IsEditor() const;
void SetHandMesh(USkeletalMesh* VirtualHandMesh, bool bReinitPos) const;
FString GetDefaultMeshPath() const;
bool IsUsingUserMesh() const;
USkeletalMesh* LoadDefaultMesh() const;
void SetDefaultMesh() const;
bool CheckGlove() const;
};
const TArray<TArray<FName>>& ASGVirtualHand::GetLeftHandFingerBoneNames()
{
static const TArray<TArray<FName>> BoneNames{
{FName(TEXT("thumb_01_l")), FName(TEXT("thumb_02_l")), FName(TEXT("thumb_03_l"))},
{FName(TEXT("index_01_l")), FName(TEXT("index_02_l")), FName(TEXT("index_03_l"))},
{FName(TEXT("middle_01_l")), FName(TEXT("middle_02_l")), FName(TEXT("middle_03_l"))},
{FName(TEXT("ring_01_l")), FName(TEXT("ring_02_l")), FName(TEXT("ring_03_l"))},
{FName(TEXT("pinky_01_l")), FName(TEXT("pinky_02_l")), FName(TEXT("pinky_03_l"))},
};
return BoneNames;
}
const TArray<TArray<FName>>& ASGVirtualHand::GetRightHandFingerBoneNames()
{
static const TArray<TArray<FName>> BoneNames{
{FName(TEXT("thumb_01_r")), FName(TEXT("thumb_02_r")), FName(TEXT("thumb_03_r"))},
{FName(TEXT("index_01_r")), FName(TEXT("index_02_r")), FName(TEXT("index_03_r"))},
{FName(TEXT("middle_01_r")), FName(TEXT("middle_02_r")), FName(TEXT("middle_03_r"))},
{FName(TEXT("ring_01_r")), FName(TEXT("ring_02_r")), FName(TEXT("ring_03_r"))},
{FName(TEXT("pinky_01_r")), FName(TEXT("pinky_02_r")), FName(TEXT("pinky_03_r"))},
};
return BoneNames;
}
const FName& ASGVirtualHand::GetLeftHandFingerBoneName(const int32 Finger, const int32 Joint)
{
const TArray<TArray<FName>>& BoneNames{GetLeftHandFingerBoneNames()};
ensureAlwaysMsgf(Finger < BoneNames.Num(), TEXT("Finger index is out of bound!"));
ensureAlwaysMsgf(Joint < BoneNames[Finger].Num(), TEXT("Joint index is out of bound!"));
const FName& BoneName{BoneNames[Finger][Joint]};
return BoneName;
}
const FName& ASGVirtualHand::GetRightHandFingerBoneName(const int32 Finger, const int32 Joint)
{
const TArray<TArray<FName>>& BoneNames{GetRightHandFingerBoneNames()};
ensureAlwaysMsgf(Finger < BoneNames.Num(), TEXT("Finger index is out of bound!"));
ensureAlwaysMsgf(Joint < BoneNames[Finger].Num(), TEXT("Joint index is out of bound!"));
const FName& BoneName{BoneNames[Finger][Joint]};
return BoneName;
}
ASGVirtualHand::ASGVirtualHand(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer),
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
{
PrimaryActorTick.bCanEverTick = true;
SceneRoot = CreateDefaultSubobject<USceneComponent>(TEXT("SceneRoot"));
SetRootComponent(SceneRoot);
Mesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Mesh"));
Mesh->SetupAttachment(RootComponent);
Mesh->SetCastShadow(true);
Mesh->SetCastHiddenShadow(false);
Mesh->bCastDynamicShadow = true;
Mesh->SetOnlyOwnerSee(false);
Mesh->SetReceivesDecals(true);
Mesh->SetCanEverAffectNavigation(false);
Mesh->SetCollisionObjectType(ECC_WorldDynamic);
Mesh->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
Mesh->SetCollisionResponseToAllChannels(ECR_Overlap);
Mesh->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Block);
Mesh->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Block);
Mesh->SetCollisionResponseToChannel(ECC_Pawn, ECR_Block);
Mesh->SetCollisionResponseToChannel(ECC_Visibility, ECR_Block);
Mesh->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Block);
Mesh->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Block);
Mesh->SetCollisionResponseToChannel(ECC_Destructible, ECR_Block);
AnimInstanceClass = USGVirtualHandAnimInstance::StaticClass();
bRight = true;
bHiddenInGameIfNoGloveDetected = true;
bAnimateInEditor = true;
const FString SkeletalMeshPath(Pimpl->GetDefaultMeshPath());
const ConstructorHelpers::FObjectFinder<USkeletalMesh> SkeletalMesh(*SkeletalMeshPath);
ensureAlwaysMsgf(SkeletalMesh.Succeeded() && SkeletalMesh.Object,
TEXT("Failed to load the skeletal mesh: '%s'"), *SkeletalMeshPath);
Pimpl->SetHandMesh(SkeletalMesh.Object, true);
Glove = nullptr;
}
void ASGVirtualHand::Tick(const float DeltaSeconds)
{
#if WITH_EDITOR
if (Pimpl->IsEditor())
{
EditorTick(DeltaSeconds);
return;
}
#endif
Super::Tick(DeltaSeconds);
(void) Pimpl->CheckGlove();
}
bool ASGVirtualHand::ShouldTickIfViewportsOnly() const
{
if (!bAnimateInEditor)
{
return false;
}
if (Pimpl->IsEditor())
{
return true;
}
return false;
}
void ASGVirtualHand::OnConstruction(const FTransform& Transform)
{
Super::OnConstruction(Transform);
if (!Pimpl->IsUsingUserMesh())
{
Pimpl->SetDefaultMesh();
}
}
void ASGVirtualHand::EditorTick(float DeltaSeconds)
{
(void) Pimpl->CheckGlove();
}
USkeletalMesh* ASGVirtualHand::GetHandMesh() const
{
ensureAlwaysMsgf(IsValid(Mesh), TEXT("Invalid Mesh object!"));
return Mesh->
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1
GetSkeletalMeshAsset()
#else
SkeletalMesh
#endif /* ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1 */
;
}
void ASGVirtualHand::SetHandMesh(USkeletalMesh* VirtualHandMesh, const bool bReinitPos) const
{
Pimpl->SetHandMesh(VirtualHandMesh, bReinitPos);
}
USkeleton* ASGVirtualHand::GetHandSkeleton() const
{
USkeletalMesh* SkeletalMesh{GetHandMesh()};
ensureAlwaysMsgf(IsValid(SkeletalMesh), TEXT("Invalid SkeletalMesh object!"));
return SkeletalMesh->
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1
GetSkeleton()
#else
Skeleton
#endif /* ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1 */
;
}
const FReferenceSkeleton& ASGVirtualHand::GetHandRefSkeleton() const
{
USkeletalMesh* SkeletalMesh{GetHandMesh()};
ensureAlwaysMsgf(IsValid(SkeletalMesh), TEXT("Invalid SkeletalMesh object!"));
return SkeletalMesh->
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1
GetRefSkeleton()
#else
RefSkeleton
#endif /* ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1 */
;
}
bool ASGVirtualHand::IsGloveConnected() const
{
return Pimpl->CheckGlove();
}
USGHandPose* ASGVirtualHand::GetHandPose()
{
USGHandPose* HandPose = nullptr;
if (IsValid(Glove))
{
Glove->GetHandPose(this, HandPose);
}
return HandPose;
}
const FName& ASGVirtualHand::GetFingerBoneName(const int32 Finger, const int32 Joint) const
{
const FName& Name{IsRight()
? GetRightHandFingerBoneName(Finger, Joint)
: GetLeftHandFingerBoneName(Finger, Joint)};
return Name;
}
const FTransform& ASGVirtualHand::GetFingerBoneRefTransform(const int32 Finger, const int32 Joint) const
{
const FName& BoneName{GetFingerBoneName(Finger, Joint)};
const FReferenceSkeleton& ReferenceSkeleton{GetHandRefSkeleton()};
const int32 BoneIndex = ReferenceSkeleton.FindBoneIndex(BoneName);
ensureAlwaysMsgf(BoneIndex != INDEX_NONE, TEXT("Invalid virtual hand bone name '%s' or index!"),
*BoneName.ToString());
const FTransform& BoneTransform{ReferenceSkeleton.GetRefBonePose()[BoneIndex]};
return BoneTransform;
}
FRotator ASGVirtualHand::GetFingerBoneRefRotation(const int32 Finger, const int32 Joint) const
{
const FTransform BoneTransform{GetFingerBoneRefTransform(Finger, Joint)};
FRotator BoneRotation{BoneTransform.GetRotation().Rotator()};
return MoveTemp(BoneRotation);
}
TMap<FName, FRotator> ASGVirtualHand::GetFingersBonesRotations()
{
TMap<FName, FRotator> Rotations;
const USGHandPose* HandPose = GetHandPose();
if (!IsValid(HandPose))
{
return MoveTemp(Rotations);
}
const TArray<TArray<FVector>> HandAngles{HandPose->GetHandAngles()};
for (int32 FingerIndex = 0; FingerIndex < HandAngles.Num(); ++FingerIndex)
{
const TArray<FVector>& FingerJointAngles{HandAngles[FingerIndex]};
for (int32 JointIndex = 0; JointIndex < FingerJointAngles.Num(); ++JointIndex)
{
const FVector& JointAngle{FingerJointAngles[JointIndex]};
const FQuat JointRotation{FQuat::MakeFromEuler(JointAngle)};
const FTransform& BoneRefTransform{GetFingerBoneRefTransform(FingerIndex, JointIndex)};
FQuat NewBoneRotation{BoneRefTransform.GetRotation() * JointRotation};
FName BoneName{GetFingerBoneName(FingerIndex, JointIndex)};
Rotations.Emplace(MoveTemp(BoneName), MoveTemp(NewBoneRotation));
}
}
return MoveTemp(Rotations);
}
ASGVirtualHand::FImpl::FImpl(ASGVirtualHand* InOwner)
: Owner(InOwner)
{
}
ASGVirtualHand::FImpl::~FImpl() = default;
void ASGVirtualHand::FImpl::SetHandMesh(USkeletalMesh* VirtualHandMesh, const bool bReinitPos) const
{
ensureAlwaysMsgf(IsValid(VirtualHandMesh), TEXT("Invalid VirtualHandMesh object!"));
ensureAlwaysMsgf(IsValid(Owner->Mesh), TEXT("Invalid Mesh object!"));
ensureAlwaysMsgf(IsValid(Owner->AnimInstanceClass), TEXT("Invalid AnimInstanceClass object!"));
Owner->Mesh->SetSkeletalMesh(VirtualHandMesh, bReinitPos);
Owner->Mesh->SetAnimInstanceClass(Owner->AnimInstanceClass);
}
bool ASGVirtualHand::FImpl::IsEditor() const
{
const UWorld* World = Owner->GetWorld();
if (World && World->WorldType == EWorldType::Editor)
{
return true;
}
return false;
}
FString ASGVirtualHand::FImpl::GetDefaultMeshPath() const
{
FString SkeletalMeshPath;
if (Owner->bRight)
{
SkeletalMeshPath = GetDefaultRightHandMeshPath();
}
else
{
SkeletalMeshPath = GetDefaultLeftHandMeshPath();
}
return MoveTemp(SkeletalMeshPath);
}
bool ASGVirtualHand::FImpl::IsUsingUserMesh() const
{
const USkeletalMesh* SkeletalMesh{Owner->GetHandMesh()};
if (!IsValid(SkeletalMesh))
{
return false;
}
const FString CurrentMeshPath(SkeletalMesh->GetPathName());
const FString LeftHandDefaultMeshPath(GetDefaultLeftHandMeshPath());
const FString LeftHandDefaultMeshPathOnly(GetDefaultLeftHandMeshPathOnly());
const FString RightHandDefaultMeshPath(GetDefaultRightHandMeshPath());
const FString RightHandDefaultMeshPathOnly(GetDefaultRightHandMeshPathOnly());
if (CurrentMeshPath == LeftHandDefaultMeshPath
|| CurrentMeshPath == LeftHandDefaultMeshPathOnly
|| CurrentMeshPath == RightHandDefaultMeshPath
|| CurrentMeshPath == RightHandDefaultMeshPathOnly)
{
return false;
}
return true;
}
USkeletalMesh* ASGVirtualHand::FImpl::LoadDefaultMesh() const
{
const FString SkeletalMeshPath(GetDefaultMeshPath());
USkeletalMesh* SkeletalMesh = Cast<USkeletalMesh>(
StaticLoadObject(USkeletalMesh::StaticClass(), nullptr, *SkeletalMeshPath));
ensureAlwaysMsgf(SkeletalMesh, TEXT("Failed to load the skeletal mesh: '%s'"), *SkeletalMeshPath);
return SkeletalMesh;
}
void ASGVirtualHand::FImpl::SetDefaultMesh() const
{
SetHandMesh(LoadDefaultMesh(), true);
}
bool ASGVirtualHand::FImpl::CheckGlove() const
{
const bool bGloveWasPresent = IsValid(Owner->Glove);
const bool bFoundGlove = USGHapticGlove::GetGlove(Owner, Owner->IsRight(), Owner->Glove);
if (!bFoundGlove && bGloveWasPresent)
{
SGLOG_ERROR(FString::Printf(TEXT("Could not find a %s glove"),
(Owner->bRight ? TEXT("right-handed") : TEXT("left-handed"))));
}
return bFoundGlove;
}
void ASGVirtualHand::FImplDeleter::operator()(const FImpl* P) const
{
delete P;
}
@@ -0,0 +1,156 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2023 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#include "SenseGlove/GameFramework/SGVirtualHandActor.h"
#include "SenseGlove/Components/SGVirtualHandComponent.h"
struct ASGVirtualHandActor::FImpl
{
/************************
* Owner object
************************/
ASGVirtualHandActor* Owner;
/************************
* Constructor / Destructor
************************/
explicit FImpl(ASGVirtualHandActor* InOwner);
~FImpl();
/************************
* Default copy constructor & copy assignment operator
************************/
FImpl(const FImpl& Rhs) = default;
FImpl& operator=(const FImpl& Rhs) = default;
/************************
* Methods
************************/
bool IsEditor() const;
FORCEINLINE USGVirtualHandComponent* GetVirtualHand() const
{
ensureAlwaysMsgf(IsValid(Owner->VirtualHand), TEXT("Invalid VirtualHand object!"));
return Owner->VirtualHand;
}
};
ASGVirtualHandActor::ASGVirtualHandActor(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer),
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
{
PrimaryActorTick.bCanEverTick = true;
SceneRoot = CreateDefaultSubobject<USceneComponent>(TEXT("SceneRoot"));
SetRootComponent(SceneRoot);
VirtualHand = CreateDefaultSubobject<USGVirtualHandComponent>(TEXT("VirtualHand"));
VirtualHand->SetupAttachment(RootComponent);
}
void ASGVirtualHandActor::Tick(const float DeltaSeconds)
{
#if WITH_EDITOR
if (Pimpl->IsEditor())
{
EditorTick(DeltaSeconds);
return;
}
#endif
Super::Tick(DeltaSeconds);
}
bool ASGVirtualHandActor::ShouldTickIfViewportsOnly() const
{
if (VirtualHand->bTickInEditor && Pimpl->IsEditor())
{
return true;
}
return false;
}
void ASGVirtualHandActor::OnConstruction(const FTransform& Transform)
{
Super::OnConstruction(Transform);
}
void ASGVirtualHandActor::EditorTick(float DeltaSeconds)
{
}
bool ASGVirtualHandActor::IsLeft() const
{
return GetVirtualHand()->IsLeft();
}
bool ASGVirtualHandActor::IsRight() const
{
return GetVirtualHand()->IsRight();
}
bool ASGVirtualHandActor::IsGloveConnected() const
{
return GetVirtualHand()->IsGloveConnected();
}
ASGVirtualHandActor::FImpl::FImpl(ASGVirtualHandActor* InOwner)
: Owner(InOwner)
{
}
ASGVirtualHandActor::FImpl::~FImpl() = default;
bool ASGVirtualHandActor::FImpl::IsEditor() const
{
const UWorld* World = Owner->GetWorld();
if (World && World->WorldType == EWorldType::Editor)
{
return true;
}
return false;
}
void ASGVirtualHandActor::FImplDeleter::operator()(const FImpl* P) const
{
delete P;
}
@@ -45,7 +45,7 @@
#include "Templates/UniquePtr.h"
#include "UObject/NameTypes.h"
#include "SGVirtualHandMeshComponent.generated.h"
#include "SGVirtualHandComponent.generated.h"
class USkeletalMesh;
class USkeleton;
@@ -56,7 +56,7 @@ class USGHapticGlove;
UCLASS(Config=Engine, Blueprintable, ClassGroup=(Rendering, Common), hidecategories=(Object, "Mesh|SkeletalAsset"),
editinlinenew, meta=(BlueprintSpawnableComponent))
class SENSEGLOVE_API USGVirtualHandMeshComponent : public USkeletalMeshComponent
class SENSEGLOVE_API USGVirtualHandComponent : public USkeletalMeshComponent
{
GENERATED_UCLASS_BODY()
@@ -100,10 +100,7 @@ public:
return !!bRight;
}
FORCEINLINE void SetRight(const bool bInRight)
{
bRight = bInRight;
}
void SetRight(const bool bInRight);
FORCEINLINE bool IsHiddenInGameIfNoGloveDetected() const
{
@@ -118,6 +115,10 @@ public:
public:
virtual void SetAnimClass(class UClass* NewClass) override;
#if WITH_EDITOR
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif /* WITH_EDITOR */
virtual void InitializeComponent() override;
virtual void TickComponent(float DeltaTime,
@@ -1,187 +0,0 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2023 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#pragma once
#include "Containers/Array.h"
#include "Containers/Map.h"
#include "GameFramework/Actor.h"
#include "Math/Rotator.h"
#include "Math/Transform.h"
#include "ReferenceSkeleton.h"
#include "Templates/UniquePtr.h"
#include "UObject/NameTypes.h"
#include "SGVirtualHand.generated.h"
class USkeletalMesh;
class USkeleton;
class USkeletalMeshComponent;
class USceneComponent;
class USGHandPose;
class USGHapticGlove;
UCLASS(Config=Game, BlueprintType)
class SENSEGLOVE_API ASGVirtualHand : public AActor
{
GENERATED_UCLASS_BODY()
public:
static const TArray<TArray<FName>>& GetLeftHandFingerBoneNames();
static const TArray<TArray<FName>>& GetRightHandFingerBoneNames();
static const FName& GetLeftHandFingerBoneName(int32 Finger, int32 Joint);
static const FName& GetRightHandFingerBoneName(int32 Finger, int32 Joint);
private:
struct FImpl;
struct FImplDeleter
{
void operator()(const FImpl* P) const;
};
TUniquePtr<FImpl, FImplDeleter> Pimpl;
FImplDeleter PimplDeleter;
private:
UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
USceneComponent* SceneRoot;
UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
USkeletalMeshComponent* Mesh;
UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
UClass* AnimInstanceClass;
UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
uint8 bRight : 1;
UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
uint8 bHiddenInGameIfNoGloveDetected : 1;
UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
uint8 bAnimateInEditor : 1;
private:
UPROPERTY(Transient)
USGHapticGlove* Glove;
public:
FORCEINLINE USkeletalMeshComponent* GetMesh() const
{
return Mesh;
}
public:
FORCEINLINE bool IsLeft() const
{
return !IsRight();
}
FORCEINLINE bool IsRight() const
{
return !!bRight;
}
FORCEINLINE void SetRight(const bool bInRight)
{
bRight = bInRight;
}
FORCEINLINE bool IsHiddenInGameIfNoGloveDetected() const
{
return !!bHiddenInGameIfNoGloveDetected;
}
FORCEINLINE void SetHiddenIfNoGloveDetected(const bool bInHiddenIfNoGloveDetected)
{
bHiddenInGameIfNoGloveDetected = bInHiddenIfNoGloveDetected;
}
FORCEINLINE bool IsAnimateInEditor() const
{
return bAnimateInEditor;
}
FORCEINLINE void SetAnimateInEditor(const bool bInAnimateInEditor)
{
bAnimateInEditor = bInAnimateInEditor;
}
protected:
FORCEINLINE void SetMesh(USkeletalMeshComponent* InMesh)
{
Mesh = InMesh;
}
FORCEINLINE UClass* GetAnimInstanceClass() const
{
return AnimInstanceClass;
}
FORCEINLINE void SetAnimInstanceClass(UClass* InAnimInstanceClass)
{
AnimInstanceClass = InAnimInstanceClass;
}
public:
virtual void Tick(float DeltaSeconds) override;
virtual bool ShouldTickIfViewportsOnly() const override;
virtual void OnConstruction(const FTransform& Transform) override;
protected:
virtual void EditorTick(float DeltaSeconds);
public:
USkeletalMesh* GetHandMesh() const;
void SetHandMesh(USkeletalMesh* VirtualHandMesh, bool bReinitPos) const;
USkeleton* GetHandSkeleton() const;
const FReferenceSkeleton& GetHandRefSkeleton() const;
bool IsGloveConnected() const;
USGHandPose* GetHandPose();
public:
const FName& GetFingerBoneName(int32 Finger, int32 Joint) const;
const FTransform& GetFingerBoneRefTransform(int32 Finger, int32 Joint) const;
FRotator GetFingerBoneRefRotation(int32 Finger, int32 Joint) const;
TMap<FName, FRotator> GetFingersBonesRotations();
};
@@ -0,0 +1,103 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2023 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#pragma once
#include "Containers/Array.h"
#include "Containers/Map.h"
#include "GameFramework/Actor.h"
#include "Templates/UniquePtr.h"
#include "UObject/NameTypes.h"
#include "SGVirtualHandActor.generated.h"
class USkeletalMesh;
class USkeleton;
class USceneComponent;
class USGHandPose;
class USGVirtualHandComponent;
UCLASS(Config=Game, BlueprintType)
class SENSEGLOVE_API ASGVirtualHandActor : public AActor
{
GENERATED_UCLASS_BODY()
private:
struct FImpl;
struct FImplDeleter
{
void operator()(const FImpl* P) const;
};
TUniquePtr<FImpl, FImplDeleter> Pimpl;
FImplDeleter PimplDeleter;
private:
UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
USceneComponent* SceneRoot;
UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
USGVirtualHandComponent* VirtualHand;
public:
FORCEINLINE USGVirtualHandComponent* GetVirtualHand() const
{
return VirtualHand;
}
protected:
FORCEINLINE void SetMesh(USGVirtualHandComponent* InVirtualHand)
{
VirtualHand = InVirtualHand;
}
public:
virtual void Tick(float DeltaSeconds) override;
virtual bool ShouldTickIfViewportsOnly() const override;
virtual void OnConstruction(const FTransform& Transform) override;
protected:
virtual void EditorTick(float DeltaSeconds);
public:
bool IsLeft() const;
bool IsRight() const;
bool IsGloveConnected() const;
};
@@ -0,0 +1,58 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2023 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#include "SGKismet/SGVirtualHandActorKismetLibrary.h"
#include "SenseGlove/GameFramework/SGVirtualHandActor.h"
USGVirtualHandComponent* UVirtualHandActorKismetLibrary::GetVirtualHand(const ASGVirtualHandActor* VirtualHandActor)
{
return VirtualHandActor->GetVirtualHand();
}
bool UVirtualHandActorKismetLibrary::IsLeft(const ASGVirtualHandActor* VirtualHandActor)
{
return VirtualHandActor->IsLeft();
}
bool UVirtualHandActorKismetLibrary::IsRight(const ASGVirtualHandActor* VirtualHandActor)
{
return VirtualHandActor->IsRight();
}
bool UVirtualHandActorKismetLibrary::IsGloveConnected(const ASGVirtualHandActor* VirtualHandActor) const
{
return VirtualHandActor->IsGloveConnected();
}
@@ -0,0 +1,124 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2023 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#include "SGKismet/SGVirtualHandComponentKismetLibrary.h"
#include "SenseGlove/Components/SGVirtualHandComponent.h"
#include "SGCore/SGHandPose.h"
#include "SGUtils/SGArrayUtils.h"
TArray<FSGNameArray> UVirtualHandComponentKismetLibrary::GetLeftHandFingerBoneNames()
{
return FSGArrayUtils::ToNestedBPArray<FName, FSGNameArray>(
USGVirtualHandComponent::GetLeftHandFingerBoneNames());
}
TArray<FSGNameArray> UVirtualHandComponentKismetLibrary::GetRightHandFingerBoneNames()
{
return FSGArrayUtils::ToNestedBPArray<FName, FSGNameArray>(
USGVirtualHandComponent::GetRightHandFingerBoneNames());
}
const FName& UVirtualHandComponentKismetLibrary::GetLeftHandFingerBoneName(const int32 Finger, const int32 Joint)
{
return USGVirtualHandComponent::GetLeftHandFingerBoneName(Finger, Joint);
}
const FName& UVirtualHandComponentKismetLibrary::GetRightHandFingerBoneName(const int32 Finger, const int32 Joint)
{
return USGVirtualHandComponent::GetRightHandFingerBoneName(Finger, Joint);
}
bool UVirtualHandComponentKismetLibrary::IsLeft(const USGVirtualHandComponent* VirtualHandComponent)
{
return VirtualHandComponent->IsLeft();
}
bool UVirtualHandComponentKismetLibrary::IsRight(const USGVirtualHandComponent* VirtualHandComponent)
{
return VirtualHandComponent->IsRight();
}
void UVirtualHandComponentKismetLibrary::SetRight(USGVirtualHandComponent* VirtualHandComponent,
const bool bInRight)
{
VirtualHandComponent->SetRight(bInRight);
}
bool UVirtualHandComponentKismetLibrary::IsHiddenInGameIfNoGloveDetected(
const USGVirtualHandComponent* VirtualHandComponent)
{
return VirtualHandComponent->IsHiddenInGameIfNoGloveDetected();
}
void UVirtualHandComponentKismetLibrary::SetHiddenIfNoGloveDetected(
USGVirtualHandComponent* VirtualHandComponent, const bool bInHiddenIfNoGloveDetected)
{
VirtualHandComponent->SetHiddenIfNoGloveDetected(bInHiddenIfNoGloveDetected);
}
bool UVirtualHandComponentKismetLibrary::IsGloveConnected(const USGVirtualHandComponent* VirtualHandComponent) const
{
return VirtualHandComponent->IsGloveConnected();
}
USGHandPose* UVirtualHandComponentKismetLibrary::GetHandPose(USGVirtualHandComponent* VirtualHandComponent)
{
return VirtualHandComponent->GetHandPose();
}
const FName& UVirtualHandComponentKismetLibrary::GetFingerBoneName(
const USGVirtualHandComponent* VirtualHandComponent, const int32 Finger, const int32 Joint) const
{
return VirtualHandComponent->GetFingerBoneName(Finger, Joint);
}
const FTransform& UVirtualHandComponentKismetLibrary::GetFingerBoneRefTransform(
const USGVirtualHandComponent* VirtualHandComponent, const int32 Finger, const int32 Joint) const
{
return VirtualHandComponent->GetFingerBoneRefTransform(Finger, Joint);
}
FRotator UVirtualHandComponentKismetLibrary::GetFingerBoneRefRotation(
const USGVirtualHandComponent* VirtualHandComponent, const int32 Finger, const int32 Joint) const
{
return VirtualHandComponent->GetFingerBoneRefRotation(Finger, Joint);
}
TMap<FName, FRotator> UVirtualHandComponentKismetLibrary::GetFingersBonesRotations(
USGVirtualHandComponent* VirtualHandComponent)
{
return VirtualHandComponent->GetFingersBonesRotations();
}
@@ -1,150 +0,0 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2023 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#include "SGKismet/SGVirtualHandKismetLibrary.h"
#include "SenseGlove/GameFramework/SGVirtualHand.h"
#include "SGCore/SGHandPose.h"
#include "SGUtils/SGArrayUtils.h"
TArray<FSGNameArray> UVirtualHandKismetLibrary::GetLeftHandFingerBoneNames()
{
return FSGArrayUtils::ToNestedBPArray<FName, FSGNameArray>(ASGVirtualHand::GetLeftHandFingerBoneNames());
}
TArray<FSGNameArray> UVirtualHandKismetLibrary::GetRightHandFingerBoneNames()
{
return FSGArrayUtils::ToNestedBPArray<FName, FSGNameArray>(ASGVirtualHand::GetRightHandFingerBoneNames());
}
const FName& UVirtualHandKismetLibrary::GetLeftHandFingerBoneName(const int32 Finger, const int32 Joint)
{
return ASGVirtualHand::GetLeftHandFingerBoneName(Finger, Joint);
}
const FName& UVirtualHandKismetLibrary::GetRightHandFingerBoneName(const int32 Finger, const int32 Joint)
{
return ASGVirtualHand::GetRightHandFingerBoneName(Finger, Joint);
}
USkeletalMeshComponent* UVirtualHandKismetLibrary::GetMesh(const ASGVirtualHand* VirtualHand)
{
return VirtualHand->GetMesh();
}
bool UVirtualHandKismetLibrary::IsLeft(const ASGVirtualHand* VirtualHand)
{
return VirtualHand->IsLeft();
}
bool UVirtualHandKismetLibrary::IsRight(const ASGVirtualHand* VirtualHand)
{
return VirtualHand->IsRight();
}
void UVirtualHandKismetLibrary::SetRight(ASGVirtualHand* VirtualHand, const bool bInRight)
{
VirtualHand->SetRight(bInRight);
}
bool UVirtualHandKismetLibrary::IsHiddenInGameIfNoGloveDetected(const ASGVirtualHand* VirtualHand)
{
return VirtualHand->IsHiddenInGameIfNoGloveDetected();
}
void UVirtualHandKismetLibrary::SetHiddenIfNoGloveDetected(ASGVirtualHand* VirtualHand,
const bool bInHiddenIfNoGloveDetected)
{
VirtualHand->SetHiddenIfNoGloveDetected(bInHiddenIfNoGloveDetected);
}
bool UVirtualHandKismetLibrary::IsAnimateInEditor(const ASGVirtualHand* VirtualHand)
{
return VirtualHand->IsAnimateInEditor();
}
void UVirtualHandKismetLibrary::SetAnimateInEditor(ASGVirtualHand* VirtualHand, const bool bInAnimateInEditor)
{
VirtualHand->SetAnimateInEditor(bInAnimateInEditor);
}
USkeletalMesh* UVirtualHandKismetLibrary::GetHandMesh(const ASGVirtualHand* VirtualHand) const
{
return VirtualHand->GetHandMesh();
}
void UVirtualHandKismetLibrary::SetHandMesh(UPARAM(ref) ASGVirtualHand* VirtualHand,
USkeletalMesh* VirtualHandMesh, const bool bReinitPos) const
{
VirtualHand->SetHandMesh(VirtualHandMesh, bReinitPos);
}
USkeleton* UVirtualHandKismetLibrary::GetHandSkeleton(const ASGVirtualHand* VirtualHand) const
{
return VirtualHand->GetHandSkeleton();
}
bool UVirtualHandKismetLibrary::IsGloveConnected(const ASGVirtualHand* VirtualHand) const
{
return VirtualHand->IsGloveConnected();
}
USGHandPose* UVirtualHandKismetLibrary::GetHandPose(ASGVirtualHand* VirtualHand)
{
return VirtualHand->GetHandPose();
}
const FName& UVirtualHandKismetLibrary::GetFingerBoneName(const ASGVirtualHand* VirtualHand,
const int32 Finger, const int32 Joint) const
{
return VirtualHand->GetFingerBoneName(Finger, Joint);
}
const FTransform& UVirtualHandKismetLibrary::GetFingerBoneRefTransform(const ASGVirtualHand* VirtualHand,
const int32 Finger, const int32 Joint) const
{
return VirtualHand->GetFingerBoneRefTransform(Finger, Joint);
}
FRotator UVirtualHandKismetLibrary::GetFingerBoneRefRotation(const ASGVirtualHand* VirtualHand,
const int32 Finger, const int32 Joint) const
{
return VirtualHand->GetFingerBoneRefRotation(Finger, Joint);
}
TMap<FName, FRotator> UVirtualHandKismetLibrary::GetFingersBonesRotations(ASGVirtualHand* VirtualHand)
{
return VirtualHand->GetFingersBonesRotations();
}
@@ -1,129 +0,0 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2023 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#include "SGKismet/SGVirtualHandMeshComponentKismetLibrary.h"
#include "SenseGlove/Components/SGVirtualHandMeshComponent.h"
#include "SGCore/SGHandPose.h"
#include "SGUtils/SGArrayUtils.h"
TArray<FSGNameArray> UVirtualHandMeshComponentKismetLibrary::GetLeftHandFingerBoneNames()
{
return FSGArrayUtils::ToNestedBPArray<FName, FSGNameArray>(
USGVirtualHandMeshComponent::GetLeftHandFingerBoneNames());
}
TArray<FSGNameArray> UVirtualHandMeshComponentKismetLibrary::GetRightHandFingerBoneNames()
{
return FSGArrayUtils::ToNestedBPArray<FName, FSGNameArray>(
USGVirtualHandMeshComponent::GetRightHandFingerBoneNames());
}
const FName& UVirtualHandMeshComponentKismetLibrary::GetLeftHandFingerBoneName(const int32 Finger, const int32 Joint)
{
return USGVirtualHandMeshComponent::GetLeftHandFingerBoneName(Finger, Joint);
}
const FName& UVirtualHandMeshComponentKismetLibrary::GetRightHandFingerBoneName(const int32 Finger, const int32 Joint)
{
return USGVirtualHandMeshComponent::GetRightHandFingerBoneName(Finger, Joint);
}
bool UVirtualHandMeshComponentKismetLibrary::IsLeft(const USGVirtualHandMeshComponent* VirtualHandMeshComponent)
{
return VirtualHandMeshComponent->IsLeft();
}
bool UVirtualHandMeshComponentKismetLibrary::IsRight(const USGVirtualHandMeshComponent* VirtualHandMeshComponent)
{
return VirtualHandMeshComponent->IsRight();
}
void UVirtualHandMeshComponentKismetLibrary::SetRight(USGVirtualHandMeshComponent* VirtualHandMeshComponent,
const bool bInRight)
{
VirtualHandMeshComponent->SetRight(bInRight);
}
bool UVirtualHandMeshComponentKismetLibrary::IsHiddenInGameIfNoGloveDetected(
const USGVirtualHandMeshComponent* VirtualHandMeshComponent)
{
return VirtualHandMeshComponent->IsHiddenInGameIfNoGloveDetected();
}
void UVirtualHandMeshComponentKismetLibrary::SetHiddenIfNoGloveDetected(
USGVirtualHandMeshComponent* VirtualHandMeshComponent,
const bool bInHiddenIfNoGloveDetected)
{
VirtualHandMeshComponent->SetHiddenIfNoGloveDetected(bInHiddenIfNoGloveDetected);
}
bool UVirtualHandMeshComponentKismetLibrary::IsGloveConnected(
const USGVirtualHandMeshComponent* VirtualHandMeshComponent) const
{
return VirtualHandMeshComponent->IsGloveConnected();
}
USGHandPose* UVirtualHandMeshComponentKismetLibrary::GetHandPose(USGVirtualHandMeshComponent* VirtualHandMeshComponent)
{
return VirtualHandMeshComponent->GetHandPose();
}
const FName& UVirtualHandMeshComponentKismetLibrary::GetFingerBoneName(
const USGVirtualHandMeshComponent* VirtualHandMeshComponent,
const int32 Finger, const int32 Joint) const
{
return VirtualHandMeshComponent->GetFingerBoneName(Finger, Joint);
}
const FTransform& UVirtualHandMeshComponentKismetLibrary::GetFingerBoneRefTransform(
const USGVirtualHandMeshComponent* VirtualHandMeshComponent,
const int32 Finger, const int32 Joint) const
{
return VirtualHandMeshComponent->GetFingerBoneRefTransform(Finger, Joint);
}
FRotator UVirtualHandMeshComponentKismetLibrary::GetFingerBoneRefRotation(
const USGVirtualHandMeshComponent* VirtualHandMeshComponent,
const int32 Finger, const int32 Joint) const
{
return VirtualHandMeshComponent->GetFingerBoneRefRotation(Finger, Joint);
}
TMap<FName, FRotator> UVirtualHandMeshComponentKismetLibrary::GetFingersBonesRotations(
USGVirtualHandMeshComponent* VirtualHandMeshComponent)
{
return VirtualHandMeshComponent->GetFingersBonesRotations();
}
@@ -0,0 +1,67 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2023 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
* A data class containing the minimum required data for a hand's forward
* kinematics.
* Used in both kinematics and calibration.
*/
#pragma once
#include "SGKismet/SGBlueprintFunctionLibrary.h"
#include "SGVirtualHandActorKismetLibrary.generated.h"
class ASGVirtualHandActor;
class USGVirtualHandComponent;
/**
* Represents data of a user's hand required for forward kinematics.
*/
UCLASS(meta=(ScriptName = "SesneGloveVirtualHandActorKismetLibrary"))
class SENSEGLOVEKISMET_API UVirtualHandActorKismetLibrary final : public USGBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
static USGVirtualHandComponent* GetVirtualHand(const ASGVirtualHandActor* VirtualHandActor);
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
static bool IsLeft(const ASGVirtualHandActor* VirtualHandActor);
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
static bool IsRight(const ASGVirtualHandActor* VirtualHandActor);
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
bool IsGloveConnected(const ASGVirtualHandActor* VirtualHandActor) const;
};
@@ -39,7 +39,6 @@
#include "Containers/Array.h"
#include "Containers/Map.h"
#include "GameFramework/Actor.h"
#include "Math/Rotator.h"
#include "Math/Transform.h"
#include "UObject/NameTypes.h"
@@ -47,18 +46,18 @@
#include "SGKismet/SGBlueprintFunctionLibrary.h"
#include "SGTypes/SGNameArray.h"
#include "SGVirtualHandMeshComponentKismetLibrary.generated.h"
#include "SGVirtualHandComponentKismetLibrary.generated.h"
class USkeletalMeshComponent;
class USGVirtualHandMeshComponent;
class USGVirtualHandComponent;
class USGHandPose;
/**
* Represents data of a user's hand required for forward kinematics.
*/
UCLASS(meta=(ScriptName = "SesneGloveVirtualHandMeshComponentKismetLibrary"))
class SENSEGLOVEKISMET_API UVirtualHandMeshComponentKismetLibrary final : public USGBlueprintFunctionLibrary
UCLASS(meta=(ScriptName = "SesneGloveVirtualHandComponentKismetLibrary"))
class SENSEGLOVEKISMET_API UVirtualHandComponentKismetLibrary final : public USGBlueprintFunctionLibrary
{
GENERATED_BODY()
@@ -76,39 +75,39 @@ public:
static const FName& GetRightHandFingerBoneName(int32 Finger, int32 Joint);
UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Mesh Component")
static bool IsLeft(const USGVirtualHandMeshComponent* VirtualHandMeshComponent);
static bool IsLeft(const USGVirtualHandComponent* VirtualHandComponent);
UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Mesh Component")
static bool IsRight(const USGVirtualHandMeshComponent* VirtualHandMeshComponent);
static bool IsRight(const USGVirtualHandComponent* VirtualHandComponent);
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Mesh Component")
static void SetRight(UPARAM(ref) USGVirtualHandMeshComponent* VirtualHandMeshComponent, bool bInRight);
static void SetRight(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent, bool bInRight);
UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Mesh Component")
static bool IsHiddenInGameIfNoGloveDetected(const USGVirtualHandMeshComponent* VirtualHandMeshComponent);
static bool IsHiddenInGameIfNoGloveDetected(const USGVirtualHandComponent* VirtualHandComponent);
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Mesh Component")
static void SetHiddenIfNoGloveDetected(UPARAM(ref) USGVirtualHandMeshComponent* VirtualHandMeshComponent,
static void SetHiddenIfNoGloveDetected(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent,
bool bInHiddenIfNoGloveDetected);
UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Mesh Component")
bool IsGloveConnected(const USGVirtualHandMeshComponent* VirtualHandMeshComponent) const;
bool IsGloveConnected(const USGVirtualHandComponent* VirtualHandComponent) const;
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Mesh Component")
USGHandPose* GetHandPose(UPARAM(ref) USGVirtualHandMeshComponent* VirtualHandMeshComponent);
USGHandPose* GetHandPose(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent);
UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Mesh Component")
const FName& GetFingerBoneName(const USGVirtualHandMeshComponent* VirtualHandMeshComponent,
const FName& GetFingerBoneName(const USGVirtualHandComponent* VirtualHandComponent,
int32 Finger, int32 Joint) const;
UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Mesh Component")
const FTransform& GetFingerBoneRefTransform(const USGVirtualHandMeshComponent* VirtualHandMeshComponent,
const FTransform& GetFingerBoneRefTransform(const USGVirtualHandComponent* VirtualHandComponent,
int32 Finger, int32 Joint) const;
UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Mesh Component")
FRotator GetFingerBoneRefRotation(const USGVirtualHandMeshComponent* VirtualHandMeshComponent,
FRotator GetFingerBoneRefRotation(const USGVirtualHandComponent* VirtualHandComponent,
int32 Finger, int32 Joint) const;
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Mesh Component")
TMap<FName, FRotator> GetFingersBonesRotations(UPARAM(ref) USGVirtualHandMeshComponent* VirtualHandMeshComponent);
TMap<FName, FRotator> GetFingersBonesRotations(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent);
};
@@ -1,129 +0,0 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2023 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
* A data class containing the minimum required data for a hand's forward
* kinematics.
* Used in both kinematics and calibration.
*/
#pragma once
#include "Containers/Array.h"
#include "Containers/Map.h"
#include "GameFramework/Actor.h"
#include "Math/Rotator.h"
#include "Math/Transform.h"
#include "UObject/NameTypes.h"
#include "SGKismet/SGBlueprintFunctionLibrary.h"
#include "SGTypes/SGNameArray.h"
#include "SGVirtualHandKismetLibrary.generated.h"
class USkeletalMeshComponent;
class ASGVirtualHand;
class USGHandPose;
/**
* Represents data of a user's hand required for forward kinematics.
*/
UCLASS(meta=(ScriptName = "SesneGloveVirtualHandKismetLibrary"))
class SENSEGLOVEKISMET_API UVirtualHandKismetLibrary final : public USGBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Virtual Hand")
static TArray<FSGNameArray> GetLeftHandFingerBoneNames();
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Virtual Hand")
static TArray<FSGNameArray> GetRightHandFingerBoneNames();
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Virtual Hand")
static const FName& GetLeftHandFingerBoneName(int32 Finger, int32 Joint);
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Virtual Hand")
static const FName& GetRightHandFingerBoneName(int32 Finger, int32 Joint);
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
static USkeletalMeshComponent* GetMesh(const ASGVirtualHand* VirtualHand);
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
static bool IsLeft(const ASGVirtualHand* VirtualHand);
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
static bool IsRight(const ASGVirtualHand* VirtualHand);
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Virtual Hand")
static void SetRight(UPARAM(ref) ASGVirtualHand* VirtualHand, bool bInRight);
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
static bool IsHiddenInGameIfNoGloveDetected(const ASGVirtualHand* VirtualHand);
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Virtual Hand")
static void SetHiddenIfNoGloveDetected(UPARAM(ref) ASGVirtualHand* VirtualHand, bool bInHiddenIfNoGloveDetected);
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
static bool IsAnimateInEditor(const ASGVirtualHand* VirtualHand);
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Virtual Hand")
static void SetAnimateInEditor(UPARAM(ref) ASGVirtualHand* VirtualHand, bool bInAnimateInEditor);
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
USkeletalMesh* GetHandMesh(const ASGVirtualHand* VirtualHand) const;
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
void SetHandMesh(UPARAM(ref) ASGVirtualHand* VirtualHand,
USkeletalMesh* VirtualHandMesh, bool bReinitPos) const;
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
USkeleton* GetHandSkeleton(const ASGVirtualHand* VirtualHand) const;
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
bool IsGloveConnected(const ASGVirtualHand* VirtualHand) const;
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Virtual Hand")
USGHandPose* GetHandPose(UPARAM(ref) ASGVirtualHand* VirtualHand);
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
const FName& GetFingerBoneName(const ASGVirtualHand* VirtualHand, int32 Finger, int32 Joint) const;
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
const FTransform& GetFingerBoneRefTransform(const ASGVirtualHand* VirtualHand, int32 Finger, int32 Joint) const;
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Virtual Hand")
FRotator GetFingerBoneRefRotation(const ASGVirtualHand* VirtualHand, int32 Finger, int32 Joint) const;
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Virtual Hand")
TMap<FName, FRotator> GetFingersBonesRotations(UPARAM(ref) ASGVirtualHand* VirtualHand);
};