diff --git a/CHANGELOG.md b/CHANGELOG.md index a5ae08b9..d8c3542e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ This is the second major release of the SenseGlove Unreal Engine Plugin adding s - The SGTouchComponent uproperties BuzzDuration and BuzzLevel now utilize different different names in order to correspond to the underlying API changes. They have been renamed to VibrotactileDuration and VibrotacktileLevel. - The SGTouchComponent uproperties ForceFeedbackLevel and BuzzLevel (now VibrotacktileLevel) parameters type have changed from int32 to float with the value range varying between 0.0f to 1.0f instead of 1 to 100 in order to correspond to the underlying API changes. - The SGVirtualHandComponent now assumes the default grab point's name as GenericGrabPoint instead of GrabPoint as default if not specified in the Unreal Blueprint Editor. +- The SGPawn on UE 5.2+ now utilizes UXRDeviceVisualizationComponent in order to properly display the controller meshes shipped with Unreal Engine's OpenXR plugin, or a user-provided mesh. On UE 5.1 this could still be set on the WristTrackerLeft and WristTrackerRight components. Please note that despite the fact that on UE 5.2+ it's still possible to utilize the WristTrackerLeft and WristTrackerRight for setting the controller meshes, this has been deprecated in UE 5.2+ and is no longer supported. ### Removed diff --git a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp index 7a8b730b..8f727a8b 100644 --- a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp +++ b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp @@ -39,7 +39,9 @@ #include "Components/PrimitiveComponent.h" #include "Components/SphereComponent.h" #include "Kismet/KismetMathLibrary.h" -#include "Runtime/Launch/Resources/Version.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" @@ -173,6 +175,15 @@ 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()); HandLeft->SetCanEverAffectNavigation(false); @@ -391,6 +402,15 @@ 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()); HandRight->SetCanEverAffectNavigation(false); diff --git a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPlayerController.cpp b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPlayerController.cpp index 615e21b7..4e5fc021 100644 --- a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPlayerController.cpp +++ b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPlayerController.cpp @@ -46,6 +46,7 @@ #include "TimerManager.h" #include "SenseGlove/Components/SGTouchComponent.h" +#include "SenseGlove/Components/SGVirtualHandComponent.h" #include "SenseGlove/GameFramework/SGPawn.h" #include "SenseGlove/Haptics/SGGrabState.h" #include "SenseGlove/Haptics/SGTouchState.h" diff --git a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h index aa68bbb3..6102e46b 100644 --- a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h +++ b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h @@ -37,7 +37,7 @@ #include "Containers/Array.h" #include "GameFramework/Pawn.h" -#include "SenseGlove/Components/SGVirtualHandComponent.h" +#include "Runtime/Launch/Resources/Version.h" #include "Templates/UniquePtr.h" #include "SenseGlove/Haptics/SGGrabState.h" @@ -48,6 +48,7 @@ class UCameraComponent; class UPrimitiveComponent; class USphereComponent; +class UXRDeviceVisualizationComponent; class USGVirtualHandComponent; class USGWristTrackerComponent; @@ -129,6 +130,9 @@ private: UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) USGWristTrackerComponent* WristTrackerLeft; + UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) + UXRDeviceVisualizationComponent* ControllerVisualizerLeft; + UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) USGVirtualHandComponent* HandLeft; @@ -162,6 +166,9 @@ private: UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) USGWristTrackerComponent* WristTrackerRight; + UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) + UXRDeviceVisualizationComponent* ControllerVisualizerRight; + UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) USGVirtualHandComponent* HandRight; @@ -244,6 +251,13 @@ 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 { return HandLeft; @@ -299,6 +313,13 @@ 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 { return HandRight; diff --git a/Source/SenseGlove/SenseGlove.Build.cs b/Source/SenseGlove/SenseGlove.Build.cs index 39f67220..1b014d6c 100644 --- a/Source/SenseGlove/SenseGlove.Build.cs +++ b/Source/SenseGlove/SenseGlove.Build.cs @@ -57,6 +57,13 @@ public class SenseGlove : ModuleRules "Engine", "HeadMountedDisplay", "InputCore", + // NOTE + // UE 5.3+ provides UXRDeviceVisualizationComponent as part of the XRBase plugin. + // UE 5.2 provides UXRDeviceVisualizationComponent as part of the HeadMountDisplay module. + // UE 5.1 does not provide the UXRDeviceVisualizationComponent type. +#if UE_5_3_OR_LATER + "XRBase", +#endif "SenseGloveBackend", "SenseGloveConnect", "SenseGloveCore", @@ -74,4 +81,4 @@ public class SenseGlove : ModuleRules } ); } -} +} \ No newline at end of file diff --git a/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp b/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp index dae3a23f..c5661338 100644 --- a/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp +++ b/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp @@ -35,8 +35,13 @@ #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" @@ -52,6 +57,15 @@ USGWristTrackerComponent* UPawnKismetLibrary::GetWristTrackerLeft(const ASGPawn* return Pawn->GetWristTrackerLeft(); } +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) { return Pawn->GetHandLeft(); @@ -107,6 +121,15 @@ USGWristTrackerComponent* UPawnKismetLibrary::GetWristTrackerRight(const ASGPawn return Pawn->GetWristTrackerRight(); } +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) { return Pawn->GetHandRight(); diff --git a/Source/SenseGloveKismet/Public/SGKismet/SGPawnKismetLibrary.h b/Source/SenseGloveKismet/Public/SGKismet/SGPawnKismetLibrary.h index 902ec0df..b1a26efa 100644 --- a/Source/SenseGloveKismet/Public/SGKismet/SGPawnKismetLibrary.h +++ b/Source/SenseGloveKismet/Public/SGKismet/SGPawnKismetLibrary.h @@ -51,6 +51,7 @@ class UCameraComponent; class USphereComponent; +class UXRDeviceVisualizationComponent; class ASGPawn; class USGVirtualHandComponent; @@ -68,6 +69,9 @@ public: UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") static USGWristTrackerComponent* GetWristTrackerLeft(const ASGPawn* Pawn); + UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") + static UXRDeviceVisualizationComponent* GetControllerVisualizerLeft(const ASGPawn* Pawn); + UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") static USGVirtualHandComponent* GetHandLeft(const ASGPawn* Pawn); @@ -101,6 +105,9 @@ public: UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") static USGWristTrackerComponent* GetWristTrackerRight(const ASGPawn* Pawn); + UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") + static UXRDeviceVisualizationComponent* GetControllerVisualizerRight(const ASGPawn* Pawn); + UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") static USGVirtualHandComponent* GetHandRight(const ASGPawn* Pawn); diff --git a/Source/SenseGloveKismet/SenseGloveKismet.Build.cs b/Source/SenseGloveKismet/SenseGloveKismet.Build.cs index 27580790..392f4689 100644 --- a/Source/SenseGloveKismet/SenseGloveKismet.Build.cs +++ b/Source/SenseGloveKismet/SenseGloveKismet.Build.cs @@ -55,6 +55,13 @@ public class SenseGloveKismet : ModuleRules "CoreUObject", "Engine", "HeadMountedDisplay", + // NOTE + // UE 5.3+ provides UXRDeviceVisualizationComponent as part of the XRBase plugin. + // UE 5.2 provides UXRDeviceVisualizationComponent as part of the HeadMountDisplay module. + // UE 5.1 does not provide the UXRDeviceVisualizationComponent type. +#if UE_5_3_OR_LATER + "XRBase", +#endif "SenseGlove", "SenseGloveCore", "SenseGloveLog",