add a new FSGHandLayer::GetWristLocation() overload which allows passing FRotator instead of FQuat as input or output parameters

This commit is contained in:
Mamadou Babaei
2026-02-20 12:08:08 +01:00
parent ba11f7bd23
commit b960cfda82
5 changed files with 64 additions and 6 deletions
+1
View File
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added a `USGHapticsComponent` to allow sending a variety of haptic feedbacks (force-feedback, vibrotactile, custom waveforms, and wrist-squeeze) to the gloves without touching SenseGlove's low-level API. - Added a `USGHapticsComponent` to allow sending a variety of haptic feedbacks (force-feedback, vibrotactile, custom waveforms, and wrist-squeeze) to the gloves without touching SenseGlove's low-level API.
- Added a `USGHandTrackerComponent` to allow retrieval or visualization of `FXRHandTrackingState` without relying on low-level SenseGlove API or UE's generic `GetHandTrackingState()` functionality. This is useful when developing a custom hand-interaction system using SenseGlove/UE OpenXR API or interfacing with third-party OpenXR-compatible plugins such as [VR Expansion Plugin (VRE)](https://vreue4.com/). Using this component removes the need to calculate the wrist offsets manually, or an extra call to `USGHapticGlove::GetWristLocation()`, in comparison to when the `FXRHandTrackingState` is retrieved via UE's `GetHandTrackingState()`. - Added a `USGHandTrackerComponent` to allow retrieval or visualization of `FXRHandTrackingState` without relying on low-level SenseGlove API or UE's generic `GetHandTrackingState()` functionality. This is useful when developing a custom hand-interaction system using SenseGlove/UE OpenXR API or interfacing with third-party OpenXR-compatible plugins such as [VR Expansion Plugin (VRE)](https://vreue4.com/). Using this component removes the need to calculate the wrist offsets manually, or an extra call to `USGHapticGlove::GetWristLocation()`, in comparison to when the `FXRHandTrackingState` is retrieved via UE's `GetHandTrackingState()`.
- A new `FSGDebugVirtualHand::Draw()` overload has been added to allow visualizing `FSGDebugGizmoSettings` directly. This is used internally by the new `USGHandTrackerComponent` to visualize its `FXRHandTrackingState` if `bVisualize` is enabled. - A new `FSGDebugVirtualHand::Draw()` overload has been added to allow visualizing `FSGDebugGizmoSettings` directly. This is used internally by the new `USGHandTrackerComponent` to visualize its `FXRHandTrackingState` if `bVisualize` is enabled.
- Added a new `FSGHandLayer::GetWristLocation()` overload to allow passing `FRotator`s instead of `FQuat`s as input or output parameters.
### Fixed ### Fixed
@@ -132,6 +132,25 @@ void FSGHandLayer::GetWristLocation(
OutWristRotation = MoveTemp(OutWristRotationContainer.Quat); OutWristRotation = MoveTemp(OutWristRotationContainer.Quat);
} }
void FSGHandLayer::GetWristLocation(
const bool bRightHanded, const FVector& ReferencePosition, const FRotator& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware, FVector& OutWristPosition, FRotator& OutWristRotation)
{
FSGIC_FVector ReferencePositionContainer{ReferencePosition};
FSGIC_FQuat ReferenceRotationContainer{ReferenceRotation.Quaternion()};
FSGIC_ESGPositionalTrackingHardware TrackingHardwareContainer{TrackingHardware};
FSGIC_FVector OutWristPositionContainer;
FSGIC_FQuat OutWristRotationContainer;
SGCoreImpl_FSGHandLayerImpl_GetWristLocation(
bRightHanded, &ReferencePositionContainer, &ReferenceRotationContainer,
&TrackingHardwareContainer,
&OutWristPositionContainer, &OutWristRotationContainer);
OutWristPosition = MoveTemp(OutWristPositionContainer.Vector);
OutWristRotation = OutWristRotationContainer.Quat.Rotator();
}
void FSGHandLayer::StopAllHaptics(const bool bRightHanded) void FSGHandLayer::StopAllHaptics(const bool bRightHanded)
{ {
SGCoreImpl_FSGHandLayerImpl_StopAllHaptics(bRightHanded); SGCoreImpl_FSGHandLayerImpl_StopAllHaptics(bRightHanded);
@@ -42,6 +42,7 @@
#include "Containers/UnrealString.h" #include "Containers/UnrealString.h"
#include "HAL/Platform.h" #include "HAL/Platform.h"
#include "Math/Quat.h" #include "Math/Quat.h"
#include "Math/Rotator.h"
#include "Math/Vector.h" #include "Math/Vector.h"
#include "UObject/ObjectMacros.h" #include "UObject/ObjectMacros.h"
@@ -148,6 +149,22 @@ public:
ESGPositionalTrackingHardware TrackingHardware, ESGPositionalTrackingHardware TrackingHardware,
FVector& OutWristPosition, FQuat& OutWristRotation); FVector& OutWristPosition, FQuat& OutWristRotation);
/**
* Calculate the Wrist Location of the chosen hand, based on a reference location and tracking hardware.
*
* @param bRightHanded
* @param ReferencePosition
* @param ReferenceRotation
* @param TrackingHardware
* @param OutWristPosition
* @param OutWristRotation
*/
static void GetWristLocation(
bool bRightHanded,
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware,
FVector& OutWristPosition, FRotator& OutWristRotation);
/** /**
* Stop all haptics on the chosen hand. * Stop all haptics on the chosen hand.
* *
@@ -91,10 +91,21 @@ bool USGHandLayerKismetLibrary::GetHandPose(UObject* WorldContextObject,
return FSGHandLayer::GetHandPose(WorldContextObject, bRightHanded, OutHandPose); return FSGHandLayer::GetHandPose(WorldContextObject, bRightHanded, OutHandPose);
} }
void USGHandLayerKismetLibrary::GetWristLocation(const bool bRightHanded, void USGHandLayerKismetLibrary::GetWristLocation_bRH_FQuat_RR_TH_OutWP_OutWR(
const FVector& ReferencePosition, const FQuat& ReferenceRotation, const bool bRightHanded,
const ESGPositionalTrackingHardware TrackingHardware, const FVector& ReferencePosition, const FQuat& ReferenceRotation,
FVector& OutWristPosition, FQuat& OutWristRotation) ESGPositionalTrackingHardware TrackingHardware,
FVector& OutWristPosition, FQuat& OutWristRotation)
{
FSGHandLayer::GetWristLocation(bRightHanded, ReferencePosition, ReferenceRotation, TrackingHardware,
OutWristPosition, OutWristRotation);
}
void USGHandLayerKismetLibrary::GetWristLocation_bRH_RP_FRotator_RR_TH_OutWP_OutWR(
const bool bRightHanded,
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware,
FVector& OutWristPosition, FRotator& OutWristRotation)
{ {
FSGHandLayer::GetWristLocation(bRightHanded, ReferencePosition, ReferenceRotation, TrackingHardware, FSGHandLayer::GetWristLocation(bRightHanded, ReferencePosition, ReferenceRotation, TrackingHardware,
OutWristPosition, OutWristRotation); OutWristPosition, OutWristRotation);
@@ -122,13 +122,23 @@ public:
/** /**
* Calculate the Wrist Location of the chosen hand, based on a reference location and tracking hardware. * Calculate the Wrist Location of the chosen hand, based on a reference location and tracking hardware.
*/ */
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Hand Layer") UFUNCTION(BlueprintCallable, DisplayName="Get Wrist Location", Category="SenseGlove | Core | Hand Layer")
static void GetWristLocation( static void GetWristLocation_bRH_FQuat_RR_TH_OutWP_OutWR(
bool bRightHanded, bool bRightHanded,
const FVector& ReferencePosition, const FQuat& ReferenceRotation, const FVector& ReferencePosition, const FQuat& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware, ESGPositionalTrackingHardware TrackingHardware,
FVector& OutWristPosition, FQuat& OutWristRotation); FVector& OutWristPosition, FQuat& OutWristRotation);
/**
* Calculate the Wrist Location of the chosen hand, based on a reference location and tracking hardware.
*/
UFUNCTION(BlueprintCallable, DisplayName="Get Wrist Location", Category="SenseGlove | Core | Hand Layer")
static void GetWristLocation_bRH_RP_FRotator_RR_TH_OutWP_OutWR(
bool bRightHanded,
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
ESGPositionalTrackingHardware TrackingHardware,
FVector& OutWristPosition, FRotator& OutWristRotation);
/** /**
* Stop all haptics on the chosen hand. * Stop all haptics on the chosen hand.
*/ */