Unreal SDK  v1.3.0
Loading...
Searching...
No Matches
WeArtHandController.h
Go to the documentation of this file.
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "..\Common\WeArtFingerState.h"
7#include "WeArtContactPoint.h"
8#include "WeArtDebugActor.h"
10#include "WeArtFingerType.h"
11#include "Components/ActorComponent.h"
13#include "WeArtHapticObject.h"
15#include "WeArtGraspEvents.h"
17#include "WeArtMessages.h"
18#include "WeArtVirtualHand.h"
19
21
28UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
29class WEARTPLUGIN_API UWeArtHandController : public UActorComponent
30{
31 GENERATED_BODY()
32
33public:
35 UPROPERTY(BlueprintReadWrite)
36 TEnumAsByte<EHandSide> EHandSide;
37
39 UPROPERTY(BlueprintReadOnly)
40 AActor* GrabbedObject;
41
43 UPROPERTY(EditAnywhere, BlueprintReadWrite)
44 UWeArtTouchableObject* TouchedObject;
46 UPROPERTY(EditAnywhere, BlueprintReadWrite)
47 UWeArtTouchableObject* TouchedObjectByThumb;
49 UPROPERTY(EditAnywhere, BlueprintReadWrite)
50 UWeArtTouchableObject* TouchedObjectByIndex;
52 UPROPERTY(EditAnywhere, BlueprintReadWrite)
53 UWeArtTouchableObject* TouchedObjectByMiddle;
55 UPROPERTY(EditAnywhere, BlueprintReadWrite)
56 FUFingerState IndexState;
57 UPROPERTY(EditAnywhere, BlueprintReadWrite)
58 FUFingerState MiddleState;
59 UPROPERTY(EditAnywhere, BlueprintReadWrite)
60 FUFingerState ThumbState;
61 UPROPERTY(EditAnywhere, BlueprintReadWrite)
62 FUFingerState PalmState;
63
65
68
70 FOnGrabbed OnGrabbed;
71
73 void UpdateClosureLimitsWhenGrabbed();
74
76 void OnReleasedGrabbedObject();
78 void HandleGraspingState(void);
79 virtual void TickComponent(float DeltaTime, ELevelTick TickType,
80 FActorComponentTickFunction* ThisTickFunction) override;
81
82 bool CanControllerGrab();
83
85 UPROPERTY()
86 AWeArtGraspEvents* WeArtGraspEvents;
87
89 UWeArtHapticObject* GetThumbHapticObject() const;
91 UWeArtHapticObject* GetIndexHapticObject() const;
93 UWeArtHapticObject* GetMiddleHapticObject() const;
94
96 UPROPERTY()
97 UWeArtTouchableObject* IndexOverlapObj;
99 UPROPERTY()
100 UWeArtTouchableObject* MiddleOverlapObj;
102 UPROPERTY()
103 UWeArtTouchableObject* ThumbOverlapObj;
104
110 ECollisionResponse GetResponseToHand(AActor* Source) const;
111
112protected:
113 // Called when the game starts
114 virtual void BeginPlay() override;
115
125 UFUNCTION(BlueprintCallable)
126 void Init(UWeArtThimbleTrackingObject* ThumbTracking, UWeArtThimbleTrackingObject* IndexTracking,
127 UWeArtThimbleTrackingObject* MiddleTracking,
128 UWeArtHapticObject* ThumbHaptic, UWeArtHapticObject* IndexHaptic, UWeArtHapticObject* MiddleHaptic);
129
131 bool CheckHandClosingState();
133 UWeArtTouchableObject* GetTouchedObjectFromFingers();
135 void HandleFingerPoints();
141 void UpdateFingerState(FUFingerState* FingerState, WeArtFingerType FingerType);
143 void HandleMasterPoints();
145 float GetMaxValue(TArray<float> numbers);
147 void HandleSlavePoints();
149 bool CheckGrabableStatus();
150
151private:
153 UWeArtHandAnimInstance* AnimInstance;
155 USkeletalMeshComponent* PhysicalHand;
157 USkeletalMeshComponent* VirtualHand;
159 UWeArtVirtualHand* VirtualHandAnim;
161 AWeArtDebugActor* DebugActor;
163 FWeArtFingersDictionary FingersDictionary;
164
166 UWeArtTouchableObject* GetTouchedObjectByFinger(FVector Location);
167
168private:
169 const FName PhysicalHandTag = "HandMesh";
170 const FName PhantomHandTag = "PhantomHand";
171 const FName VirtualHandTag = "VirtualHand";
173 const float FingerTraceRadius = 1.4f;
175 const float ContactDirectionThreshold = 0.3f;
177 const FVector PalmBoxTraceExtent = FVector(2.3, 5, 5);
179 const float CheckBoundsPointRadius = 0.15f;
181 const float ClosureThreshold = 0.4f;
183 const float FingerCloseThreshold = 0.06f;
185 HandClosingState ClosingState = HandClosingState::Open;
189 bool bInitialized = false;
191 int MasterContactPointsCount = 0;
193 int SlaveContactPointsCount = 0;
195 TArray<WeArtContactPointPartType> ContactedPoints;
196 UPROPERTY()
197 UWeArtHapticObject* ThumbHapticObject;
198 UPROPERTY()
199 UWeArtHapticObject* IndexHapticObject;
200 UPROPERTY()
201 UWeArtHapticObject* MiddleHapticObject;
202 bool bFoundGraspEvents;
203 UPROPERTY()
204 UWeArtThimbleTrackingObject* ThumbTrackingObject;
205 UPROPERTY()
206 UWeArtThimbleTrackingObject* IndexTrackingObject;
207public:
209 UFUNCTION(BlueprintCallable)
210 UWeArtThimbleTrackingObject* GetThumbTrackingObject() const;
212 UFUNCTION(BlueprintCallable)
213 UWeArtThimbleTrackingObject* GetIndexTrackingObject() const;
215 UFUNCTION(BlueprintCallable)
216 UWeArtThimbleTrackingObject* GetMiddleTrackingObject() const;
217
219 FHitResult TraceRay(const FVector StartLoc, const FVector Direction, bool Debug) const;
221 AActor* TraceCapsule(FVector Location, float Radius, FVector& HitLocation, FVector& HitNormal, bool Debug = false);
223 AActor* TraceCapsuleOutActors(FVector Location, float Radius, FVector& HitLocation, FVector& HitNormal, TArray<AActor*>& OutActors, bool Debug = false);
225 AActor* TraceBox(FVector Location, FVector Extent, FRotator Orientation, bool Debug = false);
226
227private:
228 UPROPERTY()
229 UWeArtThimbleTrackingObject* MiddleTrackingObject;
230};
#define WEARTPLUGIN_API
Definition: Definitions.WEARTPlugin.h:26
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnUXCalibrationStopSignature)
GraspingState
Definition: WeArtCommon.h:50
@ Released
Definition: WeArtCommon.h:52
HandClosingState
Definition: WeArtCommon.h:42
@ Open
Definition: WeArtCommon.h:43
EHandSide
Definition: WeArtCommon.h:8
WeArtContactPointPartType
Definition: WeArtContactPointPartType.h:4
WeArtFingerType
Definition: WeArtFingerType.h:4
ECollisionResponse GetResponseToHand(USkeletalMeshComponent *PhysicalHand, AActor *Source)
Definition: WeArtVirtualHand.cpp:6
Contains the declaration of the UWeArtVirtualHand class.
Definition: WeArtDebugActor.h:12
Handles events related to grasping actions.
Definition: WeArtGraspEvents.h:19
Definition: WeArtFingersDictionary.h:5
Animates hand movements for haptic feedback.
Definition: WeArtHandAnimInstance.h:14
Controls hand interactions and haptic feedback.
An animation instance class for virtual hand animations.
Definition: WeArtVirtualHand.h:20
Definition: WeArtFingerState.h:6