Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c2ab3aa7b
|
||
|
|
98dba77a02
|
||
|
|
e152842ead
|
||
|
|
3a59442cda
|
||
|
|
4a3db0b35a
|
||
|
|
afdaaf4950
|
||
|
|
3e1bae1e9a
|
||
|
|
60f09035ba
|
||
|
|
080e83a344
|
||
|
|
9a35132911
|
||
|
|
5a2ed01e59
|
||
|
|
1cbe24a4c9
|
||
|
|
1e11ab6320
|
||
|
|
551e625c1f
|
||
|
|
287a81356d
|
||
|
|
02690badc6
|
||
|
|
ba4441655f
|
||
|
|
9b361f5ef9
|
||
|
|
22210f05f0
|
||
|
|
baa2998c8d
|
||
|
|
4b2654a296
|
||
|
|
3393a31e5f
|
||
|
|
3d274c1734
|
||
|
|
eb8a8b197b
|
||
|
|
f3f5893fd8
|
||
|
|
c8801a48fa
|
||
|
|
de11ff03c8
|
||
|
|
42c560c43c
|
||
|
|
dfdb6017dc
|
||
|
|
2523b54a91
|
||
|
|
1d9ca12cf8
|
||
|
|
50599d2832
|
||
|
|
843c528fe1
|
||
|
|
33a0bc10b8
|
||
|
|
2dfb39842e
|
||
|
|
bae22c36f5
|
||
|
|
cfa01f1b97
|
||
|
|
ab72a893e5
|
@@ -63,7 +63,7 @@ SG_HANDBOOK_PACKED_HTML_DIR := $(SG_DOCUMENTATION_PACK_DIR)/$(SG_HANDBOOK_ESCAP
|
||||
SG_HANDBOOK_PACKED_HTML_FILE := $(SG_DOCUMENTATION_PACK_DIR)/$(SG_HANDBOOK_ESCAPED_NAME).zip
|
||||
SG_HANDBOOK_PACKED_PDF_FILE := $(SG_DOCUMENTATION_PACK_DIR)/$(SG_HANDBOOK_ESCAPED_NAME).pdf
|
||||
|
||||
SG_BROWSER_BINARY_PATH_LINUX := $(shell which brave-bin 2>/dev/null)
|
||||
SG_BROWSER_BINARY_PATH_LINUX := /opt/brave.com/brave/brave
|
||||
SG_BROWSER_BINARY_PATH_WINDOWS := C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe
|
||||
|
||||
SG_RSYNC_BIN_PATH_WINDOWS := C:\Program Files\cwrsync\bin
|
||||
|
||||
+1
-1
@@ -88,4 +88,4 @@ SG_RSYNC_SSH_BINARY_PATH_WINDOWS := $(SG_RSYNC_BIN_PATH_WINDOWS)\ssh.exe
|
||||
|
||||
### make pack
|
||||
|
||||
This target is meant to be used by the `sgum-packager` utility located in the [Packager](../Packager) folder in order to deploy the documentation in various formats along with the plugin to the Unreal Engine Marketplace.
|
||||
This target is meant to be used by the `sgum-packager` utility located in the [Packager](../Packager) folder in order to deploy the documentation in various formats along with the plugin to [Fab](https://www.fab.com/).
|
||||
|
||||
@@ -7,4 +7,4 @@ This handbook is an ongoing effort and a work in progress to document the SenseG
|
||||
Due to superior formatting and frequent updates, we recommend [the online version of the handbook]({{ #sg-handbook-revision-url }}); nonetheless, it's available in [PDF format]({{ #sg-handbook-pdf-url }}) as well.
|
||||
|
||||
> [!TIP]
|
||||
> Feel free to check out [the SenseGlove Unreal Engine Plugin landing page on the UE Marketplace](https://www.unrealengine.com/marketplace/en-US/product/the-senseglove-unreal-engine-plugin) as well.
|
||||
> Feel free to check out [the SenseGlove Unreal Engine Plugin landing page on Fab](https://www.fab.com/listings/62bcdd2a-0bb1-4f34-b7b8-c5e7c9313099) as well.
|
||||
|
||||
@@ -11,8 +11,8 @@ Welcom to the SenseGlove Unreal Engine Handbook!
|
||||
# 🚀 Getting Started
|
||||
|
||||
- [Installation](getting-started/installation/README.md)
|
||||
- [Through the Epic Games Launcher](getting-started/installation/epic-games-launcher.md)
|
||||
- [Through Microsoft Azure DevOps Repositories](getting-started/installation/microsoft-azure-devops-repositories.md)
|
||||
- [Via the Epic Games Launcher](getting-started/installation/epic-games-launcher.md)
|
||||
- [Via Microsoft Azure DevOps Repositories](getting-started/installation/microsoft-azure-devops-repositories.md)
|
||||
- [Enabling and Verifying the Plugin Version](getting-started/plugin-verify-version-enable/README.md)
|
||||
- [SenseCom](getting-started/sensecom/README.md)
|
||||
- [SenseCom on GNU/Linux](getting-started/sensecom/gnu-linux/README.md)
|
||||
@@ -63,6 +63,9 @@ Welcom to the SenseGlove Unreal Engine Handbook!
|
||||
|
||||
- [Safe Glove Access in Blueprint](advanced-topics/safe-glove-access-blueprint/README.md)
|
||||
- [OpenXR](advanced-topics/openxr/README.md)
|
||||
- [Consuming FXRHandTrackingState](advanced-topics/openxr/consuming-fxrhandtrackingstate/README.md)
|
||||
- [Blueprint](advanced-topics/openxr/consuming-fxrhandtrackingstate/blueprint.md)
|
||||
- [C++](advanced-topics/openxr/consuming-fxrhandtrackingstate/cpp.md)
|
||||
- [Consuming FXRMotionControllerData](advanced-topics/openxr/consuming-fxrmotioncontrollerdata/README.md)
|
||||
- [Blueprint](advanced-topics/openxr/consuming-fxrmotioncontrollerdata/blueprint.md)
|
||||
- [C++](advanced-topics/openxr/consuming-fxrmotioncontrollerdata/cpp.md)
|
||||
|
||||
@@ -4,6 +4,32 @@ The SenseGlove Unreal Engine Plugin has provided OpenXR-compatible hand tracking
|
||||
|
||||
Typically a user does not need to know anything about OpenXR to use the plugin, so this section of the handbook is for advanced users who are looking for a way to directly consume the OpenXR data coming directly from either a SenseGlove device or if enabled in the plugin settings from hand-tracking.
|
||||
|
||||
Since the SenseGlove Unreal Engine Plugin registers itself as an `OpenXRHandTracking` motion controller device it becomes a hand-tracking provider for Unreal Engine, thus the OpenXR data from SenseGlove could always be retrieved from the Unreal Engine's `IXTrackingSystem` with one caveat. The caveat is if another OpenXR-compatible hand-tracking plugin, e.g. Epic's own OpenXRHandTracking, is enabled simultaneously it's not guaranteed that the `FXRMotionControllerData` retrieved from the `IXTrackingSystem::GetMotionControllerData()` method is coming from SenseGlove, as this method returns the first hand-tracking plugin it could find. Thus, SenseGlove provides its own implementation of `GetMotionControllerData()` which guarantees the retrieved `FXRMotionControllerData` is coming from the SenseGlove Unreal Engine Plugin; and this is the preferred way to that.
|
||||
Since the SenseGlove Unreal Engine Plugin registers itself as an `OpenXRHandTracking` motion controller device it becomes a hand-tracking provider for Unreal Engine, thus the OpenXR data from SenseGlove could always be retrieved from the Unreal Engine's `IXTrackingSystem` with one caveat. The caveat is if another OpenXR-compatible hand-tracking plugin, e.g. Epic's own OpenXRHandTracking, is enabled simultaneously it's not guaranteed that the `FXRMotionControllerData` and `FXRHandTrackingState` structs retrieved from the `IXTrackingSystem::GetMotionControllerData()` and `IXTrackingSystem::GetHandTrackingState()` methods are coming from SenseGlove, as these methods return the first hand-tracking plugin they could find. Thus, SenseGlove provides its own implementation of `GetMotionControllerData()` and `GetHandTrackingState()` which guarantee the retrieved `FXRMotionControllerData` or `FXRHandTrackingState` are coming from the SenseGlove Unreal Engine Plugin; and this is the preferred way to that.
|
||||
|
||||
In the next sections we'll see [how we can directly consume the `FXRMotionControllerData`](consuming-fxrmotioncontrollerdata/) to draw and animate debug virtual hands in both [Blueprint](consuming-fxrmotioncontrollerdata/blueprint.md) and [C++](consuming-fxrmotioncontrollerdata/cpp.md).
|
||||
> [!NOTE]
|
||||
> In order to retrieve the latest `FXRMotionControllerState` available, The
|
||||
> SenseGlove Unreal Engine Plugin provides an alternative implementation for
|
||||
> `IXTrackingSystem::GetMotionControllerState()` as well . However, since this
|
||||
> method does not rely on the `OpenXRHandTracking` provider, it may become
|
||||
> redundant. As a result, we might consider removing this functionality in
|
||||
> future updates in favor of the one that Unreal Engine provides.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Unreal Engine versions `5.2`, `5.3`, and `5.4` are limited to
|
||||
> `FXRMotionControllerData` since at the time of their release no
|
||||
> `FXRHandTrackingState` was available.
|
||||
> Also please keep in mind that, while `FXRMotionControllerData` is pretty much
|
||||
> usable and functional in Unreal Engine `5.5`, it is recommended to utilize
|
||||
> `FXRHandTrackingState` instead. This is because this version of UE has
|
||||
> deprecated `FXRMotionControllerData` in favor of the
|
||||
> `FXRMotionControllerState` and `FXRHandTrackingState` structs. Prior to
|
||||
> version `5.5`, `FXRMotionControllerData` handled both motion controller and
|
||||
> hand tracking data. From `5.5` onward, these responsibilities have been
|
||||
> separated into the two distinct structs, providing clearer and more
|
||||
> specialized handling of each.
|
||||
|
||||
In the next sections we'll see:
|
||||
|
||||
- [How we can directly consume the `FXRMotionControllerData`](consuming-fxrmotioncontrollerdata/) on UE `5.2`, `5.3`, `5.4`, and `5.5` to draw and animate debug virtual hands in both [Blueprint](consuming-fxrmotioncontrollerdata/blueprint.md) and [C++](consuming-fxrmotioncontrollerdata/cpp.md).
|
||||
|
||||
- [How we can directly consume the `FXRHandTrackingState`](consuming-fxrhandtrackingstate/) on UE `5.5` to draw and animate debug virtual hands in both [Blueprint](consuming-fxrhandtrackingstate/blueprint.md) and [C++](consuming-fxrhandtrackingstate/cpp.md).
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
# Consuming FXRHandTrackingState
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Unreal Engine versions `5.2`, `5.3`, and `5.4` are limited to
|
||||
> `FXRMotionControllerData` since at the time of their release no
|
||||
> `FXRHandTrackingState` was available.
|
||||
> Also please keep in mind that, while `FXRMotionControllerData` is pretty much
|
||||
> usable and functional in Unreal Engine `5.5`, it is recommended to utilize
|
||||
> `FXRHandTrackingState` instead. This is because this version of UE has
|
||||
> deprecated `FXRMotionControllerData` in favor of the
|
||||
> `FXRMotionControllerState` and `FXRHandTrackingState` structs. Prior to
|
||||
> version `5.5`, `FXRMotionControllerData` handled both motion controller and
|
||||
> hand-tracking data. From `5.5` onward, these responsibilities have been
|
||||
> separated into the two distinct structs, providing clearer and more
|
||||
> specialized handling of each.
|
||||
|
||||
Taking a closer look at the `FXRHandTrackingState` declaration inside the Unreal Engine's `HeadMountedDisplay` module at `[Engine/Source/Runtime/HeadMountedDisplay/Public/HeadMountedDisplayTypes.h](https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/HeadMountedDisplay/Public/HeadMountedDisplayTypes.h)`, figuring out the data structure might not seem very straightforward:
|
||||
|
||||
```cpp
|
||||
USTRUCT(BlueprintType)
|
||||
struct FXRHandTrackingState
|
||||
{
|
||||
GENERATED_USTRUCT_BODY();
|
||||
|
||||
// The state is valid if poses have ever been provided.
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
bool bValid = false;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FName DeviceName;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FGuid ApplicationInstanceID;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
EXRSpaceType XRSpaceType = EXRSpaceType::UnrealWorldSpace;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
EControllerHand Hand = EControllerHand::Left;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
ETrackingStatus TrackingStatus = ETrackingStatus::NotTracked;
|
||||
|
||||
// The indices of this array are the values of EHandKeypoint (Palm, Wrist, ThumbMetacarpal, etc).
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
TArray<FVector> HandKeyLocations;
|
||||
|
||||
// The indices of this array are the values of EHandKeypoint (Palm, Wrist, ThumbMetacarpal, etc).
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
TArray<FQuat> HandKeyRotations;
|
||||
|
||||
// The indices of this array are the values of EHandKeypoint (Palm, Wrist, ThumbMetacarpal, etc).
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
TArray<float> HandKeyRadii;
|
||||
};
|
||||
```
|
||||
|
||||
Which on the Blueprint side it looks like this:
|
||||
|
||||

|
||||
|
||||
But, fear not, we've got you covered!
|
||||
|
||||
## FXRHandTrackingState in Unreal Engine
|
||||
|
||||
`FXRHandTrackingState` is a structure in Unreal Engine designed to hold detailed information about the state of a hand-tracking device at a given moment. This structure is essential for handling hand-tracking inputs in virtual reality (VR) applications, providing the necessary data to accurately track and represent the user's hand movements and actions within the virtual environment.
|
||||
|
||||
### Structure Members of FXRHandTrackingState
|
||||
|
||||
- **bValid**
|
||||
- **Description**: A boolean flag indicating whether the data is valid or not.
|
||||
- **Usage**: This is used to check if the motion controller data is correctly initialized and can be used for further processing.
|
||||
|
||||
- **DeviceName**
|
||||
- **Type**: `FName`
|
||||
- **Description**: The name of the device.
|
||||
- **Usage**: Identifies which device the data is coming from, useful when multiple devices are in use.
|
||||
|
||||
- **ApplicationInstanceID**
|
||||
- **Type**: `FString`
|
||||
- **Description**: A unique identifier for the application instance.
|
||||
- **Usage**: Helps in differentiating data from different instances of an application, ensuring the correct instance processes the data.
|
||||
|
||||
- **XRSpaceType**
|
||||
- **Type**: `EXRSpaceType`
|
||||
- **Description**: Enum specifying the type of XR space being used (e.g., unreal world or tracking space).
|
||||
- **Usage**: Specifies the coordinate system the XR Device is tracking itself in.
|
||||
|
||||
- **Hand**
|
||||
- **Type**: `EControllerHand`
|
||||
- **Description**: Enum indicating which hand is being tracked (left or right).
|
||||
- **Usage**: Helps identify whether the hand-tracking data pertains to the left or right hand, essential for hand-specific actions or interactions.
|
||||
|
||||
- **TrackingStatus**
|
||||
- **Type**: `EXRTrackingStatus`
|
||||
- **Description**: Enum indicating the tracking status of the hand-tracking device.
|
||||
- **Usage**: Shows whether the hand-tracking device is being tracked accurately, with possible statuses like `Tracked`, `NotTracked`, etc.
|
||||
|
||||
- **HandKeyLocations**
|
||||
- **Type**: `TArray<FVector>`
|
||||
- **Description**: An array of vectors representing key locations of the hand.
|
||||
- **Usage**: Provides detailed locations of key points on the hand, useful for precise hand-tracking and interaction.
|
||||
|
||||
- **HandKeyRotations**
|
||||
- **Type**: `TArray<FQuat>`
|
||||
- **Description**: An array of quaternions representing key rotations of the hand.
|
||||
- **Usage**: Complements the hand key locations with rotational data, ensuring accurate representation of hand movements.
|
||||
|
||||
- **HandKeyRadii**
|
||||
- **Type**: `TArray<float>`
|
||||
- **Description**: An array of floats representing the radii of key points of the hand.
|
||||
- **Usage**: Gives the size of the hand key points, aiding in collision detection and interaction fidelity.
|
||||
|
||||
### Organization of FXRHandTrackingState
|
||||
|
||||
The structure is organized to encapsulate all relevant data needed for hand-tracking in a coherent and accessible manner. Boolean flag `bValid` provides quick checks on the state of the controller data. Identifiers `DeviceName` and `ApplicationInstanceID` ensure the correct association of data. Arrays `HandKeyLocations`, `HandKeyRotations`, and `HandKeyRadii` allow detailed hand-tracking, which is critical for immersive VR experiences. Lastly, the tracking status `TrackingStatus` informs the system of the reliability of the data being processed and whether the hands are actively being tracked or they are inactive at the moment.
|
||||
|
||||
### Processing the Data for Drawing and Animating a Virtual Hand
|
||||
|
||||
In order to draw and animate a virtual hand in real-time whether the data is coming from hand-tracking or a SenseGlove device, we could consume the data from the `HandKeyLocations` and `HandKeyRotations` fields of the `FXRHandTrackingState` struct.
|
||||
|
||||
Both `HandKeyLocations` and `HandKeyRotations` contain 26 elements as defined by OpenXR's [`XR_HAND_JOINT_COUNT_EXT`](https://registry.khronos.org/OpenXR/specs/1.1/man/html/XR_HAND_JOINT_COUNT_EXT.html) and [`XrHandJointLocationsEXT`](https://registry.khronos.org/OpenXR/specs/1.0/man/html/XrHandJointLocationsEXT.html), etc.
|
||||
|
||||
Unreal Engine also provides an enum called `EHandKeypoint` naming the 26 joints, and the equivalent of `XR_HAND_JOINT_COUNT_EXT` as `EHandKeypointCount` inside `[Engine/Source/Runtime/HeadMountedDisplay/Public/HeadMountedDisplayTypes.h](https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/HeadMountedDisplay/Public/HeadMountedDisplayTypes.h)` as follows:
|
||||
|
||||
```cpp
|
||||
/**
|
||||
* Transforms that are tracked on the hand.
|
||||
* Matches the enums from WMR to make it a direct mapping
|
||||
*/
|
||||
UENUM(BlueprintType)
|
||||
enum class EHandKeypoint : uint8
|
||||
{
|
||||
Palm,
|
||||
Wrist,
|
||||
ThumbMetacarpal,
|
||||
ThumbProximal,
|
||||
ThumbDistal,
|
||||
ThumbTip,
|
||||
IndexMetacarpal,
|
||||
IndexProximal,
|
||||
IndexIntermediate,
|
||||
IndexDistal,
|
||||
IndexTip,
|
||||
MiddleMetacarpal,
|
||||
MiddleProximal,
|
||||
MiddleIntermediate,
|
||||
MiddleDistal,
|
||||
MiddleTip,
|
||||
RingMetacarpal,
|
||||
RingProximal,
|
||||
RingIntermediate,
|
||||
RingDistal,
|
||||
RingTip,
|
||||
LittleMetacarpal,
|
||||
LittleProximal,
|
||||
LittleIntermediate,
|
||||
LittleDistal,
|
||||
LittleTip
|
||||
};
|
||||
|
||||
const int32 EHandKeypointCount = static_cast<int32>(EHandKeypoint::LittleTip) + 1;
|
||||
|
||||
```
|
||||
|
||||
So, getting the any joint's location or rotation is as easy as casting the enum value and passing it as the array index.
|
||||
|
||||
```cpp
|
||||
FXRHandTrackingState HandTrackingState;
|
||||
const bool bGotHandTrackingState = FSGXRTracker::GetHandTrackingState(
|
||||
GetWorld(), EXRSpaceType::UnrealWorldSpace, EControllerHand::Left, HandTrackingState);
|
||||
|
||||
// Return if the struct data is invalid!
|
||||
if (!bGotHandTrackingState || !HandTrackingState.bValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Return if the device is not being tracked!
|
||||
if (HandTrackingState.TrackingStatus == ETrackingStatus::NotTracked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure that HandTrackingState.HandKeyLocations has the location data
|
||||
// for 26 joints!
|
||||
if (!ensureAlwaysMsgf(HandTrackingState.HandKeyLocations.Num()
|
||||
== EHandKeypointCount,
|
||||
TEXT("Invalid HandKeyLocations count!")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure that HandTrackingState.HandKeyRotations has the rotation data
|
||||
// for 26 joints!
|
||||
if (!ensureAlwaysMsgf(HandTrackingState.HandKeyRotations.Num()
|
||||
== EHandKeypointCount,
|
||||
TEXT("Invalid HandKeyRotations count!")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static constexpr int32 PalmIndex = static_cast<int32>(EHandKeypoint::Palm);
|
||||
|
||||
const FVector& PalmLocation{
|
||||
HandTrackingState.HandKeyLocations[PalmIndex]
|
||||
};
|
||||
const FRotator& PalmRotation{
|
||||
HandTrackingState.HandKeyRotations[PalmIndex].Rotator()
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
The equivalent Blueprint code for the above looks something like this:
|
||||
|
||||

|
||||
|
||||
OK, now that we've got a glimpse of how the virtual hand's joint data could be processed we are going to draw and animate a virtual hand in both [Blueprint](blueprint.md) and [C++](cpp.md) in the upcoming sections.
|
||||
@@ -0,0 +1,65 @@
|
||||
# Consuming FXRHandTrackingState in Blueprint
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Unreal Engine versions `5.2`, `5.3`, and `5.4` are limited to
|
||||
> `FXRMotionControllerData` since at the time of their release no
|
||||
> `FXRHandTrackingState` was available.
|
||||
> Also please keep in mind that, while `FXRMotionControllerData` is pretty much
|
||||
> usable and functional in Unreal Engine `5.5`, it is recommended to utilize
|
||||
> `FXRHandTrackingState` instead. This is because this version of UE has
|
||||
> deprecated `FXRMotionControllerData` in favor of the
|
||||
> `FXRMotionControllerState` and `FXRHandTrackingState` structs. Prior to
|
||||
> version `5.5`, `FXRMotionControllerData` handled both motion controller and
|
||||
> hand tracking data. From `5.5` onward, these responsibilities have been
|
||||
> separated into the two distinct structs, providing clearer and more
|
||||
> specialized handling of each.
|
||||
|
||||
Before continuing this section, please ensure you've studied the [Consuming FXRHandTrackingState](./) section, first.
|
||||
|
||||
## Drawing and Animating Virtual Hands
|
||||
|
||||
1. Create a new Virtual Reality project based [the Unreal VR Template](https://dev.epicgames.com/documentation/en-us/unreal-engine/vr-template-in-unreal-engine).
|
||||
|
||||
2. Make sure the [SenseGlove UnrealEngine plugin is installed and enabled](/getting-started/installation.md) inside your new project.
|
||||
|
||||

|
||||
|
||||
3. You could use either hand-tracking or a SenseGlove device as the input data, or both of the inside the same project. Whether you would like to use hand-tracking or a SenseGlove device, please make sure the required steps are taken for each of those first.
|
||||
|
||||
4. You could add the required Blueprint code for drawing virtual hands to either your Level Buleprint or the VRPawn Blueprint Class located at `/Content/VRTemplate/Blueprints/VRPawn`. In this guide we are going to add the code to our VRPawn.
|
||||
|
||||
5. Add a new function named `Draw Hand` with an input parameter of type `EController Hand` named `Hand`.
|
||||
|
||||

|
||||
|
||||
6. Inside this function's event graph add a `Get Hand Tracking State` node from `SenseGlove > Tracking > XR Tracker > Get Hand Tracking State`.
|
||||
|
||||

|
||||
|
||||
7. Then connect the functions `Hand` input parameter to the `Get Hand Tracking State`'s `Hand` input and right-click on the `OutHandTrackingState` parameter and use the `Break XRHandTrackingState` node to break the struct to it's fields.
|
||||
|
||||

|
||||
|
||||
8. After this, we need to perform data validation by checking the return status of the `Get Hand Tracking State` function and `FXRHandTrackingState`'s `Valid` field. Then, we check if the hand-tracking device is being tracked and indeed coming from a hand-tracking source. And, finally, we check whether we have the positions and rotations for exactly `26` joints or not.
|
||||
|
||||

|
||||
|
||||
9. OK, now it's time to draw the joints! If we check out the SenseGlove Debug module's draw option, we notice there are various ways to draw the debug virtual hand. Drawing a cube or a gizmo per joint, or draw the whole hand all at once by passing the retrieved `FXRHandTrackingState` to the `DebugVirtualHand::Draw` function! But, since the point of this tutorial is to learn how to consume the `FXRHandTrackingState` we ignore the last option. Between the debug cubes or gizmos, we are going to choose the gizmos since they better represent the rotations than the cubes.
|
||||
|
||||

|
||||
|
||||
10. In the last step inside the `Draw Hand` function, in order to draw a virtual hand with `26` joints, we have to first iterate through either of the `Hand Key Positions` or `Hand Key Rotations` arrays from the `FXRHandTrackingState` struct. Since we made sure both arrays have `26` elements before we reached this step, it's safe to just iterate over one and use the `Array Index` inside a `For Each Loop` or a `For Loop` to access the position and rotation of every joint. Then we use each array `Get (a ref)` method to access the position and rotation data inside the loop and call the `Draw` function from `SenseGlove > Debug > Gizmo` per every joint. Please note that there are two `Draw` functions and the only difference between the two is that one accepts an `FQuat` and the other a `FRotator` for its `Rotation` input parameter. In this case, we use the `FQuat` variant to avoid an extra conversion to `FRotator`. Also, please adjust the `Thickness` option for the `Settings` parameter from `1.0` to `0.2`, as the default value might be too thick for drawing a joint gizmo.
|
||||
|
||||

|
||||
|
||||
11. Well, now the full implementation for the `Draw Hand` function insde the `VRPawn` should look something like this:
|
||||
|
||||

|
||||
|
||||
12. Finally, go back to `VRPawn`'s event graph and the following code to the `Tick` event. Basically what we do here is call our newly implemented `Draw Hand` twice, once for each hand.
|
||||
|
||||

|
||||
|
||||
13. Now, go back to the `VRTemplateMap` and use the VR Preview button to run the game. If everything's done correctly, you should be able to see the virtual hands inside your VR simulation.
|
||||
|
||||

|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,259 @@
|
||||
# Consuming FXRHandTrackingState in C++
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Unreal Engine versions `5.2`, `5.3`, and `5.4` are limited to
|
||||
> `FXRMotionControllerData` since at the time of their release no
|
||||
> `FXRHandTrackingState` was available.
|
||||
> Also please keep in mind that, while `FXRMotionControllerData` is pretty much
|
||||
> usable and functional in Unreal Engine `5.5`, it is recommended to utilize
|
||||
> `FXRHandTrackingState` instead. This is because this version of UE has
|
||||
> deprecated `FXRMotionControllerData` in favor of the
|
||||
> `FXRMotionControllerState` and `FXRHandTrackingState` structs. Prior to
|
||||
> version `5.5`, `FXRMotionControllerData` handled both motion controller and
|
||||
> hand tracking data. From `5.5` onward, these responsibilities have been
|
||||
> separated into the two distinct structs, providing clearer and more
|
||||
> specialized handling of each.
|
||||
|
||||
Before continuing this section, please ensure you've first studied the [Consuming FXRHandTrackingState](./) section.
|
||||
|
||||
## Drawing and Animating Virtual Hands
|
||||
|
||||
1. Create a new Virtual Reality project based [the Unreal VR Template](https://dev.epicgames.com/documentation/en-us/unreal-engine/vr-template-in-unreal-engine).
|
||||
|
||||
2. Make sure the [SenseGlove UnrealEngine plugin is installed and enabled](/getting-started/installation.md) inside your new project.
|
||||
|
||||

|
||||
|
||||
3. You could use either hand-tracking or a SenseGlove device as the input data, or both of the inside the same project. Whether you would like to use hand-tracking or a SenseGlove device, please make sure the required steps are taken for each of those first.
|
||||
|
||||
4. From the `Tools` menu choose `New C++ class...`.
|
||||
|
||||

|
||||
|
||||
5. Choose the Unreal Engine's `APawn` class as the parent class for the new C++ pawn class.
|
||||
|
||||

|
||||
|
||||
6. Name the new pawn class `DebugPawn`.
|
||||
|
||||

|
||||
|
||||
7. Since we have created a new C++ class, this converts the current Blueprint VRTemplateMap project to a C++ one. That's why the Unreal Editor will give us a few prompts regarding opening the project in the default IDE and rebuilding the code. It might be simpler to just close the editor, then rebuild the source code inside your favorite IDE, and then start the editor with the converted project again.
|
||||
|
||||
8. Find and open the VRPawn Blueprint Class located at `/Content/VRTemplate/Blueprints/VRPawn` inside the Blueprint Editor and from the `File` menu choose the `Reparent Blueprint` class.
|
||||
|
||||

|
||||
|
||||
9. In the new `Reparent blueprint` window choose `DebugPawn` as the new parent.
|
||||
|
||||

|
||||
|
||||
10. By looking at the `Parent Class` label located under the Blueprint Editor window control buttons verify that the `ADebugPawn` class has been set as the new parent.
|
||||
|
||||

|
||||
|
||||
11. Locate the project's main Build file, in our case `VirtualHandCpp/Source/VirtualHandCpp/VirtualHandCpp.Build.cs` and add the `InputDevice`, `OpenXRHMD`, `SenseGloveBuildHacks`, `SenseGloveDebug`, `SenseGloveSettings`, and `SenseGloveTracking` modules as either a private or public dependency.
|
||||
|
||||
```csharp
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class VirtualHandCpp : ModuleRules
|
||||
{
|
||||
public VirtualHandCpp(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[]
|
||||
{
|
||||
"InputDevice",
|
||||
"OpenXRHMD",
|
||||
"SenseGloveBuildHacks",
|
||||
"SenseGloveDebug",
|
||||
"SenseGloveSettings",
|
||||
"SenseGloveTracking"
|
||||
});
|
||||
|
||||
// Uncomment if you are using Slate UI
|
||||
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
||||
|
||||
// Uncomment if you are using online features
|
||||
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
|
||||
|
||||
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
12. Locate the C++ header and source file for the `ADebugPawn` inside the project in your C++ IDE. In our case they are located at `VirtualHandCpp/Source/VirtualHandCpp/DebugPawn.h` and `VirtualHandCpp/Source/VirtualHandCpp/DebugPawn.cpp`.
|
||||
|
||||
13. Modify the `DebugPawn.h` header file to look like this:
|
||||
|
||||
```cpp
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Pawn.h"
|
||||
|
||||
#include "SGSettings/SGDebugGizmoSettings.h"
|
||||
|
||||
#include "DebugPawn.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class VIRTUALHANDCPP_API ADebugPawn : public APawn
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
// The virtual hand drawing settings.
|
||||
UPROPERTY(EditDefaultsOnly, Category="DebugPawn",
|
||||
meta=(AllowPrivateAccess="false"))
|
||||
FSGDebugGizmoSettings HandDrawingSettings;
|
||||
|
||||
public:
|
||||
// Sets default values for this pawn's properties
|
||||
ADebugPawn();
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
private:
|
||||
// The method responsible for drawing a virtual hand.
|
||||
void DrawHand(EControllerHand Hand) const;
|
||||
};
|
||||
```
|
||||
|
||||
14. Modify the `DebugPawn.cpp` implementation file to look like this:
|
||||
|
||||
|
||||
```cpp
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "DebugPawn.h"
|
||||
|
||||
#include "SGDebug/SGDebugGizmo.h"
|
||||
#include "SGTracking/SGXRTracker.h"
|
||||
|
||||
// Sets default values
|
||||
ADebugPawn::ADebugPawn()
|
||||
{
|
||||
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
// Set the default virtual hand drawing settings.
|
||||
HandDrawingSettings = FSGDebugGizmoSettings{
|
||||
1.0f,
|
||||
FColor{255, 0, 0, 255},
|
||||
FColor{0, 255, 0, 255},
|
||||
FColor{0, 0, 255, 255},
|
||||
false,
|
||||
1.1f,
|
||||
0,
|
||||
0.2f,
|
||||
};
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void ADebugPawn::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void ADebugPawn::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
// Attempt at drawing the left/right virtual hands every frame.
|
||||
DrawHand(EControllerHand::Left);
|
||||
DrawHand(EControllerHand::Right);
|
||||
}
|
||||
|
||||
// Called to bind functionality to input
|
||||
void ADebugPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
||||
{
|
||||
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
||||
}
|
||||
|
||||
void ADebugPawn::DrawHand(const EControllerHand Hand) const
|
||||
{
|
||||
// Get the world and cache it, if it's null we return early.
|
||||
UWorld* World{GetWorld()};
|
||||
if (!IsValid(World))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FXRHandTrackingState HandTrackingState;
|
||||
const bool bGotHandTrackingState = FSGXRTracker::GetHandTrackingState(
|
||||
World, EXRSpaceType::UnrealWorldSpace, Hand, HandTrackingState);
|
||||
|
||||
// Return if the struct data is invalid!
|
||||
if (!bGotHandTrackingState || !HandTrackingState.bValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Return if the device is not being tracked!
|
||||
if (HandTrackingState.TrackingStatus == ETrackingStatus::NotTracked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure that HandTrackingState.HandKeyLocations has the location data
|
||||
// for 26 joints!
|
||||
if (!ensureAlwaysMsgf(HandTrackingState.HandKeyLocations.Num()
|
||||
== EHandKeypointCount,
|
||||
TEXT("Invalid HandKeyLocations count!")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure that HandTrackingState.HandKeyRotations has the rotation data
|
||||
// for 26 joints!
|
||||
if (!ensureAlwaysMsgf(HandTrackingState.HandKeyRotations.Num()
|
||||
== EHandKeypointCount,
|
||||
TEXT("Invalid HandKeyRotations count!")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Iterate over the hand joint locations and rotations!
|
||||
for (int32 JointIndex = 0; JointIndex < EHandKeypointCount; ++JointIndex)
|
||||
{
|
||||
const FVector& JointLocation{
|
||||
HandTrackingState.HandKeyLocations[JointIndex]
|
||||
};
|
||||
const FQuat& JointRotation{
|
||||
HandTrackingState.HandKeyRotations[JointIndex]
|
||||
};
|
||||
|
||||
// Draw a single joint's gizmo!
|
||||
// Please note that we could alternatively:
|
||||
// Use FSGDebugCube::Draw() to draw a cube.
|
||||
// Or use the FSGDebugVirtualHand::Draw() method and pass the
|
||||
// HandTrackingState directly to draw the virtual hand
|
||||
// all at once without iterating the joints. But, that's not
|
||||
// goal of this tutorial.
|
||||
FSGDebugGizmo::Draw(World, JointLocation, JointRotation, HandDrawingSettings);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
15. Now, rebuild the source code and go back to the `VRTemplateMap`, then use the VR Preview button to run the game. If everything's done correctly, you should be able to see the virtual hands inside your VR simulation.
|
||||
|
||||

|
||||
BIN
Binary file not shown.
@@ -1,61 +1,75 @@
|
||||
# Consuming FXRMotionControllerData
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Unreal Engine versions `5.2`, `5.3`, and `5.4` are limited to
|
||||
> `FXRMotionControllerData` since at the time of their release no
|
||||
> `FXRHandTrackingState` was available.
|
||||
> Also please keep in mind that, while `FXRMotionControllerData` is pretty much
|
||||
> usable and functional in Unreal Engine `5.5`, it is recommended to utilize
|
||||
> `FXRHandTrackingState` instead. This is because this version of UE has
|
||||
> deprecated `FXRMotionControllerData` in favor of the
|
||||
> `FXRMotionControllerState` and `FXRHandTrackingState` structs. Prior to
|
||||
> version `5.5`, `FXRMotionControllerData` handled both motion controller and
|
||||
> hand tracking data. From `5.5` onward, these responsibilities have been
|
||||
> separated into the two distinct structs, providing clearer and more
|
||||
> specialized handling of each.
|
||||
|
||||
Taking a closer look at the `FXRMotionControllerData` declaration inside the Unreal Engine's `HeadMountedDisplay` module at `[Engine/Source/Runtime/HeadMountedDisplay/Public/HeadMountedDisplayTypes.h](https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/HeadMountedDisplay/Public/HeadMountedDisplayTypes.h)`, figuring out the data structure might not seem very straightforward:
|
||||
|
||||
```cpp
|
||||
USTRUCT(BlueprintType)
|
||||
struct FXRMotionControllerData
|
||||
{
|
||||
GENERATED_USTRUCT_BODY();
|
||||
GENERATED_USTRUCT_BODY();
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
bool bValid = false;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FName DeviceName;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FGuid ApplicationInstanceID;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
EXRVisualType DeviceVisualType = EXRVisualType::Controller;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
bool bValid = false;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FName DeviceName;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FGuid ApplicationInstanceID;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
EXRVisualType DeviceVisualType = EXRVisualType::Controller;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
EControllerHand HandIndex = EControllerHand::Left;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
EControllerHand HandIndex = EControllerHand::Left;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
ETrackingStatus TrackingStatus = ETrackingStatus::NotTracked;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
ETrackingStatus TrackingStatus = ETrackingStatus::NotTracked;
|
||||
|
||||
// Vector representing an object being held in the player's hand
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FVector GripPosition = FVector(0.0f);
|
||||
// Quaternion representing an object being held in the player's hand
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FQuat GripRotation = FQuat(EForceInit::ForceInitToZero);
|
||||
// Vector representing an object being held in the player's hand
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FVector GripPosition = FVector(0.0f);
|
||||
// Quaternion representing an object being held in the player's hand
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FQuat GripRotation = FQuat(EForceInit::ForceInitToZero);
|
||||
|
||||
// For handheld controllers, gives a vector for pointing at objects
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FVector AimPosition = FVector(0.0f);
|
||||
// For handheld controllers, gives a quaternion for pointing at objects
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FQuat AimRotation = FQuat(EForceInit::ForceInitToZero);
|
||||
// For handheld controllers, gives a vector for pointing at objects
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FVector AimPosition = FVector(0.0f);
|
||||
// For handheld controllers, gives a quaternion for pointing at objects
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FQuat AimRotation = FQuat(EForceInit::ForceInitToZero);
|
||||
|
||||
// For handheld controllers, gives a vector for representing the hand
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FVector PalmPosition = FVector(0.0f);
|
||||
// For handheld controllers, gives a quaternion for representing the hand
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FQuat PalmRotation = FQuat(EForceInit::ForceInitToZero);
|
||||
// For handheld controllers, gives a vector for representing the hand
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FVector PalmPosition = FVector(0.0f);
|
||||
// For handheld controllers, gives a quaternion for representing the hand
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
FQuat PalmRotation = FQuat(EForceInit::ForceInitToZero);
|
||||
|
||||
// The indices of this array are the values of EHandKeypoint (Palm, Wrist, ThumbMetacarpal, etc).
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
TArray<FVector> HandKeyPositions;
|
||||
// The indices of this array are the values of EHandKeypoint (Palm, Wrist, ThumbMetacarpal, etc).
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
TArray<FQuat> HandKeyRotations;
|
||||
// The indices of this array are the values of EHandKeypoint (Palm, Wrist, ThumbMetacarpal, etc).
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
TArray<float> HandKeyRadii;
|
||||
// The indices of this array are the values of EHandKeypoint (Palm, Wrist, ThumbMetacarpal, etc).
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
TArray<FVector> HandKeyPositions;
|
||||
// The indices of this array are the values of EHandKeypoint (Palm, Wrist, ThumbMetacarpal, etc).
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
TArray<FQuat> HandKeyRotations;
|
||||
// The indices of this array are the values of EHandKeypoint (Palm, Wrist, ThumbMetacarpal, etc).
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
TArray<float> HandKeyRadii;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
bool bIsGrasped = false;
|
||||
UPROPERTY(BlueprintReadOnly, Category = "XR")
|
||||
bool bIsGrasped = false;
|
||||
};
|
||||
```
|
||||
|
||||
@@ -71,68 +85,88 @@ But, fear not, we've got you covered!
|
||||
|
||||
### Structure Members of FXRMotionControllerData
|
||||
|
||||
1. **bValid**
|
||||
- **bValid**
|
||||
- **Description**: A boolean flag indicating whether the data is valid or not.
|
||||
- **Usage**: This is used to check if the motion controller data is correctly initialized and can be used for further processing.
|
||||
|
||||
2. **DeviceName**
|
||||
- **DeviceName**
|
||||
- **Type**: `FName`
|
||||
- **Description**: The name of the device.
|
||||
- **Usage**: Identifies which motion controller device the data is coming from, useful when multiple devices are in use.
|
||||
|
||||
3. **ApplicationInstanceID**
|
||||
- **ApplicationInstanceID**
|
||||
- **Type**: `FString`
|
||||
- **Description**: A unique identifier for the application instance.
|
||||
- **Usage**: Helps in differentiating data from different instances of an application, ensuring the correct instance processes the data.
|
||||
|
||||
4. **TrackingStatus**
|
||||
- **DeviceVisualType**
|
||||
- **Type**: `EXRVisualType`
|
||||
- **Description**: Enum specifying the visual type of the device (e.g., controller, hand).
|
||||
- **Usage**: Used to differentiate between various motion controller devices or hand-tracking representations for rendering and interaction purposes.
|
||||
|
||||
- **HandIndex**
|
||||
- **Type**: `EControllerHand`
|
||||
- **Description**: Enum indicating which hand is being tracked (left or right).
|
||||
- **Usage**: Helps identify whether the motion data pertains to the left or right hand, essential for hand-specific actions or interactions.
|
||||
|
||||
- **TrackingStatus**
|
||||
- **Type**: `EXRTrackingStatus`
|
||||
- **Description**: Enum indicating the tracking status of the motion controller.
|
||||
- **Usage**: Shows whether the controller is being tracked accurately, with possible statuses like `Tracked`, `NotTracked`, etc.
|
||||
|
||||
5. **GripPosition**
|
||||
- **GripPosition**
|
||||
- **Type**: `FVector`
|
||||
- **Description**: The position of the grip in world coordinates.
|
||||
- **Usage**: Provides the 3D coordinates of the controller's grip, essential for positioning the virtual representation of the controller.
|
||||
|
||||
6. **GripRotation**
|
||||
- **GripRotation**
|
||||
- **Type**: `FQuat`
|
||||
- **Description**: The rotation of the grip in world coordinates.
|
||||
- **Usage**: Provides the orientation of the controller's grip, allowing for accurate rotation and alignment in the virtual space.
|
||||
|
||||
7. **AimPosition**
|
||||
- **AimPosition**
|
||||
- **Type**: `FVector`
|
||||
- **Description**: The position of the aim point in world coordinates.
|
||||
- **Usage**: Specifies where the controller is aiming, useful for aiming or pointing actions.
|
||||
|
||||
8. **AimRotation**
|
||||
- **AimRotation**
|
||||
- **Type**: `FQuat`
|
||||
- **Description**: The rotation of the aim point in world coordinates.
|
||||
- **Usage**: Determines the orientation of the aim direction, important for actions like shooting or selecting objects in VR.
|
||||
|
||||
9. **HandKeyPositions**
|
||||
- **PalmPosition**
|
||||
- **Type**: `FVector`
|
||||
- **Description**: The position of the palm in world coordinates.
|
||||
- **Usage**: Provides the 3D location of the palm, important for determining hand gestures or interactions in VR.
|
||||
|
||||
- **PalmRotation**
|
||||
- **Type**: `FQuat`
|
||||
- **Description**: The rotation of the palm in world coordinates.
|
||||
- **Usage**: Defines the orientation of the palm, crucial for hand-based interaction accuracy and realism in VR experiences.
|
||||
|
||||
- **HandKeyPositions**
|
||||
- **Type**: `TArray<FVector>`
|
||||
- **Description**: An array of vectors representing key positions of the hand.
|
||||
- **Usage**: Provides detailed positions of key points on the hand, useful for precise hand tracking and interaction.
|
||||
|
||||
10. **HandKeyRotations**
|
||||
- **HandKeyRotations**
|
||||
- **Type**: `TArray<FQuat>`
|
||||
- **Description**: An array of quaternions representing key rotations of the hand.
|
||||
- **Usage**: Complements the hand key positions with rotational data, ensuring accurate representation of hand movements.
|
||||
|
||||
11. **HandKeyRadii**
|
||||
- **HandKeyRadii**
|
||||
- **Type**: `TArray<float>`
|
||||
- **Description**: An array of floats representing the radii of key points of the hand.
|
||||
- **Usage**: Gives the size of the hand key points, aiding in collision detection and interaction fidelity.
|
||||
|
||||
12. **bIsGrasped**
|
||||
- **bIsGrasped**
|
||||
- **Type**: `bool`
|
||||
- **Description**: A boolean indicating whether the controller is currently grasping an object.
|
||||
- **Usage**: Determines if the user is holding something, affecting interactions and animations.
|
||||
|
||||
### Organization of FXRMotionControllerData
|
||||
|
||||
The structure is organized to encapsulate all relevant data needed for motion controller tracking in a coherent and accessible manner. Boolean flags `bValid` and `bIsGrasped` provide quick checks on the state of the controller data. Identifiers `DeviceName` and `ApplicationInstanceID` ensure the correct association of data. Positional and rotational data `GripPosition`, `GripRotation`, `AimPosition`, and `AimRotation` offer precise tracking of the controller's movement. Arrays `HandKeyPositions`, `HandKeyRotations`, and `HandKeyRadii` allow detailed hand tracking, which is critical for immersive VR experiences. Lastly, the tracking status `TrackingStatus` informs the system of the reliability of the data being processed and whether the motion controller is actively being tracked or it's inactive at the moment.
|
||||
The structure is organized to encapsulate all relevant data needed for hand and motion controller tracking in a coherent and accessible manner. Boolean flags `bValid` and `bIsGrasped` provide quick checks on the state of the controller data. Identifiers `DeviceName` and `ApplicationInstanceID` ensure the correct association of data. Positional and rotational data `GripPosition`, `GripRotation`, `AimPosition`, and `AimRotation` offer precise tracking of the controller's movement. Arrays `HandKeyPositions`, `HandKeyRotations`, and `HandKeyRadii` allow detailed hand tracking, which is critical for immersive VR experiences. Lastly, the tracking status `TrackingStatus` informs the system of the reliability of the data being processed and whether the motion controller is actively being tracked or it's inactive at the moment.
|
||||
|
||||
### Processing the Data for Drawing and Animating a Virtual Hand
|
||||
|
||||
@@ -150,32 +184,32 @@ Unreal Engine also provides an enum called `EHandKeypoint` naming the 26 joints,
|
||||
UENUM(BlueprintType)
|
||||
enum class EHandKeypoint : uint8
|
||||
{
|
||||
Palm,
|
||||
Wrist,
|
||||
ThumbMetacarpal,
|
||||
ThumbProximal,
|
||||
ThumbDistal,
|
||||
ThumbTip,
|
||||
IndexMetacarpal,
|
||||
IndexProximal,
|
||||
IndexIntermediate,
|
||||
IndexDistal,
|
||||
IndexTip,
|
||||
MiddleMetacarpal,
|
||||
MiddleProximal,
|
||||
MiddleIntermediate,
|
||||
MiddleDistal,
|
||||
MiddleTip,
|
||||
RingMetacarpal,
|
||||
RingProximal,
|
||||
RingIntermediate,
|
||||
RingDistal,
|
||||
RingTip,
|
||||
LittleMetacarpal,
|
||||
LittleProximal,
|
||||
LittleIntermediate,
|
||||
LittleDistal,
|
||||
LittleTip
|
||||
Palm,
|
||||
Wrist,
|
||||
ThumbMetacarpal,
|
||||
ThumbProximal,
|
||||
ThumbDistal,
|
||||
ThumbTip,
|
||||
IndexMetacarpal,
|
||||
IndexProximal,
|
||||
IndexIntermediate,
|
||||
IndexDistal,
|
||||
IndexTip,
|
||||
MiddleMetacarpal,
|
||||
MiddleProximal,
|
||||
MiddleIntermediate,
|
||||
MiddleDistal,
|
||||
MiddleTip,
|
||||
RingMetacarpal,
|
||||
RingProximal,
|
||||
RingIntermediate,
|
||||
RingDistal,
|
||||
RingTip,
|
||||
LittleMetacarpal,
|
||||
LittleProximal,
|
||||
LittleIntermediate,
|
||||
LittleDistal,
|
||||
LittleTip
|
||||
};
|
||||
|
||||
const int32 EHandKeypointCount = static_cast<int32>(EHandKeypoint::LittleTip) + 1;
|
||||
@@ -217,7 +251,7 @@ So, getting the any joint's position or rotation is as easy as casting the enum
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure that MotionControllerData.HandKeyPositions has the rotation data
|
||||
// Ensure that MotionControllerData.HandKeyRotations has the rotation data
|
||||
// for 26 joints!
|
||||
if (!ensureAlwaysMsgf(MotionControllerData.HandKeyRotations.Num()
|
||||
== EHandKeypointCount,
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# Consuming FXRMotionControllerData in Blueprint
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Unreal Engine versions `5.2`, `5.3`, and `5.4` are limited to
|
||||
> `FXRMotionControllerData` since at the time of their release no
|
||||
> `FXRHandTrackingState` was available.
|
||||
> Also please keep in mind that, while `FXRMotionControllerData` is pretty much
|
||||
> usable and functional in Unreal Engine `5.5`, it is recommended to utilize
|
||||
> `FXRHandTrackingState` instead. This is because this version of UE has
|
||||
> deprecated `FXRMotionControllerData` in favor of the
|
||||
> `FXRMotionControllerState` and `FXRHandTrackingState` structs. Prior to
|
||||
> version `5.5`, `FXRMotionControllerData` handled both motion controller and
|
||||
> hand tracking data. From `5.5` onward, these responsibilities have been
|
||||
> separated into the two distinct structs, providing clearer and more
|
||||
> specialized handling of each.
|
||||
|
||||
Before continuing this section, please ensure you've studied the [Consuming FXRMotionControllerData](./) section, first.
|
||||
|
||||
## Drawing and Animating Virtual Hands
|
||||
@@ -48,4 +62,4 @@ Before continuing this section, please ensure you've studied the [Consuming FXRM
|
||||
|
||||
13. Now, go back to the `VRTemplateMap` and use the VR Preview button to run the game. If everything's done correctly, you should be able to see the virtual hands inside your VR simulation.
|
||||
|
||||

|
||||

|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# Consuming FXRMotionControllerData in C++
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Unreal Engine versions `5.2`, `5.3`, and `5.4` are limited to
|
||||
> `FXRMotionControllerData` since at the time of their release no
|
||||
> `FXRHandTrackingState` was available.
|
||||
> Also please keep in mind that, while `FXRMotionControllerData` is pretty much
|
||||
> usable and functional in Unreal Engine `5.5`, it is recommended to utilize
|
||||
> `FXRHandTrackingState` instead. This is because this version of UE has
|
||||
> deprecated `FXRMotionControllerData` in favor of the
|
||||
> `FXRMotionControllerState` and `FXRHandTrackingState` structs. Prior to
|
||||
> version `5.5`, `FXRMotionControllerData` handled both motion controller and
|
||||
> hand tracking data. From `5.5` onward, these responsibilities have been
|
||||
> separated into the two distinct structs, providing clearer and more
|
||||
> specialized handling of each.
|
||||
|
||||
Before continuing this section, please ensure you've first studied the [Consuming FXRMotionControllerData](./) section.
|
||||
|
||||
## Drawing and Animating Virtual Hands
|
||||
@@ -47,30 +61,30 @@ using UnrealBuildTool;
|
||||
|
||||
public class VirtualHandCpp : ModuleRules
|
||||
{
|
||||
public VirtualHandCpp(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
public VirtualHandCpp(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[]
|
||||
{
|
||||
"InputDevice",
|
||||
"OpenXRHMD",
|
||||
"SenseGloveBuildHacks",
|
||||
"SenseGloveDebug",
|
||||
"SenseGloveSettings",
|
||||
"SenseGloveTracking"
|
||||
});
|
||||
PrivateDependencyModuleNames.AddRange(new string[]
|
||||
{
|
||||
"InputDevice",
|
||||
"OpenXRHMD",
|
||||
"SenseGloveBuildHacks",
|
||||
"SenseGloveDebug",
|
||||
"SenseGloveSettings",
|
||||
"SenseGloveTracking"
|
||||
});
|
||||
|
||||
// Uncomment if you are using Slate UI
|
||||
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
||||
// Uncomment if you are using Slate UI
|
||||
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
||||
|
||||
// Uncomment if you are using online features
|
||||
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
|
||||
// Uncomment if you are using online features
|
||||
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
|
||||
|
||||
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
|
||||
}
|
||||
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -93,32 +107,32 @@ public class VirtualHandCpp : ModuleRules
|
||||
UCLASS()
|
||||
class VIRTUALHANDCPP_API ADebugPawn : public APawn
|
||||
{
|
||||
GENERATED_BODY()
|
||||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
// The virtual hand drawing settings.
|
||||
UPROPERTY(EditDefaultsOnly, Category="DebugPawn",
|
||||
meta=(AllowPrivateAccess="false"))
|
||||
FSGDebugGizmoSettings HandDrawingSettings;
|
||||
// The virtual hand drawing settings.
|
||||
UPROPERTY(EditDefaultsOnly, Category="DebugPawn",
|
||||
meta=(AllowPrivateAccess="false"))
|
||||
FSGDebugGizmoSettings HandDrawingSettings;
|
||||
|
||||
public:
|
||||
// Sets default values for this pawn's properties
|
||||
ADebugPawn();
|
||||
// Sets default values for this pawn's properties
|
||||
ADebugPawn();
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
private:
|
||||
// The method responsible for drawing a virtual hand.
|
||||
void DrawHand(EControllerHand Hand) const;
|
||||
// The method responsible for drawing a virtual hand.
|
||||
void DrawHand(EControllerHand Hand) const;
|
||||
};
|
||||
```
|
||||
|
||||
@@ -137,116 +151,116 @@ private:
|
||||
// Sets default values
|
||||
ADebugPawn::ADebugPawn()
|
||||
{
|
||||
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
// Set the default virtual hand drawing settings.
|
||||
HandDrawingSettings = FSGDebugGizmoSettings{
|
||||
1.0f,
|
||||
FColor{255, 0, 0, 255},
|
||||
FColor{0, 255, 0, 255},
|
||||
FColor{0, 0, 255, 255},
|
||||
false,
|
||||
1.1f,
|
||||
0,
|
||||
0.2f,
|
||||
};
|
||||
// Set the default virtual hand drawing settings.
|
||||
HandDrawingSettings = FSGDebugGizmoSettings{
|
||||
1.0f,
|
||||
FColor{255, 0, 0, 255},
|
||||
FColor{0, 255, 0, 255},
|
||||
FColor{0, 0, 255, 255},
|
||||
false,
|
||||
1.1f,
|
||||
0,
|
||||
0.2f,
|
||||
};
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void ADebugPawn::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
Super::BeginPlay();
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void ADebugPawn::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
// Attempt at drawing the left/right virtual hands every frame.
|
||||
DrawHand(EControllerHand::Left);
|
||||
DrawHand(EControllerHand::Right);
|
||||
// Attempt at drawing the left/right virtual hands every frame.
|
||||
DrawHand(EControllerHand::Left);
|
||||
DrawHand(EControllerHand::Right);
|
||||
}
|
||||
|
||||
// Called to bind functionality to input
|
||||
void ADebugPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
||||
{
|
||||
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
||||
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
||||
}
|
||||
|
||||
void ADebugPawn::DrawHand(const EControllerHand Hand) const
|
||||
{
|
||||
// Get the world and cache it, if it's null we return early.
|
||||
UWorld* World{GetWorld()};
|
||||
if (!IsValid(World))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Get the world and cache it, if it's null we return early.
|
||||
UWorld* World{GetWorld()};
|
||||
if (!IsValid(World))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FXRMotionControllerData MotionControllerData;
|
||||
const bool bGotMotionControllerData = FSGXRTracker::GetMotionControllerData(
|
||||
World, Hand, MotionControllerData);
|
||||
FXRMotionControllerData MotionControllerData;
|
||||
const bool bGotMotionControllerData = FSGXRTracker::GetMotionControllerData(
|
||||
World, Hand, MotionControllerData);
|
||||
|
||||
// Return if the struct data is invalid!
|
||||
if (!bGotMotionControllerData || !MotionControllerData.bValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Return if the struct data is invalid!
|
||||
if (!bGotMotionControllerData || !MotionControllerData.bValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Return if the device is not being tracked!
|
||||
if (MotionControllerData.TrackingStatus == ETrackingStatus::NotTracked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Return if the device is not being tracked!
|
||||
if (MotionControllerData.TrackingStatus == ETrackingStatus::NotTracked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure that MotionControllerData.DeviceVisualType is a hand!
|
||||
if (!ensureAlwaysMsgf(MotionControllerData.DeviceVisualType
|
||||
== EXRVisualType::Hand,
|
||||
TEXT("Invalid DeviceVisualType type!")))
|
||||
{
|
||||
}
|
||||
// Ensure that MotionControllerData.DeviceVisualType is a hand!
|
||||
if (!ensureAlwaysMsgf(MotionControllerData.DeviceVisualType
|
||||
== EXRVisualType::Hand,
|
||||
TEXT("Invalid DeviceVisualType type!")))
|
||||
{
|
||||
}
|
||||
|
||||
// Ensure that MotionControllerData.HandKeyPositions has the position data
|
||||
// for 26 joints!
|
||||
if (!ensureAlwaysMsgf(MotionControllerData.HandKeyPositions.Num()
|
||||
== EHandKeypointCount,
|
||||
TEXT("Invalid HandKeyPositions count!")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Ensure that MotionControllerData.HandKeyPositions has the position data
|
||||
// for 26 joints!
|
||||
if (!ensureAlwaysMsgf(MotionControllerData.HandKeyPositions.Num()
|
||||
== EHandKeypointCount,
|
||||
TEXT("Invalid HandKeyPositions count!")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure that MotionControllerData.HandKeyPositions has the rotation data
|
||||
// for 26 joints!
|
||||
if (!ensureAlwaysMsgf(MotionControllerData.HandKeyRotations.Num()
|
||||
== EHandKeypointCount,
|
||||
TEXT("Invalid HandKeyRotations count!")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Ensure that MotionControllerData.HandKeyRotations has the rotation data
|
||||
// for 26 joints!
|
||||
if (!ensureAlwaysMsgf(MotionControllerData.HandKeyRotations.Num()
|
||||
== EHandKeypointCount,
|
||||
TEXT("Invalid HandKeyRotations count!")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Iterate over the hand joint positions and rotations!
|
||||
for (int32 JointIndex = 0; JointIndex < EHandKeypointCount; ++JointIndex)
|
||||
{
|
||||
const FVector& JointPosition{
|
||||
MotionControllerData.HandKeyPositions[JointIndex]
|
||||
};
|
||||
const FQuat& JointRotation{
|
||||
MotionControllerData.HandKeyRotations[JointIndex]
|
||||
};
|
||||
// Iterate over the hand joint positions and rotations!
|
||||
for (int32 JointIndex = 0; JointIndex < EHandKeypointCount; ++JointIndex)
|
||||
{
|
||||
const FVector& JointPosition{
|
||||
MotionControllerData.HandKeyPositions[JointIndex]
|
||||
};
|
||||
const FQuat& JointRotation{
|
||||
MotionControllerData.HandKeyRotations[JointIndex]
|
||||
};
|
||||
|
||||
// Draw a single joint's gizmo!
|
||||
// Please note that we could alternatively:
|
||||
// Use FSGDebugCube::Draw() to draw a cube.
|
||||
// Or use the FSGDebugVirtualHand::Draw() method and pass the
|
||||
// MotionControllerData directly to draw the virtual hand
|
||||
// all at once without iterating the joints. But, that's not
|
||||
// goal of this tutorial.
|
||||
FSGDebugGizmo::Draw(World, JointPosition, JointRotation, HandDrawingSettings);
|
||||
}
|
||||
// Draw a single joint's gizmo!
|
||||
// Please note that we could alternatively:
|
||||
// Use FSGDebugCube::Draw() to draw a cube.
|
||||
// Or use the FSGDebugVirtualHand::Draw() method and pass the
|
||||
// MotionControllerData directly to draw the virtual hand
|
||||
// all at once without iterating the joints. But, that's not
|
||||
// goal of this tutorial.
|
||||
FSGDebugGizmo::Draw(World, JointPosition, JointRotation, HandDrawingSettings);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
15. Now, rebuild the source code and go back to the `VRTemplateMap`, then use the VR Preview button to run the game. If everything's done correctly, you should be able to see the virtual hands inside your VR simulation.
|
||||
|
||||

|
||||

|
||||
|
||||
@@ -5,6 +5,104 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [2.3.0] - 2024-11-13
|
||||
|
||||
This minor release includes some improvements and adds official Unreal Engine `5.5` Fab support.
|
||||
|
||||
### Added
|
||||
|
||||
- Added `USGAndroidPermissions` to the `SenseGloveAndroid` module, enhancing the plugin's permission request process on Android. Now, a pop-up prompts the user to grant permissions, preventing silent crashes when permissions haven't been granted beforehand.
|
||||
- Added Unreal Engine `5.5` Fab support.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix UE `5.5` deprecation warnings inside `USGVirtualHandComponent`.
|
||||
- Additional minor fixes and improvements that may not be listed here.
|
||||
|
||||
## [2.2.2] - 2024-11-08
|
||||
|
||||
This patch release addresses a few issues with both glove and hand-tracking.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed a chain of critical bugs that gets triggered due to `GloveConnectivityCheckInterval` getting passed as seconds to the engine rather than milliseconds. Thus, the default or any large value for `GloveConnectivityCheckInterval` causes noticeable long delays between glove-connectivity-check intervals and consequently renders the hand-tracking state invalid in certain situations when the `bFallbackToHandTrackingIfNoGloveDetected` option is false.
|
||||
|
||||
## [2.2.1] - 2024-10-23
|
||||
|
||||
This patch release focuses exclusively on updates to the documentation.
|
||||
|
||||
### Documentation
|
||||
|
||||
- Updated all URLs, screenshots, and tutorials to reflect the transition from the Unreal Engine Marketplace to Fab, Epic’s new unified content marketplace.
|
||||
- Revised documentation now points to the new home of the SenseGlove Unreal Engine Plugin on Fab, ensuring users have access to the latest resources and information.
|
||||
|
||||
## [2.2.0] - 2024-10-22
|
||||
|
||||
This is a minor release with some breaking API and ABI changes, focusing mainly on migrating away from the deprecated `FXRMotionControllerData` in favor of `FXRMotionControllerState` and `FXRHandTrackingState` on Unreal Engine `5.5+`.
|
||||
|
||||
### Added
|
||||
|
||||
- Completed support for the upcoming Unreal Engine `5.5` release.
|
||||
- Added `USGVirtualHandComponent::GetMotionControllerState()` and the equivalent Blueprint function`UVirtualHandComponentKismetLibrary::GetMotionControllerState` on UE `5.5+`.
|
||||
- Added `USGVirtualHandComponent::GetHandTrackingState()` and the equivalent Blueprint function `UVirtualHandComponentKismetLibrary::GetHandTrackingState` on UE `5.5+`.
|
||||
- Added `USGWristTrackerComponent::GetMotionControllerState()` and the equivalent Blueprint function `UWristTrackerComponentKismetLibrary::GetMotionControllerState` on UE `5.5+`.
|
||||
- Added `USGWristTrackerComponent::GetHandTrackingState()` and the equivalent Blueprint function `UWristTrackerComponentKismetLibrary::GetHandTrackingState` on UE `5.5+`.
|
||||
- Added a variant of `FSGDebugVirtualHand::Draw()` and the equivalent Blueprint function `USGDebugVirtualHandKismetLibrary::Draw_FXRHandTrackingState()` which accept `FXRHandTrackingState` on UE `5.5+`.
|
||||
- Added the new member `bTracked` to the `FSGXRHandState` struct.
|
||||
- Added `FSGXRTracker::GetMotionControllerState()` and the equivalent Blueprint function `USGXRTrackerKismetLibrary::GetMotionControllerState()`.
|
||||
- Added `FSGXRTracker::GetHandTrackingState()` and the equivalent Blueprint function `USGXRTrackerKismetLibrary::GetHandTrackingState()`.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Additional minor fixes and improvements that may not be listed here.
|
||||
|
||||
### Changed
|
||||
|
||||
- Replaced all internal usages of the `FXRMotionControllerData` struct with either `FXRMotionControllerState` or `FXRHandTrackingState` on UE `5.5+`.
|
||||
- Deprecated `USGVirtualHandComponent::GetMotionControllerData()` on UE `5.5+`.
|
||||
- Deprecated `USGWristTrackerComponent::GetMotionControllerData()` on UE `5.5+`.
|
||||
- Deprecated the variant of `FSGDebugVirtualHand::Draw()` which accepts `FXRMotionControllerData` as a parameter on UE `5.5+`.
|
||||
- Renamed `USGDebugVirtualHandKismetLibrary::Draw` to `USGDebugVirtualHandKismetLibrary::Draw_FXRMotionControllerData` for more clarification.
|
||||
- Renamed an `FSGXRHandState` member from `bReceivedJointPoses` to `bHasReceivedJointPoses`.
|
||||
- Changed the `FSGXRTracker::GetAllKeypointStates()` signature on UE `5.5+` to match the `IHandTracker` interface API changes.
|
||||
- The animation system on UE `5.5+` has been revamped to utilize `FXRHandTrackingState` instead of `FXRMotionControllerData`.
|
||||
- The wrist tracking system on UE `5.5+` has been revamped to utilize `FXRHandTrackingState` instead of `FXRMotionControllerData`.
|
||||
- The hand interaction manipulation on UE `5.5+` has been revamped to utilize `FXRHandTrackingState`.
|
||||
- The virtual hand debugging system on UE `5.5+` has been revamped to utilize `FXRHandTrackingState`.
|
||||
|
||||
### Documentation
|
||||
|
||||
- Added the documentation on consuming the `FXRHandTrackingState` struct in both Blueprint and C++.
|
||||
- Updated the documentation on consuming the `FXRMotionControllerData` struct.
|
||||
- Additional minor documentation fixes and improvements that may not be listed here.
|
||||
|
||||
## [2.1.4] - 2024-10-22
|
||||
|
||||
This is a bugfix release that delivers some documentation fixes.
|
||||
|
||||
### Documentation
|
||||
|
||||
- Updated the documentation on consuming the `FXRMotionControllerData` struct.
|
||||
- Additional minor documentation fixes and improvements that may not be listed here.
|
||||
|
||||
## [2.1.3] - 2024-10-11
|
||||
|
||||
This bugfix release centers on adding initial support for the upcoming Unreal Engine `5.5`.
|
||||
|
||||
### Added
|
||||
|
||||
- Added initial support for the upcoming Unreal Engine `5.5` release. Please note that, while the plugin is functional, a few adjustments are still required to address deprecation warnings. Specifically, the `FXRMotionControllerData` struct needs to be replaced with the newly introduced `FXRMotionControllerState` and `FXRHandTrackingState` structs, along with adjustments to adhere to the new hand-tracking API changes.
|
||||
- Added support for Epic Native Toolchain `v23`.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix a bug inside `USGVirtualHandComponent::PostEditChangeProperty()` where the get member name check happens against the wrong class and member names.
|
||||
- Additional minor fixes and improvements that may not be listed here.
|
||||
|
||||
### Changed
|
||||
|
||||
- The SenseGlove libraries have been updated to `v2.105.0-02a2e508`.
|
||||
|
||||
## [2.1.2] - 2024-09-02
|
||||
|
||||
This is a bugfix release that addresses a few non-critical issues and documentation fixes.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
│
|
||||
├── Documentation (this will be generated by running the <code>make</code> command inside the Handbook directory)
|
||||
│
|
||||
├── Handbook (this is the mdBook source code, used to generate the Documentation folder and not distributed to the Unreal Engine Marketplace)
|
||||
├── Handbook (this is the mdBook source code, used to generate the Documentation folder and not distributed to [Fab](https://www.fab.com/))
|
||||
│
|
||||
├── Resources
|
||||
│
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## Planned Features Completion Status
|
||||
|
||||
### Implemented as of v2.1.0
|
||||
### Implemented as of v2.3.x
|
||||
|
||||
- [X] Full SenseGlove low-level core API access through Unreal C++.
|
||||
- [X] Full SenseGlove low-level core API access through Blueprint.
|
||||
@@ -28,16 +28,19 @@
|
||||
- [X] C++/Blueprint interaction events such as OnGrabStateUpdated, OnTouchStateUpdated, OnActorGrabbed, OnActorReleased, OnActorBeginTouch, and OnActorEndTouch.
|
||||
- [X] A fall back to HMD and wrist tracker hardware auto-detection mechanism when automatic detection of the wrist tracker hardware is desired.
|
||||
- [X] OpenXR-compatible hand tracking (XR_EXT_hand_tracking) support.
|
||||
- [X] FXRMotionControllerData compatible hand animation system.
|
||||
- [X] FXRMotionControllerData compatible wrist tracking system.
|
||||
- [X] FXRMotionControllerData compatible hand interaction manipulation system.
|
||||
- [X] `FXRMotionControllerData` compatible hand animation system on UE versions `5.2`, `5.3`, and `5.4`.
|
||||
- [X] `FXRHandTrackingState` compatible hand animation system on UE versions `5.5+`.
|
||||
- [X] `FXRMotionControllerData` compatible wrist tracking system on UE versions `5.2`, `5.3`, and `5.4`.
|
||||
- [X] `FXRHandTrackingState` compatible wrist tracking system on UE versions `5.5+`.
|
||||
- [X] `FXRMotionControllerData` compatible hand interaction manipulation system on UE versions `5.2`, `5.3`, and `5.4`.
|
||||
- [X] `FXRHandTrackingState` compatible hand interaction manipulation system on UE versions `5.5+`.
|
||||
- [X] Ability to fallback to hand tracking when a glove is not present and use the bare hands for interactions, or a combination of glove and hand tracking if no motion controller input is detected.
|
||||
- [X] The SenseGlove grab/touch sockets one-click-setup ability on any Epic-compliant virtual hand mesh from within the Unreal Editor's Content Browser, Skeleton Editor, or Skeletal Mesh Editor.
|
||||
- [X] A flexible virtual hand animation system that can take the mesh bone's transforms into account for a more reliable hand animation.
|
||||
- [X] Ability to manage the Engine Scalability Settings through the SenseGlove plugin in order to change the graphics settings on the fly.
|
||||
- [X] Ability to automatically ask for the required permissions on Android when the plugin is enabled in any UE project.
|
||||
|
||||
### Upcoming features planned for the v2.2.0 release
|
||||
|
||||
### Upcoming features planned for the v2.4.x release
|
||||
|
||||
### Planned features long-term
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
## Platform Support Matrix
|
||||
|
||||
| | **Windows (MSVC 2017)** | **Windows (MSVC 2019)** | **Windows (MSVC 2022)** | **Linux x86-64 (Native Toolchain)** | **Linux AArch64 (Native Toolchain)** | **Meta Quest Stand-alone (Android NDK)** | **HTC VIVE Stand-alone (Android NDK)** | **UE Marketplace Version** | **Azure DevOps Version** |
|
||||
|:--------:|:-----------------------:|:-----------------------:|:-----------------------:|:-----------------------------------:|:------------------------------------:|:----------------------------------------:|:--------------------------------------:|:--------------------------:|:------------------------:|
|
||||
| **5.4** | ❌ | ❌ | ✅ v2.1.x | ✅ v2.1.x | ✅ v2.1.x | ✅ v2.1.x (r25b) | ❓ | ✅ v2.1.2 | ✅ v2.1.2 |
|
||||
| **5.3** | ❌ | ✅ v2.1.x | ✅ v2.1.x | ✅ v2.1.x | ✅ v2.1.x | ✅ v2.1.x (r25b) | ❓ | ✅ v2.1.2 | ✅ v2.1.2 |
|
||||
| **5.2** | ❌ | ✅ v2.1.x | ✅ v2.1.x | ✅ v2.1.x | ✅ v2.1.x | ✅ v2.1.x (r25b) | ❓ | ✅ v2.1.2 | ✅ v2.1.2 |
|
||||
| **5.1** | ❌ | ⚠️ v2.0.x | ⚠️ v2.0.x | ⚠️ v2.0.x | ⚠️ v2.0.x | ⚠️ v2.0.x (r25b) | ❓ | ⚠️ v2.0.1 | ⚠️ v2.0.2 |
|
||||
| **5.0** | ❌ | ⚠️ v1.6.x | ⚠️ v1.6.x | ⚠️ v1.6.x | ⚠️ v1.6.x | ⚠️ v1.6.x (r21e) | ❓ | ⚠️ v1.6.1 | ⚠️ v1.6.1 |
|
||||
| **4.27** | ⚠️ v1.4.x | ⚠️ v1.4.x | ⚠️ v1.4.x | ⚠️ v1.4.x | ⚠️ v1.4.x | ⚠️ v1.4.x (r21e) | ❓ | ⚠️ v1.3.1 | ⚠️ v1.4.3 |
|
||||
| **4.26** | ⚠️ v1.0.x | ⚠️ v1.0.x | ❌ | ⚠️ v1.0.x | ❌ | ❌ | ❌ | ❌ | ⚠️ v1.0.4 |
|
||||
| **4.25** | ⚠️ v1.0.x | ⚠️ v1.0.x | ❌ | ⚠️ v1.0.x | ❌ | ❌ | ❌ | ❌ | ⚠️ v1.0.4 |
|
||||
| **4.24** | ⚠️ v1.0.x | ⚠️ v1.0.x | ❌ | ⚠️ v1.0.x | ❌ | ❌ | ❌ | ❌ | ⚠️ v1.0.4 |
|
||||
| **4.23** | ⚠️ v1.0.x | ⚠️ v1.0.x | ❌ | ⚠️ v1.0.x | ❌ | ❌ | ❌ | ❌ | ⚠️ v1.0.4 |
|
||||
| **4.22** | ⚠️ v1.0.x | ⚠️ v1.0.x | ❌ | ⚠️ v1.0.x | ❌ | ❌ | ❌ | ❌ | ⚠️ v1.0.4 |
|
||||
| | **Windows (MSVC 2017)** | **Windows (MSVC 2019)** | **Windows (MSVC 2022)** | **Linux x86-64 (Native Toolchain)** | **Linux AArch64 (Native Toolchain)** | **Meta Quest Stand-alone (Android NDK)** | **HTC VIVE Stand-alone (Android NDK)** | **Fab** | **Azure DevOps Version** |
|
||||
|:--------:|:-----------------------:|:-----------------------:|:-----------------------:|:-----------------------------------:|:------------------------------------:|:----------------------------------------:|:--------------------------------------:|:--------:|:------------------------:|
|
||||
| **5.5** | ❌ | ❌ | ✅ v2.3.x | ✅ v2.3.x | ✅ v2.3.x | ✅ v2.3.x (r25b) | ❓ | ✅ v2.3.0 | ✅ v2.3.0 |
|
||||
| **5.4** | ❌ | ❌ | ✅ v2.3.x | ✅ v2.3.x | ✅ v2.3.x | ✅ v2.3.x (r25b) | ❓ | ✅ v2.3.0 | ✅ v2.3.0 |
|
||||
| **5.3** | ❌ | ✅ v2.3.x | ✅ v2.3.x | ✅ v2.3.x | ✅ v2.3.x | ✅ v2.3.x (r25b) | ❓ | ✅ v2.3.0 | ✅ v2.3.0 |
|
||||
| **5.2** | ❌ | ✅ v2.3.x | ✅ v2.3.x | ✅ v2.3.x | ✅ v2.3.x | ✅ v2.3.x (r25b) | ❓ | ✅ v2.3.0 | ✅ v2.3.0 |
|
||||
| **5.1** | ❌ | ⚠️ v2.0.x | ⚠️ v2.0.x | ⚠️ v2.0.x | ⚠️ v2.0.x | ⚠️ v2.0.x (r25b) | ❓ | ⚠️ v2.0.0 | ⚠️ v2.0.2 |
|
||||
| **5.0** | ❌ | ⚠️ v1.6.x | ⚠️ v1.6.x | ⚠️ v1.6.x | ⚠️ v1.6.x | ⚠️ v1.6.x (r21e) | ❓ | ⚠️ v1.6.1 | ⚠️ v1.6.1 |
|
||||
| **4.27** | ⚠️ v1.4.x | ⚠️ v1.4.x | ⚠️ v1.4.x | ⚠️ v1.4.x | ⚠️ v1.4.x | ⚠️ v1.4.x (r21e) | ❓ | ⚠️ v1.3.1 | ⚠️ v1.4.3 |
|
||||
| **4.26** | ⚠️ v1.0.x | ⚠️ v1.0.x | ❌ | ⚠️ v1.0.x | ❌ | ❌ | ❌ | ❌ | ⚠️ v1.0.4 |
|
||||
| **4.25** | ⚠️ v1.0.x | ⚠️ v1.0.x | ❌ | ⚠️ v1.0.x | ❌ | ❌ | ❌ | ❌ | ⚠️ v1.0.4 |
|
||||
| **4.24** | ⚠️ v1.0.x | ⚠️ v1.0.x | ❌ | ⚠️ v1.0.x | ❌ | ❌ | ❌ | ❌ | ⚠️ v1.0.4 |
|
||||
| **4.23** | ⚠️ v1.0.x | ⚠️ v1.0.x | ❌ | ⚠️ v1.0.x | ❌ | ❌ | ❌ | ❌ | ⚠️ v1.0.4 |
|
||||
| **4.22** | ⚠️ v1.0.x | ⚠️ v1.0.x | ❌ | ⚠️ v1.0.x | ❌ | ❌ | ❌ | ❌ | ⚠️ v1.0.4 |
|
||||
|
||||
* <code>✅</code> Supported
|
||||
* <code>⚠️</code> Not supported by the latest release and might be lacking features
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
The SenseGlove Unreal Engine Plugin could be installed using various methods:
|
||||
|
||||
- Through [the Epic Games Launcher](https://store.epicgames.com/en-US/download) by navigating to [the SenseGlove Unreal Engine Plugin landing page on the Unreal Engine Marketplace](https://www.unrealengine.com/marketplace/en-US/product/the-senseglove-unreal-engine-plugin).
|
||||
- Through [the SenseGlove Unreal Engine Plugin Microsoft Azure DevOps repository](https://dev.azure.com/SenseGlove/_git/SenseGlove-Unreal).
|
||||
- Via [the Epic Games Launcher](https://store.epicgames.com/en-US/download) by navigating to [the SenseGlove Unreal Engine Plugin landing page on Fab](https://www.fab.com/listings/62bcdd2a-0bb1-4f34-b7b8-c5e7c9313099).
|
||||
- Via [the SenseGlove Unreal Engine Plugin Microsoft Azure DevOps repository](https://dev.azure.com/SenseGlove/_git/SenseGlove-Unreal).
|
||||
|
||||
In the following chapters, we discover each of those methods:
|
||||
|
||||
- [Installation through the Epic Games Launcher](epic-games-launcher.md)
|
||||
- [Installation through Microsoft Azure DevOps Repositories](microsoft-azure-devops-repositories.md)
|
||||
- [Installation via the Epic Games Launcher](epic-games-launcher.md)
|
||||
- [Installation via Microsoft Azure DevOps Repositories](microsoft-azure-devops-repositories.md)
|
||||
|
||||
## Video Tutorials
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
LFS
Executable
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -1,46 +1,68 @@
|
||||
# Plugin Installation through the Epic Games Launcher
|
||||
# Plugin Installation via the Epic Games Launcher
|
||||
|
||||
Before we start the plugin installation through [the Epic Games Launcher](https://store.epicgames.com/en-US/download) please make sure you have [a signed-in Epic Games account on your installed Epic Games Launcher and a supported Unreal Engine version already installed](https://dev.epicgames.com/documentation/en-us/unreal-engine/installing-unreal-engine). The supported engine versions are listed on [the Platform Support Matrix](../../appendix/platform-support-matrix.md).
|
||||
Before beginning the plugin installation via [the Epic Games Launcher](https://store.epicgames.com/en-US/download), ensure you have [signed into your Epic Games account on the Epic Games Launcher](https://store.epicgames.com/en-US/download) and that you have a [supported version of Unreal Engine installed](https://dev.epicgames.com/documentation/en-us/unreal-engine/installing-unreal-engine). Supported engine versions can be found in the [Platform Support Matrix](../../appendix/platform-support-matrix.md).
|
||||
|
||||
1. Run the Epic Games Launcher.
|
||||
|
||||

|
||||

|
||||
|
||||
2. Navigate to the `Marketplace` tab.
|
||||
2. Navigate to the `Fab` tab and click `Start exploring` button which in turn opens your default web browser pointing to the [Fab home page](https://www.fab.com/).
|
||||
|
||||

|
||||

|
||||
|
||||
3. On the `Marketplace` tab, inside the search box, start typing `SenseGlove` which filters the plugin matching that search phrase in real-time. Select `The SenseGlove Unreal Engine Plugin`.
|
||||
3. On the [Fab home page](https://www.fab.com/), enter the term `SenseGlove` in the search box and press Enter. Alternatively, you can go directly to the [SenseGlove Unreal Engine Plugin landing page on Fab](https://www.fab.com/listings/62bcdd2a-0bb1-4f34-b7b8-c5e7c9313099) directly instead of taking the above two steps.
|
||||
|
||||

|
||||

|
||||
|
||||
4. Once on [the SenseGlove Unreal Engine Plugin marketplace page](https://www.unrealengine.com/marketplace/en-US/product/the-senseglove-unreal-engine-plugin), click on the `Install to Engine` button.
|
||||
4. Click on the `SenseGlove Unreal Engine Plugin` in the search results to navigate to its dedicated page.
|
||||
|
||||

|
||||

|
||||
|
||||
5. You'll be prompted to choose a compatible engine version. Select your desired engine version and hit this `Install` button.
|
||||
5. On the [SenseGlove Unreal Engine Plugin landing page on Fab](https://www.fab.com/listings/62bcdd2a-0bb1-4f34-b7b8-c5e7c9313099) click the `Download` button.
|
||||
|
||||

|
||||

|
||||
|
||||
6. The launcher will show the download and installation progress. Please wait for it to finish.
|
||||
6. If this is your first download from Fab, you will need to agree to the Fab End User License Agreement (EULA) before proceeding.
|
||||
|
||||

|
||||
 prompt")
|
||||
|
||||
7. While the download and installation are in progress you can see the progress in more detail by clicking on the `Downloads` section on the sidebar.
|
||||
7. After clicking `Download`, a pop-up will notify you that the plugin is available in your Vault in the Epic Games Launcher, or the Fab UE5 Plugin.
|
||||
|
||||

|
||||
> [!NOTE]
|
||||
> According to the
|
||||
> [Fab launch announcement](https://www.unrealengine.com/en-US/blog/fab-epics-new-unified-content-marketplace-launches-today):
|
||||
>
|
||||
> The Fab integration in UEFN is undergoing maintenance and will be back online shortly, and the Fab integration in the Unreal Engine 5 Editor is coming soon.
|
||||
|
||||
8. Once the download and installation are done, you can head to the `Library` tab to verify the installation. In case you have lots of assets or plugins installed, you could search the term `SenseGlove` inside the search box for the `Vault` section and you should be able to see that the SenseGlove Unreal Engine Plugin has been added to your vault.
|
||||

|
||||
|
||||

|
||||
8. Go back to the Epic Games Launcher, navigate to the `Library` tab, and in the `Fab Library` section, click the `Refresh Fab items` button.
|
||||
|
||||
9. If you click on the `Installed Plugins` link under the engine you've just installed the plugin to, you should be able to see the SenseGlove Unreal Engine Plugin listed as installed.
|
||||

|
||||
|
||||

|
||||
9. Once the Fab library is refreshed and synchronized, use the Vault search box to find the `SenseGlove Unreal Engine Plugin`. Click the `Install to Engine` button.
|
||||
|
||||
10. One last confirmation could be navigating to `YourEngineInstallationPath/Engine/Plugins/Marketplace` directory. The SenseGlove Unreal Engine Plugin source and binaries can be found inside this directory. This is especially useful in case one desires to copy the plugin for example to their own project's source code to run it at the project level instead of running it at the engine level.
|
||||

|
||||
|
||||

|
||||
10. You'll be prompted to choose a compatible engine version. Select your desired engine version from the list, then click `Install`.
|
||||
|
||||

|
||||
|
||||
11. The Epic Games Launcher will show the plugin's download and installation progress. Please wait for it to complete.
|
||||
|
||||

|
||||
|
||||
12. While the download and installation are in progress, you can see the progress in more details by clicking on the `Downloads` section on the sidebar.
|
||||
|
||||

|
||||
|
||||
13. Once the download and installation are complete, verify its installation by clicking `Installed Plugins` under the engine you've just installed it to. The SenseGlove plugin should appear as installed among other currently installed plugins.
|
||||
|
||||

|
||||
|
||||
14. One last confirmation could be navigating to `YourEngineInstallationPath/Engine/Plugins/Marketplace` directory. The SenseGlove Unreal Engine Plugin source and binaries can be found inside this directory. This is especially useful in case one desires to copy the plugin for example to their own project's source code to run it at the project level instead of running it at the engine level.
|
||||
|
||||

|
||||
|
||||
> [!WARNING]
|
||||
> Please note that it is best practice to install the plugin either at the
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# Plugin Installation through Microsoft Azure DevOps Repositories
|
||||
# Plugin Installation via Microsoft Azure DevOps Repositories
|
||||
|
||||
While [plugin installation through the Epic Games Launcher](epic-games-launcher.md) is the most convenient method for most users to obtain and install the latest version of [the SenseGlove Unreal Engine Plugin marketplace page](https://www.unrealengine.com/marketplace/en-US/product/the-senseglove-unreal-engine-plugin), there might be valid reasons to instead download and install the plugin directly from [the SenseGlove Unreal Engine Plugin Microsoft Azure DevOps Repository](https://dev.azure.com/SenseGlove/_git/SenseGlove-Unreal). These reasons may include:
|
||||
While [plugin installation via the Epic Games Launcher](epic-games-launcher.md) is the most convenient method for most users to obtain and install the latest version of [the SenseGlove Unreal Engine Plugin via Fab](https://www.fab.com/listings/62bcdd2a-0bb1-4f34-b7b8-c5e7c9313099), there might be valid reasons to instead download and install the plugin directly from [the SenseGlove Unreal Engine Plugin Microsoft Azure DevOps Repository](https://dev.azure.com/SenseGlove/_git/SenseGlove-Unreal). These reasons may include:
|
||||
|
||||
- Downloading an older version that is no longer available on [the Unreal Engine Marketplace](https://www.unrealengine.com/marketplace/en-US/store).
|
||||
- Downloading a recent version that has been submitted to the Unreal Engine Marketplace, but is still awaiting approval and publication by the Unreal Engine Marketplace Team.
|
||||
- Downloading an older version that is no longer available on [Fab](https://www.fab.com/).
|
||||
- Downloading a recent version that has been submitted to Fab, but is still awaiting approval and publication by the Fab Team.
|
||||
- Downloading an under-development, unstable release of the plugin for testing purposes.
|
||||
- Or, any other specific needs that require direct access to the repository.
|
||||
|
||||
@@ -17,11 +17,11 @@ To download a specific version of the plugin, follow these steps:
|
||||
|
||||
2. Locate the branch dropdown menu at the top of the page, just below the navigation bar, and next to the `Copy to clipboard` icon. There you'll find a dropdown menu. By default, it usually selects the [master](https://dev.azure.com/SenseGlove/_git/SenseGlove-Unreal?path=%2F&version=GBmaster&_a=contents) branch.
|
||||
|
||||

|
||||

|
||||
|
||||
3. Use the dropdown menu to choose a desired branch containing the source code for a specific version of Unreal Engine or a specific release of the plugin marked with a release tag.
|
||||
|
||||

|
||||

|
||||
|
||||
> [!NOTE]
|
||||
> A branch named with engine version numbers, such as `5.4`, `5.3`, etc.,
|
||||
@@ -49,7 +49,7 @@ To download a specific version of the plugin, follow these steps:
|
||||
|
||||
4. After selecting your desired branch or tag, click on the kebab menu (three vertical dots) located at the top right of the screen and choose `Download as Zip` to obtain the source code for that branch or tag.
|
||||
|
||||

|
||||

|
||||
|
||||
## Download a Specific Version for a Specifc Unreal Engine Version
|
||||
|
||||
@@ -57,17 +57,17 @@ As mentioned earlier, due to breaking changes between Unreal Engine versions, it
|
||||
|
||||
1. First, choose the appropriate branch for your desired Unreal Engine version from the branch dropdown menu, as discussed earlier. Then navigate to the `History` tab.
|
||||
|
||||

|
||||

|
||||
|
||||
2. Look through the commit history for a commit message that says `bump the plugin version to vX.X.X` as all releases are finalized with this exact commit message and the plugin version. Next, click on the commit message for the version you are looking for.
|
||||
2. Look via the commit history for a commit message that says `bump the plugin version to vX.X.X` as all releases are finalized with this exact commit message and the plugin version. Next, click on the commit message for the version you are looking for.
|
||||
|
||||
3. Once you've selected the correct commit, click on the `Browse Files` button next to the kebab menu (three vertical dots) at the top right of the screen.
|
||||
|
||||

|
||||

|
||||
|
||||
4. You should now be in the `Content` tab, with the branch dropdown menu displaying the commit hash instead of a branch name or tag. Click on the kebab menu (three vertical dots) again, and select `Download as Zip`. This will give you a zip file containing the exact release you need, compatible with your chosen Unreal Engine version.
|
||||
|
||||

|
||||

|
||||
|
||||
## Download the Bleeding-edge Development Branch
|
||||
|
||||
@@ -86,7 +86,7 @@ As mentioned earlier, due to breaking changes between Unreal Engine versions, it
|
||||
|
||||
Downloading the [`dev`](https://dev.azure.com/SenseGlove/_git/SenseGlove-Unreal?path=%2F&version=GBdev&_a=contents) branch is as easy as choosing the `dev` branch from the branch dropdown menu (as discussed earlier) and then choosing `Download as Zip` from the kebab menu (three vertical dots).
|
||||
|
||||

|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
@@ -211,11 +211,11 @@ MyCppProject
|
||||
|
||||
For a Blueprint-only project, on Microsoft Windows simply double-clicking the project's `.uproject` file should present you with a pop-up informing you that some binary modules are missing.
|
||||
|
||||

|
||||

|
||||
|
||||
After confirming, the build process will start automatically, and a dialog indicating the build progress will be shown:
|
||||
|
||||

|
||||

|
||||
|
||||
Once finished successfully, the project will be loaded.
|
||||
|
||||
@@ -224,11 +224,11 @@ Once finished successfully, the project will be loaded.
|
||||
|
||||
For C++ projects, on Microsoft Windows, right-click on your C++ `.uproject` file and choose `Generate Visual Studio project files`:
|
||||
|
||||

|
||||

|
||||
|
||||
A dialog will pop up shows you the progress of generating the Visual Studio project files:
|
||||
|
||||

|
||||

|
||||
|
||||
Once the project files are generated, open up the C++ project in your preferred C++ IDE and build the project. After this, the project can be loaded in the Unreal Editor.
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ To help you navigate the SenseGlove Unreal Engine Handbook, we have organized th
|
||||
This section covers the basics of the SenseGlove Unreal Engine Plugin:
|
||||
|
||||
- [Installation](../getting-started/installation/)
|
||||
- [Through the Epic Games Launcher](../getting-started/installation/epic-games-launcher.md)
|
||||
- [Through Microsoft Azure DevOps Repositories](../getting-started/installation/microsoft-azure-devops-repositories.md)
|
||||
- [Via the Epic Games Launcher](../getting-started/installation/epic-games-launcher.md)
|
||||
- [Via Microsoft Azure DevOps Repositories](../getting-started/installation/microsoft-azure-devops-repositories.md)
|
||||
- [Enabling and Verifying the Plugin Version](../getting-started/plugin-verify-version-enable/)
|
||||
- [SenseCom](../getting-started/sensecom/)
|
||||
- [SenseCom on GNU/Linux](../getting-started/sensecom/gnu-linux/)
|
||||
@@ -65,6 +65,9 @@ For users familiar with the basics, this section explores advanced features of t
|
||||
|
||||
- [Safe Glove Access in Blueprint](../advanced-topics/safe-glove-access-blueprint/)
|
||||
- [OpenXR](../advanced-topics/openxr/)
|
||||
- [Consuming FXRHandTrackingState](../advanced-topics/openxr/consuming-fxrhandtrackingstate/)
|
||||
- [Blueprint](../advanced-topics/openxr/consuming-fxrhandtrackingstate/blueprint.md)
|
||||
- [C++](../advanced-topics/openxr/consuming-fxrhandtrackingstate/cpp.md)
|
||||
- [Consuming FXRMotionControllerData](../advanced-topics/openxr/consuming-fxrmotioncontrollerdata/)
|
||||
- [Blueprint](../advanced-topics/openxr/consuming-fxrmotioncontrollerdata/blueprint.md)
|
||||
- [C++](../advanced-topics/openxr/consuming-fxrmotioncontrollerdata/cpp.md)
|
||||
|
||||
@@ -42,6 +42,7 @@ Deploy:
|
||||
PasswordEnvVar: SGUM_PACKAGER_REPOSITORY_PASSWORD
|
||||
|
||||
Branches:
|
||||
- "5.5"
|
||||
- "5.4"
|
||||
- "5.3"
|
||||
- "5.2"
|
||||
@@ -181,11 +182,13 @@ Rocket:
|
||||
PackageDirectory: "%TEMP%\\SenseGlove-Unreal\\Rocket"
|
||||
|
||||
EnginePaths:
|
||||
- "5.5": "C:\\OPT\\UE_5.5"
|
||||
- "5.4": "C:\\OPT\\UE_5.4"
|
||||
- "5.3": "C:\\OPT\\UE_5.3"
|
||||
- "5.2": "C:\\OPT\\UE_5.2"
|
||||
|
||||
NDKPaths:
|
||||
- "5.5": "%LOCALAPPDATA%\\Android\\Sdk\\ndk\\25.1.8937393"
|
||||
- "5.4": "%LOCALAPPDATA%\\Android\\Sdk\\ndk\\25.1.8937393"
|
||||
- "5.3": "%LOCALAPPDATA%\\Android\\Sdk\\ndk\\25.1.8937393"
|
||||
- "5.2": "%LOCALAPPDATA%\\Android\\Sdk\\ndk\\25.1.8937393"
|
||||
|
||||
@@ -14,7 +14,7 @@ For examples, demo scenes, tutorials, and extra resources please check out [the
|
||||
|
||||
Various instructions on [how to download and install the SenseGlove Unreal Engine Plugin](Handbook/src/getting-started/installation/README.md) are available. It could either be installed through [the Epic Games Launcher](Handbook/src/getting-started/installation/epic-games-launcher.md), or [through Microsoft Azure DevOps repositories](Handbook/src/getting-started/installation/microsoft-azure-devops-repositories.md).
|
||||
|
||||
For more information, visit [the SenseGlove Unreal Engine Handbook on the Epic Marketplace](https://www.unrealengine.com/marketplace/en-US/product/the-senseglove-unreal-engine-plugin).
|
||||
For more information, visit [the SenseGlove Unreal Engine Plugin on Fab](https://www.fab.com/listings/62bcdd2a-0bb1-4f34-b7b8-c5e7c9313099).
|
||||
|
||||
### Platform Support Matrix
|
||||
|
||||
|
||||
+5
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"FileVersion": 3,
|
||||
"Version": 1,
|
||||
"VersionName": "2.1.2",
|
||||
"VersionName": "2.3.0",
|
||||
"FriendlyName": "SenseGlove",
|
||||
"Description": "Integrating the SenseGlove haptic controller into Unreal Engine",
|
||||
"Category": "Virtual Reality",
|
||||
@@ -274,6 +274,10 @@
|
||||
}
|
||||
],
|
||||
"Plugins": [
|
||||
{
|
||||
"Name": "AndroidPermission",
|
||||
"Enabled": true
|
||||
},
|
||||
{
|
||||
"Name": "OpenXR",
|
||||
"Enabled": true,
|
||||
|
||||
@@ -44,10 +44,8 @@
|
||||
#include "Containers/UnrealString.h"
|
||||
#include "Engine/SkeletalMesh.h"
|
||||
#include "Math/Rotator.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
|
||||
#include "SenseGlove/Components/SGVirtualHandComponent.h"
|
||||
#include "SGLog/SGLog.h"
|
||||
|
||||
FSGVirtualHandAnimInstanceProxy::FSGVirtualHandAnimInstanceProxy()
|
||||
: FAnimInstanceProxy{}
|
||||
@@ -108,6 +106,16 @@ void FSGVirtualHandAnimInstanceProxy::PreEvaluateAnimation(UAnimInstance* InAnim
|
||||
return;
|
||||
}
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
const bool bGotHandTrackingState = VirtualHand->GetHandTrackingState(
|
||||
EXRSpaceType::UnrealWorldSpace, HandTrackingState);
|
||||
if (!bGotHandTrackingState || !HandTrackingState.bValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ensureAlwaysMsgf(HandTrackingState.HandKeyLocations.Num() == HandTrackingState.HandKeyRotations.Num(),
|
||||
TEXT("Mismatched hand tracking state locations and rotations!"));
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
const bool bGotMotionControllerData = VirtualHand->GetMotionControllerData(MotionControllerData);
|
||||
if (!bGotMotionControllerData || !MotionControllerData.bValid)
|
||||
{
|
||||
@@ -115,10 +123,18 @@ void FSGVirtualHandAnimInstanceProxy::PreEvaluateAnimation(UAnimInstance* InAnim
|
||||
}
|
||||
ensureAlwaysMsgf(MotionControllerData.HandKeyPositions.Num() == MotionControllerData.HandKeyRotations.Num(),
|
||||
TEXT("Mismatched motion controller data positions and rotations!"));
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
|
||||
BoneNamesMap.Empty();
|
||||
for (TArray<FQuat>::SizeType HandKeyIndex = 0;
|
||||
HandKeyIndex < MotionControllerData.HandKeyRotations.Num(); ++HandKeyIndex)
|
||||
HandKeyIndex <
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
HandTrackingState.HandKeyRotations.Num()
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
MotionControllerData.HandKeyRotations.Num()
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
; ++HandKeyIndex)
|
||||
{
|
||||
const FName& BoneName{VirtualHand->GetHandBoneName(HandKeyIndex)};
|
||||
BoneNamesMap.Add(HandKeyIndex, BoneName);
|
||||
@@ -136,10 +152,17 @@ bool FSGVirtualHandAnimInstanceProxy::Evaluate(FPoseContext& Output)
|
||||
return FAnimInstanceProxy::Evaluate(Output);
|
||||
}
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
if (!HandTrackingState.bValid)
|
||||
{
|
||||
return FAnimInstanceProxy::Evaluate(Output);
|
||||
}
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
if (!MotionControllerData.bValid)
|
||||
{
|
||||
return FAnimInstanceProxy::Evaluate(Output);
|
||||
}
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
FComponentSpacePoseContext PoseContext{Output.AnimInstanceProxy};
|
||||
PoseContext.Pose.InitPose(Output.Pose);
|
||||
@@ -164,9 +187,16 @@ bool FSGVirtualHandAnimInstanceProxy::Evaluate(FPoseContext& Output)
|
||||
BoneReference.BoneIndex = BoneIndex;
|
||||
BoneReference.bUseSkeletonIndex = true;
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
const FVector& HandKeyLocation{HandTrackingState.HandKeyLocations[HandKeyIndex]};
|
||||
const FQuat& HandKeyRotation{HandTrackingState.HandKeyRotations[HandKeyIndex]};
|
||||
const FTransform HandKeyTransform{HandKeyRotation, HandKeyLocation};
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
const FVector& HandKeyPosition{MotionControllerData.HandKeyPositions[HandKeyIndex]};
|
||||
const FQuat& HandKeyRotation{MotionControllerData.HandKeyRotations[HandKeyIndex]};
|
||||
const FTransform HandKeyTransform{HandKeyRotation, HandKeyPosition};
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
const FTransform BoneTransform{AnimationBoneCorrectionOffsetTransform * HandKeyTransform};
|
||||
FRotator BoneRotation{BoneTransform.GetRotation().Rotator()};
|
||||
|
||||
|
||||
@@ -236,7 +236,11 @@ USGVirtualHandComponent::USGVirtualHandComponent(const FObjectInitializer& Objec
|
||||
Super::SetCollisionResponseToChannel(ECC_Vehicle, ECR_Block);
|
||||
Super::SetCollisionResponseToChannel(ECC_Destructible, ECR_Block);
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
Super::SetAnimInstanceClass(USGVirtualHandAnimInstance::StaticClass());
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
Super::SetAnimClass(USGVirtualHandAnimInstance::StaticClass());
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
bRight = true;
|
||||
|
||||
@@ -291,6 +295,15 @@ FSGVirtualHandSettings USGVirtualHandComponent::GetVirtualHandSettings() const
|
||||
return VirtualHandSettings;
|
||||
}
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
void USGVirtualHandComponent::SetAnimInstanceClass(UClass* NewClass)
|
||||
{
|
||||
ensureAlwaysMsgf((TIsDerivedFrom<decltype(NewClass), USGVirtualHandAnimInstance>::IsDerived),
|
||||
TEXT("The AnimInstance class must be a subclass of USGVirtualHandAnimInstance!"));
|
||||
|
||||
Super::SetAnimInstanceClass(NewClass);
|
||||
}
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
void USGVirtualHandComponent::SetAnimClass(UClass* NewClass)
|
||||
{
|
||||
ensureAlwaysMsgf((TIsDerivedFrom<decltype(NewClass), USGVirtualHandAnimInstance>::IsDerived),
|
||||
@@ -298,6 +311,7 @@ void USGVirtualHandComponent::SetAnimClass(UClass* NewClass)
|
||||
|
||||
Super::SetAnimClass(NewClass);
|
||||
}
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
void USGVirtualHandComponent::PostInitProperties()
|
||||
{
|
||||
@@ -326,8 +340,8 @@ void USGVirtualHandComponent::PostEditChangeProperty(FPropertyChangedEvent& Prop
|
||||
|
||||
static const FName OverridePluginSettingsName{
|
||||
FImpl::ParseVirtualHandSettingsOverridesPropertyName(
|
||||
GET_MEMBER_NAME_CHECKED(FSGWristTrackingSettingsOverrides,
|
||||
FSGWristTrackingSettingsOverrides::bOverridePluginSettings))
|
||||
GET_MEMBER_NAME_CHECKED(FSGVirtualHandSettingsOverrides,
|
||||
FSGVirtualHandSettingsOverrides::bOverridePluginSettings))
|
||||
};
|
||||
|
||||
if (PropertyName == RightName)
|
||||
@@ -452,8 +466,10 @@ bool USGVirtualHandComponent::GetMotionControllerData(FXRMotionControllerData& O
|
||||
OutMotionControllerData.bValid = false;
|
||||
|
||||
const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left;
|
||||
PRAGMA_DISABLE_DEPRECATION_WARNINGS
|
||||
const bool bGotMotionControllerData =
|
||||
FSGXRTracker::GetMotionControllerData(this, Hand, OutMotionControllerData);
|
||||
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
||||
if (!bGotMotionControllerData || !OutMotionControllerData.bValid)
|
||||
{
|
||||
return false;
|
||||
@@ -462,6 +478,46 @@ bool USGVirtualHandComponent::GetMotionControllerData(FXRMotionControllerData& O
|
||||
return OutMotionControllerData.bValid;
|
||||
}
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
|
||||
bool USGVirtualHandComponent::GetMotionControllerState(
|
||||
const EXRSpaceType XRSpaceType, const EXRControllerPoseType XRControllerPoseType,
|
||||
FXRMotionControllerState& OutMotionControllerState)
|
||||
{
|
||||
OutMotionControllerState.bValid = false;
|
||||
|
||||
const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left;
|
||||
const bool bGotMotionControllerState =
|
||||
FSGXRTracker::GetMotionControllerState(
|
||||
this, XRSpaceType, Hand, XRControllerPoseType, OutMotionControllerState);
|
||||
if (!bGotMotionControllerState || !OutMotionControllerState.bValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return OutMotionControllerState.bValid;
|
||||
}
|
||||
|
||||
bool USGVirtualHandComponent::GetHandTrackingState(
|
||||
const EXRSpaceType XRSpaceType,
|
||||
FXRHandTrackingState& OutHandTrackingState)
|
||||
{
|
||||
OutHandTrackingState.bValid = false;
|
||||
|
||||
const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left;
|
||||
const bool bGotHandTrackingState =
|
||||
FSGXRTracker::GetHandTrackingState(
|
||||
this, XRSpaceType, Hand, OutHandTrackingState);
|
||||
if (!bGotHandTrackingState || !OutHandTrackingState.bValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return OutHandTrackingState.bValid;
|
||||
}
|
||||
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
const TArray<FName>& USGVirtualHandComponent::GetHandBoneNames() const
|
||||
{
|
||||
const TArray<FName>& Names{
|
||||
@@ -747,12 +803,25 @@ void USGVirtualHandComponent::FImpl::SetVisibility(const bool bInVisible)
|
||||
|
||||
void USGVirtualHandComponent::FImpl::UpdateVisibility()
|
||||
{
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
FXRHandTrackingState HandTrackingState;
|
||||
const bool bGotHandTrackingState =
|
||||
Owner->GetHandTrackingState(EXRSpaceType::UnrealWorldSpace, HandTrackingState);
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
FXRMotionControllerData MotionControllerData;
|
||||
const bool bGotMotionControllerData = Owner->GetMotionControllerData(MotionControllerData);
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
const bool bHandDataAvailable =
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
bGotHandTrackingState
|
||||
&& HandTrackingState.bValid
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
bGotMotionControllerData
|
||||
&& MotionControllerData.bValid
|
||||
&& MotionControllerData.DeviceVisualType == EXRVisualType::Hand;
|
||||
&& MotionControllerData.DeviceVisualType == EXRVisualType::Hand
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
;
|
||||
const bool bHandVisible = Owner->IsVisible();
|
||||
const bool bShouldBeVisibleWhenHandDataUnavailable =
|
||||
Owner->GetVirtualHandSettings().bVisibleWhenHandDataUnavailable;
|
||||
@@ -811,6 +880,16 @@ void USGVirtualHandComponent::FImpl::DrawDebugVirtualHand() const
|
||||
return;
|
||||
}
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
FXRHandTrackingState HandTrackingState;
|
||||
const bool bGotHandTrackingState = Owner->GetHandTrackingState(EXRSpaceType::UnrealWorldSpace, HandTrackingState);
|
||||
if (!bGotHandTrackingState || !HandTrackingState.bValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FSGDebugVirtualHand::Draw(World, HandTrackingState, Owner->GetVirtualHandSettings().DebuggingSettings);
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
FXRMotionControllerData MotionControllerData;
|
||||
const bool bGotMotionControllerData = Owner->GetMotionControllerData(MotionControllerData);
|
||||
if (!bGotMotionControllerData || !MotionControllerData.bValid)
|
||||
@@ -819,6 +898,7 @@ void USGVirtualHandComponent::FImpl::DrawDebugVirtualHand() const
|
||||
}
|
||||
|
||||
FSGDebugVirtualHand::Draw(World, MotionControllerData, Owner->GetVirtualHandSettings().DebuggingSettings);
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
}
|
||||
|
||||
void USGVirtualHandComponent::FImpl::TriggerHandVisibilityChangedEvent(const bool bNewVisibility) const
|
||||
|
||||
@@ -246,8 +246,11 @@ bool USGWristTrackerComponent::GetMotionControllerData(FXRMotionControllerData&
|
||||
OutMotionControllerData.bValid = false;
|
||||
|
||||
const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left;
|
||||
PRAGMA_DISABLE_DEPRECATION_WARNINGS
|
||||
const bool bGotMotionControllerData =
|
||||
FSGXRTracker::GetMotionControllerData(this, Hand, OutMotionControllerData);
|
||||
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
||||
|
||||
if (!bGotMotionControllerData || !OutMotionControllerData.bValid)
|
||||
{
|
||||
return false;
|
||||
@@ -256,6 +259,46 @@ bool USGWristTrackerComponent::GetMotionControllerData(FXRMotionControllerData&
|
||||
return OutMotionControllerData.bValid;
|
||||
}
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
|
||||
bool USGWristTrackerComponent::GetMotionControllerState(
|
||||
const EXRSpaceType XRSpaceType, const EXRControllerPoseType XRControllerPoseType,
|
||||
FXRMotionControllerState& OutMotionControllerState)
|
||||
{
|
||||
OutMotionControllerState.bValid = false;
|
||||
|
||||
const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left;
|
||||
const bool bGotMotionControllerState =
|
||||
FSGXRTracker::GetMotionControllerState(
|
||||
this, XRSpaceType, Hand, XRControllerPoseType, OutMotionControllerState);
|
||||
if (!bGotMotionControllerState || !OutMotionControllerState.bValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return OutMotionControllerState.bValid;
|
||||
}
|
||||
|
||||
bool USGWristTrackerComponent::GetHandTrackingState(
|
||||
const EXRSpaceType XRSpaceType,
|
||||
FXRHandTrackingState& OutHandTrackingState)
|
||||
{
|
||||
OutHandTrackingState.bValid = false;
|
||||
|
||||
const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left;
|
||||
const bool bGotHandTrackingState =
|
||||
FSGXRTracker::GetHandTrackingState(
|
||||
this, XRSpaceType, Hand, OutHandTrackingState);
|
||||
if (!bGotHandTrackingState || !OutHandTrackingState.bValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return OutHandTrackingState.bValid;
|
||||
}
|
||||
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
USGWristTrackerComponent::FImpl::FImpl(USGWristTrackerComponent* InOwner)
|
||||
: bOverridePluginSettingsPropertyAlreadyModified(false),
|
||||
Owner(InOwner)
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "Components/PrimitiveComponent.h"
|
||||
#include "Components/SphereComponent.h"
|
||||
#include "Kismet/KismetMathLibrary.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
#include "UObject/UObjectGlobals.h"
|
||||
#include "XRDeviceVisualizationComponent.h"
|
||||
|
||||
@@ -430,7 +431,7 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer)
|
||||
this, TEXT("RightThumbFingertipTouchCollider"));
|
||||
RightThumbFingertipTouchCollider->SetRelativeScale3D(RightHandSettings.TouchSettings.DefaultColliderSize);
|
||||
RightThumbFingertipTouchCollider->SetupAttachment(
|
||||
HandRight,RightHandSettings.TouchSettings.ThumbColliderSocketName);
|
||||
HandRight, RightHandSettings.TouchSettings.ThumbColliderSocketName);
|
||||
RightThumbFingertipTouchCollider->SetCastShadow(false);
|
||||
RightThumbFingertipTouchCollider->bCastDynamicShadow = false;
|
||||
RightThumbFingertipTouchCollider->SetReceivesDecals(true);
|
||||
@@ -2192,7 +2193,13 @@ void ASGPawn::FImpl::RecordHandVelocity(FSGGrabState& GrabState, const float Del
|
||||
{
|
||||
if (GrabState.HandVelocityHistory.IsValidIndex(0))
|
||||
{
|
||||
GrabState.HandVelocityHistory.RemoveAt(0, 1, false);
|
||||
GrabState.HandVelocityHistory.RemoveAt(0, 1,
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
EAllowShrinking::No
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
false
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
);
|
||||
GrabState.HandVelocityHistory.Emplace(MoveTemp(HandVelocity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
*/
|
||||
|
||||
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Delegates/IDelegateInstance.h"
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "HeadMountedDisplayTypes.h"
|
||||
#include "Math/Quat.h"
|
||||
#include "Math/Transform.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
#include "Templates/UniquePtr.h"
|
||||
#include "UObject/NameTypes.h"
|
||||
|
||||
@@ -67,7 +68,12 @@ private:
|
||||
bool bVirtualHandVisible;
|
||||
bool bMarkRenderStateDirty;
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
FXRHandTrackingState HandTrackingState;
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
FXRMotionControllerData MotionControllerData;
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
TMap<TArray<FQuat>::SizeType, FName> BoneNamesMap;
|
||||
|
||||
FTransform AnimationBoneCorrectionOffsetTransform;
|
||||
@@ -103,10 +109,17 @@ protected:
|
||||
return bMarkRenderStateDirty;
|
||||
}
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
FORCEINLINE const FXRHandTrackingState& GetHandTrackingState() const
|
||||
{
|
||||
return HandTrackingState;
|
||||
}
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
FORCEINLINE const FXRMotionControllerData& GetMotionControllerData() const
|
||||
{
|
||||
return MotionControllerData;
|
||||
}
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
FORCEINLINE const TMap<TArray<FQuat>::SizeType, FName>& GetBoneNamesMap() const
|
||||
{
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "Math/Transform.h"
|
||||
#include "Misc/AssertionMacros.h"
|
||||
#include "ReferenceSkeleton.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
#include "Templates/UniquePtr.h"
|
||||
#include "UObject/NameTypes.h"
|
||||
|
||||
@@ -145,7 +146,11 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
virtual void SetAnimInstanceClass(class UClass* NewClass) override;
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
virtual void SetAnimClass(class UClass* NewClass) override;
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
virtual void PostInitProperties() override;
|
||||
|
||||
@@ -175,8 +180,19 @@ protected:
|
||||
public:
|
||||
bool IsGloveConnected() const;
|
||||
USGHapticGlove* GetConnectedGlove() const;
|
||||
|
||||
UE_DEPRECATED(5.5, "Deprecated by UE 5.5 in favor of GetMotionControllerState and GetHandTrackingState")
|
||||
bool GetMotionControllerData(FXRMotionControllerData& OutMotionControllerData);
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
bool GetMotionControllerState(
|
||||
EXRSpaceType XRSpaceType, EXRControllerPoseType XRControllerPoseType,
|
||||
FXRMotionControllerState& OutMotionControllerState);
|
||||
bool GetHandTrackingState(
|
||||
EXRSpaceType XRSpaceType,
|
||||
FXRHandTrackingState& OutHandTrackingState);
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
public:
|
||||
const TArray<FName>& GetHandBoneNames() const;
|
||||
const FName& GetHandBoneName(int32 Joint) const;
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "Math/Rotator.h"
|
||||
#include "Math/Vector.h"
|
||||
#include "MotionControllerComponent.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
#include "Templates/UniquePtr.h"
|
||||
|
||||
#include "SGSettings/SGWristTrackingSettings.h"
|
||||
@@ -164,5 +165,15 @@ protected:
|
||||
FActorComponentTickFunction* ThisTickFunction);
|
||||
|
||||
public:
|
||||
UE_DEPRECATED(5.5, "Deprecated by UE 5.5 in favor of GetMotionControllerState and GetHandTrackingState")
|
||||
bool GetMotionControllerData(FXRMotionControllerData& OutMotionControllerData);
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
bool GetMotionControllerState(
|
||||
EXRSpaceType XRSpaceType, EXRControllerPoseType XRControllerPoseType,
|
||||
FXRMotionControllerState& OutMotionControllerState);
|
||||
bool GetHandTrackingState(
|
||||
EXRSpaceType XRSpaceType,
|
||||
FXRHandTrackingState& OutHandTrackingState);
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
};
|
||||
@@ -0,0 +1,190 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author Mamadou Babaei <mamadou@senseglove.com>
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* (The MIT License)
|
||||
*
|
||||
* Copyright (c) 2020 - 2024 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 "SGAndroid/SGAndroidPermissions.h"
|
||||
|
||||
#include "AndroidPermissionCallbackProxy.h"
|
||||
#include "AndroidPermissionFunctionLibrary.h"
|
||||
#include "Engine/Engine.h"
|
||||
|
||||
#include "SGLog/SGLog.h"
|
||||
|
||||
struct USGAndroidPermissions::FImpl
|
||||
{
|
||||
/************************
|
||||
* Member variables
|
||||
************************/
|
||||
|
||||
TFunction<void(const TArray<FString>&, const TArray<bool>&)> PermissionsGrantedCallback;
|
||||
|
||||
/************************
|
||||
* Owner object
|
||||
************************/
|
||||
|
||||
USGAndroidPermissions* Owner;
|
||||
|
||||
/************************
|
||||
* Constructor / Destructor
|
||||
************************/
|
||||
|
||||
explicit FImpl(USGAndroidPermissions* InOwner);
|
||||
~FImpl();
|
||||
|
||||
/************************
|
||||
* Default copy constructor & copy assignment operator
|
||||
************************/
|
||||
|
||||
FImpl(const FImpl& Rhs) = default;
|
||||
FImpl& operator=(const FImpl& Rhs) = default;
|
||||
};
|
||||
|
||||
USGAndroidPermissions* USGAndroidPermissions::GetInstance()
|
||||
{
|
||||
if (!ensureAlwaysMsgf(GEngine, TEXT("The engine has not been initialized!")))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
USGAndroidPermissions* Instance{GEngine->GetEngineSubsystem<USGAndroidPermissions>()};
|
||||
return Instance;
|
||||
}
|
||||
|
||||
USGAndroidPermissions::USGAndroidPermissions()
|
||||
: Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
||||
{
|
||||
}
|
||||
|
||||
void USGAndroidPermissions::Request(
|
||||
const TFunction<void(const TArray<FString>&, const TArray<bool>&)>& PermissionsGrantedCallback)
|
||||
{
|
||||
TArray<FString> Permissions{
|
||||
"android.permission.ACCESS_BACKGROUND_LOCATION",
|
||||
"android.permission.ACCESS_FINE_LOCATION",
|
||||
"android.permission.BLUETOOTH",
|
||||
"android.permission.BLUETOOTH_ADMIN",
|
||||
"android.permission.BLUETOOTH_ADVERTISE",
|
||||
"android.permission.BLUETOOTH_CONNECT",
|
||||
"android.permission.BLUETOOTH_SCAN",
|
||||
};
|
||||
|
||||
bool bHasAllRequiredPermissions = false;
|
||||
for (const FString& Permission: Permissions)
|
||||
{
|
||||
const bool bHasPermission = UAndroidPermissionFunctionLibrary::CheckPermission(Permission);
|
||||
bHasAllRequiredPermissions = bHasPermission;
|
||||
if (!bHasAllRequiredPermissions)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bHasAllRequiredPermissions)
|
||||
{
|
||||
Pimpl->PermissionsGrantedCallback = PermissionsGrantedCallback;
|
||||
|
||||
UAndroidPermissionFunctionLibrary::AcquirePermissions(
|
||||
MoveTemp(Permissions))->OnPermissionsGrantedDelegate.AddUObject(
|
||||
this, &USGAndroidPermissions::OnPermissionsGranted);
|
||||
}
|
||||
else
|
||||
{
|
||||
TArray<bool> GrantedResults;
|
||||
for (int32 i = 0; i < Permissions.Num(); ++i)
|
||||
{
|
||||
GrantedResults.Add(true);
|
||||
}
|
||||
PermissionsGrantedCallback(MoveTemp(Permissions), MoveTemp(GrantedResults));
|
||||
}
|
||||
}
|
||||
|
||||
void USGAndroidPermissions::OnPermissionsGranted(const TArray<FString>& Permissions, const TArray<bool>& GrantResults)
|
||||
{
|
||||
if (!ensureAlwaysMsgf(Permissions.Num() == GrantResults.Num(),
|
||||
TEXT("Mismatched number of Permissions and GrantedResults!")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32 i = 0; i < Permissions.Num(); i++)
|
||||
{
|
||||
if (GrantResults[i])
|
||||
{
|
||||
SGLOG("Permission Granted", Permissions[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
SGLOG("Permission Denied", Permissions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Pimpl->PermissionsGrantedCallback(Permissions, GrantResults);
|
||||
}
|
||||
|
||||
bool USGAndroidPermissions::ShouldCreateSubsystem(UObject* Outer) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void USGAndroidPermissions::Initialize(FSubsystemCollectionBase& Collection)
|
||||
{
|
||||
SGLOG("Initializing the SenseGlove Android permissions singleton with the engine lifetime...");
|
||||
|
||||
Super::Initialize(Collection);
|
||||
|
||||
SGLOG("The SenseGlove Android permissions singleton has been successfully initialized with the engine lifetime!");
|
||||
}
|
||||
|
||||
void USGAndroidPermissions::Deinitialize()
|
||||
{
|
||||
SGLOG("De-initializing the SenseGlove Android permissions singleton due to the engine lifetime expiration...");
|
||||
|
||||
Super::Deinitialize();
|
||||
|
||||
(void) Pimpl.Release();
|
||||
|
||||
SGLOG("The SenseGlove Android permissions singleton has been successfully de-initialized!");
|
||||
}
|
||||
|
||||
USGAndroidPermissions::FImpl::FImpl(USGAndroidPermissions* InOwner)
|
||||
: Owner(InOwner)
|
||||
{
|
||||
}
|
||||
|
||||
USGAndroidPermissions::FImpl::~FImpl() = default;
|
||||
|
||||
void USGAndroidPermissions::FImplDeleter::operator()(const FImpl* P) const
|
||||
{
|
||||
delete P;
|
||||
}
|
||||
@@ -35,6 +35,9 @@
|
||||
|
||||
#include "SenseGloveAndroidModule.h"
|
||||
|
||||
#include "Misc/CoreDelegates.h"
|
||||
|
||||
#include "SGAndroid/SGAndroidPermissions.h"
|
||||
#include "SGAndroid/SGConnectJNI.h"
|
||||
#include "SGAndroid/SGCoreJNI.h"
|
||||
#include "SGLog/SGLog.h"
|
||||
@@ -45,16 +48,8 @@ void FSenseGloveAndroidModule::StartupModule()
|
||||
{
|
||||
SGLOG("Starting up the SenseGloveAndroid module...");
|
||||
|
||||
#if PLATFORM_ANDROID
|
||||
const int32 R1 = FSGConnectJNI::Initialize();
|
||||
const int32 R2 = FSGCoreJNI::Initialize();
|
||||
|
||||
ensureAlwaysMsgf(R1 == 0,
|
||||
TEXT("Failed to initialize the SGConnect JNI bridge to SGConnect for Android! Status Code: %d"), R1);
|
||||
|
||||
ensureAlwaysMsgf(R2 == 0,
|
||||
TEXT("Failed to initialize the SGCore JNI bridge to SGConnect for Android! Status Code: %d"), R2);
|
||||
#endif /* PLATFORM_ANDROID */
|
||||
OnPostEngineInitHandle = FCoreDelegates::OnPostEngineInit.AddRaw(
|
||||
this, &FSenseGloveAndroidModule::OnPostEngineInit);
|
||||
}
|
||||
|
||||
void FSenseGloveAndroidModule::PreUnloadCallback()
|
||||
@@ -72,4 +67,26 @@ void FSenseGloveAndroidModule::ShutdownModule()
|
||||
SGLOG("Shutting down the SenseGloveAndroid module...");
|
||||
}
|
||||
|
||||
void FSenseGloveAndroidModule::OnPostEngineInit() const
|
||||
{
|
||||
#if PLATFORM_ANDROID
|
||||
USGAndroidPermissions::GetInstance()->Request(
|
||||
[](const TArray<FString>& Permissions, const TArray<bool>& GrantResults)
|
||||
{
|
||||
const int32 R1 = FSGConnectJNI::Initialize();
|
||||
const int32 R2 = FSGCoreJNI::Initialize();
|
||||
|
||||
ensureAlwaysMsgf(R1 == 0,
|
||||
TEXT(
|
||||
"Failed to initialize the SGConnect JNI bridge to SGConnect for Android! Status Code: %d"
|
||||
), R1);
|
||||
|
||||
ensureAlwaysMsgf(R2 == 0,
|
||||
TEXT("Failed to initialize the SGCore JNI bridge to SGConnect for Android! Status Code: %d"
|
||||
), R2);
|
||||
|
||||
});
|
||||
#endif /* PLATFORM_ANDROID */
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@@ -35,17 +35,24 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Delegates/IDelegateInstance.h"
|
||||
#include "Modules/ModuleInterface.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "SenseGloveAndroid"
|
||||
|
||||
class FSenseGloveAndroidModule : public IModuleInterface
|
||||
{
|
||||
private:
|
||||
FDelegateHandle OnPostEngineInitHandle;
|
||||
|
||||
public:
|
||||
virtual void StartupModule() override;
|
||||
virtual void PreUnloadCallback() override;
|
||||
virtual void PostLoadCallback() override;
|
||||
virtual void ShutdownModule() override;
|
||||
|
||||
private:
|
||||
void OnPostEngineInit() const;
|
||||
};
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author Mamadou Babaei <mamadou@senseglove.com>
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* (The MIT License)
|
||||
*
|
||||
* Copyright (c) 2020 - 2024 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/UnrealString.h"
|
||||
#include "Subsystems/EngineSubsystem.h"
|
||||
#include "Templates/Function.h"
|
||||
#include "Templates/SharedPointer.h"
|
||||
#include "UObject/ObjectMacros.h"
|
||||
|
||||
#include "SGAndroidPermissions.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class SENSEGLOVEANDROID_API USGAndroidPermissions : public UEngineSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
static USGAndroidPermissions* GetInstance();
|
||||
|
||||
private:
|
||||
struct FImpl;
|
||||
|
||||
struct FImplDeleter
|
||||
{
|
||||
void operator()(const FImpl* P) const;
|
||||
};
|
||||
|
||||
TUniquePtr<FImpl, FImplDeleter> Pimpl;
|
||||
FImplDeleter PimplDeleter;
|
||||
|
||||
private:
|
||||
USGAndroidPermissions();
|
||||
|
||||
public:
|
||||
void Request(
|
||||
const TFunction<void(const TArray<FString>&, const TArray<bool>&)>& PermissionsGrantedCallback);
|
||||
|
||||
private:
|
||||
void OnPermissionsGranted(
|
||||
const TArray<FString>& Permissions, const TArray<bool>& GrantResults);
|
||||
|
||||
public:
|
||||
virtual bool ShouldCreateSubsystem(UObject* Outer) const override;
|
||||
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
virtual void Deinitialize() override;
|
||||
};
|
||||
@@ -46,6 +46,7 @@ public class SenseGloveAndroid : ModuleRules
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"AndroidPermission",
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
|
||||
@@ -116,13 +116,13 @@
|
||||
</if>
|
||||
</loopElements>
|
||||
|
||||
<addPermission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
|
||||
<addPermission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
<addPermission android:name="android.permission.BLUETOOTH"/>
|
||||
<addPermission android:name="android.permission.BLUETOOTH_ADMIN"/>
|
||||
<addPermission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
|
||||
<addPermission android:name="android.permission.BLUETOOTH_CONNECT"/>
|
||||
<addPermission android:name="android.permission.BLUETOOTH_SCAN"/>
|
||||
<addPermission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
|
||||
<addPermission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
</androidManifestUpdates>
|
||||
|
||||
<buildGradleAdditions>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
#include "SGBackend.generated.h"
|
||||
|
||||
UCLASS(config = SenseGloveBackend)
|
||||
UCLASS()
|
||||
class SENSEGLOVEBACKEND_API USGBackend : public UEngineSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
TUniquePtr<FImpl, FImplDeleter> Pimpl;
|
||||
FImplDeleter PimplDeleter;
|
||||
|
||||
public:
|
||||
private:
|
||||
USGBackend();
|
||||
|
||||
public:
|
||||
|
||||
@@ -113,7 +113,9 @@ public class SenseGloveConnectImpl : ModuleRules
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
|
||||
LibraryName = string.Format("lib{0}.a", LibraryName);
|
||||
|
||||
#if UE_5_3_OR_LATER
|
||||
#if UE_5_5_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v23"));
|
||||
#elif UE_5_3_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
|
||||
#elif UE_5_2_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v21"));
|
||||
@@ -128,7 +130,9 @@ public class SenseGloveConnectImpl : ModuleRules
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
|
||||
LibraryName = string.Format("lib{0}.a", LibraryName);
|
||||
|
||||
#if UE_5_3_OR_LATER
|
||||
#if UE_5_5_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v23"));
|
||||
#elif UE_5_3_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
|
||||
#elif UE_5_2_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v21"));
|
||||
@@ -233,7 +237,9 @@ public class SenseGloveConnectImpl : ModuleRules
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
|
||||
LibraryName = string.Format("lib{0}.a", LibraryName);
|
||||
|
||||
#if UE_5_3_OR_LATER
|
||||
#if UE_5_5_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v23"));
|
||||
#elif UE_5_3_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
|
||||
#elif UE_5_2_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v21"));
|
||||
@@ -248,7 +254,9 @@ public class SenseGloveConnectImpl : ModuleRules
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
|
||||
LibraryName = string.Format("lib{0}.a", LibraryName);
|
||||
|
||||
#if UE_5_3_OR_LATER
|
||||
#if UE_5_5_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v23"));
|
||||
#elif UE_5_3_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
|
||||
#elif UE_5_2_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v21"));
|
||||
|
||||
@@ -112,7 +112,9 @@ public class SenseGloveCoreImpl : ModuleRules
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
|
||||
LibraryName = string.Format("lib{0}.a", LibraryName);
|
||||
|
||||
#if UE_5_3_OR_LATER
|
||||
#if UE_5_5_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v23"));
|
||||
#elif UE_5_3_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
|
||||
#elif UE_5_2_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v21"));
|
||||
@@ -127,7 +129,9 @@ public class SenseGloveCoreImpl : ModuleRules
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "linux"));
|
||||
LibraryName = string.Format("lib{0}.a", LibraryName);
|
||||
|
||||
#if UE_5_3_OR_LATER
|
||||
#if UE_5_5_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v23"));
|
||||
#elif UE_5_3_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v22"));
|
||||
#elif UE_5_2_OR_LATER
|
||||
LibraryPath = Path.GetFullPath(Path.Combine(LibraryPath, "v21"));
|
||||
|
||||
@@ -73,3 +73,35 @@ void FSGDebugVirtualHand::Draw(const UWorld* World,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
void FSGDebugVirtualHand::Draw(const UWorld* World,
|
||||
const FXRHandTrackingState& HandTrackingState,
|
||||
const FSGVirtualHandDebuggingSettings& Settings)
|
||||
{
|
||||
ensureAlwaysMsgf(Settings.DrawingMode != ESGDebugVirtualHandDrawingMode::None,
|
||||
TEXT("Invalid virtual hand drawing mode!"));
|
||||
|
||||
ensureAlwaysMsgf(HandTrackingState.bValid,
|
||||
TEXT("Invalid hand tracking state!"));
|
||||
|
||||
ensureAlwaysMsgf(HandTrackingState.HandKeyLocations.Num() == HandTrackingState.HandKeyRotations.Num(),
|
||||
TEXT("Mismatched hand tracking state locations and rotations!"));
|
||||
|
||||
for (TArray<FVector>::SizeType HandKeyIndex = 0;
|
||||
HandKeyIndex < HandTrackingState.HandKeyLocations.Num(); ++HandKeyIndex)
|
||||
{
|
||||
const FVector& HandKeyLocation{HandTrackingState.HandKeyLocations[HandKeyIndex]};
|
||||
const FQuat& HandKeyRotation{HandTrackingState.HandKeyRotations[HandKeyIndex]};
|
||||
|
||||
if (Settings.DrawingMode == ESGDebugVirtualHandDrawingMode::CubicJoints)
|
||||
{
|
||||
FSGDebugCube::Draw(World, HandKeyLocation, HandKeyRotation, Settings.DebugCubicHandSettings);
|
||||
}
|
||||
else if (Settings.DrawingMode == ESGDebugVirtualHandDrawingMode::GizmoJoints)
|
||||
{
|
||||
FSGDebugGizmo::Draw(World, HandKeyLocation, HandKeyRotation, Settings.DebugGizmoHandSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "HeadMountedDisplayTypes.h"
|
||||
#include "Math/Rotator.h"
|
||||
#include "Math/Vector.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
|
||||
#include "SGSettings/SGVirtualHandDebuggingSettings.h"
|
||||
|
||||
@@ -47,11 +48,19 @@ class UWorld;
|
||||
class SENSEGLOVEDEBUG_API FSGDebugVirtualHand final
|
||||
{
|
||||
public:
|
||||
UE_DEPRECATED(5.5, "Deprecated in favor of the variant that accepts FXRHandTrackingState")
|
||||
static void Draw(
|
||||
const UWorld* World,
|
||||
const FXRMotionControllerData& MotionControllerData,
|
||||
const FSGVirtualHandDebuggingSettings& Settings);
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
static void Draw(
|
||||
const UWorld* World,
|
||||
const FXRHandTrackingState& HandTrackingState,
|
||||
const FSGVirtualHandDebuggingSettings& Settings);
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
public:
|
||||
FSGDebugVirtualHand() = delete;
|
||||
virtual ~FSGDebugVirtualHand() = delete;
|
||||
|
||||
+15
-2
@@ -37,11 +37,24 @@
|
||||
|
||||
#include "SGDebug/SGDebugVirtualHand.h"
|
||||
|
||||
void USGDebugVirtualHandKismetLibrary::Draw(
|
||||
void USGDebugVirtualHandKismetLibrary::Draw_FXRMotionControllerData(
|
||||
UObject* WorldContextObject,
|
||||
const FXRMotionControllerData& MotionControllerData, const FSGVirtualHandDebuggingSettings& Settings)
|
||||
const FXRMotionControllerData& MotionControllerData,
|
||||
const FSGVirtualHandDebuggingSettings& Settings)
|
||||
{
|
||||
ensureAlwaysMsgf(WorldContextObject, TEXT("Invalid world context object!"));
|
||||
|
||||
PRAGMA_DISABLE_DEPRECATION_WARNINGS
|
||||
FSGDebugVirtualHand::Draw(WorldContextObject->GetWorld(), MotionControllerData, Settings);
|
||||
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
||||
}
|
||||
|
||||
void USGDebugVirtualHandKismetLibrary::Draw_FXRHandTrackingState(
|
||||
UObject* WorldContextObject,
|
||||
const FXRHandTrackingState& HandTrackingState,
|
||||
const FSGVirtualHandDebuggingSettings& Settings)
|
||||
{
|
||||
ensureAlwaysMsgf(WorldContextObject, TEXT("Invalid world context object!"));
|
||||
|
||||
FSGDebugVirtualHand::Draw(WorldContextObject->GetWorld(), HandTrackingState, Settings);
|
||||
}
|
||||
+12
-3
@@ -35,8 +35,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "UObject/ObjectMacros.h"
|
||||
#include "HeadMountedDisplayTypes.h"
|
||||
|
||||
#include "SGKismet/SGBlueprintFunctionLibrary.h"
|
||||
#include "SGDebug/SGDebugVirtualHand.h"
|
||||
|
||||
#include "SGDebugVirtualHandKismetLibrary.generated.h"
|
||||
|
||||
@@ -48,10 +50,17 @@ class SENSEGLOVEDEBUGKISMET_API USGDebugVirtualHandKismetLibrary final : public
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, Category="SenseGlove | Debug | Virtual Hand",
|
||||
UFUNCTION(BlueprintCallable, DisplayName="Draw", Category="SenseGlove | Debug | Virtual Hand",
|
||||
meta=(WorldContext="WorldContextObject"))
|
||||
static void Draw(
|
||||
static void Draw_FXRMotionControllerData(
|
||||
UObject* WorldContextObject,
|
||||
const FXRMotionControllerData& MotionControllerData,
|
||||
const FSGVirtualHandDebuggingSettings& Settings);
|
||||
|
||||
UFUNCTION(BlueprintCallable, DisplayName="Draw", Category="SenseGlove | Debug | Virtual Hand",
|
||||
meta=(WorldContext="WorldContextObject"))
|
||||
static void Draw_FXRHandTrackingState(
|
||||
UObject* WorldContextObject,
|
||||
const FXRHandTrackingState& HandTrackingState,
|
||||
const FSGVirtualHandDebuggingSettings& Settings);
|
||||
};
|
||||
@@ -113,7 +113,23 @@ USGHapticGlove* UVirtualHandComponentKismetLibrary::GetConnectedGlove(
|
||||
bool UVirtualHandComponentKismetLibrary::GetMotionControllerData(
|
||||
USGVirtualHandComponent* VirtualHandComponent, FXRMotionControllerData& OutMotionControllerData)
|
||||
{
|
||||
PRAGMA_DISABLE_DEPRECATION_WARNINGS
|
||||
return VirtualHandComponent->GetMotionControllerData(OutMotionControllerData);
|
||||
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
||||
}
|
||||
|
||||
bool UVirtualHandComponentKismetLibrary::GetMotionControllerState(USGVirtualHandComponent* VirtualHandComponent,
|
||||
const EXRSpaceType XRSpaceType, const EXRControllerPoseType XRControllerPoseType,
|
||||
FXRMotionControllerState& OutMotionControllerState)
|
||||
{
|
||||
return VirtualHandComponent->GetMotionControllerState(
|
||||
XRSpaceType, XRControllerPoseType, OutMotionControllerState);
|
||||
}
|
||||
|
||||
bool UVirtualHandComponentKismetLibrary::GetHandTrackingState(USGVirtualHandComponent* VirtualHandComponent,
|
||||
const EXRSpaceType XRSpaceType, FXRHandTrackingState& OutHandTrackingState)
|
||||
{
|
||||
return VirtualHandComponent->GetHandTrackingState(XRSpaceType, OutHandTrackingState);
|
||||
}
|
||||
|
||||
const TArray<FName>& UVirtualHandComponentKismetLibrary::GetHandBoneNames(
|
||||
|
||||
@@ -93,5 +93,24 @@ const FRotator& UWristTrackerComponentKismetLibrary::GetWristRotation(
|
||||
bool UWristTrackerComponentKismetLibrary::GetMotionControllerData(
|
||||
USGWristTrackerComponent* WristTrackerComponent, FXRMotionControllerData& OutMotionControllerData)
|
||||
{
|
||||
PRAGMA_DISABLE_DEPRECATION_WARNINGS
|
||||
return WristTrackerComponent->GetMotionControllerData(OutMotionControllerData);
|
||||
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
||||
}
|
||||
|
||||
bool UWristTrackerComponentKismetLibrary::GetMotionControllerState(
|
||||
USGWristTrackerComponent* WristTrackerComponent,
|
||||
const EXRSpaceType XRSpaceType, const EXRControllerPoseType XRControllerPoseType,
|
||||
FXRMotionControllerState& OutMotionControllerState)
|
||||
{
|
||||
return WristTrackerComponent->GetMotionControllerState(
|
||||
XRSpaceType, XRControllerPoseType, OutMotionControllerState);
|
||||
}
|
||||
|
||||
bool UWristTrackerComponentKismetLibrary::GetHandTrackingState(
|
||||
USGWristTrackerComponent* WristTrackerComponent,
|
||||
const EXRSpaceType XRSpaceType, FXRHandTrackingState& OutHandTrackingState)
|
||||
{
|
||||
return WristTrackerComponent->GetHandTrackingState(
|
||||
XRSpaceType, OutHandTrackingState);
|
||||
}
|
||||
@@ -106,6 +106,16 @@ public:
|
||||
static bool GetMotionControllerData(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent,
|
||||
FXRMotionControllerData& OutMotionControllerData);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Component")
|
||||
static bool GetMotionControllerState(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent,
|
||||
EXRSpaceType XRSpaceType, EXRControllerPoseType XRControllerPoseType,
|
||||
FXRMotionControllerState& OutMotionControllerState);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Component")
|
||||
static bool GetHandTrackingState(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent,
|
||||
EXRSpaceType XRSpaceType,
|
||||
FXRHandTrackingState& OutHandTrackingState);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Component")
|
||||
static const TArray<FName>& GetHandBoneNames(const USGVirtualHandComponent* VirtualHandComponent);
|
||||
|
||||
|
||||
@@ -86,4 +86,14 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Wrist Tracker Component")
|
||||
static bool GetMotionControllerData(UPARAM(ref) USGWristTrackerComponent* WristTrackerComponent,
|
||||
FXRMotionControllerData& OutMotionControllerData);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Wrist Tracker Component")
|
||||
static bool GetMotionControllerState(UPARAM(ref) USGWristTrackerComponent* WristTrackerComponent,
|
||||
EXRSpaceType XRSpaceType, EXRControllerPoseType XRControllerPoseType,
|
||||
FXRMotionControllerState& OutMotionControllerState);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Wrist Tracker Component")
|
||||
static bool GetHandTrackingState(UPARAM(ref) USGWristTrackerComponent* WristTrackerComponent,
|
||||
EXRSpaceType XRSpaceType,
|
||||
FXRHandTrackingState& OutHandTrackingState);
|
||||
};
|
||||
@@ -51,7 +51,7 @@ struct SENSEGLOVESETTINGS_API FSGGloveTrackingSettings
|
||||
|
||||
public:
|
||||
/**
|
||||
* The interval in which the tracking module checks for glove connectivity.
|
||||
* The interval in which the tracking module checks for glove connectivity (in milliseconds).
|
||||
*
|
||||
* The default is 16.666666f which means 60 times per second.
|
||||
*/
|
||||
|
||||
@@ -59,7 +59,7 @@ struct SENSEGLOVESETTINGS_API FSGTrackingSettings
|
||||
|
||||
public:
|
||||
/**
|
||||
* Determines whether to fallback to hand-tracking, or not, when no SenseGlove device is detected:
|
||||
* Determines whether to fall back to hand-tracking, or not, when no SenseGlove device is detected:
|
||||
*
|
||||
* - If disabled, only a real glove will be tracked.
|
||||
* - If enabled, the plugin will fall back to hand-tracking when it's available and supported by the HMD device.
|
||||
|
||||
@@ -58,7 +58,7 @@ struct USGGloveTracker::FImpl
|
||||
{
|
||||
const USGSettings* Settings{USGSettings::GetInstance()};
|
||||
ensureAlwaysMsgf(Settings, TEXT("The settings subsystem has not been initialized!"));
|
||||
return Settings->GetTrackingSettings().GloveTrackingSettings.GloveConnectivityCheckInterval;
|
||||
return Settings->GetTrackingSettings().GloveTrackingSettings.GloveConnectivityCheckInterval * 0.001f;
|
||||
}
|
||||
|
||||
/************************
|
||||
@@ -137,7 +137,16 @@ void USGGloveTracker::Initialize(FSubsystemCollectionBase& Collection)
|
||||
Pimpl->GloveConnectivityCheckTimer, GloveConnectivityCheckHandler, GloveConnectivityCheckInterval,
|
||||
true, -1.0f);
|
||||
|
||||
SGLOG("The glove connectivity check timer has been started successfully!");
|
||||
if (ensureAlwaysMsgf(TimerManager.IsTimerActive(Pimpl->GloveConnectivityCheckTimer),
|
||||
TEXT("GloveConnectivityCheckTimer is not active")))
|
||||
{
|
||||
SGLOG("The glove connectivity check timer has been started successfully!");
|
||||
SGLOG("The glove connectivity timer interval is: ", GloveConnectivityCheckInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
SGLOG_ERROR("The glove connectivity check timer has failed to start!");
|
||||
}
|
||||
}
|
||||
|
||||
SGLOG("The SenseGlove tracking singleton has been successfully initialized with the world lifetime!");
|
||||
|
||||
@@ -43,7 +43,8 @@ FSGXRHandState::FSGXRHandState()
|
||||
Locations{XR_TYPE_HAND_JOINT_LOCATIONS_EXT},
|
||||
KeypointTransforms{},
|
||||
Radii{},
|
||||
bReceivedJointPoses(false)
|
||||
bHasReceivedJointPoses(false),
|
||||
bTracked(false)
|
||||
{
|
||||
Velocities.jointCount = XR_HAND_JOINT_COUNT_EXT;
|
||||
Velocities.jointVelocities = JointVelocities;
|
||||
@@ -60,7 +61,7 @@ bool FSGXRHandState::GetTransform(const EHandKeypoint Keypoint, FTransform& OutT
|
||||
check(static_cast<int32>(Keypoint) < EHandKeypointCount);
|
||||
OutTransform = KeypointTransforms[static_cast<uint32>(Keypoint)];
|
||||
|
||||
return bReceivedJointPoses;
|
||||
return bHasReceivedJointPoses;
|
||||
}
|
||||
|
||||
const FTransform& FSGXRHandState::GetTransform(const EHandKeypoint Keypoint) const
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION <= 3
|
||||
#include "OpenXRHMD.h"
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION <= 3 */
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
|
||||
#include "SGCore/SGHapticGlove.h"
|
||||
#include "SGLog/SGLog.h"
|
||||
@@ -999,7 +998,9 @@ FTransform FSGXRTracker::FImpl::GetMeshFingerStartBoneRefTransform(
|
||||
}
|
||||
|
||||
bool FSGXRTracker::GetMotionControllerData(
|
||||
UObject* WorldContextObject, const EControllerHand Hand, FXRMotionControllerData& OutMotionControllerData)
|
||||
UObject* WorldContextObject,
|
||||
const EControllerHand Hand,
|
||||
FXRMotionControllerData& OutMotionControllerData)
|
||||
{
|
||||
OutMotionControllerData.DeviceName = NAME_None;
|
||||
OutMotionControllerData.ApplicationInstanceID = FApp::GetInstanceId();
|
||||
@@ -1164,9 +1165,41 @@ bool FSGXRTracker::GetMotionControllerData(
|
||||
{
|
||||
OutMotionControllerData.DeviceVisualType = EXRVisualType::Hand;
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
bool bTracked = false;
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
OutMotionControllerData.bValid = HandTracker->GetAllKeypointStates(
|
||||
Hand, OutMotionControllerData.HandKeyPositions, OutMotionControllerData.HandKeyRotations,
|
||||
OutMotionControllerData.HandKeyRadii);
|
||||
Hand,
|
||||
OutMotionControllerData.HandKeyPositions,
|
||||
OutMotionControllerData.HandKeyRotations,
|
||||
OutMotionControllerData.HandKeyRadii
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
, bTracked
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
);
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
// Unused!
|
||||
(void) bTracked;
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
// TODO
|
||||
// Begin backward compatibility with the deprecated function, remove this block along with the deprecated
|
||||
// GetAllKeypointStates (though it should be time to remove this entire function as well)!
|
||||
if (!OutMotionControllerData.bValid)
|
||||
{
|
||||
PRAGMA_DISABLE_DEPRECATION_WARNINGS
|
||||
OutMotionControllerData.bValid = HandTracker->GetAllKeypointStates(
|
||||
Hand,
|
||||
OutMotionControllerData.HandKeyPositions,
|
||||
OutMotionControllerData.HandKeyRotations,
|
||||
OutMotionControllerData.HandKeyRadii);
|
||||
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
||||
}
|
||||
// End backward compability.
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
if (!ensureAlwaysMsgf(
|
||||
!OutMotionControllerData.bValid
|
||||
@@ -1186,13 +1219,293 @@ bool FSGXRTracker::GetMotionControllerData(
|
||||
OutMotionControllerData.TrackingStatus = ETrackingStatus::Tracked;
|
||||
}
|
||||
|
||||
/// TODO
|
||||
// This is reportedly a WMR-specific convenience function for rapid prototyping. Not sure if it's useful for OpenXR.
|
||||
OutMotionControllerData.bIsGrasped = false;
|
||||
|
||||
return OutMotionControllerData.bValid;
|
||||
}
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
|
||||
bool FSGXRTracker::GetMotionControllerState(
|
||||
UObject* WorldContextObject,
|
||||
const EXRSpaceType XRSpaceType, const EControllerHand Hand, const EXRControllerPoseType XRControllerPoseType,
|
||||
FXRMotionControllerState& OutMotionControllerState)
|
||||
{
|
||||
auto ToMotionSourceName = [](
|
||||
const EControllerHand Hand, const EXRControllerPoseType XRControllerPoseType) -> FLazyName
|
||||
{
|
||||
static FLazyName LeftAim = "LeftAim";
|
||||
static FLazyName LeftGrip = "LeftGrip";
|
||||
static FLazyName LeftPalm = "LeftPalm";
|
||||
static FLazyName RightAim = "RightAim";
|
||||
static FLazyName RightGrip = "RightGrip";
|
||||
static FLazyName RightPalm = "RightPalm";
|
||||
if (Hand == EControllerHand::Left)
|
||||
{
|
||||
switch (XRControllerPoseType)
|
||||
{
|
||||
case EXRControllerPoseType::Aim:
|
||||
return LeftAim;
|
||||
case EXRControllerPoseType::Grip:
|
||||
return LeftGrip;
|
||||
case EXRControllerPoseType::Palm:
|
||||
return LeftPalm;
|
||||
default:
|
||||
check(false);
|
||||
return LeftGrip;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (XRControllerPoseType)
|
||||
{
|
||||
case EXRControllerPoseType::Aim:
|
||||
return RightAim;
|
||||
case EXRControllerPoseType::Grip:
|
||||
return RightGrip;
|
||||
case EXRControllerPoseType::Palm:
|
||||
return RightPalm;
|
||||
default:
|
||||
check(false);
|
||||
return RightGrip;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
OutMotionControllerState.DeviceName = NAME_None;
|
||||
OutMotionControllerState.ApplicationInstanceID = FApp::GetInstanceId();
|
||||
OutMotionControllerState.TrackingStatus = ETrackingStatus::NotTracked;
|
||||
OutMotionControllerState.Hand = Hand;
|
||||
OutMotionControllerState.XRSpaceType = XRSpaceType;
|
||||
OutMotionControllerState.bValid = false;
|
||||
|
||||
if (!IsValid(WorldContextObject))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsValid(WorldContextObject))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IXRTrackingSystem* XRTrackingSystem{GEngine ? GEngine->XRSystem.Get() : nullptr};
|
||||
if (!XRTrackingSystem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 4
|
||||
IOpenXRHMD* OpenXRHMD{XRTrackingSystem->GetIOpenXRHMD()};
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 4 */
|
||||
FOpenXRHMD* OpenXRHMD{static_cast<FOpenXRHMD*>(GEngine->XRSystem.Get())};
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 4 */
|
||||
if (!OpenXRHMD)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TArray<int32> Devices;
|
||||
const int32 HandIndex = static_cast<int32>(Hand);
|
||||
const bool bGotDevices =
|
||||
XRTrackingSystem->EnumerateTrackedDevices(Devices, EXRTrackedDeviceType::Controller);
|
||||
if (bGotDevices && Devices.IsValidIndex(HandIndex))
|
||||
{
|
||||
const XrSession Session{OpenXRHMD->GetSession()};
|
||||
if (Session)
|
||||
{
|
||||
XrInteractionProfileState Profile = {XR_TYPE_INTERACTION_PROFILE_STATE};
|
||||
const XrPath TopLevelUserPath{OpenXRHMD->GetTrackedDevicePath(Devices[HandIndex])};
|
||||
const XrResult CurrentInteractionProfile{
|
||||
xrGetCurrentInteractionProfile(Session, TopLevelUserPath, &Profile)
|
||||
};
|
||||
if (XR_SUCCEEDED(CurrentInteractionProfile) && Profile.interactionProfile != XR_NULL_PATH)
|
||||
{
|
||||
OutMotionControllerState.DeviceName = FOpenXRPath(Profile.interactionProfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((Hand == EControllerHand::Left) || (Hand == EControllerHand::Right))
|
||||
{
|
||||
static const FName MotionControllerName("OpenXR");
|
||||
TArray<IMotionController*> MotionControllers{
|
||||
IModularFeatures::Get().GetModularFeatureImplementations<IMotionController>(
|
||||
IMotionController::GetModularFeatureName())
|
||||
};
|
||||
IMotionController* MotionController{nullptr};
|
||||
for (IMotionController* MotionControllerIterator: MotionControllers)
|
||||
{
|
||||
if (!MotionControllerIterator)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const FName DeviceTypeName{MotionControllerIterator->GetMotionControllerDeviceTypeName()};
|
||||
if (DeviceTypeName != MotionControllerName)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
MotionController = MotionControllerIterator;
|
||||
break;
|
||||
}
|
||||
|
||||
if (MotionController)
|
||||
{
|
||||
{
|
||||
// Handle the pose that is actually being requested.
|
||||
|
||||
const FName MotionSource{ToMotionSourceName(Hand, XRControllerPoseType)};
|
||||
const FTransform TrackingToWorld{
|
||||
XRSpaceType == EXRSpaceType::UnrealWorldSpace
|
||||
? XRTrackingSystem->GetTrackingToWorldTransform()
|
||||
: FTransform::Identity
|
||||
};
|
||||
const float WorldToMeters = XRSpaceType == EXRSpaceType::UnrealWorldSpace
|
||||
? XRTrackingSystem->GetWorldToMetersScale()
|
||||
: 100.0f;
|
||||
|
||||
FVector Position{FVector::ZeroVector};
|
||||
FRotator Rotation{FRotator::ZeroRotator};
|
||||
|
||||
bool bGotMotionControllerOrientationAndPosition = MotionController->GetControllerOrientationAndPosition(
|
||||
0, MotionSource, Rotation, Position, WorldToMeters);
|
||||
|
||||
if (bGotMotionControllerOrientationAndPosition)
|
||||
{
|
||||
OutMotionControllerState.ControllerLocation = TrackingToWorld.TransformPosition(Position);
|
||||
OutMotionControllerState.ControllerRotation = TrackingToWorld.TransformRotation(FQuat{Rotation});
|
||||
}
|
||||
|
||||
OutMotionControllerState.bValid |= bGotMotionControllerOrientationAndPosition;
|
||||
OutMotionControllerState.TrackingStatus =
|
||||
MotionController->GetControllerTrackingStatus(0, MotionSource);
|
||||
}
|
||||
|
||||
{
|
||||
// We always provide the grip transform in Unreal space for XRVisualizationFunctionLibrary;
|
||||
// The bValid and TrackingStatus above are also valid for this pose.
|
||||
|
||||
const FName MotionSource = ToMotionSourceName(Hand, EXRControllerPoseType::Grip);
|
||||
const FTransform TrackingToWorld{XRTrackingSystem->GetTrackingToWorldTransform()};
|
||||
const float WorldToMeters = XRTrackingSystem->GetWorldToMetersScale();
|
||||
|
||||
FVector Position = FVector::ZeroVector;
|
||||
FRotator Rotation = FRotator::ZeroRotator;
|
||||
|
||||
bool bGotMotionControllerOrientationAndPosition = MotionController->GetControllerOrientationAndPosition(
|
||||
0, MotionSource, Rotation, Position, WorldToMeters);
|
||||
|
||||
if (bGotMotionControllerOrientationAndPosition)
|
||||
{
|
||||
OutMotionControllerState.GripUnrealSpaceLocation = TrackingToWorld.TransformPosition(Position);
|
||||
OutMotionControllerState.GripUnrealSpaceRotation =
|
||||
TrackingToWorld.TransformRotation(FQuat(Rotation));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return OutMotionControllerState.bValid;
|
||||
}
|
||||
|
||||
bool FSGXRTracker::GetHandTrackingState(
|
||||
UObject* WorldContextObject,
|
||||
const EXRSpaceType XRSpaceType, const EControllerHand Hand,
|
||||
FXRHandTrackingState& OutHandTrackingState)
|
||||
{
|
||||
OutHandTrackingState.ApplicationInstanceID = FApp::GetInstanceId();
|
||||
OutHandTrackingState.TrackingStatus = ETrackingStatus::NotTracked;
|
||||
OutHandTrackingState.Hand = Hand;
|
||||
OutHandTrackingState.XRSpaceType = XRSpaceType;
|
||||
OutHandTrackingState.bValid = false;
|
||||
|
||||
if (!IsValid(WorldContextObject))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IXRTrackingSystem* XRTrackingSystem{GEngine ? GEngine->XRSystem.Get() : nullptr};
|
||||
if (!XRTrackingSystem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 4
|
||||
IOpenXRHMD* OpenXRHMD{XRTrackingSystem->GetIOpenXRHMD()};
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 4 */
|
||||
FOpenXRHMD* OpenXRHMD{static_cast<FOpenXRHMD*>(GEngine->XRSystem.Get())};
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 4 */
|
||||
if (!OpenXRHMD)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
FName HandTrackerName("OpenXRHandTracking");
|
||||
TArray<IHandTracker*> HandTrackers = IModularFeatures::Get().GetModularFeatureImplementations<IHandTracker>(
|
||||
IHandTracker::GetModularFeatureName());
|
||||
IHandTracker* HandTracker = nullptr;
|
||||
for (auto Itr: HandTrackers)
|
||||
{
|
||||
if (Itr->GetHandTrackerDeviceTypeName() == HandTrackerName)
|
||||
{
|
||||
HandTracker = Itr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Hand == EControllerHand::Left) || (Hand == EControllerHand::Right))
|
||||
{
|
||||
const bool bHandTrackingStateValid = HandTracker && HandTracker->IsHandTrackingStateValid();
|
||||
if (bHandTrackingStateValid)
|
||||
{
|
||||
bool bTracked = false;
|
||||
OutHandTrackingState.bValid = HandTracker->GetAllKeypointStates(
|
||||
Hand,
|
||||
OutHandTrackingState.HandKeyLocations,
|
||||
OutHandTrackingState.HandKeyRotations,
|
||||
OutHandTrackingState.HandKeyRadii,
|
||||
bTracked);
|
||||
|
||||
/// TODO
|
||||
// Begin backward compatibility with the deprecated function, remove this block along with the deprecated
|
||||
// GetAllKeypointStates.
|
||||
if (!OutHandTrackingState.bValid)
|
||||
{
|
||||
PRAGMA_DISABLE_DEPRECATION_WARNINGS
|
||||
OutHandTrackingState.bValid = HandTracker->GetAllKeypointStates(
|
||||
Hand,
|
||||
OutHandTrackingState.HandKeyLocations,
|
||||
OutHandTrackingState.HandKeyRotations,
|
||||
OutHandTrackingState.HandKeyRadii);
|
||||
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
||||
bTracked = OutHandTrackingState.bValid;
|
||||
// The inability to distinguish this is the reason for the deprecation.
|
||||
}
|
||||
// End backward compability.
|
||||
|
||||
if (!ensureAlwaysMsgf(
|
||||
!OutHandTrackingState.bValid
|
||||
|| (OutHandTrackingState.HandKeyLocations.Num() == EHandKeypointCount
|
||||
&& OutHandTrackingState.HandKeyRotations.Num() == EHandKeypointCount
|
||||
&& OutHandTrackingState.HandKeyRadii.Num() == EHandKeypointCount),
|
||||
TEXT("Corrupted OutHandTrackingState!")))
|
||||
{
|
||||
OutHandTrackingState.bValid = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (OutHandTrackingState.bValid)
|
||||
{
|
||||
OutHandTrackingState.TrackingStatus = bTracked ? ETrackingStatus::Tracked : ETrackingStatus::NotTracked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return OutHandTrackingState.bValid;
|
||||
}
|
||||
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
FSGXRTracker::FSGXRTracker(const TSharedRef<FGenericApplicationMessageHandler>& InMessageHandler)
|
||||
: Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
||||
{
|
||||
@@ -1462,7 +1775,7 @@ ETrackingStatus FSGXRTracker::GetControllerTrackingStatus(const int32 Controller
|
||||
if (bFallbackToHandTrackingIfNoGloveDetected)
|
||||
{
|
||||
const FSGXRHandState& HandState{bRight ? GetRightHandState() : GetLeftHandState()};
|
||||
return HandState.bReceivedJointPoses ? ETrackingStatus::Tracked : ETrackingStatus::NotTracked;
|
||||
return HandState.bTracked ? ETrackingStatus::Tracked : ETrackingStatus::NotTracked;
|
||||
}
|
||||
|
||||
return ETrackingStatus::NotTracked;
|
||||
@@ -1588,9 +1901,17 @@ bool FSGXRTracker::GetKeypointState(
|
||||
return bGotTransform;
|
||||
}
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
bool FSGXRTracker::GetAllKeypointStates(
|
||||
const EControllerHand Hand,
|
||||
TArray<FVector>& OutPositions, TArray<FQuat>& OutRotations, TArray<float>& OutRadii,
|
||||
bool& OutIsTracked) const
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
bool FSGXRTracker::GetAllKeypointStates(
|
||||
const EControllerHand Hand,
|
||||
TArray<FVector>& OutPositions, TArray<FQuat>& OutRotations, TArray<float>& OutRadii) const
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5*/
|
||||
|
||||
{
|
||||
if (!IsHandTrackingStateValid())
|
||||
{
|
||||
@@ -1611,11 +1932,17 @@ bool FSGXRTracker::GetAllKeypointStates(
|
||||
Hand == EControllerHand::Left ? GetLeftHandState() : GetRightHandState()
|
||||
};
|
||||
|
||||
if (!HandState.bReceivedJointPoses)
|
||||
if (!HandState.bHasReceivedJointPoses)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
OutIsTracked = HandState.bTracked;
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5*/
|
||||
|
||||
// If we ever received poses we return the last data we received, even if not currently tracking to avoid poping
|
||||
// back to (0.0f, 0.0f, 0.0f) and the like.
|
||||
OutPositions.Empty(EHandKeypointCount);
|
||||
OutRotations.Empty(EHandKeypointCount);
|
||||
OutRadii.Empty(EHandKeypointCount);
|
||||
@@ -1747,8 +2074,9 @@ bool FSGXRTracker::FImpl::UpdateXRHandTrackingData(
|
||||
|
||||
XR_ENSURE(XRLocateHandJointsEXT(OutHandState.HandTracker, &LocateInfo, &OutHandState.Locations));
|
||||
|
||||
OutHandState.bReceivedJointPoses = OutHandState.Locations.isActive == XR_TRUE;
|
||||
if (!OutHandState.bReceivedJointPoses)
|
||||
OutHandState.bTracked = OutHandState.Locations.isActive == XR_TRUE;
|
||||
OutHandState.bHasReceivedJointPoses |= HandStates->bTracked;
|
||||
if (!OutHandState.bTracked)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1875,21 +2203,16 @@ bool FSGXRTracker::FImpl::GetControllerTransform(
|
||||
if (!bTracked && bFallbackToHandTrackingIfNoGloveDetected)
|
||||
{
|
||||
const FSGXRHandState& HandState{bRight ? Owner->GetRightHandState() : Owner->GetLeftHandState()};
|
||||
if (!HandState.bReceivedJointPoses)
|
||||
if (!HandState.bHasReceivedJointPoses)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const EHandKeypoint KeyPoint = KeyPointInfoPtr->Key;
|
||||
const FTransform& ControllerTransform{
|
||||
bRight
|
||||
? GetRightHandState().GetTransform(KeyPoint)
|
||||
: GetLeftHandState().GetTransform(KeyPoint)
|
||||
};
|
||||
|
||||
const FTransform& ControllerTransform{HandStates->GetTransform(KeyPoint)};
|
||||
OutTransform = ControllerTransform;
|
||||
bOutMotionSourceHandTracking = true;
|
||||
bTracked = true;
|
||||
bTracked = HandState.bTracked;
|
||||
}
|
||||
|
||||
return bTracked;
|
||||
@@ -2386,7 +2709,8 @@ bool FSGXRTracker::FImpl::UpdateSGHandState(const bool bRight, FSGXRHandState& O
|
||||
return false;
|
||||
}
|
||||
|
||||
OutHandState.bReceivedJointPoses = true;
|
||||
OutHandState.bHasReceivedJointPoses = true;
|
||||
OutHandState.bTracked = true;
|
||||
|
||||
const TArray<TArray<FVector>> JointLocations{HandPose->GetJointPositions()};
|
||||
const TArray<TArray<FQuat>> JointRotations{HandPose->GetJointRotationsQ()};
|
||||
|
||||
@@ -51,12 +51,16 @@ public:
|
||||
XrHandJointVelocitiesEXT Velocities;
|
||||
XrHandJointLocationsEXT Locations;
|
||||
|
||||
// Transforms are cached in Unreal Tracking Space
|
||||
// Transforms are cached in Unreal Tracking Space.
|
||||
FTransform KeypointTransforms[EHandKeypointCount];
|
||||
|
||||
float Radii[EHandKeypointCount];
|
||||
|
||||
bool bReceivedJointPoses;
|
||||
// true if this hand has ever been tracked, and therefore its poses are valid.
|
||||
bool bHasReceivedJointPoses;
|
||||
|
||||
// true if tracked right now.
|
||||
bool bTracked;
|
||||
|
||||
public:
|
||||
FSGXRHandState();
|
||||
|
||||
@@ -55,8 +55,22 @@ class SENSEGLOVETRACKING_API FSGXRTracker final : public IOpenXRExtensionPlugin,
|
||||
public IHandTracker
|
||||
{
|
||||
public:
|
||||
static bool GetMotionControllerData(UObject* WorldContextObject, EControllerHand Hand,
|
||||
FXRMotionControllerData& OutMotionControllerData);
|
||||
UE_DEPRECATED(5.5, "Deprecated by UE 5.5 in favor of GetMotionControllerState and GetHandTrackingState")
|
||||
static bool GetMotionControllerData(
|
||||
UObject* WorldContextObject,
|
||||
EControllerHand Hand,
|
||||
FXRMotionControllerData& OutMotionControllerData);
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
static bool GetMotionControllerState(
|
||||
UObject* WorldContextObject,
|
||||
EXRSpaceType XRSpaceType, EControllerHand Hand, EXRControllerPoseType XRControllerPoseType,
|
||||
FXRMotionControllerState& OutMotionControllerState);
|
||||
static bool GetHandTrackingState(
|
||||
UObject* WorldContextObject,
|
||||
EXRSpaceType XRSpaceType, EControllerHand Hand,
|
||||
FXRHandTrackingState& OutHandTrackingState);
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
private:
|
||||
struct FImpl;
|
||||
@@ -158,7 +172,15 @@ public:
|
||||
virtual bool GetKeypointState(
|
||||
EControllerHand Hand,
|
||||
EHandKeypoint Keypoint, FTransform& OutTransform, float& OutRadius) const override;
|
||||
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
virtual bool GetAllKeypointStates(
|
||||
EControllerHand Hand,
|
||||
TArray<FVector>& OutPositions, TArray<FQuat>& OutRotations, TArray<float>& OutRadii,
|
||||
bool& OutIsTracked) const override;
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
virtual bool GetAllKeypointStates(
|
||||
EControllerHand Hand,
|
||||
TArray<FVector>& OutPositions, TArray<FQuat>& OutRotations, TArray<float>& OutRadii) const override;
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
};
|
||||
@@ -42,5 +42,24 @@
|
||||
bool USGXRTrackerKismetLibrary::GetMotionControllerData(
|
||||
UObject* WorldContextObject, const EControllerHand Hand, FXRMotionControllerData& OutMotionControllerData)
|
||||
{
|
||||
PRAGMA_DISABLE_DEPRECATION_WARNINGS
|
||||
return FSGXRTracker::GetMotionControllerData(WorldContextObject, Hand, OutMotionControllerData);
|
||||
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
||||
}
|
||||
|
||||
bool USGXRTrackerKismetLibrary::GetMotionControllerState(
|
||||
UObject* WorldContextObject,
|
||||
const EXRSpaceType XRSpaceType, const EControllerHand Hand, const EXRControllerPoseType XRControllerPoseType,
|
||||
FXRMotionControllerState& OutMotionControllerState)
|
||||
{
|
||||
return FSGXRTracker::GetMotionControllerState(
|
||||
WorldContextObject, XRSpaceType, Hand, XRControllerPoseType, OutMotionControllerState);
|
||||
}
|
||||
|
||||
bool USGXRTrackerKismetLibrary::GetHandTrackingState(
|
||||
UObject* WorldContextObject,
|
||||
const EXRSpaceType XRSpaceType, const EControllerHand Hand,
|
||||
FXRHandTrackingState& OutHandTrackingState)
|
||||
{
|
||||
return FSGXRTracker::GetHandTrackingState(WorldContextObject, XRSpaceType, Hand, OutHandTrackingState);
|
||||
}
|
||||
@@ -53,6 +53,22 @@ class SENSEGLOVETRACKINGKISMET_API USGXRTrackerKismetLibrary final : public USGB
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, Category="SenseGlove | Tracking | XR Tracker",
|
||||
meta=(WorldContext="WorldContextObject"))
|
||||
static bool GetMotionControllerData(UObject* WorldContextObject, EControllerHand Hand,
|
||||
FXRMotionControllerData& OutMotionControllerData);
|
||||
static bool GetMotionControllerData(
|
||||
UObject* WorldContextObject,
|
||||
EControllerHand Hand,
|
||||
FXRMotionControllerData& OutMotionControllerData);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="SenseGlove | Tracking | XR Tracker",
|
||||
meta=(WorldContext="WorldContextObject"))
|
||||
static bool GetMotionControllerState(
|
||||
UObject* WorldContextObject,
|
||||
EXRSpaceType XRSpaceType, EControllerHand Hand, EXRControllerPoseType XRControllerPoseType,
|
||||
FXRMotionControllerState& OutMotionControllerState);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="SenseGlove | Tracking | XR Tracker",
|
||||
meta=(WorldContext="WorldContextObject"))
|
||||
static bool GetHandTrackingState(
|
||||
UObject* WorldContextObject,
|
||||
EXRSpaceType XRSpaceType, EControllerHand Hand,
|
||||
FXRHandTrackingState& OutHandTrackingState);
|
||||
};
|
||||
@@ -35,12 +35,14 @@
|
||||
|
||||
#include "SGUtils/SGEngineUtils.h"
|
||||
|
||||
#include "CoreGlobals.h"
|
||||
#if WITH_EDITOR
|
||||
#include "Editor.h"
|
||||
#endif /* WITH_EDITOR */
|
||||
#include "Engine/Engine.h"
|
||||
#include "Engine/GameViewportClient.h"
|
||||
#include "Engine/World.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
#include "Subsystems/EngineSubsystem.h"
|
||||
|
||||
UWorld* FSGEngineUtils::GetWorld()
|
||||
@@ -53,8 +55,21 @@ UWorld* FSGEngineUtils::GetWorld()
|
||||
if (IsValid(GEditor))
|
||||
{
|
||||
{
|
||||
const bool bIsPIE = GPlayInEditorID != -1;
|
||||
const int32 WorldPIEInstance = bIsPIE ? GPlayInEditorID : 1;
|
||||
const bool bIsPIE =
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
UE::GetPlayInEditorID()
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
GPlayInEditorID
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
!= -1;
|
||||
const int32 WorldPIEInstance = bIsPIE
|
||||
?
|
||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||
UE::GetPlayInEditorID()
|
||||
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
GPlayInEditorID
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
: 1;
|
||||
const FWorldContext* WorldContext{GEditor->GetPIEWorldContext(WorldPIEInstance)};
|
||||
if (WorldContext)
|
||||
{
|
||||
|
||||
BIN
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user