Cesium for Unreal 2.13.2
Loading...
Searching...
No Matches
CesiumFlyToComponent.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "CesiumGeospatial/SimplePlanarEllipsoidCurve.h"
7#include "CesiumFlyToComponent.generated.h"
8
9class UCurveFloat;
11
12/**
13 * The delegate for when the Actor finishes flying.
14 */
15DECLARE_DYNAMIC_MULTICAST_DELEGATE(FCesiumFlightCompleted);
16
17/**
18 * The delegate for when the Actor's flight is interrupted.
19 */
20DECLARE_DYNAMIC_MULTICAST_DELEGATE(FCesiumFlightInterrupted);
21
22/**
23 * Indicates which rotation to use for orienting the object during flights.
24 */
25UENUM(BlueprintType)
26enum class ECesiumFlyToRotation : uint8 {
27 /**
28 * Uses the relative rotation of the root component of the Actor to which the
29 * CesiumFlyToComponent is attached.
30 */
31 Actor,
32
33 /**
34 * Uses the ControlRotation of the Controller of the Pawn to which the
35 * CesiumFlyToComponent is attached. The ControlRotation is interpreted as
36 * being relative to the Unreal coordinate system.
37 *
38 * If the component is attached to an Actor that is not a Pawn, or if the Pawn
39 * does not have a Controller, this option is equivalent to the "Actor"
40 * option.
41 */
43
44 /**
45 * Uses the ControlRotation of the Controller of the Pawn to which the
46 * CesiumFlyToComponent is attached. The ControlRotation is interpreted as
47 * being relative to the Pawn's local East-South-Up coordinate system.
48 *
49 * This is the option to use with a GlobeAwareDefaultPawn or a DynamicPawn,
50 * because those classes interpret the ControlRotation as being relative to
51 * East-South-Up.
52 *
53 * If the component is attached to an Actor that is not a Pawn, or if the Pawn
54 * does not have a Controller, this option is equivalent to the "Actor"
55 * option.
56 */
58};
59
60/**
61 * Smoothly animates the Actor to which it is attached on a flight to a new
62 * location on the globe.
63 */
64UCLASS(ClassGroup = "Cesium", Meta = (BlueprintSpawnableComponent))
65class CESIUMRUNTIME_API UCesiumFlyToComponent
67 GENERATED_BODY()
68
69public:
71
72 /**
73 * A curve that is used to determine the flight progress percentage for all
74 * the other curves. The input is the fraction (0.0 to 1.0) of the total time
75 * that has passed so far, and the output is the fraction of the total curve
76 * that should be traversed at this time. This curve allows the Actor to
77 * accelerate and deaccelerate as desired throughout the flight.
78 */
79 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
80 UCurveFloat* ProgressCurve;
81
82 /**
83 * A curve that controls what percentage of the maximum height the Actor
84 * should take at a given time on the flight. This curve must be kept in the 0
85 * to 1 range on both axes. The MaximumHeightByDistanceCurve controls the
86 * actual maximum height that is achieved during the flight.
87 *
88 * If this curve is not specified, the height will be a smooth interpolation
89 * between the height at the original location and the height at the
90 * destination location, and the MaximumHeightByDistanceCurve will be ignored.
91 */
92 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
93 UCurveFloat* HeightPercentageCurve;
94
95 /**
96 * A curve that controls the maximum height that will be achieved during the
97 * flight as a function of the straight-line distance of the flight, in
98 * meters. If the start and end point are on opposite sides of the globe, the
99 * straight-line distance goes through the Earth even though the flight itself
100 * will not.
101 *
102 * If HeightPercentageCurve is not specified, this property is ignored.
103 * If HeightPercentageCurve is specified, but this property is not, then the
104 * maximum height is 30,000 meters regardless of distance.
105 */
106 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
107 UCurveFloat* MaximumHeightByDistanceCurve;
108
109 /**
110 * The length in seconds that the flight should last.
111 */
112 UPROPERTY(
113 EditAnywhere,
114 BlueprintReadWrite,
115 Category = "Cesium",
116 meta = (ClampMin = 0.0))
117 float Duration = 5.0f;
118
119 /**
120 * Indicates which rotation to use during flights.
121 */
122 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
124
125 /**
126 * A delegate that will be called when the Actor finishes flying.
127 *
128 */
129 UPROPERTY(BlueprintAssignable, Category = "Cesium");
130 FCesiumFlightCompleted OnFlightComplete;
131
132 /**
133 * A delegate that will be called when the Actor's flight is interrupted.
134 *
135 */
136 UPROPERTY(BlueprintAssignable, Category = "Cesium");
137 FCesiumFlightInterrupted OnFlightInterrupted;
138
139 /**
140 * Begin a smooth flight to the given Earth-Centered, Earth-Fixed
141 * (ECEF) destination, such that the Actor ends at the specified yaw and
142 * pitch. The yaw and pitch are expressed relative to an East-South-Up frame
143 * at the destination. The characteristics of the flight can be configured
144 * with the properties on this component.
145 *
146 * If CanInterruptByMoving is true and the Actor moves independent of this
147 * component, then the flight in progress will be canceled.
148 */
149 UFUNCTION(BlueprintCallable, Category = "Cesium")
150 void FlyToLocationEarthCenteredEarthFixed(
151 const FVector& EarthCenteredEarthFixedDestination,
152 double YawAtDestination,
153 double PitchAtDestination,
154 bool CanInterruptByMoving);
155
156 /**
157 * Begin a smooth camera flight to the given WGS84 longitude in degrees (x),
158 * latitude in degrees (y), and height in meters (z) such that the camera
159 * ends at the given yaw and pitch. The yaw and pitch are expressed relative
160 * to an East-South-Up frame at the destination. The characteristics of the
161 * flight can be configured with the properties on this component.
162 *
163 * Note that the height is measured in meters above the WGS84 ellipsoid, and
164 * should not be confused with a height relative to mean sea level, which may
165 * be tens of meters different depending on where you are on the globe.
166 *
167 * If CanInterruptByMoving is true and the Actor moves independent of this
168 * component, then the flight in progress will be canceled.
169 */
170 UFUNCTION(BlueprintCallable, Category = "Cesium")
171 void FlyToLocationLongitudeLatitudeHeight(
172 const FVector& LongitudeLatitudeHeightDestination,
173 double YawAtDestination,
174 double PitchAtDestination,
175 bool CanInterruptByMoving);
176
177 /**
178 * Begin a smooth flight to the given destination in Unreal coordinates, such
179 * that the Actor ends at the specified yaw and pitch. The yaw and pitch are
180 * expressed relative to an East-South-Up frame at the destination. The
181 * characteristics of the flight can be configured with the properties on this
182 * component.
183 *
184 * If CanInterruptByMoving is true and the Actor moves independent of this
185 * component, then the flight in progress will be canceled.
186 */
187 UFUNCTION(BlueprintCallable, Category = "Cesium")
188 void FlyToLocationUnreal(
189 const FVector& UnrealDestination,
190 double YawAtDestination,
191 double PitchAtDestination,
192 bool CanInterruptByMoving);
193
194 /**
195 * Interrupts the flight that is currently in progress, leaving the Actor
196 * wherever it is currently.
197 */
198 UFUNCTION(BlueprintCallable, Category = "Cesium")
199 void InterruptFlight();
200
201protected:
202 virtual void TickComponent(
203 float DeltaTime,
204 ELevelTick TickType,
205 FActorComponentTickFunction* ThisTickFunction) override;
206
207private:
208 FQuat GetCurrentRotationEastSouthUp();
209 void SetCurrentRotationEastSouthUp(const FQuat& EastSouthUpRotation);
210
211 bool _flightInProgress = false;
212 bool _canInterruptByMoving;
213 float _currentFlyTime;
214 double _maxHeight;
215 FVector _destinationEcef;
216 FQuat _sourceRotation;
217 FQuat _destinationRotation;
218 FVector _previousPositionEcef;
219 TUniquePtr<CesiumGeospatial::SimplePlanarEllipsoidCurve> _currentCurve;
220 double _length;
221};
ECesiumFlyToRotation
Indicates which rotation to use for orienting the object during flights.
@ Actor
Uses the relative rotation of the root component of the Actor to which the CesiumFlyToComponent is at...
@ ControlRotationInEastSouthUp
Uses the ControlRotation of the Controller of the Pawn to which the CesiumFlyToComponent is attached.
@ ControlRotationInUnreal
Uses the ControlRotation of the Controller of the Pawn to which the CesiumFlyToComponent is attached.
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FCesiumFlightCompleted)
The delegate for when the Actor finishes flying.
Smoothly animates the Actor to which it is attached on a flight to a new location on the globe.
This component can be added to a movable actor to anchor it to the globe and maintain precise placeme...