Unreal SDK  v1.1
Loading...
Searching...
No Matches
WeArtTouchableObject.h
Go to the documentation of this file.
1#pragma once
2
3#include "CoreMinimal.h"
4#include "Components/ActorComponent.h"
5#include "WeArtCommon.h"
6#include "WeArtTouchEffect.h"
7#include <set>
8#include <map>
9
10// Included cause of a bug in UnrealHeaderTool.
11// Those are already included in WeArtEffect.h,
12// but need to be included there as well.
13#include "WeArtTemperature.h"
14#include "WeArtForce.h"
15#include "WeArtTexture.h"
16#include "WeArtHapticObject.h"
17#include "WeArtTouchableObject.generated.h"
18
19
20// A class representing objects providing nontrivial effect to the player's
21// @HapticObject. Interacts with the Haptic Objects by adding effect on begin
22// overlap and removing then on overlap end.
23// The effects themselves are then handled by the Haptic Object itself.
24UCLASS( ClassGroup=(Custom), Blueprintable, meta=(BlueprintSpawnableComponent) )
25class WEARTPLUGIN_API UWeArtTouchableObject : public UActorComponent
26{
27 GENERATED_BODY()
28
29public:
30 // Sets default values for this component's properties
31 UWeArtTouchableObject();
32
33protected:
34
35 // State variables
36 UPROPERTY(EditAnywhere, Meta = (DisplayName = "Temperature"))
37 FWeArtTemperature weArtTemperature;
38 UPROPERTY(EditAnywhere, Meta = (DisplayName = "Stiffness"))
39 FWeArtForce weArtStiffness;
40 UPROPERTY(EditAnywhere, Meta = (DisplayName = "Texture"))
41 FWeArtTexture weArtTexture;
42
43 UPROPERTY(EditAnywhere, Meta = (DisplayName = "Volume Texture", ClampMin = 0.0, ClampMax = 100.0))
44 float VolumeTexture = WeArtConstants::defaultVolumeTexture;
45
46 // Grasping-related variables.
47 AActor* grasperActor = nullptr;
48 UWeArtHapticObject* thumbHapticObject;
49 UWeArtHapticObject* indexHapticObject;
50 UWeArtHapticObject* middleHapticObject;
51
52 // Called when the game starts
53 virtual void BeginPlay() override;
54
55public:
56 bool isSimulatingPhysics;
57 GraspingState graspingState = GraspingState::Released;
58
59 UPROPERTY(EditAnywhere, Meta = (DisplayName = "Graspable"))
60 bool IsGraspable;
61
62 UPROPERTY(NoClear, Meta = (DisplayName = "Collision Multiplier", ClampMin = 0.0, ClampMax = 100.0))
63 float CollisionMultiplier = WeArtConstants::defaultCollisionMultiplier;
64
65 // Called every frame
66 virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
67
68 // Overlap handlers. Unity's equivalent of "StayOverlapped" is handled by the tick event.
69 // Hit events are not currently handled at all, being more specific than their Unity counterparts
70 // and not really suitable for our use.
71 UFUNCTION()
72 void BeginOverlap(AActor* MyOverlappedActor, AActor* OtherActor);
73 UFUNCTION()
74 void EndOverlap(AActor* MyOverlappedActor, AActor* OtherActor);
75
76 UFUNCTION(BlueprintCallable, Category = "WEART TouchableObject")
77 void UpdateTemperature(bool active, float value);
78 UFUNCTION(BlueprintCallable, Category = "WEART TouchableObject")
79 void UpdateStiffness(bool active, float value);
80 UFUNCTION(BlueprintCallable, Category = "WEART TouchableObject")
81 void UpdateTexture(bool active, TextureType textureType);
82
83 UFUNCTION(BlueprintCallable, Category = "WEART TouchableObject")
84 float GetTemperatureValue();
85 UFUNCTION(BlueprintCallable, Category = "WEART TouchableObject")
86 float GetStiffnessValue();
87 UFUNCTION(BlueprintCallable, Category = "WEART TouchableObject")
88 TextureType GetTextureType();
89 UFUNCTION(BlueprintCallable, Category = "WEART TouchableObject")
90 float GetTextureVolume();
91 UFUNCTION(BlueprintCallable, Category = "WEART TouchableObject")
92 void UpdateIsForcedVelocity(bool value);
93 UFUNCTION(BlueprintCallable, Category = "WEART TouchableObject")
94 bool GetIsForcedVelocity();
95 UFUNCTION(BlueprintCallable, Category = "WEART TouchableObject")
96 void UpdateTextureVolume(float value);
97
98 void Grab(AActor* grasper, UWeArtHapticObject* thumbHaptic, UWeArtHapticObject* indexHaptic, UWeArtHapticObject* middleHaptic);
99 void Release(void);
100 void ComputeDynamicGraspForce(float thumbClosureValue, float middleClosureValue, float indexClosureValue);
101 void SetEffectGraspForce(float thumbForce, float indexForce, float middleForce);
102
103
104
105protected:
106 std::set<UWeArtHapticObject*> touchedHapticObjects;
107 std::map<UWeArtHapticObject*, WeArtTouchEffect*> touchedHapticEffects;
108
109private:
110 WeArtTouchEffect* thumbGraspEffect = nullptr;
111 WeArtTouchEffect* indexGraspEffect = nullptr;
112 WeArtTouchEffect* middleGraspEffect = nullptr;
113};
TextureType
Definition: WeArtCommon.h:48
GraspingState
Definition: WeArtCommon.h:40
@ Released
Definition: WeArtCommon.h:42
Effect to be applied to the thimble.
Definition: WeArtTouchEffect.h:22
Definition: WeArtCommon.h:71
Force value to be applied to an effect.
Definition: WeArtForce.h:11
Temperature value to be applied to an effect.
Definition: WeArtTemperature.h:11
Texture information to be applied to an effect.
Definition: WeArtTexture.h:11