5#include "CesiumGeospatial/GlobeAnchor.h"
6#include "Components/ActorComponent.h"
7#include "Delegates/IDelegateInstance.h"
8#include "CesiumGlobeAnchorComponent.generated.h"
20UCLASS(ClassGroup = Cesium, Meta = (BlueprintSpawnableComponent))
24#pragma region Properties
45 Meta = (AllowPrivateAccess))
46 TSoftObjectPtr<ACesiumGeoreference> Georeference =
nullptr;
63 Meta = (AllowPrivateAccess))
91 Meta = (AllowPrivateAccess))
92 bool AdjustOrientationForGlobeWhenMoving =
true;
110 Meta = (AllowPrivateAccess))
111 bool DetectTransformChanges =
true;
125 Meta = (AllowPrivateAccess))
126 bool TeleportWhenUpdatingTransform =
true;
147 Meta = (AllowPrivateAccess))
148 FMatrix ActorToEarthCenteredEarthFixedMatrix;
152#pragma region Property Accessors
163 UFUNCTION(BlueprintGetter)
175 UFUNCTION(BlueprintSetter)
187 UFUNCTION(BlueprintGetter)
197 UFUNCTION(BlueprintCallable, Category =
"Cesium")
204 UFUNCTION(BlueprintGetter, Category =
"Cesium")
217 UFUNCTION(BlueprintGetter, Category =
"Cesium")
233 UFUNCTION(BlueprintSetter, Category =
"Cesium")
242 UFUNCTION(BlueprintGetter, Category =
"Cesium")
251 UFUNCTION(BlueprintSetter, Category =
"Cesium")
273 UFUNCTION(BlueprintGetter, Category =
"Cesium")
295 UFUNCTION(BlueprintSetter, Category =
"Cesium")
305 UFUNCTION(BlueprintGetter, Category =
"Cesium")
316 UFUNCTION(BlueprintSetter, Category =
"Cesium")
321#pragma region Public Methods
335 Meta = (ReturnDisplayName =
"LongitudeLatitudeHeight"))
344 Meta = (ReturnDisplayName =
"Longitude"))
353 Meta = (ReturnDisplayName =
"Latitude"))
366 Meta = (ReturnDisplayName =
"Height"))
381 UFUNCTION(BlueprintCallable, Category =
"Cesium")
391 meta = (ReturnDisplayName =
"EarthCenteredEarthFixedPosition"))
403 UFUNCTION(BlueprintCallable, Category =
"Cesium")
405 const FVector& EarthCenteredEarthFixedPosition);
416 meta = (ReturnDisplayName =
"EastSouthUpRotation"))
430 UFUNCTION(BlueprintCallable, Category =
"Cesium")
446 meta = (ReturnDisplayName =
"EarthCenteredEarthFixedRotation"))
459 UFUNCTION(BlueprintCallable, Category =
"Cesium")
461 const FQuat& EarthCenteredEarthFixedRotation);
467 UFUNCTION(BlueprintCallable, Category =
"Cesium")
475 UFUNCTION(BlueprintCallable, Category =
"Cesium")
496 UFUNCTION(BlueprintCallable, Category =
"Cesium")
501#pragma region Obsolete
510 "Cesium For Unreal v2.0",
511 "The resolved georeference can no longer be explicitly invalidated. To change the georeference, call SetGeoreference or ReregisterComponent.")
518 "The resolved georeference can no longer be explicitly invalidated. To change the georeference, call SetGeoreference or ReregisterComponent."))
522#pragma region Unreal Lifecycle
548 PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
override;
570#pragma region Implementation Details
574 USceneComponent* _getRootComponent(
bool warnIfNull)
const;
576 FTransform _getCurrentRelativeTransform()
const;
578 void _setCurrentRelativeTransform(
const FTransform& relativeTransform);
581 _createOrUpdateNativeGlobeAnchorFromRelativeTransform(
582 const FTransform& newRelativeTransform);
585 _createOrUpdateNativeGlobeAnchorFromECEF(
const FMatrix& newActorToECEFMatrix);
587 void _updateFromNativeGlobeAnchor(
590 void _setNewActorToECEFFromRelativeTransform();
592#if WITH_EDITORONLY_DATA
595 UPROPERTY(Meta = (DeprecatedProperty))
596 double _actorToECEF_Array_DEPRECATED[16];
606 bool _actorToECEFIsValid = false;
613 bool _updatingActorTransform = false;
615 bool _lastRelativeTransformIsValid = false;
616 FTransform _lastRelativeTransform{};
626 void _onActorTransformChanged(
627 USceneComponent* InRootComponent,
628 EUpdateTransformFlags UpdateTransformFlags,
629 ETeleportType Teleport);
637 UFUNCTION(CallInEditor)
638 void _onGeoreferenceChanged();
Controls how global geospatial coordinates are mapped to coordinates in the Unreal Engine level.
This component can be added to a movable actor to anchor it to the globe and maintain precise placeme...
void MoveToLongitudeLatitudeHeight(const FVector &LongitudeLatitudeHeight)
Moves the Actor to which this component is attached to a given longitude in degrees (X),...
FVector GetLongitudeLatitudeHeight() const
Gets the longitude in degrees (X), latitude in degrees (Y), and height in meters above the ellipsoid ...
FQuat GetEastSouthUpRotation() const
Gets the rotation of the Actor relative to a local coordinate system centered on this object where th...
FVector GetEarthCenteredEarthFixedPosition() const
Gets the Earth-Centered, Earth-Fixed (ECEF) coordinates of the Actor in meters.
void SetEastSouthUpRotation(const FQuat &EastSouthUpRotation)
Sets the rotation of the Actor relative to a local coordinate system centered on this object where th...
virtual void OnUnregister() override
Called when a component is unregistered.
double GetHeight() const
Gets the height in meters above the ellipsoid.
virtual void OnComponentCreated() override
Called when a component is created (not loaded).
void SetGeoreference(TSoftObjectPtr< ACesiumGeoreference > NewGeoreference)
Sets the designated georeference actor controlling how the owning actor's coordinate system relates t...
void SetDetectTransformChanges(bool Value)
Sets a flag indicating whether to update the globe anchor when the Actor's transform changes.
friend class FCesiumGlobeAnchorCustomization
void MoveToEarthCenteredEarthFixedPosition(const FVector &EarthCenteredEarthFixedPosition)
Moves the Actor to which this component is attached to a given globe position in Earth-Centered,...
FMatrix GetActorToEarthCenteredEarthFixedMatrix() const
Gets the 4x4 transformation matrix from the Actor's local coordinate system to the Earth-Centered,...
virtual void Serialize(FArchive &Ar) override
Handles reading, writing, and reference collecting using FArchive.
void SetAdjustOrientationForGlobeWhenMoving(bool Value)
Sets a flag indicating whether to adjust the Actor's orientation based on globe curvature as the Acto...
bool GetTeleportWhenUpdatingTransform() const
Gets a flag indicating whether to move objects to the updated transform immediately and without affec...
void Sync()
Synchronizes the properties of this globe anchor.
void SnapLocalUpToEllipsoidNormal()
Rotates the Actor so that its local +Z axis is aligned with the ellipsoid surface normal at its curre...
void SetActorToEarthCenteredEarthFixedMatrix(const FMatrix &Value)
Sets the 4x4 transformation matrix from the Actor's local coordinate system to the Earth-Centered,...
virtual void OnRegister() override
Called when a component is registered.
TSoftObjectPtr< ACesiumGeoreference > GetGeoreference() const
Gets the designated georeference actor controlling how the owning actor's coordinate system relates t...
void SetTeleportWhenUpdatingTransform(bool Value)
Sets a flag indicating whether to move objects to the updated transform immediately and without affec...
void SetEarthCenteredEarthFixedRotation(const FQuat &EarthCenteredEarthFixedRotation)
Sets the rotation of the Actor relative to the Earth-Centered, Earth-Fixed (ECEF) coordinate system.
void InvalidateResolvedGeoreference()
DEPRECATED.
bool GetDetectTransformChanges() const
Gets a flag indicating whether to update the globe anchor when the Actor's transform changes.
void SnapToEastSouthUp()
Rotates the Actor so that its +X axis points in the local East direction, its +Y axis points in the l...
bool GetAdjustOrientationForGlobeWhenMoving() const
Gets a flag indicating whether to adjust the Actor's orientation based on globe curvature as the Acto...
UCesiumEllipsoid * GetEllipsoid() const
Obtains the UCesiumEllipsoid set on the georeference used by this component.
ACesiumGeoreference * GetResolvedGeoreference() const
Gets the resolved georeference used by this component.
FQuat GetEarthCenteredEarthFixedRotation() const
Gets the rotation of the Actor relative to the Earth-Centered, Earth-Fixed (ECEF) coordinate system.
ACesiumGeoreference * ResolveGeoreference(bool bForceReresolve=false)
Resolves the Cesium Georeference to use with this Component.
double GetLatitude() const
Gets the latitude in degrees.
double GetLongitude() const
Gets the longitude in degrees.