NVIDIA DeepLearning Dataset Synthesizer (NDDS)
 All Classes Namespaces Functions Variables Typedefs Pages
OrbitalMovementComponent.h
1 /*
2 * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * NVIDIA CORPORATION and its licensors retain all intellectual property
5 * and proprietary rights in and to this software, related documentation
6 * and any modifications thereto. Any use, reproduction, disclosure or
7 * distribution of this software and related documentation without an express
8 * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 */
10 
11 #pragma once
12 
13 #include "DomainRandomizationDNNPCH.h"
14 #include "RandomComponentBase.h"
15 #include "OrbitalMovementComponent.generated.h"
16 
17 /**
18 * RandomTextureComponent randomly change the color parameter of the materials in the owner's mesh
19 */
20 /// @cond DOXYGEN_SUPPRESSED_CODE
21 UCLASS(Blueprintable, ClassGroup = (NVIDIA), meta = (BlueprintSpawnableComponent), HideCategories = (Replication, ComponentReplication, Cooking, Events, ComponentTick, Actor, Input, Rendering, Collision, PhysX, Activation, Sockets))
22 /// @endcond DOXYGEN_SUPPRESSED_CODE
23 class DOMAINRANDOMIZATIONDNN_API UOrbitalMovementComponent : public URandomComponentBase
24 {
25  GENERATED_BODY()
26 
27 public:
29 
30  AActor* GetFocalActor();
31  void SetFocalActor(AActor* NewFocalActor);
32 
33 protected:
34  virtual void BeginPlay() override;
35  virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
36  virtual void OnRandomization_Implementation() override;
37 
38  void UpdateDistanceToTarget();
39  void OnYawRotationCompleted(float DeltaTime);
40 
41  void TeleportRandomly();
42 
43 protected: // Editor properties
44  UPROPERTY(EditAnywhere, Category = "Movement")
45  bool bShouldMove;
46 
47  // If true, the owner will teleport instead of moving between random locations on the constrained sphere
48  UPROPERTY(EditAnywhere, Category = "Movement")
49  bool bTeleportRandomly;
50 
51  // If true, the actor will not be able to move if its way is blocked
52  // Otherwise the actor can go through other object or teleport overlap with the other
53  UPROPERTY(EditAnywhere)
54  bool bCheckCollision;
55 
56  // The actor which is the center of the orbit movement
57  UPROPERTY(EditAnywhere, Category = "Movement", meta = (EditCondition = bShouldMove))
58  AActor* FocalTargetActor;
59 
60  // How fast (angle per second) should the owner rotate
61  UPROPERTY(EditAnywhere, Category = "Movement", meta = (EditCondition = bShouldMove))
62  float RotationSpeed;
63 
64  // How fast (angle per second) should the owner change the pitch
65  UPROPERTY(EditAnywhere, Category = "Movement", meta = (EditCondition = bShouldMove))
66  float PitchRotationSpeed;
67 
68  UPROPERTY(EditAnywhere, Category = "Movement", meta = (EditCondition = bShouldMove))
69  FFloatInterval YawRotationRange;
70 
71  UPROPERTY(EditAnywhere, Category = "Movement", meta = (EditCondition = bShouldMove))
72  FFloatInterval PitchRotationRange;
73 
74  // If true, after each full yaw rotation, the yaw direction change from min to max to max to min and vice-versa
75  UPROPERTY(EditAnywhere, Category = "Movement", meta = (EditCondition = bShouldMove))
76  bool bRevertYawDirectionAfterEachRotation;
77 
78  UPROPERTY(EditAnywhere, Category = "Movement", meta = (EditCondition = bShouldMove))
79  bool bRandomizePitchAfterEachYawRotation;
80 
81  // If true, the owner will change its distance (selected randomly in TargetDistanceRange) to the target when orbiting
82  UPROPERTY(EditAnywhere, Category = "Movement")
83  bool bShouldChangeDistance;
84 
85  // How far does the owner need to stay from the target
86  UPROPERTY(EditAnywhere, Category = "Movement", meta = (EditCondition = bShouldChangeDistance))
87  FFloatInterval TargetDistanceRange;
88 
89  // How fast (unit per second) does the owner change its distance from the target
90  // NOTE: This speed is independent from the rotation speed
91  UPROPERTY(EditAnywhere, Category = "Movement", meta = (EditCondition = bShouldChangeDistance))
92  float DistanceChangeSpeed;
93 
94  // How long (seconds) to wait before the owner change its distance to the target
95  UPROPERTY(EditAnywhere, Category = "Movement", meta = (EditCondition = bShouldChangeDistance))
96  float TargetDistanceChangeDuration;
97 
98  UPROPERTY(EditAnywhere, Category = "Movement", meta = (EditCondition = bShouldChangeDistance))
99  bool bOnlyChangeDistanceWhenPitchChanged;
100 
101  // If true, the owner also randomly rotated when moving
102  UPROPERTY(EditAnywhere, Category = "Movement")
103  bool bShouldWiggle;
104 
105  UPROPERTY(EditAnywhere, Category = "Movement", meta = (EditCondition = bShouldWiggle))
106  FRandomRotationData WiggleRotationData;
107 
108 protected: // Transient properties
109  UPROPERTY(Transient)
110  FRotator RotationFromTarget;
111  UPROPERTY(Transient)
112  float CurrentDistanceToTarget;
113  UPROPERTY(Transient)
114  float DistanceToTarget;
115  UPROPERTY(Transient)
116  float DistanceChangeCountdown;
117  UPROPERTY(Transient)
118  float TargetYaw;
119 };