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;
106 Meta = (AllowPrivateAccess))
107 bool TeleportWhenUpdatingTransform =
true;
128 Meta = (AllowPrivateAccess))
129 FMatrix ActorToEarthCenteredEarthFixedMatrix;
133#pragma region Property Accessors
144 UFUNCTION(BlueprintGetter)
156 UFUNCTION(BlueprintSetter)
168 UFUNCTION(BlueprintGetter)
178 UFUNCTION(BlueprintCallable, Category =
"Cesium")
185 UFUNCTION(BlueprintGetter, Category =
"Cesium")
198 UFUNCTION(BlueprintGetter, Category =
"Cesium")
214 UFUNCTION(BlueprintSetter, Category =
"Cesium")
223 UFUNCTION(BlueprintGetter, Category =
"Cesium")
232 UFUNCTION(BlueprintSetter, Category =
"Cesium")
254 UFUNCTION(BlueprintGetter, Category =
"Cesium")
276 UFUNCTION(BlueprintSetter, Category =
"Cesium")
281#pragma region Public Methods
295 Meta = (ReturnDisplayName =
"LongitudeLatitudeHeight"))
304 Meta = (ReturnDisplayName =
"Longitude"))
313 Meta = (ReturnDisplayName =
"Latitude"))
326 Meta = (ReturnDisplayName =
"Height"))
341 UFUNCTION(BlueprintCallable, Category =
"Cesium")
351 meta = (ReturnDisplayName =
"EarthCenteredEarthFixedPosition"))
363 UFUNCTION(BlueprintCallable, Category =
"Cesium")
365 const FVector& EarthCenteredEarthFixedPosition);
376 meta = (ReturnDisplayName =
"EastSouthUpRotation"))
390 UFUNCTION(BlueprintCallable, Category =
"Cesium")
406 meta = (ReturnDisplayName =
"EarthCenteredEarthFixedRotation"))
419 UFUNCTION(BlueprintCallable, Category =
"Cesium")
421 const FQuat& EarthCenteredEarthFixedRotation);
427 UFUNCTION(BlueprintCallable, Category =
"Cesium")
435 UFUNCTION(BlueprintCallable, Category =
"Cesium")
455 UFUNCTION(BlueprintCallable, Category =
"Cesium")
460#pragma region Obsolete
469 "Cesium For Unreal v2.0",
470 "The resolved georeference can no longer be explicitly invalidated. To change the georeference, call SetGeoreference or ReregisterComponent.")
477 "The resolved georeference can no longer be explicitly invalidated. To change the georeference, call SetGeoreference or ReregisterComponent."))
481#pragma region Unreal Lifecycle
507 PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
override;
529#pragma region Implementation Details
533 USceneComponent* _getRootComponent(
bool warnIfNull)
const;
535 FTransform _getCurrentRelativeTransform()
const;
537 void _setCurrentRelativeTransform(
const FTransform& relativeTransform);
540 _createOrUpdateNativeGlobeAnchorFromRelativeTransform(
541 const FTransform& newRelativeTransform);
544 _createOrUpdateNativeGlobeAnchorFromECEF(
const FMatrix& newActorToECEFMatrix);
546 void _updateFromNativeGlobeAnchor(
549 void _setNewActorToECEFFromRelativeTransform();
551#if WITH_EDITORONLY_DATA
554 UPROPERTY(Meta = (DeprecatedProperty))
555 double _actorToECEF_Array_DEPRECATED[16];
565 bool _actorToECEFIsValid = false;
572 bool _updatingActorTransform = false;
574 bool _lastRelativeTransformIsValid = false;
575 FTransform _lastRelativeTransform{};
585 void _onActorTransformChanged(
586 USceneComponent* InRootComponent,
587 EUpdateTransformFlags UpdateTransformFlags,
588 ETeleportType Teleport);
596 UFUNCTION(CallInEditor)
597 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...
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 Actors'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 Actors'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.
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.