Unreal SDK  v1.2.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;
54
56 UPROPERTY(EditAnywhere, BlueprintReadWrite)
57 FUFingerState IndexState;
58 UPROPERTY(EditAnywhere, BlueprintReadWrite)
59 FUFingerState MiddleState;
60 UPROPERTY(EditAnywhere, BlueprintReadWrite)
61 FUFingerState ThumbState;
62 FUFingerState PalmState;
63
64
65public:
67
70
72 FOnGrabbed OnGrabbed;
73
75 void UpdateClosureLimitsWhenGrabbed();
76
78 void OnReleasedGrabbedObject();
80 void HandleGraspingState(void);
81 virtual void TickComponent(float DeltaTime, ELevelTick TickType,
82 FActorComponentTickFunction* ThisTickFunction) override;
83
85 AWeArtGraspEvents* WeArtGraspEvents;
86
88 UWeArtHapticObject* GetThumbHapticObject() const;
90 UWeArtHapticObject* GetIndexHapticObject() const;
92 UWeArtHapticObject* GetMiddleHapticObject() const;
93
95 UWeArtTouchableObject* IndexOverlapObj;
97 UWeArtTouchableObject* MiddleOverlapObj;
99 UWeArtTouchableObject* ThumbOverlapObj;
100
106 ECollisionResponse GetResponseToHand(AActor* Source) const;
107
108protected:
109 // Called when the game starts
110 virtual void BeginPlay() override;
111
121 UFUNCTION(BlueprintCallable)
122 void Init(UWeArtThimbleTrackingObject* ThumbTracking, UWeArtThimbleTrackingObject* IndexTracking,
123 UWeArtThimbleTrackingObject* MiddleTracking,
124 UWeArtHapticObject* ThumbHaptic, UWeArtHapticObject* IndexHaptic, UWeArtHapticObject* MiddleHaptic);
125
127 bool CheckHandClosingState();
129 UWeArtTouchableObject* GetTouchedObjectFromFingers();
131 void HandleFingerPoints();
137 void UpdateFingerState(FUFingerState* FingerState, WeArtFingerType FingerType);
139 void HandleMasterPoints();
141 float GetMaxValue(TArray<float> numbers);
143 void HandleSlavePoints();
145 bool CheckGrabableStatus();
146
147private:
149 UWeArtHandAnimInstance* AnimInstance;
151 USkeletalMeshComponent* PhysicalHand;
153 USkeletalMeshComponent* VirtualHand;
155 UWeArtVirtualHand* VirtualHandAnim;
157 AWeArtDebugActor* DebugActor;
159 FWeArtFingersDictionary FingersDictionary;
160
162 UWeArtTouchableObject* GetTouchedObjectByFinger(FVector Location);
164 FHitResult TraceRay(const FVector StartLoc, const FVector Direction, bool Debug);
166 AActor* TraceCapsule(FVector Location, float Radius, FVector& HitLocation, FVector& HitNormal, bool Debug = false);
168 AActor* TraceCapsuleOutActors(FVector Location, float Radius, FVector& HitLocation, FVector& HitNormal, TArray<AActor*>& OutActors, bool Debug = false);
170 AActor* TraceBox(FVector Location, FVector Extent, FRotator Orientation, bool Debug = false);
171
172
173private:
174 const FName PhysicalHandTag = "HandMesh";
175 const FName PhantomHandTag = "PhantomHand";
176 const FName VirtualHandTag = "VirtualHand";
178 const float FingerTraceRadius = 1.4f;
180 const float ContactDirectionThreshold = 0.3f;
182 const FVector PalmBoxTraceExtent = FVector(2.3, 5, 5);
184 const float CheckBoundsPointRadius = 0.15f;
186 const float ClosureThreshold = 0.4f;
188 const float FingerCloseThreshold = 0.06f;
190 HandClosingState ClosingState = HandClosingState::Open;
194 bool bInitialized = false;
196 int MasterContactPointsCount = 0;
198 int SlaveContactPointsCount = 0;
200 TArray<WeArtContactPointPartType> ContactedPoints;
201 UWeArtHapticObject* ThumbHapticObject;
202 UWeArtHapticObject* IndexHapticObject;
203 UWeArtHapticObject* MiddleHapticObject;
204 bool bFoundGraspEvents;
205 UWeArtThimbleTrackingObject* ThumbTrackingObject;
206 UWeArtThimbleTrackingObject* IndexTrackingObject;
207 bool CanBeGrabbed;
208public:
210 UWeArtThimbleTrackingObject* GetThumbTrackingObject() const;
212 UWeArtThimbleTrackingObject* GetIndexTrackingObject() const;
214 UWeArtThimbleTrackingObject* GetMiddleTrackingObject() const;
215
216private:
217 UWeArtThimbleTrackingObject* MiddleTrackingObject;
218};
#define WEARTPLUGIN_API
Definition: Definitions.WEARTPlugin.h:292
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