From 5a917afa27df34bb0f37ec6319a9fb7cf26d44f2 Mon Sep 17 00:00:00 2001 From: Mamadou Babaei Date: Mon, 27 May 2024 16:37:44 +0200 Subject: [PATCH] implement bHandTrackingVisualizationAllowed --- CHANGELOG.md | 7 +- .../Components/SGVirtualHandComponent.cpp | 2 +- .../Components/SGWristTrackerComponent.cpp | 35 ++++++++ .../SenseGlove/GameFramework/SGPawn.cpp | 82 ++++++++++++------- .../GameFramework/SGPlayerController.cpp | 6 -- .../Components/SGWristTrackerComponent.h | 20 +++++ .../Public/SenseGlove/GameFramework/SGPawn.h | 4 - .../Private/SGKismet/SGPawnKismetLibrary.cpp | 11 --- .../SGWristTrackerComponentKismetLibrary.cpp | 12 +++ .../SGWristTrackerComponentKismetLibrary.h | 9 ++ .../SGSettings/SGWristTrackingSettings.cpp | 5 +- .../SGSettings/SGWristTrackingSettings.h | 4 + 12 files changed, 144 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index edb90895..33cfa7bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,11 +21,14 @@ This is a minor release focusing mainly on bringing OpenXR-compatible hand track - Added FSGVirtualHandAnimInstanceProxy::GetMotionControllerData usable only by child classes. - USGVirtualHandComponent introduced new uproperties AnimationBoneRotationCorrectionOffset and bAnimationShouldApplyBoneLocation with their equivalent getters and setters. - Added USGVirtualHandComponent::GetMotionControllerData(). -- Added the SenseGloveDebugKismet module in order to allow drawing of debug gizmos and virtual hands from Blueprint. -- Added a new static Draw() method overload to DebugGizmo which allows passing a FQuat instead of a FRotator. +- Added USGWristTrackerComponent::GetMotionControllerData(). +- Added USGWristTrackerComponent::OnWristDeviceVisualTypeChanged event in order to be able to notify other components/actors whenever the wrist-tracking device switches between hand tracking or motion controllers. +- Added the SenseGloveDebugKismet module in order to allow drawing of debugging gizmos and virtual hands from Blueprint. +- Added a new static Draw() method overload to DebugGizmo which allows passing an FQuat instead of a FRotator. ### Changed +- The SGSettings has been fully revamped with more customizations added and categorized in a different manner. - The SGSettings constructor visibility has been changed from public to private. - The SenseGlove libraries have been updated to v2.103.0-4a8bd81d. - GetHandPose() has been replaced by GetMotionControllerData inside USGVirtualHandComponent (see the relevant entry in the Added and Removed sections). diff --git a/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp b/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp index f31aec46..18fac3a9 100644 --- a/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp +++ b/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp @@ -387,7 +387,7 @@ bool USGVirtualHandComponent::GetMotionControllerData(FXRMotionControllerData& O if (GEngine) { - IXRTrackingSystem* XrtTrackingSystem = GEngine->XRSystem.Get(); + IXRTrackingSystem* XrtTrackingSystem{GEngine->XRSystem.Get()}; if (XrtTrackingSystem) { const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left; diff --git a/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp b/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp index a92a2d2a..32b3d777 100644 --- a/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp +++ b/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp @@ -38,6 +38,7 @@ #include "Animation/Skeleton.h" #include "Components/SkeletalMeshComponent.h" #include "Engine/SkeletalMesh.h" +#include "IXRTrackingSystem.h" #include "UObject/ConstructorHelpers.h" #include "SGDebug/SGDebugGizmo.h" @@ -104,6 +105,7 @@ USGWristTrackerComponent::USGWristTrackerComponent(const FObjectInitializer& Obj bRight = true; + DeviceVisualType = EXRVisualType::Controller; WristLocation = FVector::ZeroVector; WristRotation = FRotator::ZeroRotator; } @@ -200,6 +202,23 @@ void USGWristTrackerComponent::EditorTick( Pimpl->UpdateWristTrackingData(); } +bool USGWristTrackerComponent::GetMotionControllerData(FXRMotionControllerData& OutMotionControllerData) +{ + OutMotionControllerData.bValid = false; + + if (GEngine) + { + IXRTrackingSystem* XrtTrackingSystem{GEngine->XRSystem.Get()}; + if (XrtTrackingSystem) + { + const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left; + XrtTrackingSystem->GetMotionControllerData(this, Hand, OutMotionControllerData); + } + } + + return OutMotionControllerData.bValid; +} + USGWristTrackerComponent::FImpl::FImpl(USGWristTrackerComponent* InOwner) : Owner(InOwner) { @@ -230,6 +249,22 @@ void USGWristTrackerComponent::FImpl::UpdateMotionSource() const void USGWristTrackerComponent::FImpl::UpdateWristTrackingData() const { + FXRMotionControllerData MotionControllerData; + const bool bGotMotionControllerData = Owner->GetMotionControllerData(MotionControllerData); + if (bGotMotionControllerData) + { + const bool bDeviceVisualTypeUpdated = Owner->DeviceVisualType != MotionControllerData.DeviceVisualType; + if (bDeviceVisualTypeUpdated) + { + Owner->DeviceVisualType = MotionControllerData.DeviceVisualType; + + if (Owner->WristDeviceVisualTypeChangedEvent.IsBound()) + { + Owner->WristDeviceVisualTypeChangedEvent.Broadcast(Owner->DeviceVisualType); + } + } + } + FVector NewWristLocation{Owner->GetComponentLocation()}; FRotator NewWristRotation{Owner->GetComponentRotation()}; diff --git a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp index b9ffe15a..a384775c 100644 --- a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp +++ b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp @@ -39,9 +39,7 @@ #include "Components/PrimitiveComponent.h" #include "Components/SphereComponent.h" #include "Kismet/KismetMathLibrary.h" -#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 #include "XRDeviceVisualizationComponent.h" -#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 */ #include "UObject/UObjectGlobals.h" #include "SenseGlove/Components/SGGrabComponent.h" @@ -93,9 +91,21 @@ struct ASGPawn::FImpl void SetVisibility(USceneComponent* SceneComponent, const bool bVisibility) const; - void UpdateHandLocation(const bool bRight, const FVector& Location, const bool bUpdateVirtualHand); - void UpdateLeftHandLocation(const FVector& Location, const bool bUpdateVirtualHand); - void UpdateRightHandLocation(const FVector& Location, const bool bUpdateVirtualHand); + void UpdateWristTrackerVisualization(const bool bRight, const EXRVisualType VisualType) const; + + FORCEINLINE void UpdateLeftWristTrackerVisualization(const EXRVisualType VisualType) const + { + UpdateWristTrackerVisualization(false, VisualType); + } + + FORCEINLINE void UpdateRightWristTrackerVisualization(const EXRVisualType VisualType) const + { + UpdateWristTrackerVisualization(true, VisualType); + } + + void UpdateHandLocation(const bool bRight, const FVector& Location, const bool bUpdateVirtualHand) const; + void UpdateLeftHandLocation(const FVector& Location, const bool bUpdateVirtualHand) const; + void UpdateRightHandLocation(const FVector& Location, const bool bUpdateVirtualHand) const; void UpdateHandRotation(const bool bRight, const FRotator& Rotation, const bool bUpdateVirtualHand); void UpdateLeftHandRotation(const FRotator& Rotation, const bool bUpdateVirtualHand); @@ -177,14 +187,10 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) WristTrackerLeft->SetupAttachment(GetRootComponent()); WristTrackerLeft->SetRight(false); -#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 ControllerVisualizerLeft = ObjectInitializer.CreateDefaultSubobject( this, TEXT("ControllerVisualizerLeft")); ControllerVisualizerLeft->SetupAttachment(WristTrackerLeft); ControllerVisualizerLeft->SetDisplayModelSource(FName("OpenXR")); -#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 */ - WristTrackerLeft->SetDisplayModelSource(FName("OpenXR")); -#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 */ HandLeft = ObjectInitializer.CreateDefaultSubobject(this, TEXT("HandLeft")); HandLeft->SetupAttachment(GetRootComponent()); @@ -403,14 +409,10 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) WristTrackerRight->SetupAttachment(GetRootComponent()); WristTrackerRight->SetRight(true); -#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 ControllerVisualizerRight = ObjectInitializer.CreateDefaultSubobject( this, TEXT("ControllerVisualizerRight")); ControllerVisualizerRight->SetupAttachment(WristTrackerRight); ControllerVisualizerRight->SetDisplayModelSource(FName("OpenXR")); -#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 */ - WristTrackerRight->SetDisplayModelSource(FName("OpenXR")); -#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 */ HandRight = ObjectInitializer.CreateDefaultSubobject(this, TEXT("HandRight")); HandRight->SetupAttachment(GetRootComponent()); @@ -668,6 +670,18 @@ void ASGPawn::BeginPlay() WristTrackerRight->IsRight() && HandRight->IsRight(), TEXT("The right hand and the right wrist do not track the right hand!")); + WristTrackerLeft->OnWristDeviceVisualTypeChanged().AddWeakLambda( + this, [&](const EXRVisualType VisualType) -> void + { + Pimpl->UpdateLeftWristTrackerVisualization(VisualType); + }); + + WristTrackerLeft->OnWristDeviceVisualTypeChanged().AddWeakLambda( + this, [&](const EXRVisualType VisualType) -> void + { + Pimpl->UpdateRightWristTrackerVisualization(VisualType); + }); + WristTrackerLeft->OnWristLocationChanged().AddWeakLambda(this, [&](const FVector& Location)-> void { Pimpl->UpdateLeftHandLocation(Location, !Pimpl->IsLeftHandOverlappingWithAnyActor()); @@ -1507,7 +1521,6 @@ void ASGPawn::Grab(USGVirtualHandComponent* Hand, AActor* Actor) Pimpl->UnregisterLeftHandOverlappedActor(Actor); } -#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 const bool bAttached = Actor->AttachToComponent(Hand, MoveTemp(AttachmentRules), SocketName); if (bAttached) { @@ -1531,17 +1544,6 @@ void ASGPawn::Grab(USGVirtualHandComponent* Hand, AActor* Actor) SGLOG_ERROR("Failed to grab the actor with the left hand!", Actor, SocketName); } } -#else - Actor->AttachToComponent(Hand, MoveTemp(AttachmentRules), SocketName); - if (Hand->IsRight()) - { - Pimpl->SetRightHandGrabbedActor(Actor); - } - else - { - Pimpl->SetLeftHandGrabbedActor(Actor); - } -#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 */ Pimpl->TriggerActorGrabbedEvent(Hand, Actor); } @@ -1785,7 +1787,31 @@ void ASGPawn::FImpl::SetVisibility(USceneComponent* SceneComponent, const bool b SceneComponent->SetVisibility(bVisibility); } -void ASGPawn::FImpl::UpdateHandLocation(const bool bRight, const FVector& Location, const bool bUpdateVirtualHand) +void ASGPawn::FImpl::UpdateWristTrackerVisualization(const bool bRight, const EXRVisualType VisualType) const +{ + const USGWristTrackerComponent* WristTracker{bRight ? Owner->WristTrackerRight : Owner->WristTrackerLeft}; + if (!IsValid(WristTracker)) + { + return; + } + + const FSGWristTrackingSettings& Settings{WristTracker->GetWristTrackingSettings()}; + const bool bIsVisualizationActive = VisualType == EXRVisualType::Controller + || !!Settings.bHandTrackingVisualizationAllowed; + + UXRDeviceVisualizationComponent* ControllerVisualizer{ + bRight ? Owner->ControllerVisualizerLeft : Owner->ControllerVisualizerRight + }; + + if (!IsValid(ControllerVisualizer)) + { + return; + } + + ControllerVisualizer->SetIsVisualizationActive(bIsVisualizationActive); +} + +void ASGPawn::FImpl::UpdateHandLocation(const bool bRight, const FVector& Location, const bool bUpdateVirtualHand) const { if (bRight) { @@ -1797,7 +1823,7 @@ void ASGPawn::FImpl::UpdateHandLocation(const bool bRight, const FVector& Locati } } -void ASGPawn::FImpl::UpdateLeftHandLocation(const FVector& Location, const bool bUpdateVirtualHand) +void ASGPawn::FImpl::UpdateLeftHandLocation(const FVector& Location, const bool bUpdateVirtualHand) const { if (bUpdateVirtualHand) { @@ -1806,7 +1832,7 @@ void ASGPawn::FImpl::UpdateLeftHandLocation(const FVector& Location, const bool Owner->RealHandLeft->SetWorldLocation(Location); } -void ASGPawn::FImpl::UpdateRightHandLocation(const FVector& Location, const bool bUpdateVirtualHand) +void ASGPawn::FImpl::UpdateRightHandLocation(const FVector& Location, const bool bUpdateVirtualHand) const { if (bUpdateVirtualHand) { diff --git a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPlayerController.cpp b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPlayerController.cpp index d0f4925b..2bf701fc 100644 --- a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPlayerController.cpp +++ b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPlayerController.cpp @@ -36,13 +36,7 @@ #include "SenseGlove/GameFramework/SGPlayerController.h" #include "Runtime/Launch/Resources/Version.h" - -#if ENGINE_MAJOR_VERSION > 5 || ( ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 2 ) #include "Engine/TimerHandle.h" -#else /* ENGINE_MAJOR_VERSION > 5 || ( ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 2 ) */ -#include "Engine/EngineTypes.h" -#endif /* ENGINE_MAJOR_VERSION > 5 || ( ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 2 ) */ - #include "TimerManager.h" #include "SenseGlove/Components/SGTouchComponent.h" diff --git a/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerComponent.h b/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerComponent.h index 6b875f24..5b05e1ec 100644 --- a/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerComponent.h +++ b/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerComponent.h @@ -36,6 +36,7 @@ #pragma once #include "GameFramework/Actor.h" +#include "HeadMountedDisplayTypes.h" #include "Math/Rotator.h" #include "Math/Vector.h" #include "MotionControllerComponent.h" @@ -51,6 +52,13 @@ class SENSEGLOVE_API USGWristTrackerComponent : public UMotionControllerComponen GENERATED_UCLASS_BODY() public: + DECLARE_EVENT_OneParam(USGWristTrackerComponent, FWristDeviceVisualTypeChangedEvent, EXRVisualType) + + FWristDeviceVisualTypeChangedEvent& OnWristDeviceVisualTypeChanged() + { + return WristDeviceVisualTypeChangedEvent; + }; + DECLARE_EVENT_OneParam(USGWristTrackerComponent, FWristLocationChangedEvent, const FVector&) FWristLocationChangedEvent& OnWristLocationChanged() @@ -74,6 +82,7 @@ public: }; private: + FWristDeviceVisualTypeChangedEvent WristDeviceVisualTypeChangedEvent; FWristLocationChangedEvent WristLocationChangedEvent; FWristRotationChangedEvent WristRotationChangedEvent; FWristLocationAndRotationChangedEvent WristLocationAndRotationChangedEvent; @@ -107,6 +116,9 @@ private: FSGWristTrackingSettings WristTrackingSettings; private: + UPROPERTY(Transient) + EXRVisualType DeviceVisualType; + UPROPERTY(Transient) FVector WristLocation; @@ -139,6 +151,11 @@ public: const FSGWristTrackingSettings& GetWristTrackingSettings() const; void SetWristTrackingSettings(const FSGWristTrackingSettings& InWristTrackingSettings); + FORCEINLINE EXRVisualType GetDeviceVisualType() const + { + return DeviceVisualType; + } + FORCEINLINE const FVector& GetWristLocation() const { return WristLocation; @@ -166,4 +183,7 @@ protected: virtual void EditorTick(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction); + +public: + bool GetMotionControllerData(FXRMotionControllerData& OutMotionControllerData); }; \ No newline at end of file diff --git a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h index 6102e46b..e812d410 100644 --- a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h +++ b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h @@ -251,12 +251,10 @@ public: return WristTrackerLeft; } -#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 FORCEINLINE UXRDeviceVisualizationComponent* GetControllerVisualizerLeft() const { return ControllerVisualizerLeft; } -#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 */ FORCEINLINE USGVirtualHandComponent* GetHandLeft() const { @@ -313,12 +311,10 @@ public: return WristTrackerRight; } -#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 FORCEINLINE UXRDeviceVisualizationComponent* GetControllerVisualizerRight() const { return ControllerVisualizerLeft; } -#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 */ FORCEINLINE USGVirtualHandComponent* GetHandRight() const { diff --git a/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp b/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp index c5661338..96011ce6 100644 --- a/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp +++ b/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp @@ -36,12 +36,9 @@ #include "SGKismet/SGPawnKismetLibrary.h" #include "Runtime/Launch/Resources/Version.h" - #include "Camera/CameraComponent.h" #include "Components/SphereComponent.h" -#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 #include "XRDeviceVisualizationComponent.h" -#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 */ #include "SenseGlove/Components/SGVirtualHandComponent.h" #include "SenseGlove/Components/SGWristTrackerComponent.h" @@ -59,11 +56,7 @@ USGWristTrackerComponent* UPawnKismetLibrary::GetWristTrackerLeft(const ASGPawn* UXRDeviceVisualizationComponent* UPawnKismetLibrary::GetControllerVisualizerLeft(const ASGPawn* Pawn) { -#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 return Pawn->GetControllerVisualizerLeft(); -#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 */ - return nullptr; -#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 */ } USGVirtualHandComponent* UPawnKismetLibrary::GetHandLeft(const ASGPawn* Pawn) @@ -123,11 +116,7 @@ USGWristTrackerComponent* UPawnKismetLibrary::GetWristTrackerRight(const ASGPawn UXRDeviceVisualizationComponent* UPawnKismetLibrary::GetControllerVisualizerRight(const ASGPawn* Pawn) { -#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 return Pawn->GetControllerVisualizerRight(); -#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 */ - return nullptr; -#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 */ } USGVirtualHandComponent* UPawnKismetLibrary::GetHandRight(const ASGPawn* Pawn) diff --git a/Source/SenseGloveKismet/Private/SGKismet/SGWristTrackerComponentKismetLibrary.cpp b/Source/SenseGloveKismet/Private/SGKismet/SGWristTrackerComponentKismetLibrary.cpp index a6e5f315..e365f950 100644 --- a/Source/SenseGloveKismet/Private/SGKismet/SGWristTrackerComponentKismetLibrary.cpp +++ b/Source/SenseGloveKismet/Private/SGKismet/SGWristTrackerComponentKismetLibrary.cpp @@ -78,6 +78,12 @@ void UWristTrackerComponentKismetLibrary::SetRight( WristTrackerComponent->SetRight(bInRight); } +EXRVisualType UWristTrackerComponentKismetLibrary::GetDeviceVisualType( + const USGWristTrackerComponent* WristTrackerComponent) +{ + return WristTrackerComponent->GetDeviceVisualType(); +} + const FVector& UWristTrackerComponentKismetLibrary::GetWristLocation( const USGWristTrackerComponent* WristTrackerComponent) { @@ -88,4 +94,10 @@ const FRotator& UWristTrackerComponentKismetLibrary::GetWristRotation( const USGWristTrackerComponent* WristTrackerComponent) { return WristTrackerComponent->GetWristRotation(); +} + +bool UWristTrackerComponentKismetLibrary::GetMotionControllerData( + USGWristTrackerComponent* WristTrackerComponent, FXRMotionControllerData& OutMotionControllerData) +{ + return WristTrackerComponent->GetMotionControllerData(OutMotionControllerData); } \ No newline at end of file diff --git a/Source/SenseGloveKismet/Public/SGKismet/SGWristTrackerComponentKismetLibrary.h b/Source/SenseGloveKismet/Public/SGKismet/SGWristTrackerComponentKismetLibrary.h index e1ab9e3a..1a17011c 100644 --- a/Source/SenseGloveKismet/Public/SGKismet/SGWristTrackerComponentKismetLibrary.h +++ b/Source/SenseGloveKismet/Public/SGKismet/SGWristTrackerComponentKismetLibrary.h @@ -35,6 +35,8 @@ #pragma once +#include "HeadMountedDisplayTypes.h" + #include "SGKismet/SGBlueprintFunctionLibrary.h" #include "SGSettings/SGWristTrackingSettings.h" @@ -74,9 +76,16 @@ public: UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Wrist Tracker Component") static void SetRight(UPARAM(ref) USGWristTrackerComponent* WristTrackerComponent, bool bInRight); + UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Wrist Tracker Component") + static EXRVisualType GetDeviceVisualType(const USGWristTrackerComponent* WristTrackerComponent); + UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Wrist Tracker Component") static const FVector& GetWristLocation(const USGWristTrackerComponent* WristTrackerComponent); UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Wrist Tracker Component") static const FRotator& GetWristRotation(const USGWristTrackerComponent* WristTrackerComponent); + + UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Wrist Tracker Component") + static bool GetMotionControllerData(UPARAM(ref) USGWristTrackerComponent* WristTrackerComponent, + FXRMotionControllerData& OutMotionControllerData); }; \ No newline at end of file diff --git a/Source/SenseGloveSettings/Private/SGSettings/SGWristTrackingSettings.cpp b/Source/SenseGloveSettings/Private/SGSettings/SGWristTrackingSettings.cpp index 517f6fc6..5434e416 100644 --- a/Source/SenseGloveSettings/Private/SGSettings/SGWristTrackingSettings.cpp +++ b/Source/SenseGloveSettings/Private/SGSettings/SGWristTrackingSettings.cpp @@ -37,6 +37,7 @@ FSGWristTrackingSettings::FSGWristTrackingSettings() : FSGWristTrackingSettings( + false, ESGPositionalTrackingHardware::None, FVector::ZeroVector, FVector::ZeroVector, @@ -50,6 +51,7 @@ FSGWristTrackingSettings::FSGWristTrackingSettings() } FSGWristTrackingSettings::FSGWristTrackingSettings( + const bool bInHandTrackingVisualizationAllowed, const ESGPositionalTrackingHardware InTrackingHardware, const FVector& InTrackingHardwareLocationOffsetLeftHand, const FVector& InTrackingHardwareLocationOffsetRightHand, @@ -59,7 +61,8 @@ FSGWristTrackingSettings::FSGWristTrackingSettings( const EControllerHand InRightHandMotionSource, const bool bInDrawDebugGizmo, const FSGDebugGizmoSettings& InDebugGizmoSettings) - : TrackingHardware(InTrackingHardware), + : bHandTrackingVisualizationAllowed(bInHandTrackingVisualizationAllowed), + TrackingHardware(InTrackingHardware), TrackingHardwareLocationOffsetLeftHand(InTrackingHardwareLocationOffsetLeftHand), TrackingHardwareLocationOffsetRightHand(InTrackingHardwareLocationOffsetRightHand), TrackingHardwareRotationOffsetLeftHand(InTrackingHardwareRotationOffsetLeftHand), diff --git a/Source/SenseGloveSettings/Public/SGSettings/SGWristTrackingSettings.h b/Source/SenseGloveSettings/Public/SGSettings/SGWristTrackingSettings.h index af9aa0d5..a3037507 100644 --- a/Source/SenseGloveSettings/Public/SGSettings/SGWristTrackingSettings.h +++ b/Source/SenseGloveSettings/Public/SGSettings/SGWristTrackingSettings.h @@ -49,6 +49,9 @@ struct SENSEGLOVESETTINGS_API FSGWristTrackingSettings GENERATED_USTRUCT_BODY() public: + UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking") + uint8 bHandTrackingVisualizationAllowed : 1; + /** * If set to Custom, any desired location and rotation can be specified. */ @@ -114,6 +117,7 @@ public: FSGWristTrackingSettings(); FSGWristTrackingSettings( + bool bInHandTrackingVisualizationAllowed, ESGPositionalTrackingHardware InTrackingHardware, const FVector& InTrackingHardwareLocationOffsetLeftHand, const FVector& InTrackingHardwareLocationOffsetRightHand,