A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
PixoVRToolBase.h
Go to the documentation of this file.
1// Copyright(c) Pixo Group. All Rights Reserved.
2
3#pragma once
4
6#include "CoreMinimal.h"
8#include "PixoVRToolBase.generated.h"
9
10class USoundBase;
11class UBoxComponent;
13class UAudioComponent;
14class USoundAttenuation;
15
17
22UCLASS(Blueprintable, ClassGroup = ToolMenu)
23class PIXOCORE_API APixoVRToolBase : public AActor, public IVRGripInterface, public IPixoVRGripInterface, public IPixoVRToolInterface
24{
27public:
29
30protected:
31 virtual void BeginPlay() override;
32 virtual void Tick(float DeltaSeconds) override;
33
34 UFUNCTION()
35 virtual void OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool FromSweep, const FHitResult& SweepResult);
36
37 UFUNCTION(Server, Reliable, WithValidation)
38 void ServerStartPlayingSound(USoundBase* Sound, const FVector& SoundLocation, float VolumeMultiplier = 1.0f);
39
40 UFUNCTION(Server, Reliable, WithValidation)
41 void ServerStopPlayingSound(USoundBase* Sound);
42
43 UFUNCTION(Server, Reliable, WithValidation)
44 void ServerStartPlayingSoundViaComponent(USoundBase* Sound, float VolumeMultiplier = 1.0f);
45
46 UFUNCTION(Server, Reliable, WithValidation)
47 void ServerStopPlayingSoundViaComponent();
49 UFUNCTION(Server, Reliable, WithValidation)
50 void ServerAdjustPlayingSoundVolumeViaComponent(float InVolumeMultiplier = 1.0f);
51
52 UFUNCTION(Server, Reliable, WithValidation)
53 void ServerOnDropped();
54
55 bool IsRightHand(UGripMotionControllerComponent* GrippingController) const;
57public:
58
59 virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
60
61 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVRToolbox | Tools")
62 bool IsDestroyable();
63
64 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVRToolbox | Tools")
65 void HandleDestroy();
66
67 UFUNCTION(BlueprintCallable, Category = Tool)
68 bool IsGripped();
69
72 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVRToolbox | Tools")
73 void InitializeTool(const FPixoToolData& InToolData);
74 virtual void InitializeTool_Implementation(const FPixoToolData& InToolData) override;
75
78 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
79 bool DenyGrippingPixoVR(UGripMotionControllerComponent* GrippingController);
80 virtual bool DenyGrippingPixoVR_Implementation(UGripMotionControllerComponent* GrippingController) override;
81
83 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
84 bool DenyTriggerGripping();
85 virtual bool DenyTriggerGripping_Implementation() override;
86
88 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
89 bool DenyDropping();
90 virtual bool DenyDropping_Implementation() override;
91
93 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
94 void OnGripObject(UGripMotionControllerComponent* GrippingController, AActor* GrippedActor);
95 virtual void OnGripObject_Implementation(UGripMotionControllerComponent* GrippingController, AActor* GrippedActor) override;
96
98 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
99 void OnTryGripObject(UGripMotionControllerComponent* GrippingController, AActor* GrippedActor);
100 virtual void OnTryGripObject_Implementation(UGripMotionControllerComponent* GrippingController, AActor* GrippedActor) override;
103 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
104 void OnGripObjectRelease(UGripMotionControllerComponent* GrippingController, AActor* GrippedActor);
105 virtual void OnGripObjectRelease_Implementation(UGripMotionControllerComponent* GrippingController, AActor* GrippedActor) override;
106
108 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
109 void GripTriggerMode(EPixoVRGripTriggerModeEnum& GripTriggerMode);
110 virtual void GripTriggerMode_Implementation(EPixoVRGripTriggerModeEnum& GripTriggerMode) override;
111
113 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
114 void GripTriggerTransform(UGripMotionControllerComponent* GrippingController, bool& bUseCustomTransform, FTransform& CustomTransform);
115 virtual void GripTriggerTransform_Implementation(UGripMotionControllerComponent* GrippingController, bool& bUseCustomTransform, FTransform& CustomTransform) override;
116
118 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
119 void GripMode(EPixoVRGripModeEnum& GripMode);
120 virtual void GripMode_Implementation(EPixoVRGripModeEnum& GripMode) override;
121
123 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
124 bool DisablePhysicsOnDrop();
125 virtual bool DisablePhysicsOnDrop_Implementation() override;
126
127 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
128 void OnObjectPaused();
129 virtual void OnObjectPaused_Implementation() override;
130
131 UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
132 void OnObjectUnPaused();
133 virtual void OnObjectUnPaused_Implementation() override;
135
136 bool DestroyOnExit() { return bDestroyOnExit; }
137 bool CanExitsWithoutOwner() const { return ToolData.CanExistWithoutOwner; }
138
139private:
140 UFUNCTION(NetMulticast, Reliable)
141 void MulticastStartPlayingSound(USoundBase* Sound, const FVector& SoundLocation, float VolumeMultiplier);
143 UFUNCTION(NetMulticast, Reliable)
144 void MulticastStopPlayingSound(USoundBase* Sound);
145
146 UFUNCTION(NetMulticast, Reliable)
147 void MulticastStartPlayingSoundViaComponent(USoundBase* Sound, float VolumeMultiplier);
148
149 UFUNCTION(NetMulticast, Reliable)
150 void MulticastStopPlayingSoundViaComponent();
152 UFUNCTION(NetMulticast, Reliable)
153 void MulticastAdjustPlayingSoundVolumeViaComponent(float InVolumeMultiplier);
154
155 UFUNCTION(NetMulticast, Reliable)
156 void MulticastToggleCollision(ECollisionEnabled::Type Type);
157
158 UFUNCTION(Server, Reliable, WithValidation)
159 void ServerUseTool(UGripMotionControllerComponent* GrippingController, AActor* GrippedActor);
161 UFUNCTION(Server, Reliable, WithValidation)
162 void ServerDestroyTool();
163
164 USoundAttenuation* GetDefaultAttenuationSettings();
165
166protected:
167#pragma region Components
168 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Tool)
169 UStaticMeshComponent* ToolMeshComponent;
170
171 UPROPERTY(VisibleAnywhere, Category = Tool)
172 UBoxComponent* GrabBoxComponent;
173
174 UPROPERTY(VisibleAnywhere, Category = Tool)
175 UAudioComponent* AudioComponent;
176
177 UPROPERTY()
178 USoundAttenuation* DefaultAttenuationSettings;
179
180#pragma endregion Components
181
182#pragma region Variables
183 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = GripBehavior)
184 USoundBase* GripSound;
185
186 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = DropBehavior)
187 bool bDestroyOnDrop;
188
189 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = DropBehavior)
190 bool bDestroyOnExit;
191
192 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = DropBehavior)
193 float DestroyDelay;
194
195 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = DropBehavior)
196 bool bAdvancedDrop;
197
198 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = GripBehavior)
199 bool bToggleCollisionOnUsage;
200
201 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = TransformOffset)
202 FTransform RightHandGrip;
203
204 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = TransformOffset)
205 FTransform LeftHandGrip;
206#pragma endregion Variables
207
208#pragma region State
209 UPROPERTY(Replicated, BlueprintReadOnly, Category = ToolData)
210 FPixoToolData ToolData;
211
212 UPROPERTY(Replicated, BlueprintReadOnly, Category = GripBehavior)
213 EControllerHand GrabHand;
215 UPROPERTY(Replicated, BlueprintReadOnly, Category = GripBehavior)
216 bool bIsGripped;
217
218 UPROPERTY(BlueprintReadOnly, Category = GripBehavior)
219 bool bIsGripAllowed;
220
221 FGripAction OnGripAction;
223 UPROPERTY(Replicated, BlueprintReadOnly, Category = ToolBehavior)
224 bool bIsPaused;
225
226 struct
227 {
228 bool bIsPendingKill;
229 float TimeBeforeKilled;
230 } DestroyState;
231
232#pragma endregion State
233};
EPixoVRGripModeEnum
UENUM(BlueprintType)
EPixoVRGripTriggerModeEnum
UENUM(BlueprintType)
DECLARE_MULTICAST_DELEGATE_OneParam(FGripAction, bool)
Base class for PixoVR tools.
FPixoToolData ToolData
UPROPERTY(Replicated, BlueprintReadOnly, Category = ToolData)
bool bIsGripped
UPROPERTY(Replicated, BlueprintReadOnly, Category = GripBehavior)
FTransform LeftHandGrip
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = TransformOffset)
void ServerOnDropped()
UFUNCTION(Server, Reliable, WithValidation)
EControllerHand GrabHand
UPROPERTY(Replicated, BlueprintReadOnly, Category = GripBehavior)
bool DenyGrippingPixoVR(UGripMotionControllerComponent *GrippingController)
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
bool DenyDropping()
Deny dropping. If this is set to true the actor will not be dropped after releasing until set to fals...
float DestroyDelay
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = DropBehavior)
bool bIsGripAllowed
UPROPERTY(BlueprintReadOnly, Category = GripBehavior)
void ServerDestroyTool()
UFUNCTION(Server, Reliable, WithValidation)
void InitializeTool(const FPixoToolData &InToolData)
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVRToolbox | Tools")
void GripTriggerMode(EPixoVRGripTriggerModeEnum &GripTriggerMode)
Will be used to determine how the gripping trigger should behave.
FGripAction OnGripAction
void OnObjectPaused()
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
USoundAttenuation * DefaultAttenuationSettings
UPROPERTY()
void MulticastAdjustPlayingSoundVolumeViaComponent(float InVolumeMultiplier)
UFUNCTION(NetMulticast, Reliable)
bool DisablePhysicsOnDrop()
Disable Physics on Drop. When this is set to 'true' if user drops object it will disable physics else...
UStaticMeshComponent * ToolMeshComponent
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Tool)
void OnGripObject(UGripMotionControllerComponent *GrippingController, AActor *GrippedActor)
Will be called when user grabs an object.
void ServerAdjustPlayingSoundVolumeViaComponent(float InVolumeMultiplier=1.0f)
UFUNCTION(Server, Reliable, WithValidation)
bool bToggleCollisionOnUsage
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = GripBehavior)
void MulticastStartPlayingSoundViaComponent(USoundBase *Sound, float VolumeMultiplier)
UFUNCTION(NetMulticast, Reliable)
USoundBase * GripSound
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = GripBehavior)
void GripTriggerTransform(UGripMotionControllerComponent *GrippingController, bool &bUseCustomTransform, FTransform &CustomTransform)
This specified transformation will be used when flag is set and a grip is happening.
void MulticastStartPlayingSound(USoundBase *Sound, const FVector &SoundLocation, float VolumeMultiplier)
UFUNCTION(NetMulticast, Reliable)
FTransform RightHandGrip
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = TransformOffset)
bool bIsPaused
UPROPERTY(Replicated, BlueprintReadOnly, Category = ToolBehavior)
bool bDestroyOnExit
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = DropBehavior)
void OnObjectUnPaused()
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVR | Grip Interface")
void OnGripObjectRelease(UGripMotionControllerComponent *GrippingController, AActor *GrippedActor)
Will be called when the user releases an object.
void ServerStartPlayingSound(USoundBase *Sound, const FVector &SoundLocation, float VolumeMultiplier=1.0f)
UFUNCTION(Server, Reliable, WithValidation)
UAudioComponent * AudioComponent
UPROPERTY(VisibleAnywhere, Category = Tool)
bool bAdvancedDrop
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = DropBehavior)
UBoxComponent * GrabBoxComponent
UPROPERTY(VisibleAnywhere, Category = Tool)
bool CanExitsWithoutOwner() const
void OnTryGripObject(UGripMotionControllerComponent *GrippingController, AActor *GrippedActor)
Will be called when user tried to grab the object.
void MulticastStopPlayingSoundViaComponent()
UFUNCTION(NetMulticast, Reliable)
void MulticastToggleCollision(ECollisionEnabled::Type Type)
UFUNCTION(NetMulticast, Reliable)
void GripMode(EPixoVRGripModeEnum &GripMode)
Will be used to determine how to do the grabbing. Using normal attachment or a physics constraint.
void ServerUseTool(UGripMotionControllerComponent *GrippingController, AActor *GrippedActor)
UFUNCTION(Server, Reliable, WithValidation)
bool bDestroyOnDrop
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = DropBehavior)
bool DenyTriggerGripping()
Deny gripping after triggering grip.
bool IsDestroyable()
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVRToolbox | Tools")
void ServerStopPlayingSoundViaComponent()
UFUNCTION(Server, Reliable, WithValidation)
void ServerStartPlayingSoundViaComponent(USoundBase *Sound, float VolumeMultiplier=1.0f)
UFUNCTION(Server, Reliable, WithValidation)
void ServerStopPlayingSound(USoundBase *Sound)
UFUNCTION(Server, Reliable, WithValidation)
void HandleDestroy()
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "PixoVRToolbox | Tools")
void MulticastStopPlayingSound(USoundBase *Sound)
UFUNCTION(NetMulticast, Reliable)
Interface for PixoVR tool functionality.
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = MotionController)
Represents data for a tool in PixoCore.