4#include "CoreMinimal.h"
5#include "UObject/Object.h"
6#include "Engine/Texture.h"
7#include "Engine/EngineTypes.h"
8#include "HeadMountedDisplayTypes.h"
11#include "Animation/AnimInstanceProxy.h"
13#include "Engine/DataAsset.h"
15#include "OpenXRHandPoseComponent.generated.h"
17USTRUCT(BlueprintType, Category =
"VRExpansionFunctions|OpenXR|HandSkeleton")
23 UPROPERTY(Transient, NotReplicated)
26 UPROPERTY(Transient, NotReplicated)
27 bool bAllowDeformingMesh;
30 UPROPERTY(Transient, NotReplicated)
31 bool bEnableUE4HandRepSavings;
33 UPROPERTY(Transient, NotReplicated)
34 TArray<FTransform> SkeletalTransforms;
36 UPROPERTY(Transient, NotReplicated)
43 bAllowDeformingMesh =
false;
44 bEnableUE4HandRepSavings =
true;
50 return SkeletalTransforms.Num() > 0;
56 bool NetSerialize(FArchive& Ar,
class UPackageMap* Map,
bool& bOutSuccess);
64 WithNetSerializer =
true
68USTRUCT(BlueprintType, Category =
"VRGestures")
75 UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "VRGesture")
79 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "VRGesture")
83 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "VRGesture", meta = (ClampMin = "0.0", ClampMax = "100.0", UIMin = "0.0", UIMax = "100.0"))
100USTRUCT(BlueprintType, Category =
"VRGestures")
107 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category =
"VRGesture")
111 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "VRGesture")
120 void InitPoseValues()
133UCLASS(BlueprintType, Category =
"VRGestures")
140 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category =
"VRGestures")
141 TArray <FOpenXRGesture> Gestures;
151UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent))
160 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category =
"VRGestures")
163 UFUNCTION(BlueprintCallable, Category = "VRGestures")
164 void SetDetectGestures(
bool bNewDetectGestures)
166 bDetectGestures = bNewDetectGestures;
169 UPROPERTY(BlueprintAssignable, Category =
"VRGestures")
170 FOpenXRGestureDetected OnNewGestureDetected;
172 UPROPERTY(BlueprintAssignable, Category = "VRGestures")
173 FOpenXRGestureEnded OnGestureEnded;
176 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "VRGestures")
179 UFUNCTION(BlueprintCallable, Category = "VRGestures")
182 UFUNCTION(BlueprintCallable, Category = "VRGestures", meta = (
DisplayName = "DetectCurrentPose"))
189 inline
bool IsLocallyControlled()
const
191#if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 22
192 const AActor* MyOwner = GetOwner();
193 return MyOwner->HasLocalNetOwner();
196 const AActor* MyOwner = GetOwner();
197 const APawn* MyPawn = Cast<APawn>(MyOwner);
198 return MyPawn ? MyPawn->IsLocallyControlled() : (MyOwner && MyOwner->Role == ENetRole::ROLE_Authority);
203 void TickComponent(
float DeltaTime,
enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
override;
207 virtual void BeginPlay()
override;
209 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
"SkeletalData|Actions")
210 bool bGetMockUpPoseForDebugging;
212 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SkeletalData|Actions")
215 UPROPERTY(Replicated, Transient, ReplicatedUsing = OnRep_SkeletalTransformLeft)
218 UPROPERTY(Replicated, Transient, ReplicatedUsing = OnRep_SkeletalTransformRight)
221 UFUNCTION(Unreliable, Server, WithValidation)
224 bool bLerpingPositionLeft;
225 bool bReppedOnceLeft;
227 bool bLerpingPositionRight;
228 bool bReppedOnceRight;
232 bool bReplicatedOnce;
236 TArray<FTransform> NewTransforms;
250 FTransformLerpManager LeftHandRepManager;
251 FTransformLerpManager RightHandRepManager;
254 virtual
void OnRep_SkeletalTransformLeft()
256 for (
int i = 0; i < HandSkeletalActions.Num(); i++)
258 if (HandSkeletalActions[i].TargetHand == LeftHandRep.TargetHand)
260 HandSkeletalActions[i].OldSkeletalTransforms = HandSkeletalActions[i].SkeletalTransforms;
264 if(bSmoothReplicatedSkeletalData)
265 LeftHandRepManager.NotifyNewData(HandSkeletalActions[i], ReplicationRateForSkeletalAnimations);
272 virtual
void OnRep_SkeletalTransformRight()
274 for (
int i = 0; i < HandSkeletalActions.Num(); i++)
276 if (HandSkeletalActions[i].TargetHand == RightHandRep.TargetHand)
278 HandSkeletalActions[i].OldSkeletalTransforms = HandSkeletalActions[i].SkeletalTransforms;
282 if (bSmoothReplicatedSkeletalData)
283 RightHandRepManager.NotifyNewData(HandSkeletalActions[i], ReplicationRateForSkeletalAnimations);
290 UPROPERTY(EditAnywhere, Category = SkeletalData)
291 bool bReplicateSkeletalData;
294 UPROPERTY(EditAnywhere, Category = SkeletalData)
295 bool bSmoothReplicatedSkeletalData;
297 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = SkeletalData)
298 float ReplicationRateForSkeletalAnimations;
301 float SkeletalNetUpdateCount;
303 float SkeletalUpdateCount;
316 virtual void PreUpdate(
UAnimInstance* InAnimInstance,
float DeltaSeconds)
override;
321 TArray<FBPOpenXRActionSkeletalData> HandSkeletalActionData;
325UCLASS(transient, Blueprintable, hideCategories = AnimInstance, BlueprintType)
343 virtual void NativeBeginPlay()
override;
347 UFUNCTION(BlueprintCallable, Category =
"BoneMappings")
EVRSkeletalHandIndex
UENUM(BlueprintType)
EXRHandJointType
UENUM(BlueprintType)
@ OXR_HAND_JOINT_LITTLE_TIP_EXT
@ OXR_HAND_JOINT_INDEX_TIP_EXT
@ OXR_HAND_JOINT_MIDDLE_TIP_EXT
@ OXR_HAND_JOINT_THUMB_TIP_EXT
@ OXR_HAND_JOINT_RING_TIP_EXT
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOpenXRGestureDetected, const FName &, GestureDetected, int32, GestureIndex, EVRSkeletalHandIndex, ActionHandType)
UCLASS(transient, Blueprintable, hideCategories = AnimInstance, BlueprintType)
virtual FAnimInstanceProxy * CreateAnimInstanceProxy() override
FOpenXRAnimInstanceProxy AnimInstanceProxy
UOpenXRHandPoseComponent * OwningPoseComp
UPROPERTY(transient)
UCLASS(BlueprintType, Category = "VRGestures")
TArray< FOpenXRGesture > Gestures
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "VRGestures")
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent))
FTransformLerpManager LeftHandRepManager
bool bSmoothReplicatedSkeletalData
UPROPERTY(EditAnywhere, Category = SkeletalData)
virtual void OnRep_SkeletalTransformLeft()
UFUNCTION()
TArray< FBPOpenXRActionSkeletalData > HandSkeletalActions
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SkeletalData|Actions")
FBPSkeletalRepContainer RightHandRep
UPROPERTY(Replicated, Transient, ReplicatedUsing = OnRep_SkeletalTransformRight)
bool bDetectGestures
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "VRGestures")
bool bLerpingPositionLeft
bool bGetMockUpPoseForDebugging
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SkeletalData|Actions")
bool bReplicateSkeletalData
UPROPERTY(EditAnywhere, Category = SkeletalData)
FBPSkeletalRepContainer LeftHandRep
UPROPERTY(Replicated, Transient, ReplicatedUsing = OnRep_SkeletalTransformLeft)
UOpenXRGestureDatabase * GesturesDB
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "VRGestures")
FOpenXRGestureEnded OnGestureEnded
UPROPERTY(BlueprintAssignable, Category = "VRGestures")
float ReplicationRateForSkeletalAnimations
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = SkeletalData)
virtual void OnRep_SkeletalTransformRight()
UFUNCTION()
void SetDetectGestures(bool bNewDetectGestures)
UFUNCTION(BlueprintCallable, Category = "VRGestures")
float SkeletalNetUpdateCount
bool bLerpingPositionRight
FOpenXRGestureDetected OnNewGestureDetected
UPROPERTY(BlueprintAssignable, Category = "VRGestures")
bool IsLocallyControlled() const
FTransformLerpManager RightHandRepManager
void Server_SendSkeletalTransforms(const FBPSkeletalRepContainer &SkeletalInfo)
UFUNCTION(Unreliable, Server, WithValidation)
float SkeletalUpdateCount
USTRUCT(BlueprintType, Category = "VRExpansionFunctions|OpenXR|HandSkeleton")
TArray< FTransform > OldSkeletalTransforms
UPROPERTY(BlueprintReadOnly, NotReplicated, Transient, Category = Default)
TArray< FTransform > SkeletalTransforms
UPROPERTY(BlueprintReadOnly, NotReplicated, Transient, Category = Default)
USTRUCT(BlueprintType, Category = "VRExpansionFunctions|SteamVR|HandSkeleton")
USTRUCT(BlueprintType, Category = "VRExpansionFunctions|OpenXR|HandSkeleton")
uint8 BoneCount
UPROPERTY(Transient, NotReplicated)
EVRSkeletalHandIndex TargetHand
UPROPERTY(Transient, NotReplicated)
bool bEnableUE4HandRepSavings
UPROPERTY(Transient, NotReplicated)
bool bAllowDeformingMesh
UPROPERTY(Transient, NotReplicated)
TArray< FTransform > SkeletalTransforms
UPROPERTY(Transient, NotReplicated)
FBPSkeletalRepContainer()
static void CopyReplicatedTo(const FBPSkeletalRepContainer &Container, FBPOpenXRActionSkeletalData &Other)
EVRSkeletalHandIndex TargetHand
TArray< FBPOpenXRActionSkeletalData > HandSkeletalActionData
FOpenXRAnimInstanceProxy()
USTRUCT(BlueprintType, Category = "VRGestures")
float Threshold
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "VRGesture", meta = (ClampMin = "0....
EXRHandJointType IndexType
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "VRGesture")
FOpenXRGestureFingerPosition(FVector TipLoc, EXRHandJointType Type)
FOpenXRGestureFingerPosition()
FVector Value
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "VRGesture")
USTRUCT(BlueprintType, Category = "VRGestures")
FName Name
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "VRGesture")
TArray< FOpenXRGestureFingerPosition > FingerValues
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "VRGesture")