cesium-native  0.41.0
CesiumGeospatial::GlobeAnchor Class Referencefinal

Anchors an object to the globe by defining a transformation from the object's coordinate to the globe-fixed coordinate system (usually Earth-Centered, Earth-Fixed or ECEF). More...

#include <CesiumGeospatial/GlobeAnchor.h>

Public Member Functions

 GlobeAnchor (const glm::dmat4 &anchorToFixed)
 Constructs a new instance with a given transformation to the globe-fixed coordinate system. More...
 
const glm::dmat4 & getAnchorToFixedTransform () const
 Gets the transformation from the anchor's coordinate system to the globe-fixed coordinate system.
 
void setAnchorToFixedTransform (const glm::dmat4 &newAnchorToFixed, bool adjustOrientation, const Ellipsoid &ellipsoid CESIUM_DEFAULT_ELLIPSOID)
 Sets the new transformation from the anchor's coordinate system to globe-fixed coordinates. More...
 
glm::dmat4 getAnchorToLocalTransform (const LocalHorizontalCoordinateSystem &localCoordinateSystem) const
 Gets the transformation from the anchor's coordinate system to the given local-horizontal coordinate system.
 
void setAnchorToLocalTransform (const LocalHorizontalCoordinateSystem &localCoordinateSystem, const glm::dmat4 &newAnchorToLocal, bool adjustOrientation, const Ellipsoid &ellipsoid CESIUM_DEFAULT_ELLIPSOID)
 Sets the globe-fixed transformation based on a new transformation from anchor coordinates to a local-horizontal coordinate system. More...
 

Static Public Member Functions

static GlobeAnchor fromAnchorToLocalTransform (const LocalHorizontalCoordinateSystem &localCoordinateSystem, const glm::dmat4 &anchorToLocal)
 Creates a new instance from a transformation to a local coordinate system. More...
 
static GlobeAnchor fromAnchorToFixedTransform (const glm::dmat4 &anchorToFixed)
 Creates a new instance from a transformation to the globe-fixed coordinate system. More...
 

Detailed Description

Anchors an object to the globe by defining a transformation from the object's coordinate to the globe-fixed coordinate system (usually Earth-Centered, Earth-Fixed or ECEF).

This class allows the anchored coordinate system to be realized in any LocalHorizontalCoordinateSystem. When the object is moved, either by specifying a new globe-fixed transform or a new local transform, the orientation may optionally be updated to keep the object upright at its new location on the globe.

Definition at line 26 of file GlobeAnchor.h.

Constructor & Destructor Documentation

◆ GlobeAnchor()

CesiumGeospatial::GlobeAnchor::GlobeAnchor ( const glm::dmat4 &  anchorToFixed)
explicit

Constructs a new instance with a given transformation to the globe-fixed coordinate system.

Parameters
anchorToFixedThe matrix transforming from this object's coordinate system to the globe-fixed coordinate system.

Member Function Documentation

◆ fromAnchorToFixedTransform()

static GlobeAnchor CesiumGeospatial::GlobeAnchor::fromAnchorToFixedTransform ( const glm::dmat4 &  anchorToFixed)
static

Creates a new instance from a transformation to the globe-fixed coordinate system.

Parameters
anchorToFixedThe matrix transforming from this object's coordinate system to the globe-fixed coordinate system.

◆ fromAnchorToLocalTransform()

static GlobeAnchor CesiumGeospatial::GlobeAnchor::fromAnchorToLocalTransform ( const LocalHorizontalCoordinateSystem localCoordinateSystem,
const glm::dmat4 &  anchorToLocal 
)
static

Creates a new instance from a transformation to a local coordinate system.

For example, in a game engine, the transformation may be the game object's initial transformation to the game engine's world coordinate system.

Parameters
localCoordinateSystemThe local coordinate system that is the target of the transformation.
anchorToLocalThe matrix transforming from this object's coordinate system to the local coordinate system.

◆ setAnchorToFixedTransform()

void CesiumGeospatial::GlobeAnchor::setAnchorToFixedTransform ( const glm::dmat4 &  newAnchorToFixed,
bool  adjustOrientation,
const Ellipsoid &ellipsoid  CESIUM_DEFAULT_ELLIPSOID 
)

Sets the new transformation from the anchor's coordinate system to globe-fixed coordinates.

Parameters
newAnchorToFixedThe new matrix transforming from this object's coordinate system to the globe-fixed coordinate system.
adjustOrientationWhether to adjust the anchor's orientation based on globe curvature as the anchor moves. The Earth is not flat, so as we move across its surface, the direction of "up" changes. If we ignore this fact and leave an object's orientation unchanged as it moves over the globe surface, the object will become increasingly tilted and eventually be completely upside-down when we arrive at the opposite side of the globe. When this parameter is true, this method will automatically apply a rotation to the anchor to account for globe curvature when the position on the globe changes. This parameter should usually be true, but it may be useful to set it to false it when the caller already accounts for globe curvature itself, because in that case anchor would be over-rotated.

◆ setAnchorToLocalTransform()

void CesiumGeospatial::GlobeAnchor::setAnchorToLocalTransform ( const LocalHorizontalCoordinateSystem localCoordinateSystem,
const glm::dmat4 &  newAnchorToLocal,
bool  adjustOrientation,
const Ellipsoid &ellipsoid  CESIUM_DEFAULT_ELLIPSOID 
)

Sets the globe-fixed transformation based on a new transformation from anchor coordinates to a local-horizontal coordinate system.

For example, in a game engine, the new transformation may be the game object's normal transformation to the game engine's world coordinate system. It may need to be updated because the object was just moved by the physics engine.

Parameters
localCoordinateSystemThe local coordinate system that is the target of the transformation.
newAnchorToLocalThe new matrix transforming from this object's coordinate system to the local coordinate system.
adjustOrientationWhether to adjust the anchor's orientation based on globe curvature as the anchor moves. The Earth is not flat, so as we move across its surface, the direction of "up" changes. If we ignore this fact and leave an object's orientation unchanged as it moves over the globe surface, the object will become increasingly tilted and eventually be completely upside-down when we arrive at the opposite side of the globe. When this parameter is true, this method will automatically apply a rotation to the anchor to account for globe curvature when the position on the globe changes. This parameter should usually be true, but it may be useful to set it to false it when the caller already accounts for globe curvature itself, because in that case anchor would be over-rotated.

The documentation for this class was generated from the following file: