Cesium for Unreal 2.13.2
Loading...
Searching...
No Matches
GlobeAwareDefaultPawn.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "CesiumGeospatial/Ellipsoid.h"
6#include "CoreMinimal.h"
7#include "GameFramework/DefaultPawn.h"
8#include <glm/mat3x3.hpp>
9#include <glm/vec3.hpp>
10#include <vector>
11#include "GlobeAwareDefaultPawn.generated.h"
12
15class UCurveFloat;
17
18/**
19 * The delegate for when the pawn finishes flying
20 * which is triggered from _handleFlightStep
21 */
23
24/**
25 * The delegate for when the pawn's flying is interrupted
26 * which is triggered from _interruptFlight
27 */
29
30/**
31 * This pawn can be used to easily move around the globe while maintaining a
32 * sensible orientation. As the pawn moves across the horizon, it automatically
33 * changes its own up direction such that the world always looks right-side up.
34 */
35UCLASS()
36class CESIUMRUNTIME_API AGlobeAwareDefaultPawn : public ADefaultPawn {
37 GENERATED_BODY()
38
39public:
41
42 /**
43 * Input callback to move forward in local space (or backward if Val is
44 * negative).
45 * @param Val Amount of movement in the forward direction (or backward if
46 * negative).
47 * @see APawn::AddMovementInput()
48 */
49 virtual void MoveForward(float Val) override;
50
51 /**
52 * Input callback to strafe right in local space (or left if Val is negative).
53 * @param Val Amount of movement in the right direction (or left if negative).
54 * @see APawn::AddMovementInput()
55 */
56 virtual void MoveRight(float Val) override;
57
58 /**
59 * Input callback to move up in world space (or down if Val is negative).
60 * @param Val Amount of movement in the world up direction (or down if
61 * negative).
62 * @see APawn::AddMovementInput()
63 */
64 virtual void MoveUp_World(float Val) override;
65
66 /**
67 * Gets the absolute rotation of the camera view from the Unreal world.
68 */
69 virtual FRotator GetViewRotation() const override;
70
71 /**
72 * Gets the rotation of the aim direction, which is the same as the View
73 * Rotation.
74 */
75 virtual FRotator GetBaseAimRotation() const override;
76
77 UPROPERTY(
78 meta =
79 (DeprecatedProperty,
80 DeprecationMessage =
81 "FlyToGranularityDegrees has been deprecated. This property no longer needs to be set."))
82 float FlyToGranularityDegrees_DEPRECATED = 0.01f;
83
84 UPROPERTY(
85 BlueprintAssignable,
86 meta =
87 (DeprecatedProperty,
88 DeprecationMessage =
89 "Use OnFlightComplete on CesiumFlyToComponent instead."))
90 FCompletedFlight OnFlightComplete_DEPRECATED;
91
92 UPROPERTY(
93 BlueprintAssignable,
94 meta =
95 (DeprecatedProperty,
96 DeprecationMessage =
97 "Use OnFlightInterrupted on CesiumFlyToComponent instead."))
98 FInterruptedFlight OnFlightInterrupt_DEPRECATED;
99
100 /**
101 * Gets the transformation from globe's reference frame to the Unreal world
102 * (relative to the floating origin). This is equivalent to calling
103 * GetActorTransform on this pawn's attach parent, if it has one. If this pawn
104 * does not have an attach parent, an identity transformation is returned.
105 */
106 UFUNCTION(BlueprintPure, Category = "Cesium")
107 const FTransform& GetGlobeToUnrealWorldTransform() const;
108
109 /**
110 * Begin a smooth camera flight to the given Earth-Centered, Earth-Fixed
111 * (ECEF) destination such that the camera ends at the specified yaw and
112 * pitch. The characteristics of the flight can be configured with
113 * {@see FlyToAltitudeProfileCurve}, {@see FlyToProgressCurve},
114 * {@see FlyToMaximumAltitudeCurve}, and {@see FlyToDuration}
115 */
116 UFUNCTION(
117 BlueprintCallable,
118 meta =
119 (DeprecatedFunction,
120 DeprecationMessage =
121 "Use FlyToEarthCenteredEarthFixed on CesiumFlyToComponent instead."))
122 void FlyToLocationECEF(
123 const FVector& ECEFDestination,
124 double YawAtDestination,
125 double PitchAtDestination,
126 bool CanInterruptByMoving);
127
128 /**
129 * Begin a smooth camera flight to the given WGS84 longitude in degrees (x),
130 * latitude in degrees (y), and height in meters (z) such that the camera
131 * ends at the given yaw and pitch. The characteristics of the flight can be
132 * configured with {@see FlyToAltitudeProfileCurve},
133 * {@see FlyToProgressCurve}, {@see FlyToMaximumAltitudeCurve},
134 * {@see FlyToDuration}, and {@see FlyToGranularityDegrees}.
135 */
136 UFUNCTION(
137 BlueprintCallable,
138 meta =
139 (DeprecatedFunction,
140 DeprecationMessage =
141 "Use FlyToLocationLongitudeLatitudeHeight on CesiumFlyToComponent instead."))
143 const FVector& LongitudeLatitudeHeightDestination,
144 double YawAtDestination,
145 double PitchAtDestination,
146 bool CanInterruptByMoving);
147
148protected:
149 virtual void Serialize(FArchive& Ar) override;
150 virtual void PostLoad() override;
151
152 /**
153 * THIS PROPERTY IS DEPRECATED.
154 *
155 * Get the Georeference instance from the Globe Anchor Component instead.
156 */
157 UPROPERTY(
158 Category = "Cesium",
159 BlueprintReadOnly,
160 BlueprintGetter = GetGeoreference,
161 Meta =
162 (DeprecatedProperty,
163 DeprecationMessage =
164 "Get the Georeference instance from the Globe Anchor Component instead."))
165 ACesiumGeoreference* Georeference_DEPRECATED;
166
167 /**
168 * Gets the Georeference Actor associated with this instance. It is obtained
169 * from the Globe Anchor Component.
170 */
171 UFUNCTION(BlueprintGetter, Category = "Cesium")
172 ACesiumGeoreference* GetGeoreference() const;
173
174 /**
175 * The Globe Anchor Component that precisely ties this Pawn to the Globe.
176 */
177 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Cesium")
179
180private:
181 UPROPERTY(
182 Category = "Cesium",
183 BlueprintGetter = GetFlyToProgressCurve_DEPRECATED,
184 BlueprintSetter = SetFlyToProgressCurve_DEPRECATED,
185 meta =
186 (AllowPrivateAccess,
187 DeprecatedProperty,
188 DeprecationMessage =
189 "Use ProgressCurve on CesiumFlyToComponent instead."))
190 UCurveFloat* FlyToProgressCurve_DEPRECATED;
191 UFUNCTION(BlueprintGetter)
192 UCurveFloat* GetFlyToProgressCurve_DEPRECATED() const;
193 UFUNCTION(BlueprintSetter)
194 void SetFlyToProgressCurve_DEPRECATED(UCurveFloat* NewValue);
195
196 UPROPERTY(
197 Category = "Cesium",
198 BlueprintGetter = GetFlyToAltitudeProfileCurve_DEPRECATED,
199 BlueprintSetter = SetFlyToAltitudeProfileCurve_DEPRECATED,
200 meta =
201 (AllowPrivateAccess,
202 DeprecatedProperty,
203 DeprecationMessage =
204 "Use HeightPercentageCurve on CesiumFlyToComponent instead."))
205 UCurveFloat* FlyToAltitudeProfileCurve_DEPRECATED;
206 UFUNCTION(BlueprintGetter)
207 UCurveFloat* GetFlyToAltitudeProfileCurve_DEPRECATED() const;
208 UFUNCTION(BlueprintSetter)
209 void SetFlyToAltitudeProfileCurve_DEPRECATED(UCurveFloat* NewValue);
210
211 UPROPERTY(
212 Category = "Cesium",
213 BlueprintGetter = GetFlyToMaximumAltitudeCurve_DEPRECATED,
214 BlueprintSetter = SetFlyToMaximumAltitudeCurve_DEPRECATED,
215 meta =
216 (AllowPrivateAccess,
217 DeprecatedProperty,
218 DeprecationMessage =
219 "Use MaximumHeightByDistanceCurve on CesiumFlyToComponent instead."))
220 UCurveFloat* FlyToMaximumAltitudeCurve_DEPRECATED;
221 UFUNCTION(BlueprintGetter)
222 UCurveFloat* GetFlyToMaximumAltitudeCurve_DEPRECATED() const;
223 UFUNCTION(BlueprintSetter)
224 void SetFlyToMaximumAltitudeCurve_DEPRECATED(UCurveFloat* NewValue);
225
226 UPROPERTY(
227 Category = "Cesium",
228 BlueprintGetter = GetFlyToDuration_DEPRECATED,
229 BlueprintSetter = SetFlyToDuration_DEPRECATED,
230 meta =
231 (AllowPrivateAccess,
232 DeprecatedProperty,
233 DeprecationMessage =
234 "Use Duration on CesiumFlyToComponent instead."))
235 float FlyToDuration_DEPRECATED = 5.0f;
236 UFUNCTION(BlueprintGetter)
237 float GetFlyToDuration_DEPRECATED() const;
238 UFUNCTION(BlueprintSetter)
239 void SetFlyToDuration_DEPRECATED(float NewValue);
240
241 void _moveAlongViewAxis(EAxis::Type axis, double Val);
242 void _moveAlongVector(const FVector& axis, double Val);
243
244 UFUNCTION()
245 void _onFlightComplete();
246
247 UFUNCTION()
248 void _onFlightInterrupted();
249};
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FCompletedFlight)
The delegate for when the pawn finishes flying which is triggered from _handleFlightStep.
Controls how global geospatial coordinates are mapped to coordinates in the Unreal Engine level.
This pawn can be used to easily move around the globe while maintaining a sensible orientation.
virtual FRotator GetBaseAimRotation() const override
Gets the rotation of the aim direction, which is the same as the View Rotation.
virtual FRotator GetViewRotation() const override
Gets the absolute rotation of the camera view from the Unreal world.
virtual void MoveForward(float Val) override
Input callback to move forward in local space (or backward if Val is negative).
virtual void MoveUp_World(float Val) override
Input callback to move up in world space (or down if Val is negative).
virtual void MoveRight(float Val) override
Input callback to strafe right in local space (or left if Val is negative).
Smoothly animates the Actor to which it is attached on a flight to a new location on the globe.
FCesiumFlightCompleted OnFlightComplete
A delegate that will be called when the Actor finishes flying.
UCurveFloat * ProgressCurve
A curve that is used to determine the flight progress percentage for all the other curves.
float Duration
The length in seconds that the flight should last.
UCurveFloat * MaximumHeightByDistanceCurve
A curve that controls the maximum height that will be achieved during the flight as a function of the...
void FlyToLocationLongitudeLatitudeHeight(const FVector &LongitudeLatitudeHeightDestination, double YawAtDestination, double PitchAtDestination, bool CanInterruptByMoving)
Begin a smooth camera flight to the given WGS84 longitude in degrees (x), latitude in degrees (y),...
FCesiumFlightInterrupted OnFlightInterrupted
A delegate that will be called when the Actor's flight is interrupted.
UCurveFloat * HeightPercentageCurve
A curve that controls what percentage of the maximum height the Actor should take at a given time on ...
This component can be added to a movable actor to anchor it to the globe and maintain precise placeme...