6#include "CesiumGeospatial/GlobeAnchor.h"
7#include "Components/ActorComponent.h"
8#include "Delegates/IDelegateInstance.h"
9#include "CesiumGlobeAnchorComponent.generated.h"
42UCLASS(ClassGroup = Cesium,
Meta = (BlueprintSpawnableComponent))
46#pragma region Properties
67 Meta = (AllowPrivateAccess))
68 TSoftObjectPtr<ACesiumGeoreference> Georeference =
nullptr;
88 ReturnDisplayName =
"Height Reference",
89 InvalidEnumValues =
"None"))
104 Meta = (AllowPrivateAccess))
105 TSoftObjectPtr<ACesium3DTileset> ReferencedTileset =
nullptr;
119 Meta = (AllowPrivateAccess, ReturnDisplayName =
"Height Update Interval"))
120 int HeightUpdateInterval = 1;
137 Meta = (AllowPrivateAccess))
165 Meta = (AllowPrivateAccess))
166 bool AdjustOrientationForGlobeWhenMoving =
true;
186 Meta = (AllowPrivateAccess))
187 bool DetectTransformChanges =
true;
201 Meta = (AllowPrivateAccess))
202 bool TeleportWhenUpdatingTransform =
true;
223 Meta = (AllowPrivateAccess))
224 FMatrix ActorToEarthCenteredEarthFixedMatrix;
228#pragma region Property Accessors
239 UFUNCTION(BlueprintGetter)
251 UFUNCTION(BlueprintSetter)
255 UFUNCTION(BlueprintGetter, Category =
"Cesium")
258 UFUNCTION(BlueprintSetter, Category =
"Cesium")
264 Meta = (ReturnDisplayName =
"Referenced Tileset"))
267 UFUNCTION(BlueprintSetter, Category =
"Cesium")
270 UFUNCTION(BlueprintGetter, Category =
"Cesium")
273 UFUNCTION(BlueprintSetter, Category =
"Cesium")
285 UFUNCTION(BlueprintGetter, Category =
"Cesium")
295 UFUNCTION(BlueprintCallable, Category =
"Cesium")
302 UFUNCTION(BlueprintGetter, Category =
"Cesium")
315 UFUNCTION(BlueprintGetter, Category =
"Cesium")
331 UFUNCTION(BlueprintSetter, Category =
"Cesium")
340 UFUNCTION(BlueprintGetter, Category =
"Cesium")
349 UFUNCTION(BlueprintSetter, Category =
"Cesium")
371 UFUNCTION(BlueprintGetter, Category =
"Cesium")
393 UFUNCTION(BlueprintSetter, Category =
"Cesium")
403 UFUNCTION(BlueprintGetter, Category =
"Cesium")
414 UFUNCTION(BlueprintSetter, Category =
"Cesium")
419#pragma region Public Methods
442 Meta = (ReturnDisplayName =
"LongitudeLatitudeHeight"))
453 Meta = (ReturnDisplayName =
"Longitude"))
462 Meta = (ReturnDisplayName =
"Latitude"))
483 Meta = (ReturnDisplayName =
"Height"))
508 UFUNCTION(BlueprintCallable, Category =
"Cesium")
510 const FVector& LongitudeLatitudeHeight,
521 meta = (ReturnDisplayName =
"EarthCenteredEarthFixedPosition"))
533 UFUNCTION(BlueprintCallable, Category =
"Cesium")
535 const FVector& EarthCenteredEarthFixedPosition);
546 meta = (ReturnDisplayName =
"EastSouthUpRotation"))
560 UFUNCTION(BlueprintCallable, Category =
"Cesium")
576 meta = (ReturnDisplayName =
"EarthCenteredEarthFixedRotation"))
589 UFUNCTION(BlueprintCallable, Category =
"Cesium")
591 const FQuat& EarthCenteredEarthFixedRotation);
597 UFUNCTION(BlueprintCallable, Category =
"Cesium")
605 UFUNCTION(BlueprintCallable, Category =
"Cesium")
626 UFUNCTION(BlueprintCallable, Category =
"Cesium")
631#pragma region Obsolete
640 "Cesium For Unreal v2.0",
641 "The resolved georeference can no longer be explicitly invalidated. To change the georeference, call SetGeoreference or ReregisterComponent.")
648 "The resolved georeference can no longer be explicitly invalidated. To change the georeference, call SetGeoreference or ReregisterComponent."))
652#pragma region Unreal Lifecycle
678 PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
override;
704 FActorComponentTickFunction* ThisTickFunction)
override;
706#pragma region Implementation Details
708 int _heightReferenceUpdateCounter = 0;
715 float _fixedHeightAboveHeightReference = 0.0f;
721 bool _setHeightFromTilesetReference();
726 bool _isUsingTilesetHeightReference(
733 FVector _computeLocalDown(
735 const FVector& unrealWorldPosition) const;
745 bool _queryLongitudeLatitudeHeightPositionOnTileset(
746 FVector& groundIntersection,
747 const
std::optional<FVector>& alternateStartPosition =
std::nullopt);
751 USceneComponent* _getRootComponent(
bool warnIfNull) const;
753 FTransform _getCurrentRelativeTransform() const;
755 void _setCurrentRelativeTransform(const FTransform& relativeTransform);
758 _createOrUpdateNativeGlobeAnchorFromRelativeTransform(
759 const FTransform& newRelativeTransform);
762 _createOrUpdateNativeGlobeAnchorFromECEF(const FMatrix& newActorToECEFMatrix);
764 void _updateFromNativeGlobeAnchor(
767 void _setNewActorToECEFFromRelativeTransform();
769#if WITH_EDITORONLY_DATA
772 UPROPERTY(
Meta = (DeprecatedProperty))
773 double _actorToECEF_Array_DEPRECATED[16];
783 bool _actorToECEFIsValid = false;
790 bool _updatingActorTransform = false;
792 bool _lastRelativeTransformIsValid = false;
793 FTransform _lastRelativeTransform{};
803 void _onActorTransformChanged(
804 USceneComponent* InRootComponent,
805 EUpdateTransformFlags UpdateTransformFlags,
806 ETeleportType Teleport);
814 UFUNCTION(CallInEditor)
815 void _onGeoreferenceChanged();
ECesiumHeightReference
The frame of reference from which to interpret a given height value.
@ Tileset
Height is interpreted relative to the surface of a 3D tileset.
@ None
No specified Height Reference.
@ Ellipsoid
Height is interpreted relative to the ellipsoid.
Controls how global geospatial coordinates are mapped to coordinates in the Unreal Engine level.
void SetReferencedTileset(const TSoftObjectPtr< ACesium3DTileset > &NewTileset)
double GetHeight(const ECesiumHeightReference HeightReferenceOverride=ECesiumHeightReference::None) const
Gets the height in meters above the specified height reference.
FVector GetLongitudeLatitudeHeight(const ECesiumHeightReference HeightReferenceOverride=ECesiumHeightReference::None) const
Gets the longitude in degrees (X), latitude in degrees (Y), and height in meters relative to the spec...
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.
TSoftObjectPtr< ACesium3DTileset > GetReferencedTileset() const
ECesiumHeightReference GetHeightReference() const
UCesiumGlobeAnchorComponent()
virtual void OnComponentCreated() override
Called when a component is created (not loaded).
void SetDetectTransformChanges(bool Value)
Sets a flag indicating whether to update the globe anchor when the Actor's transform changes.
void SetHeightReference(ECesiumHeightReference NewHeightReference)
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,...
int GetHeightUpdateInterval() const
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override
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 SetHeightUpdateInterval(int NewHeightReferenceUpdateInterval)
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 SetGeoreference(const TSoftObjectPtr< ACesiumGeoreference > &NewGeoreference)
Sets 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 MoveToLongitudeLatitudeHeight(const FVector &LongitudeLatitudeHeight, const ECesiumHeightReference HeightReferenceOverride=ECesiumHeightReference::None)
Moves the Actor to which this component is attached to a given longitude in degrees (X),...
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.