Cesium for Unreal 2.12.0
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
23
29DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(
32 OldEllipsoid,
34 NewEllipsoid);
35
48UCLASS()
49class CESIUMRUNTIME_API ACesiumGeoreference : public AActor {
50 GENERATED_BODY()
51public:
55 static const double kMinimumScale;
56
70 UFUNCTION(
71 BlueprintCallable,
72 Category = "Cesium",
73 meta = (WorldContext = "WorldContextObject"))
75 GetDefaultGeoreference(const UObject* WorldContextObject);
76
91 UFUNCTION(BlueprintCallable, Category = "Cesium")
92 static ACesiumGeoreference* GetDefaultGeoreferenceForActor(AActor* Actor);
93
98 UPROPERTY(BlueprintAssignable, Category = "Cesium")
99 FGeoreferenceUpdated OnGeoreferenceUpdated;
100
105 UPROPERTY(BlueprintAssignable, Category = "Cesium")
107
108#pragma region Properties
109
110private:
116 UPROPERTY(
117 Category = "Cesium",
118 EditAnywhere,
119 BlueprintReadWrite,
120 BlueprintGetter = GetEllipsoid,
121 BlueprintSetter = SetEllipsoid,
122 meta = (AllowPrivateAccess))
123 UCesiumEllipsoid* Ellipsoid;
124
136 UPROPERTY(
137 Category = "Cesium",
138 EditAnywhere,
139 BlueprintReadWrite,
140 BlueprintGetter = GetOriginPlacement,
141 BlueprintSetter = SetOriginPlacement,
142 meta = (AllowPrivateAccess))
143 EOriginPlacement OriginPlacement = EOriginPlacement::CartographicOrigin;
144
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
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
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
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
221 UPROPERTY(
222 meta =
223 (DeprecatedProperty,
224 DeprecationMessage =
225 "Add a CesiumOriginShiftComponent to the appropriate Actor instead."))
226 APlayerCameraManager* SubLevelCamera_DEPRECATED = nullptr;
227
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
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:
266 UFUNCTION(BlueprintPure, Category = "Cesium")
267 FVector GetOriginLongitudeLatitudeHeight() const;
268
276 UFUNCTION(BlueprintCallable, Category = "Cesium")
277 void SetOriginLongitudeLatitudeHeight(
278 const FVector& TargetLongitudeLatitudeHeight);
279
285 UFUNCTION(BlueprintPure, Category = "Cesium")
286 FVector GetOriginEarthCenteredEarthFixed() const;
287
298 UFUNCTION(BlueprintCallable, Category = "Cesium")
299 void SetOriginEarthCenteredEarthFixed(
300 const FVector& TargetEarthCenteredEarthFixed);
301
314 UFUNCTION(BlueprintGetter)
315 EOriginPlacement GetOriginPlacement() const;
316
329 UFUNCTION(BlueprintSetter)
330 void SetOriginPlacement(EOriginPlacement NewValue);
331
336 UFUNCTION(BlueprintGetter)
337 double GetOriginLatitude() const;
338
343 UFUNCTION(BlueprintSetter)
344 void SetOriginLatitude(double NewValue);
345
350 UFUNCTION(BlueprintGetter)
351 double GetOriginLongitude() const;
352
357 UFUNCTION(BlueprintSetter)
358 void SetOriginLongitude(double NewValue);
359
364 UFUNCTION(BlueprintGetter)
365 double GetOriginHeight() const;
366
371 UFUNCTION(BlueprintSetter)
372 void SetOriginHeight(double NewValue);
373
379 UFUNCTION(BlueprintGetter)
380 double GetScale() const;
381
387 UFUNCTION(BlueprintSetter)
388 void SetScale(double NewValue);
389
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
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
414 UFUNCTION(BlueprintGetter)
415 UCesiumSubLevelSwitcherComponent* GetSubLevelSwitcher() const {
416 return this->SubLevelSwitcher;
417 }
418
423 UFUNCTION(BlueprintCallable, BlueprintGetter, Category = "Cesium")
424 UCesiumEllipsoid* GetEllipsoid() const;
425
432 UFUNCTION(BlueprintSetter, Category = "Cesium")
433 void SetEllipsoid(UCesiumEllipsoid* NewEllipsoid);
434
435#if WITH_EDITOR
440 UFUNCTION(BlueprintGetter)
441 bool GetShowLoadRadii() const;
442
447 UFUNCTION(BlueprintSetter)
448 void SetShowLoadRadii(bool NewValue);
449#endif // WITH_EDITOR
450
451#pragma endregion
452
453#pragma region Transformation Functions
454
455public:
464 UFUNCTION(
465 BlueprintPure,
466 Category = "Cesium",
467 meta = (ReturnDisplayName = "UnrealPosition"))
468 FVector TransformLongitudeLatitudeHeightPositionToUnreal(
469 const FVector& LongitudeLatitudeHeight) const;
470
479 UFUNCTION(
480 BlueprintPure,
481 Category = "Cesium",
482 meta = (ReturnDisplayName = "LongitudeLatitudeHeight"))
483 FVector TransformUnrealPositionToLongitudeLatitudeHeight(
484 const FVector& UnrealPosition) const;
485
494 UFUNCTION(
495 BlueprintPure,
496 Category = "Cesium",
497 meta = (ReturnDisplayName = "UnrealPosition"))
498 FVector TransformEarthCenteredEarthFixedPositionToUnreal(
499 const FVector& EarthCenteredEarthFixedPosition) const;
500
508 UFUNCTION(
509 BlueprintPure,
510 Category = "Cesium",
511 meta = (ReturnDisplayName = "EarthCenteredEarthFixedPosition"))
512 FVector TransformUnrealPositionToEarthCenteredEarthFixed(
513 const FVector& UnrealPosition) const;
514
523 UFUNCTION(
524 BlueprintPure,
525 Category = "Cesium",
526 meta = (ReturnDisplayName = "UnrealDirection"))
527 FVector TransformEarthCenteredEarthFixedDirectionToUnreal(
528 const FVector& EarthCenteredEarthFixedDirection) const;
529
538 UFUNCTION(
539 BlueprintPure,
540 Category = "Cesium",
541 meta = (ReturnDisplayName = "EarthCenteredEarthFixedPosition"))
542 FVector TransformUnrealDirectionToEarthCenteredEarthFixed(
543 const FVector& UnrealDirection) const;
544
562 UFUNCTION(
563 BlueprintPure,
564 Category = "Cesium",
565 meta = (ReturnDisplayName = "EastSouthUpRotator"))
566 FRotator TransformUnrealRotatorToEastSouthUp(
567 const FRotator& UnrealRotator,
568 const FVector& UnrealLocation) const;
569
587 UFUNCTION(
588 BlueprintPure,
589 Category = "Cesium",
590 meta = (ReturnDisplayName = "UnrealRotator"))
591 FRotator TransformEastSouthUpRotatorToUnreal(
592 const FRotator& EastSouthUpRotator,
593 const FVector& UnrealLocation) const;
594
603 UFUNCTION(
604 BlueprintPure,
605 Category = "Cesium",
606 meta = (ReturnDisplayName = "UnrealToEarthCenteredEarthFixedMatrix"))
607 FMatrix ComputeUnrealToEarthCenteredEarthFixedTransformation() const;
608
617 UFUNCTION(
618 BlueprintPure,
619 Category = "Cesium",
620 meta = (ReturnDisplayName = "EarthCenteredEarthFixedToUnrealMatrix"))
621 FMatrix ComputeEarthCenteredEarthFixedToUnrealTransformation() const;
622
639 UFUNCTION(
640 BlueprintPure,
641 Category = "Cesium",
642 meta = (ReturnDisplayName = "EastSouthUpToUnrealMatrix"))
643 FMatrix
644 ComputeEastSouthUpToUnrealTransformation(const FVector& UnrealLocation) const;
645
664 UFUNCTION(
665 BlueprintPure,
666 Category = "Cesium",
667 meta = (ReturnDisplayName = "EastSouthUpToUnrealMatrix"))
668 FMatrix
669 ComputeEastSouthUpAtEarthCenteredEarthFixedPositionToUnrealTransformation(
670 const FVector& EarthCenteredEarthFixedPosition) const;
671
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:
715 UFUNCTION(Category = "Cesium")
716 void PlaceGeoreferenceOriginHere();
717
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
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
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
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
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:
849 void UpdateGeoreference();
850
855 static FName DEFAULT_GEOREFERENCE_TAG;
856
858 glm::dmat4(1.0)};
859
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.
Manages the asynchronous switching between sub-levels, making sure that a previous sub-level is hidde...