3 #include "CoreMinimal.h" 4 #include "UObject/ObjectMacros.h" 5 #include "Engine/TextureCube.h" 6 #include "Components/PrimitiveComponent.h" 7 #include "SceneViewExtension.h" 8 #include "IMotionController.h" 9 #include "LateUpdateManager.h" 10 #include "IIdentifiableXRDevice.h" 11 #include "Components/ActorComponent.h" 12 #include "Components/SceneCaptureComponentCube.h" 13 #include "Engine/TextureRenderTargetCube.h" 14 #include "Engine/DataAsset.h" 15 #include "VRTP.generated.h" 19 enum class EVRTPBackgroundMode : uint8
21 MM_COLOR UMETA(DisplayName =
"Color"),
22 MM_SKYBOX UMETA(DisplayName =
"Skybox"),
23 MM_BLUR UMETA(DisplayName =
"Blur")
28 enum class EVRTPMaskMode : uint8
30 MM_OFF UMETA(DisplayName =
"Off"),
31 MM_MASK UMETA(DisplayName =
"Mask"),
32 MM_WINDOW UMETA(DisplayName =
"Window"),
33 MM_PORTAL UMETA(DisplayName =
"Portal")
37 USTRUCT(BlueprintType)
40 GENERATED_USTRUCT_BODY()
43 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
"Capture")
44 TSubclassOf<class AActor> SkyboxBlueprint;
47 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capture")
48 UTextureCube* CubeMapOverride;
51 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Post Process")
52 UMaterial* PostProcessMaterial;
55 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effect Settings")
56 FLinearColor EffectColor;
59 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effect Settings", meta = (ClampMin = "0.0", ClampMax = "1.0"))
63 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effect Settings", meta = (ClampMin = "0.0", ClampMax = "10.0"))
67 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effect Settings")
68 EVRTPBackgroundMode BackgroundMode;
71 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effect Settings")
72 bool ApplyEffectColor;
75 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effect Settings")
79 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effect Settings|Mask Settings")
80 EVRTPMaskMode MaskMode;
83 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Effect Settings|Mask Settings", meta = (ClampMin = "0", ClampMax = "255"))
87 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Direction specific")
88 bool bDirectionSpecific;
91 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Direction specific")
92 float DirectionalVerticalStrength;
95 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Direction specific")
96 float DirectionalHorizontalStrength;
99 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Angular Velocity")
100 bool bUseAngularVelocity;
103 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Angular Velocity", meta = (ClampMin = "0.0", ClampMax = "10.0"))
104 float AngularStrength;
107 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Angular Velocity", meta = (ClampMin = "0.0", ClampMax = "180.0"))
111 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Angular Velocity", meta = (ClampMin = "0.0", ClampMax = "180.0"))
115 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Angular Velocity", meta = (ClampMin = "0.0", ClampMax = "1.0"))
116 float AngularSmoothing;
119 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Velocity")
123 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Velocity", meta = (ClampMin = "0.0", ClampMax = "10.0"))
124 float VelocityStrength;
127 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Velocity", meta = (ClampMin = "0.0", ClampMax = "1000.0"))
131 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Velocity", meta = (ClampMin = "0.0", ClampMax = "1000.0"))
135 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Velocity", meta = (ClampMin = "0.0", ClampMax = "1.0"))
136 float VelocitySmoothing;
139 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Acceleration")
140 bool bUseAcceleration;
143 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Acceleration", meta = (ClampMin = "0.0", ClampMax = "10.0"))
144 float AccelerationStrength;
147 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Acceleration", meta = (ClampMin = "0.0", ClampMax = "1000.0"))
148 float AccelerationMin;
151 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Acceleration", meta = (ClampMin = "0.0", ClampMax = "1000.0"))
152 float AccelerationMax;
155 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Motion Settings|Acceleration", meta = (ClampMin = "0.0", ClampMax = "1.0"))
156 float AccelerationSmoothing;
160 SkyboxBlueprint = NULL;
161 CubeMapOverride = NULL;
162 PostProcessMaterial = NULL;
163 EffectColor = FLinearColor::Black;
166 BackgroundMode = EVRTPBackgroundMode::MM_COLOR;
167 ApplyEffectColor =
false;
169 MaskMode = EVRTPMaskMode::MM_OFF;
171 bDirectionSpecific =
false;
172 DirectionalVerticalStrength = 1.5f;
173 DirectionalHorizontalStrength = 1.5f;
174 bUseAngularVelocity =
false;
178 AngularSmoothing = 0;
179 bUseVelocity =
false;
180 VelocityStrength = 0;
183 VelocitySmoothing = 0;
184 bUseAcceleration =
false;
185 AccelerationStrength = 0;
188 AccelerationSmoothing = 0;
200 UPROPERTY(EditAnywhere)
204 class FPrimitiveSceneInfo;
205 class FRHICommandListImmediate;
207 class FSceneViewFamily;
210 UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = MotionController, HideCategories = ("VRTunnellingPro"))
213 GENERATED_UCLASS_BODY()
216 virtual void BeginPlay()
override;
217 void BeginDestroy()
override;
220 UPROPERTY(BlueprintReadWrite, BlueprintSetter = SetAssociatedPlayerIndex, Category =
"VR Tunnelling | MotionController")
223 UPROPERTY(BlueprintSetter = SetTrackingSource, BlueprintGetter = GetTrackingSource, Category = "VR Tunnelling | MotionController")
224 EControllerHand Hand_DEPRECATED;
227 UPROPERTY(BlueprintReadWrite, BlueprintSetter = SetTrackingMotionSource, Category = "VR Tunnelling | MotionController")
231 UPROPERTY(BlueprintReadWrite, Category = "VR Tunnelling | MotionController")
232 uint32 bDisableLowLatencyUpdate : 1;
235 UPROPERTY(BlueprintReadOnly, Category = "VR Tunnelling | MotionController")
236 ETrackingStatus CurrentTrackingStatus;
238 void TickComponent(
float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
240 UFUNCTION(BlueprintPure, Category = "MotionController")
bool IsTracked()
const 245 UFUNCTION(BlueprintSetter, meta = (DeprecatedFunction, DeprecationMessage =
"Please use the Motion Source property instead of Hand"))
246 void SetTrackingSource(const EControllerHand NewSource);
248 UFUNCTION(BlueprintGetter, meta = (DeprecatedFunction, DeprecationMessage = "Please use the Motion Source property instead of Hand"))
249 EControllerHand GetTrackingSource() const;
251 UFUNCTION(BlueprintSetter)
252 void SetTrackingMotionSource(const FName NewSource);
254 UFUNCTION(BlueprintSetter)
255 void SetAssociatedPlayerIndex(const int32 NewPlayer);
258 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Tunnelling|Effect Preset")
262 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Tunnelling|Effect Preset")
266 UPROPERTY(EditAnywhere, BlueprintReadWrite, AdvancedDisplay, Category = "VR Tunnelling")
267 TSubclassOf<class AActor> SkyboxBlueprint;
268 UPROPERTY(EditAnywhere)
269 TSubclassOf<class AActor> SkyboxBlueprintSwap;
272 UPROPERTY(EditAnywhere, BlueprintReadWrite, AdvancedDisplay, Category = "VR Tunnelling")
273 UTextureCube* CubeMapOverride;
274 UPROPERTY(EditAnywhere)
275 UTextureCube* CubeMapOverrideSwap;
278 UPROPERTY(EditAnywhere, BlueprintReadWrite, AdvancedDisplay, Category = "VR Tunnelling")
279 UMaterial* PostProcessMaterial;
280 UPROPERTY(EditAnywhere)
281 UMaterial* PostProcessMaterialSwap;
284 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Effect Settings")
285 FLinearColor EffectColor;
286 UPROPERTY(EditAnywhere)
287 FLinearColor EffectColorSwap;
290 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Effect Settings", meta = (ClampMin = "0.0", ClampMax = "1.0"))
291 float EffectCoverage;
292 UPROPERTY(EditAnywhere)
293 float EffectCoverageSwap;
296 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Effect Settings", meta = (ClampMin = "0.0", ClampMax = "10.0"))
298 UPROPERTY(EditAnywhere)
299 float EffectFeatherSwap;
302 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Effect Settings")
303 EVRTPBackgroundMode BackgroundMode;
304 UPROPERTY(EditAnywhere)
305 EVRTPBackgroundMode BackgroundModeSwap;
308 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Effect Settings")
309 bool ApplyEffectColor;
310 UPROPERTY(EditAnywhere)
311 bool ApplyEffectColorSwap;
314 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Effect Settings")
316 UPROPERTY(EditAnywhere)
317 bool ForceEffectSwap;
320 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Effect Settings|Mask Settings")
321 EVRTPMaskMode MaskMode;
322 UPROPERTY(EditAnywhere)
323 EVRTPMaskMode MaskModeSwap;
326 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Effect Settings|Mask Settings", meta = (ClampMin = "0", ClampMax = "255"))
328 UPROPERTY(EditAnywhere)
329 int32 StencilIndexSwap;
332 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Direction Specific")
333 bool bDirectionSpecific;
334 UPROPERTY(EditAnywhere)
335 bool bDirectionSpecificSwap;
338 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Direction Specific")
339 float DirectionalVerticalStrength;
340 UPROPERTY(EditAnywhere)
341 float DirectionalVerticalStrengthSwap;
344 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Direction Specific")
345 float DirectionalHorizontalStrength;
346 UPROPERTY(EditAnywhere)
347 float DirectionalHorizontalStrengthSwap;
350 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Angular Velocity")
351 bool bUseAngularVelocity;
352 UPROPERTY(EditAnywhere)
353 bool bUseAngularVelocitySwap;
356 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Angular Velocity", meta = (ClampMin = "0.0", ClampMax = "10.0"))
357 float AngularStrength;
358 UPROPERTY(EditAnywhere)
359 float AngularStrengthSwap;
362 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Angular Velocity", meta = (ClampMin = "0.0", ClampMax = "180.0"))
364 UPROPERTY(EditAnywhere)
365 float AngularMinSwap;
368 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Angular Velocity", meta = (ClampMin = "0.0", ClampMax = "180.0"))
370 UPROPERTY(EditAnywhere)
371 float AngularMaxSwap;
374 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Angular Velocity", meta = (ClampMin = "0.0", ClampMax = "1.0"))
375 float AngularSmoothing;
376 UPROPERTY(EditAnywhere)
377 float AngularSmoothingSwap;
380 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Velocity")
382 UPROPERTY(EditAnywhere)
383 bool bUseVelocitySwap;
386 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Velocity", meta = (ClampMin = "0.0", ClampMax = "10.0"))
387 float VelocityStrength;
388 UPROPERTY(EditAnywhere)
389 float VelocityStrengthSwap;
392 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Velocity", meta = (ClampMin = "0.0", ClampMax = "1000.0"))
394 UPROPERTY(EditAnywhere)
395 float VelocityMinSwap;
398 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Velocity", meta = (ClampMin = "0.0", ClampMax = "1000.0"))
400 UPROPERTY(EditAnywhere)
401 float VelocityMaxSwap;
404 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Velocity", meta = (ClampMin = "0.0", ClampMax = "1.0"))
405 float VelocitySmoothing;
406 UPROPERTY(EditAnywhere)
407 float VelocitySmoothingSwap;
410 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Acceleration")
411 bool bUseAcceleration;
412 UPROPERTY(EditAnywhere)
413 bool bUseAccelerationSwap;
416 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Acceleration", meta = (ClampMin = "0.0", ClampMax = "10.0"))
417 float AccelerationStrength;
418 UPROPERTY(EditAnywhere)
419 float AccelerationStrengthSwap;
422 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Acceleration", meta = (ClampMin = "0.0", ClampMax = "1000.0"))
423 float AccelerationMin;
424 UPROPERTY(EditAnywhere)
425 float AccelerationMinSwap;
428 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Acceleration", meta = (ClampMin = "0.0", ClampMax = "1000.0"))
429 float AccelerationMax;
430 UPROPERTY(EditAnywhere)
431 float AccelerationMaxSwap;
434 UPROPERTY(EditAnywhere, BlueprintReadWrite, SimpleDisplay, Category = "VR Tunnelling|Motion Settings|Acceleration", meta = (ClampMin = "0.0", ClampMax = "1.0"))
435 float AccelerationSmoothing;
436 UPROPERTY(EditAnywhere)
437 float AccelerationSmoothingSwap;
440 USceneCaptureComponentCube* SceneCaptureCube;
441 UTextureRenderTargetCube* TC;
444 UMaterialInstanceDynamic* PostProcessMID;
450 UFUNCTION(BlueprintCallable, Category = "VR Tunnelling")
454 UFUNCTION(BlueprintCallable, Category = "VR Tunnelling")
455 void SetBackgroundMode(EVRTPBackgroundMode NewBackgroundMode);
458 UFUNCTION(BlueprintCallable, Category = "VR Tunnelling")
459 void SetMaskMode(EVRTPMaskMode NewMaskMode);
462 UFUNCTION(BlueprintCallable, Category = "VR Tunnelling")
463 void SetEffectColor(FLinearColor NewColor);
466 UFUNCTION(BlueprintCallable, Category = "VR Tunnelling")
467 void ApplyColor(
bool Enabled);
470 UFUNCTION(BlueprintCallable, Category = "VR Tunnelling")
471 void SetStencilMask(int32 NewStencilIndex,
bool UpdateMaskedObjects = true);
474 UFUNCTION(BlueprintCallable, Category = "VR Tunnelling")
475 void UpdateMaskedObjects();
478 UFUNCTION(BlueprintCallable, Category = "VR Tunnelling")
479 void SetFeather(
float NewFeather);
482 virtual
void Serialize(FArchive& Ar) override;
485 virtual void PreEditChange(UProperty* PropertyAboutToChange)
override;
486 virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
override;
491 virtual void OnComponentDestroyed(
bool bDestroyingHierarchy)
override;
495 virtual void CreateRenderState_Concurrent()
override;
496 virtual void SendRenderTransform_Concurrent()
override;
500 IMotionController* InUseMotionController;
503 UFUNCTION(BlueprintImplementableEvent, Category =
"Motion Controller Update")
504 void OnMotionControllerUpdated();
507 UFUNCTION(BlueprintCallable, Category = "Motion Controller Update")
508 float GetParameterValue(FName InName,
bool& bValueFound);
513 FVector LastPosition;
517 float VelocitySmoothed;
518 float AccelerationSmoothed;
527 bool PollControllerState(FVector& Position, FRotator& Orientation,
float WorldToMetersScale);
529 FTransform RenderThreadRelativeTransform;
530 FVector RenderThreadComponentScale;
532 void CacheSettings();
535 void InitFromPreset();
537 void UpdatePostProcessSettings();
538 void CalculateMotion(
float DeltaTime);
539 void ApplyBackgroundMode();
540 void ApplyMaskMode();
541 void ApplyStencilMasks();
544 class FViewExtension : public FSceneViewExtensionBase
547 FViewExtension(
const FAutoRegister& AutoRegister,
UVRTunnellingPro* InMotionControllerComponent);
548 virtual ~FViewExtension() {}
551 virtual void SetupViewFamily(FSceneViewFamily& InViewFamily)
override {}
552 virtual void SetupView(FSceneViewFamily& InViewFamily, FSceneView& InView)
override {}
553 virtual void BeginRenderViewFamily(FSceneViewFamily& InViewFamily)
override;
554 virtual void PreRenderView_RenderThread(FRHICommandListImmediate& RHICmdList, FSceneView& InView)
override {}
555 virtual void PreRenderViewFamily_RenderThread(FRHICommandListImmediate& RHICmdList, FSceneViewFamily& InViewFamily)
override;
556 virtual void PostRenderViewFamily_RenderThread(FRHICommandListImmediate& RHICmdList, FSceneViewFamily& InViewFamily)
override;
557 virtual int32 GetPriority()
const override {
return -10; }
558 virtual bool IsActiveThisFrame(
class FViewport* InViewport)
const;
565 FLateUpdateManager LateUpdate;
566 FTransform PrevTransform;
568 TSharedPtr< FViewExtension, ESPMode::ThreadSafe > ViewExtension;
571 int32 PreEditMaterialCount = 0;
VRTP Preset Definition (Applied to desktop version only)
Definition: VRTP.h:38
Preset data asset definition.
Definition: VRTP.h:194
Tunnelling primitive component, for dektop applications.
Definition: VRTP.h:211