Cesium for Unreal 2.13.2
Loading...
Searching...
No Matches
CesiumGeoreference.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "CesiumEllipsoid.h"
6#include "CesiumGeospatial/LocalHorizontalCoordinateSystem.h"
7#include "CesiumSubLevel.h"
8#include "Delegates/Delegate.h"
9#include "GameFramework/Actor.h"
10#include "GeoTransforms.h"
11#include "OriginPlacement.h"
12#include "CesiumGeoreference.generated.h"
13
14class APlayerCameraManager;
15class FLevelCollectionModel;
17
18/**
19 * The delegate for the ACesiumGeoreference::OnGeoreferenceUpdated,
20 * which is triggered from UpdateGeoreference
21 */
23
24/**
25 * The event that triggers when a georeference's ellipsoid is changed.
26 * This should be used for performing any necessary coordinate changes.
27 * The parameters are (OldEllipsoid, NewEllipsoid).
28 */
29DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(
32 OldEllipsoid,
34 NewEllipsoid);
35
36/**
37 * Controls how global geospatial coordinates are mapped to coordinates in the
38 * Unreal Engine level. Internally, Cesium uses a global Earth-centered,
39 * Earth-fixed (ECEF) ellipsoid-centered coordinate system, where the ellipsoid
40 * is usually the World Geodetic System 1984 (WGS84) ellipsoid. This is a
41 * right-handed system centered at the Earth's center of mass, where +X is in
42 * the direction of the intersection of the Equator and the Prime Meridian (zero
43 * degrees longitude), +Y is in the direction of the intersection of the Equator
44 * and +90 degrees longitude, and +Z is through the North Pole. This Actor is
45 * used by other Cesium Actors and components to control how this coordinate
46 * system is mapped into an Unreal Engine world and level.
47 */
48UCLASS()
49class CESIUMRUNTIME_API ACesiumGeoreference : public AActor {
50 GENERATED_BODY()
51public:
52 /**
53 * The minimum allowed value for the Scale property, 1e-6.
54 */
55 static const double kMinimumScale;
56
57 /**
58 * Finds and returns a CesiumGeoreference in the world. It searches in the
59 * following order:
60 *
61 * 1. A CesiumGeoreference that is tagged with "DEFAULT_GEOREFERENCE" and
62 * found in the PersistentLevel.
63 * 2. A CesiumGeoreference with the name "CesiumGeoreferenceDefault" and found
64 * in the PersistentLevel.
65 * 3. Any CesiumGeoreference in the PersistentLevel.
66 *
67 * If no CesiumGeoreference is found with this search, a new one is created in
68 * the persistent level and given the "DEFAULT_GEOREFERENCE" tag.
69 */
70 UFUNCTION(
71 BlueprintCallable,
72 Category = "Cesium",
73 meta = (WorldContext = "WorldContextObject"))
75 GetDefaultGeoreference(const UObject* WorldContextObject);
76
77 /**
78 * Finds and returns the CesiumGeoreference suitable for use with the given
79 * Actor. It searches in the following order:
80 *
81 * 1. A CesiumGeoreference that is an attachment parent of the given Actor.
82 * 2. A CesiumGeoreference that is tagged with "DEFAULT_GEOREFERENCE" and
83 * found in the PersistentLevel.
84 * 3. A CesiumGeoreference with the name "CesiumGeoreferenceDefault" and found
85 * in the PersistentLevel.
86 * 4. Any CesiumGeoreference in the PersistentLevel.
87 *
88 * If no CesiumGeoreference is found with this search, a new one is created in
89 * the persistent level and given the "DEFAULT_GEOREFERENCE" tag.
90 */
91 UFUNCTION(BlueprintCallable, Category = "Cesium")
92 static ACesiumGeoreference* GetDefaultGeoreferenceForActor(AActor* Actor);
93
94 /**
95 * A delegate that will be called whenever the Georeference is
96 * modified in a way that affects its computations.
97 */
98 UPROPERTY(BlueprintAssignable, Category = "Cesium")
99 FGeoreferenceUpdated OnGeoreferenceUpdated;
100
101 /**
102 * An event that will be called whenever the georeference's ellipsoid has
103 * been modified.
104 */
105 UPROPERTY(BlueprintAssignable, Category = "Cesium")
107
108#pragma region Properties
109
110private:
111 /**
112 * The Ellipsoid being used by this georeference. The ellipsoid informs how
113 * cartographic coordinates will be interpreted and how they are transformed
114 * into cartesian coordinates.
115 */
116 UPROPERTY(
117 Category = "Cesium",
118 EditAnywhere,
119 BlueprintReadWrite,
120 BlueprintGetter = GetEllipsoid,
121 BlueprintSetter = SetEllipsoid,
122 meta = (AllowPrivateAccess))
123 UCesiumEllipsoid* Ellipsoid;
124
125 /**
126 * The placement of this Actor's origin (coordinate 0,0,0) within the tileset.
127 *
128 * 3D Tiles tilesets often use Earth-centered, Earth-fixed coordinates, such
129 * that the tileset content is in a small bounding volume 6-7 million meters
130 * (the radius of the Earth) away from the coordinate system origin. This
131 * property allows an alternative position, other then the tileset's true
132 * origin, to be treated as the origin for the purpose of this Actor. Using
133 * this property will preserve vertex precision (and thus avoid jittering)
134 * much better than setting the Actor's Transform property.
135 */
136 UPROPERTY(
137 Category = "Cesium",
138 EditAnywhere,
139 BlueprintReadWrite,
140 BlueprintGetter = GetOriginPlacement,
141 BlueprintSetter = SetOriginPlacement,
142 meta = (AllowPrivateAccess))
143 EOriginPlacement OriginPlacement = EOriginPlacement::CartographicOrigin;
144
145 /**
146 * The latitude of the custom origin placement in degrees, in the range [-90,
147 * 90]
148 */
149 UPROPERTY(
150 Category = "Cesium",
151 EditAnywhere,
152 BlueprintReadWrite,
153 BlueprintGetter = GetOriginLatitude,
154 BlueprintSetter = SetOriginLatitude,
155 Interp,
156 meta =
157 (AllowPrivateAccess,
158 EditCondition =
159 "OriginPlacement==EOriginPlacement::CartographicOrigin",
160 ClampMin = -90.0,
161 ClampMax = 90.0))
162 double OriginLatitude = 39.736401;
163
164 /**
165 * The longitude of the custom origin placement in degrees, in the range
166 * [-180, 180]
167 */
168 UPROPERTY(
169 Category = "Cesium",
170 EditAnywhere,
171 BlueprintReadWrite,
172 BlueprintGetter = GetOriginLongitude,
173 BlueprintSetter = SetOriginLongitude,
174 Interp,
175 meta =
176 (AllowPrivateAccess,
177 EditCondition =
178 "OriginPlacement==EOriginPlacement::CartographicOrigin",
179 ClampMin = -180.0,
180 ClampMax = 180.0))
181 double OriginLongitude = -105.25737;
182
183 /**
184 * The height of the custom origin placement in meters above the
185 * ellipsoid.
186 */
187 UPROPERTY(
188 Category = "Cesium",
189 EditAnywhere,
190 BlueprintReadWrite,
191 BlueprintGetter = GetOriginHeight,
192 BlueprintSetter = SetOriginHeight,
193 Interp,
194 meta =
195 (AllowPrivateAccess,
196 EditCondition =
197 "OriginPlacement==EOriginPlacement::CartographicOrigin"))
198 double OriginHeight = 2250.0;
199
200 /**
201 * The percentage scale of the globe in the Unreal world. If this value is 50,
202 * for example, one meter on the globe occupies half a meter in the Unreal
203 * world.
204 */
205 UPROPERTY(
206 Category = "Cesium",
207 EditAnywhere,
208 BlueprintReadWrite,
209 BlueprintSetter = SetScale,
210 BlueprintGetter = GetScale,
211 Interp,
212 Meta = (AllowPrivateAccess, UIMin = 0.000001, UIMax = 100.0))
213 double Scale = 100.0;
214
215 /**
216 * The camera to use to determine which sub-level is closest, so that one can
217 * be activated and all others deactivated.
218 * @deprecated Add a CesiumOriginShiftComponent to the appropriate Actor
219 * instead.
220 */
221 UPROPERTY(
222 meta =
223 (DeprecatedProperty,
224 DeprecationMessage =
225 "Add a CesiumOriginShiftComponent to the appropriate Actor instead."))
226 APlayerCameraManager* SubLevelCamera_DEPRECATED = nullptr;
227
228 /**
229 * The component that allows switching between the sub-levels registered with
230 * this georeference.
231 */
232 UPROPERTY(
233 Instanced,
234 Category = "Cesium|Sub-levels",
235 BlueprintReadOnly,
236 BlueprintGetter = GetSubLevelSwitcher,
237 meta = (AllowPrivateAccess))
238 UCesiumSubLevelSwitcherComponent* SubLevelSwitcher;
239
240#if WITH_EDITORONLY_DATA
241 /**
242 * Whether to visualize the level loading radii in the editor. Helpful for
243 * initially positioning the level and choosing a load radius.
244 */
245 UPROPERTY(
246 Category = "Cesium|Sub-levels",
247 EditAnywhere,
248 BlueprintReadWrite,
249 BlueprintGetter = GetShowLoadRadii,
250 BlueprintSetter = SetShowLoadRadii,
251 meta = (AllowPrivateAccess))
252 bool ShowLoadRadii = true;
253#endif
254
255#pragma endregion
256
257#pragma region PropertyAccessors
258
259public:
260 /**
261 * Returns the georeference origin position as an FVector where `X` is
262 * longitude (degrees), `Y` is latitude (degrees), and `Z` is height above the
263 * ellipsoid (meters). Only valid if the placement type is Cartographic Origin
264 * (i.e. Longitude / Latitude / Height).
265 */
266 UFUNCTION(BlueprintPure, Category = "Cesium")
267 FVector GetOriginLongitudeLatitudeHeight() const;
268
269 /**
270 * This aligns the specified longitude in degrees (X), latitude in
271 * degrees (Y), and height above the ellipsoid in meters (Z) to the Unreal
272 * origin. That is, it moves the globe so that these coordinates exactly fall
273 * on the origin. Only valid if the placement type is Cartographic Origin
274 * (i.e. Longitude / Latitude / Height).
275 */
276 UFUNCTION(BlueprintCallable, Category = "Cesium")
277 void SetOriginLongitudeLatitudeHeight(
278 const FVector& TargetLongitudeLatitudeHeight);
279
280 /**
281 * Returns the georeference origin position as an FVector in Earth-Centerd,
282 * Earth-Fixed (ECEF) coordinates. Only valid if the placement type is
283 * Cartographic Origin (i.e. Longitude / Latitude / Height).
284 */
285 UFUNCTION(BlueprintPure, Category = "Cesium")
286 FVector GetOriginEarthCenteredEarthFixed() const;
287
288 /**
289 * This aligns the specified Earth-Centered, Earth-Fixed (ECEF) coordinates to
290 * the Unreal origin. That is, it moves the globe so that these coordinates
291 * exactly fall on the origin. Only valid if the placement type is
292 * Cartographic Origin (i.e. Longitude / Latitude / Height). Note that if the
293 * provided ECEF coordiantes are near the center of the Earth so that
294 * Longitude, Latitude, and Height are undefined, this function will instead
295 * place the origin at 0 degrees longitude, 0 degrees latitude, and 0 meters
296 * height about the ellipsoid.
297 */
298 UFUNCTION(BlueprintCallable, Category = "Cesium")
299 void SetOriginEarthCenteredEarthFixed(
300 const FVector& TargetEarthCenteredEarthFixed);
301
302 /**
303 * Gets the placement of this Actor's origin (coordinate 0,0,0) within the
304 * tileset.
305 *
306 * 3D Tiles tilesets often use Earth-centered, Earth-fixed coordinates, such
307 * that the tileset content is in a small bounding volume 6-7 million meters
308 * (the radius of the Earth) away from the coordinate system origin. This
309 * property allows an alternative position, other then the tileset's true
310 * origin, to be treated as the origin for the purpose of this Actor. Using
311 * this property will preserve vertex precision (and thus avoid jittering)
312 * much better than setting the Actor's Transform property.
313 */
314 UFUNCTION(BlueprintGetter)
315 EOriginPlacement GetOriginPlacement() const;
316
317 /**
318 * Sets the placement of this Actor's origin (coordinate 0,0,0) within the
319 * tileset.
320 *
321 * 3D Tiles tilesets often use Earth-centered, Earth-fixed coordinates, such
322 * that the tileset content is in a small bounding volume 6-7 million meters
323 * (the radius of the Earth) away from the coordinate system origin. This
324 * property allows an alternative position, other then the tileset's true
325 * origin, to be treated as the origin for the purpose of this Actor. Using
326 * this property will preserve vertex precision (and thus avoid jittering)
327 * much better than setting the Actor's Transform property.
328 */
329 UFUNCTION(BlueprintSetter)
330 void SetOriginPlacement(EOriginPlacement NewValue);
331
332 /**
333 * Gets the latitude of the custom origin placement in degrees, in the range
334 * [-90, 90]
335 */
336 UFUNCTION(BlueprintGetter)
337 double GetOriginLatitude() const;
338
339 /**
340 * Sets the latitude of the custom origin placement in degrees, in the range
341 * [-90, 90]
342 */
343 UFUNCTION(BlueprintSetter)
344 void SetOriginLatitude(double NewValue);
345
346 /**
347 * Gets the longitude of the custom origin placement in degrees, in the range
348 * [-180, 180]
349 */
350 UFUNCTION(BlueprintGetter)
351 double GetOriginLongitude() const;
352
353 /**
354 * Sets the longitude of the custom origin placement in degrees, in the range
355 * [-180, 180]
356 */
357 UFUNCTION(BlueprintSetter)
358 void SetOriginLongitude(double NewValue);
359
360 /**
361 * Gets the height of the custom origin placement in meters above the
362 * ellipsoid.
363 */
364 UFUNCTION(BlueprintGetter)
365 double GetOriginHeight() const;
366
367 /**
368 * Sets the height of the custom origin placement in meters above the
369 * ellipsoid.
370 */
371 UFUNCTION(BlueprintSetter)
372 void SetOriginHeight(double NewValue);
373
374 /**
375 * Gets the percentage scale of the globe in the Unreal world. If this value
376 * is 50, for example, one meter on the globe occupies half a meter in the
377 * Unreal world.
378 */
379 UFUNCTION(BlueprintGetter)
380 double GetScale() const;
381
382 /**
383 * Sets the percentage scale of the globe in the Unreal world. If this value
384 * is 50, for example, one meter on the globe occupies half a meter in the
385 * Unreal world.
386 */
387 UFUNCTION(BlueprintSetter)
388 void SetScale(double NewValue);
389
390 /**
391 * Gets the camera to use to determine which sub-level is closest, so that one
392 * can be activated and all others deactivated.
393 */
394 UE_DEPRECATED(
395 "Cesium For Unreal v2.0",
396 "Add a CesiumOriginShiftComponent to the appropriate Actor instead.")
397 UFUNCTION(BlueprintGetter)
398 APlayerCameraManager* GetSubLevelCamera() const;
399
400 /**
401 * Sets the camera to use to determine which sub-level is closest, so that one
402 * can be activated and all others deactivated.
403 */
404 UE_DEPRECATED(
405 "Cesium For Unreal v2.0",
406 "Add a CesiumOriginShiftComponent to the appropriate Actor instead.")
407 UFUNCTION(BlueprintSetter)
408 void SetSubLevelCamera(APlayerCameraManager* NewValue);
409
410 /**
411 * Gets the component that allows switching between different sub-levels
412 * registered with this georeference.
413 */
414 UFUNCTION(BlueprintGetter)
415 UCesiumSubLevelSwitcherComponent* GetSubLevelSwitcher() const {
416 return this->SubLevelSwitcher;
417 }
418
419 /**
420 * Returns a pointer to the UCesiumEllipsoid currently being used by this
421 * georeference.
422 */
423 UFUNCTION(BlueprintCallable, BlueprintGetter, Category = "Cesium")
424 UCesiumEllipsoid* GetEllipsoid() const;
425
426 /**
427 * Sets the UCesiumEllipsoid used by this georeference.
428 *
429 * Calling this will cause all tilesets under this georeference to be
430 * reloaded.
431 */
432 UFUNCTION(BlueprintSetter, Category = "Cesium")
433 void SetEllipsoid(UCesiumEllipsoid* NewEllipsoid);
434
435#if WITH_EDITOR
436 /**
437 * Gets whether to visualize the level loading radii in the editor. Helpful
438 * for initially positioning the level and choosing a load radius.
439 */
440 UFUNCTION(BlueprintGetter)
441 bool GetShowLoadRadii() const;
442
443 /**
444 * Sets whether to visualize the level loading radii in the editor. Helpful
445 * for initially positioning the level and choosing a load radius.
446 */
447 UFUNCTION(BlueprintSetter)
448 void SetShowLoadRadii(bool NewValue);
449#endif // WITH_EDITOR
450
451#pragma endregion
452
453#pragma region Transformation Functions
454
455public:
456 /**
457 * Transforms the given longitude in degrees (x), latitude in
458 * degrees (y), and height above the ellipsoid in meters (z) into Unreal
459 * coordinates. The resulting position should generally not be interpreted as
460 * an Unreal _world_ position, but rather a position expressed in some parent
461 * Actor's reference frame as defined by its transform. This way, the chain of
462 * Unreal transforms places and orients the "globe" in the Unreal world.
463 */
464 UFUNCTION(
465 BlueprintPure,
466 Category = "Cesium",
467 meta = (ReturnDisplayName = "UnrealPosition"))
468 FVector TransformLongitudeLatitudeHeightPositionToUnreal(
469 const FVector& LongitudeLatitudeHeight) const;
470
471 /**
472 * Transforms a position in Unreal coordinates into longitude in degrees (x),
473 * latitude in degrees (y), and height above the ellipsoid in meters (z). The
474 * position should generally not be an Unreal _world_ position, but rather a
475 * position expressed in some parent Actor's reference frame as defined by its
476 * transform. This way, the chain of Unreal transforms places and orients the
477 * "globe" in the Unreal world.
478 */
479 UFUNCTION(
480 BlueprintPure,
481 Category = "Cesium",
482 meta = (ReturnDisplayName = "LongitudeLatitudeHeight"))
483 FVector TransformUnrealPositionToLongitudeLatitudeHeight(
484 const FVector& UnrealPosition) const;
485
486 /**
487 * Transforms a position in Earth-Centered, Earth-Fixed (ECEF) coordinates
488 * into Unreal coordinates. The resulting position should generally not be
489 * interpreted as an Unreal _world_ position, but rather a position expressed
490 * in some parent Actor's reference frame as defined by its transform. This
491 * way, the chain of Unreal transforms places and orients the "globe" in the
492 * Unreal world.
493 */
494 UFUNCTION(
495 BlueprintPure,
496 Category = "Cesium",
497 meta = (ReturnDisplayName = "UnrealPosition"))
498 FVector TransformEarthCenteredEarthFixedPositionToUnreal(
499 const FVector& EarthCenteredEarthFixedPosition) const;
500
501 /**
502 * Transforms the given position from Unreal coordinates to Earth-Centered,
503 * Earth-Fixed (ECEF). The position should generally not be an Unreal _world_
504 * position, but rather a position expressed in some parent Actor's reference
505 * frame as defined by its transform. This way, the chain of Unreal transforms
506 * places and orients the "globe" in the Unreal world.
507 */
508 UFUNCTION(
509 BlueprintPure,
510 Category = "Cesium",
511 meta = (ReturnDisplayName = "EarthCenteredEarthFixedPosition"))
512 FVector TransformUnrealPositionToEarthCenteredEarthFixed(
513 const FVector& UnrealPosition) const;
514
515 /**
516 * Transforms a direction vector in Earth-Centered, Earth-Fixed (ECEF)
517 * coordinates into Unreal coordinates. The resulting direction vector should
518 * generally not be interpreted as an Unreal _world_ vector, but rather a
519 * vector expressed in some parent Actor's reference frame as defined by its
520 * transform. This way, the chain of Unreal transforms places and orients the
521 * "globe" in the Unreal world.
522 */
523 UFUNCTION(
524 BlueprintPure,
525 Category = "Cesium",
526 meta = (ReturnDisplayName = "UnrealDirection"))
527 FVector TransformEarthCenteredEarthFixedDirectionToUnreal(
528 const FVector& EarthCenteredEarthFixedDirection) const;
529
530 /**
531 * Transforms the given direction vector from Unreal coordinates to
532 * Earth-Centered, Earth-Fixed (ECEF) coordinates. The direction vector should
533 * generally not be an Unreal _world_ vector, but rather a vector expressed in
534 * some parent Actor's reference frame as defined by its transform. This way,
535 * the chain of Unreal transforms places and orients the "globe" in the Unreal
536 * world.
537 */
538 UFUNCTION(
539 BlueprintPure,
540 Category = "Cesium",
541 meta = (ReturnDisplayName = "EarthCenteredEarthFixedPosition"))
542 FVector TransformUnrealDirectionToEarthCenteredEarthFixed(
543 const FVector& UnrealDirection) const;
544
545 /**
546 * Given a Rotator that transforms an object into the Unreal coordinate
547 * system, returns a new Rotator that transforms that object into an
548 * East-South-Up frame centered at a given location.
549 *
550 * In an East-South-Up frame, +X points East, +Y points South, and +Z points
551 * Up. However, the directions of "East", "South", and "Up" in Unreal or ECEF
552 * coordinates vary depending on where on the globe we are talking about.
553 * That is why this function takes a location, expressed in Unreal
554 * coordinates, that defines the origin of the East-South-Up frame of
555 * interest.
556 *
557 * The Unreal location and the resulting Rotator should generally not be
558 * relative to the Unreal _world_, but rather be expressed in some parent
559 * Actor's reference frame as defined by its Transform. This way, the chain of
560 * Unreal transforms places and orients the "globe" in the Unreal world.
561 */
562 UFUNCTION(
563 BlueprintPure,
564 Category = "Cesium",
565 meta = (ReturnDisplayName = "EastSouthUpRotator"))
566 FRotator TransformUnrealRotatorToEastSouthUp(
567 const FRotator& UnrealRotator,
568 const FVector& UnrealLocation) const;
569
570 /**
571 * Given a Rotator that transforms an object into the East-South-Up frame
572 * centered at a given location, returns a new Rotator that transforms that
573 * object into Unreal coordinates.
574 *
575 * In an East-South-Up frame, +X points East, +Y points South, and +Z points
576 * Up. However, the directions of "East", "South", and "Up" in Unreal or ECEF
577 * coordinates vary depending on where on the globe we are talking about.
578 * That is why this function takes a location, expressed in Unreal
579 * coordinates, that defines the origin of the East-South-Up frame of
580 * interest.
581 *
582 * The Unreal location and the resulting Rotator should generally not be
583 * relative to the Unreal _world_, but rather be expressed in some parent
584 * Actor's reference frame as defined by its Transform. This way, the chain of
585 * Unreal transforms places and orients the "globe" in the Unreal world.
586 */
587 UFUNCTION(
588 BlueprintPure,
589 Category = "Cesium",
590 meta = (ReturnDisplayName = "UnrealRotator"))
591 FRotator TransformEastSouthUpRotatorToUnreal(
592 const FRotator& EastSouthUpRotator,
593 const FVector& UnrealLocation) const;
594
595 /**
596 * Computes the transformation matrix from the Unreal coordinate system to the
597 * Earth-Centered, Earth-Fixed (ECEF) coordinate system. The Unreal
598 * coordinates should generally not be interpreted as Unreal _world_
599 * coordinates, but rather a coordinate system based on some parent Actor's
600 * reference frame as defined by its transform. This way, the chain of Unreal
601 * transforms places and orients the "globe" in the Unreal world.
602 */
603 UFUNCTION(
604 BlueprintPure,
605 Category = "Cesium",
606 meta = (ReturnDisplayName = "UnrealToEarthCenteredEarthFixedMatrix"))
607 FMatrix ComputeUnrealToEarthCenteredEarthFixedTransformation() const;
608
609 /**
610 * Computes the transformation matrix from the Earth-Centered, Earth-Fixed
611 * (ECEF) coordinate system to the Unreal coordinate system. The Unreal
612 * coordinates should generally not be interpreted as Unreal _world_
613 * coordinates, but rather a coordinate system based on some parent Actor's
614 * reference frame as defined by its transform. This way, the chain of Unreal
615 * transforms places and orients the "globe" in the Unreal world.
616 */
617 UFUNCTION(
618 BlueprintPure,
619 Category = "Cesium",
620 meta = (ReturnDisplayName = "EarthCenteredEarthFixedToUnrealMatrix"))
621 FMatrix ComputeEarthCenteredEarthFixedToUnrealTransformation() const;
622
623 /**
624 * Computes the matrix that transforms from an East-South-Up frame centered at
625 * a given location to the Unreal frame.
626 *
627 * In an East-South-Up frame, +X points East, +Y points South, and +Z points
628 * Up. However, the directions of "East", "South", and "Up" in Unreal or ECEF
629 * coordinates vary depending on where on the globe we are talking about.
630 * That is why this function takes a location, expressed in Unreal
631 * coordinates, that defines the origin of the East-South-Up frame of
632 * interest.
633 *
634 * The Unreal location and the resulting matrix should generally not be
635 * relative to the Unreal _world_, but rather be expressed in some parent
636 * Actor's reference frame as defined by its Transform. This way, the chain of
637 * Unreal transforms places and orients the "globe" in the Unreal world.
638 */
639 UFUNCTION(
640 BlueprintPure,
641 Category = "Cesium",
642 meta = (ReturnDisplayName = "EastSouthUpToUnrealMatrix"))
643 FMatrix
644 ComputeEastSouthUpToUnrealTransformation(const FVector& UnrealLocation) const;
645
646 /**
647 * Computes the matrix that transforms from an East-South-Up frame centered at
648 * a given location to the Unreal frame. The location is expressed as an
649 * Earth-Centered, Earth-Fixed (ECEF) position. To use an Unreal position
650 * instead, use ComputeUnrealToEastSouthUpTransformation.
651 *
652 * In an East-South-Up frame, +X points East, +Y points South, and +Z points
653 * Up. However, the directions of "East", "South", and "Up" in Unreal or ECEF
654 * coordinates vary depending on where on the globe we are talking about.
655 * That is why this function takes a location, expressed in ECEF
656 * coordinates, that defines the origin of the East-South-Up frame of
657 * interest.
658 *
659 * The resulting matrix should generally not be relative to the Unreal
660 * _world_, but rather be expressed in some parent Actor's reference frame as
661 * defined by its Transform. This way, the chain of Unreal transforms places
662 * and orients the "globe" in the Unreal world.
663 */
664 UFUNCTION(
665 BlueprintPure,
666 Category = "Cesium",
667 meta = (ReturnDisplayName = "EastSouthUpToUnrealMatrix"))
668 FMatrix
669 ComputeEastSouthUpAtEarthCenteredEarthFixedPositionToUnrealTransformation(
670 const FVector& EarthCenteredEarthFixedPosition) const;
671
672 /**
673 * Computes the matrix that transforms from the Unreal frame to an
674 * East-South-Up frame centered at a given location. The location is expressed
675 * in Unreal coordinates. To use an Earth-Centered, Earth-Fixed position
676 * instead, use
677 * ComputeEastSouthUpAtEarthCenteredEarthFixedPositionToUnrealTransformation.
678 *
679 * In an East-South-Up frame, +X points East, +Y points South, and +Z points
680 * Up. However, the directions of "East", "South", and "Up" in Unreal or ECEF
681 * coordinates vary depending on where on the globe we are talking about.
682 * That is why this function takes a location, expressed in Unreal
683 * coordinates, that defines the origin of the East-South-Up frame of
684 * interest.
685 *
686 * The Unreal location and the resulting matrix should generally not be
687 * relative to the Unreal _world_, but rather be expressed in some parent
688 * Actor's reference frame as defined by its Transform. This way, the chain of
689 * Unreal transforms places and orients the "globe" in the Unreal world.
690 */
691 UFUNCTION(
692 BlueprintPure,
693 Category = "Cesium",
694 meta = (ReturnDisplayName = "UnrealToEastSouthUpMatrix"))
695 FMatrix
696 ComputeUnrealToEastSouthUpTransformation(const FVector& UnrealLocation) const;
697
698#pragma endregion
699
700#pragma region Editor Support
701
702#if WITH_EDITOR
703public:
704 /**
705 * Places the georeference origin at the camera's current location. Rotates
706 * the globe so the current longitude/latitude/height of the camera is at the
707 * Unreal origin. The camera is also teleported to the new Unreal origin and
708 * rotated so that the view direction is maintained.
709 *
710 * Warning: Before clicking, ensure that all non-Cesium objects in the
711 * persistent level are georeferenced with the "CesiumGlobeAnchorComponent"
712 * or attached to an actor with that component. Ensure that static actors only
713 * exist in georeferenced sub-levels.
714 */
715 UFUNCTION(Category = "Cesium")
716 void PlaceGeoreferenceOriginHere();
717
718 /**
719 * Creates a new Level Instance Actor at the current viewport location, and
720 * attaches the Cesium Sub Level Component to it. You will be prompted for
721 * where to store the new level.
722 *
723 * Warning: Before clicking, ensure that all non-Cesium objects in the
724 * persistent level are georeferenced with the "CesiumGlobeAnchorComponent"
725 * or attached to an actor with that component. Ensure that static actors only
726 * exist in georeferenced sub-levels.
727 */
728 UFUNCTION(Category = "Cesium")
729 void CreateSubLevelHere();
730#endif
731
732private:
733 // This property mirrors RootComponent, and exists only so that the root
734 // component's transform is editable in the Editor.
735 UPROPERTY(VisibleAnywhere, Category = "Cesium")
736 USceneComponent* Root;
737
738#if WITH_EDITOR
739 /**
740 * @brief Show the load radius of each sub-level as a sphere.
741 *
742 * If this is not called "in-game", and `ShowLoadRadii` is `true`,
743 * then it will show a sphere indicating the load radius of each
744 * sub-level.
745 */
746 void _showSubLevelLoadRadii() const;
747#endif
748
749#pragma endregion
750
751#pragma region Unreal Lifecycle
752
753protected:
754 virtual bool ShouldTickIfViewportsOnly() const override;
755 virtual void Tick(float DeltaTime) override;
756 virtual void Serialize(FArchive& Ar) override;
757 virtual void BeginPlay() override;
758 virtual void OnConstruction(const FTransform& Transform) override;
759 virtual void PostLoad() override;
760
761#if WITH_EDITOR
762 virtual void
763 PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
764#endif
765
766#pragma endregion
767
768#pragma region Obsolete
769
770public:
771 UE_DEPRECATED(
772 "Cesium For Unreal v2.0",
773 "Use transformation functions on ACesiumGeoreference and UCesiumEllipsoid instead.")
774 GeoTransforms GetGeoTransforms() const noexcept;
775
776private:
777 PRAGMA_DISABLE_DEPRECATION_WARNINGS
778 UPROPERTY(
779 Meta =
780 (DeprecatedProperty,
781 DeprecationMessage =
782 "Create sub-levels by adding a UCesiumSubLevelComponent to an ALevelInstance Actor."))
783 TArray<FCesiumSubLevel> CesiumSubLevels_DEPRECATED;
784 PRAGMA_ENABLE_DEPRECATION_WARNINGS
785
786#if WITH_EDITOR
787 void _createSubLevelsFromWorldComposition();
788#endif
789
790 /**
791 * Transforms the given longitude in degrees (x), latitude in
792 * degrees (y), and height above the ellipsoid in meters (z) into
793 * Earth-Centered, Earth-Fixed (ECEF) coordinates.
794 */
795 UFUNCTION(
796 BlueprintPure,
797 Category = "Cesium",
798 meta =
799 (DeprecatedFunction,
800 DeprecationMessage =
801 "Use LongitudeLatitudeHeightToEllipsoidCenteredEllipsoidFixed on UCesiumEllipsoid instead."))
802 FVector TransformLongitudeLatitudeHeightToEcef(
803 const FVector& LongitudeLatitudeHeight) const;
804
805 /**
806 * Transforms the given Earth-Centered, Earth-Fixed (ECEF) coordinates into
807 * Ellipsoid longitude in degrees (x), latitude in degrees (y), and height
808 * above the ellipsoid in meters (z).
809 */
810 UFUNCTION(
811 BlueprintPure,
812 Category = "Cesium",
813 meta =
814 (DeprecatedFunction,
815 DeprecationMessage =
816 "Use EllipsoidCenteredEllipsoidFixedToLongitudeLatitudeHeight on UCesiumEllipsoid instead."))
817 FVector TransformEcefToLongitudeLatitudeHeight(const FVector& Ecef) const;
818
819 /**
820 * Computes the rotation matrix from the local East-North-Up to
821 * Earth-Centered, Earth-Fixed (ECEF) at the specified ECEF location.
822 */
823 UFUNCTION(
824 BlueprintPure,
825 Category = "Cesium",
826 meta =
827 (DeprecatedFunction,
828 DeprecationMessage =
829 "Use EastNorthUpToEllipsoidCenteredEllipsoidFixed on UCesiumEllipsoid instead."))
830 FMatrix ComputeEastNorthUpToEcef(const FVector& Ecef) const;
831
832#pragma endregion
833
834private:
835#pragma region Implementation Details
836
837public:
839
841 GetCoordinateSystem() const noexcept {
842 return this->_coordinateSystem;
843 }
844
845private:
846 /**
847 * Recomputes all world georeference transforms.
848 */
849 void UpdateGeoreference();
850
851 /**
852 * A tag that is assigned to Georeferences when they are created
853 * as the "default" Georeference for a certain world.
854 */
855 static FName DEFAULT_GEOREFERENCE_TAG;
856
858 glm::dmat4(1.0)};
859
860 /**
861 * Updates _geoTransforms based on the current ellipsoid and center, and
862 * returns the old transforms.
863 */
864 void _updateCoordinateSystem();
865
866 friend class FCesiumGeoreferenceCustomization;
867#pragma endregion
868};
@ Actor
Uses the relative rotation of the root component of the Actor to which the CesiumFlyToComponent is at...
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FGeoreferenceUpdated)
The delegate for the ACesiumGeoreference::OnGeoreferenceUpdated, which is triggered from UpdateGeoref...
EOriginPlacement
An enumeration of the possible strategies for placing the origin of a Georeference.
Controls how global geospatial coordinates are mapped to coordinates in the Unreal Engine level.
virtual void PostLoad() override
static const double kMinimumScale
The minimum allowed value for the Scale property, 1e-6.
virtual void BeginPlay() override
virtual void OnConstruction(const FTransform &Transform) override
const CesiumGeospatial::LocalHorizontalCoordinateSystem & GetCoordinateSystem() const noexcept
virtual void Serialize(FArchive &Ar) override
virtual void Tick(float DeltaTime) override
virtual bool ShouldTickIfViewportsOnly() const override
The event that triggers when a georeference's ellipsoid is changed.
A lightweight structure to encapsulate coordinate transforms.
A component intended to be attached to a Level Instance Actor that turns that Level Instance into a C...
Manages the asynchronous switching between sub-levels, making sure that a previous sub-level is hidde...