cesium-native  0.41.0
CesiumRasterOverlays::RasterOverlayUtilities Struct Reference

Static Public Member Functions

static std::optional< RasterOverlayDetailscreateRasterOverlayTextureCoordinates (CesiumGltf::Model &gltf, const glm::dmat4 &modelToEcefTransform, const std::optional< CesiumGeospatial::GlobeRectangle > &globeRectangle, std::vector< CesiumGeospatial::Projection > &&projections, bool invertVCoordinate=false, const std::string_view &textureCoordinateAttributeBaseName=DEFAULT_TEXTURE_COORDINATE_BASE_NAME, int32_t firstTextureCoordinateID=0)
 Creates texture coordinates for mapping RasterOverlay tiles to a glTF model. More...
 
static std::optional< CesiumGltf::ModelupsampleGltfForRasterOverlays (const CesiumGltf::Model &parentModel, CesiumGeometry::UpsampledQuadtreeNode childID, bool hasInvertedVCoordinate=false, const std::string_view &textureCoordinateAttributeBaseName=DEFAULT_TEXTURE_COORDINATE_BASE_NAME, int32_t textureCoordinateIndex=0, const CesiumGeospatial::Ellipsoid &ellipsoid=CesiumGeospatial::Ellipsoid::WGS84)
 Creates a new glTF model from one of the quadtree children of the given parent model. More...
 
static glm::dvec2 computeDesiredScreenPixels (double geometricError, double maximumScreenSpaceError, const CesiumGeospatial::Projection &projection, const CesiumGeometry::Rectangle &rectangle, const CesiumGeospatial::Ellipsoid &ellipsoid CESIUM_DEFAULT_ELLIPSOID)
 Computes the desired screen pixels for a raster overlay texture. More...
 
static glm::dvec4 computeTranslationAndScale (const CesiumGeometry::Rectangle &geometryRectangle, const CesiumGeometry::Rectangle &overlayRectangle)
 Computes the texture translation and scale necessary to align a raster overlay with the given rectangle on geometry whose texture coordinates were computed using a different rectangle. More...
 

Static Public Attributes

static constexpr std::string_view DEFAULT_TEXTURE_COORDINATE_BASE_NAME
 

Detailed Description

Definition at line 22 of file RasterOverlayUtilities.h.

Member Function Documentation

◆ computeDesiredScreenPixels()

static glm::dvec2 CesiumRasterOverlays::RasterOverlayUtilities::computeDesiredScreenPixels ( double  geometricError,
double  maximumScreenSpaceError,
const CesiumGeospatial::Projection projection,
const CesiumGeometry::Rectangle rectangle,
const CesiumGeospatial::Ellipsoid &ellipsoid  CESIUM_DEFAULT_ELLIPSOID 
)
static

Computes the desired screen pixels for a raster overlay texture.

This method is used to determine the appropriate number of "screen pixels" to use for a raster overlay texture to be attached to a glTF (which is usually a 3D Tiles tile). In other words, how detailed should the texture be? The answer depends, of course, on how close we'll get to the model. If we're going to get very close, we'll need a higher-resolution raster overlay texture than if we will stay far away from it.

In 3D Tiles, we can only get so close to a model before it switches to the next higher level-of-detail by showing its children instead. The switch distance is controlled by the geometric error of the tile, as well as by the maximum screen space error of the tileset. So this method requires both of those parameters.

The answer also depends on the size of the model on the screen at this switch distance. To determine that, this method takes a projection and a rectangle that bounds the tile, expressed in that projection. This rectangle is projected onto the screen at the switch distance, and the size of that rectangle on the screen is the target screen pixels returned by this method.

The target screen pixels returned here may be further modified by the raster overlay's RasterOverlay::getTile method. In particular, it will usually be divided by the raster overlay's maximum screen space error of the raster overlay (not to be confused with the maximum screen space error of the tileset, mentioned above).

Parameters
geometricErrorThe geometric error of the tile.
maximumScreenSpaceErrorThe maximum screen-space error used to render the tileset.
projectionThe projection in which the rectangle parameter is provided.
rectangleThe 2D extent of the tile, expressed in the projection.
ellipsoidThe ellipsoid with which computations are performed.
Returns
The desired screen pixels.

◆ computeTranslationAndScale()

static glm::dvec4 CesiumRasterOverlays::RasterOverlayUtilities::computeTranslationAndScale ( const CesiumGeometry::Rectangle geometryRectangle,
const CesiumGeometry::Rectangle overlayRectangle 
)
static

Computes the texture translation and scale necessary to align a raster overlay with the given rectangle on geometry whose texture coordinates were computed using a different rectangle.

Parameters
geometryRectangleThe geometry rectangle used to the compute the texture coordinates.
overlayRectangleThe rectangle covered by the raster overlay texture.
Returns
The translation in X and Y, and the scale in Z and W.

◆ createRasterOverlayTextureCoordinates()

static std::optional<RasterOverlayDetails> CesiumRasterOverlays::RasterOverlayUtilities::createRasterOverlayTextureCoordinates ( CesiumGltf::Model gltf,
const glm::dmat4 &  modelToEcefTransform,
const std::optional< CesiumGeospatial::GlobeRectangle > &  globeRectangle,
std::vector< CesiumGeospatial::Projection > &&  projections,
bool  invertVCoordinate = false,
const std::string_view &  textureCoordinateAttributeBaseName = DEFAULT_TEXTURE_COORDINATE_BASE_NAME,
int32_t  firstTextureCoordinateID = 0 
)
static

Creates texture coordinates for mapping RasterOverlay tiles to a glTF model.

Generates new texture coordinates for the gltf using the given projections. The first new texture coordinate (u or s) will be 0.0 at the minimumX of the given rectangle and 1.0 at the maximumX. The second texture coordinate (v or t) will be 0.0 at the minimumY of the given rectangle and 1.0 at the maximumY.

Coordinate values for vertices in between these extremes are determined by projecting the vertex position with the projection and then computing the fractional distance of that projected position between the minimum and maximum.

Projected positions that fall outside the globeRectangle will be clamped to the edges, so the coordinate values will never be less then 0.0 or greater than 1.0.

These texture coordinates are stored in the provided glTF, and a new primitive attribute is added to each primitive for each projection. The new primitive attributes are named with textureCoordinateAttributeBaseName followed by a number, starting with firstTextureCoordinateID and incrementing for each projection. For example, if textureCoordinateAttributeBaseName is _CESIUMOVERLAY_ and firstTextureCoordinateID is 0 (the defaults), then the texture coordinates for the first projection will be stored in an attribute named _CESIUMOVERLAY_0, the second will be in _CESIUMOVERLAY_1, and so on.

Parameters
gltfThe glTF model.
modelToEcefTransformThe transformation of this glTF to ECEF coordinates.
globeRectangleThe rectangle that all projected vertex positions are expected to lie within. If this parameter is std::nullopt, it is computed from the vertices.
projectionsThe projections for which to generate texture coordinates. There is a linear relationship between the coordinates of this projection and the generated texture coordinates.
invertVCoordinateTrue if the V texture coordinate should be inverted so that it is 1.0 at the Southern end of the rectangle and 0.0 at the Northern end. This is useful with images that use the typical North-up orientation.
textureCoordinateAttributeBaseNameThe base name to use for the texture coordinate attributes, without a number on the end. Defaults to DEFAULT_TEXTURE_COORDINATE_BASE_NAME.
firstTextureCoordinateIDThe texture coordinate ID of the first projection.
Returns
The details of the generated texture coordinates.

◆ upsampleGltfForRasterOverlays()

static std::optional<CesiumGltf::Model> CesiumRasterOverlays::RasterOverlayUtilities::upsampleGltfForRasterOverlays ( const CesiumGltf::Model parentModel,
CesiumGeometry::UpsampledQuadtreeNode  childID,
bool  hasInvertedVCoordinate = false,
const std::string_view &  textureCoordinateAttributeBaseName = DEFAULT_TEXTURE_COORDINATE_BASE_NAME,
int32_t  textureCoordinateIndex = 0,
const CesiumGeospatial::Ellipsoid ellipsoid = CesiumGeospatial::Ellipsoid::WGS84 
)
static

Creates a new glTF model from one of the quadtree children of the given parent model.

The parent model subdivision is guided by texture coordinates. These texture coordinates must follow a map projection, and the parent tile is divided into quadrants as divided by this map projection. To create the necessary texture coordinates, use createRasterOverlayTextureCoordinates.

Parameters
parentModelThe parent model to upsample.
childIDThe quadtree tile ID of the child model. This is used to determine which of the four children of the parent tile to generate.
hasInvertedVCoordinateTrue if the V texture coordinate has 0.0 as the Northern-most coordinate; False if the V texture coordinate has 0.0 as the Southern-most coordiante.
textureCoordinateAttributeBaseNameThe base name of the attribute that holds the projected texture coordinates. The textureCoordinateIndex is appended to this name. Defaults to DEFAULT_TEXTURE_COORDINATE_BASE_NAME.
textureCoordinateIndexThe index of the texture coordinate set to use. For example, if textureCoordinateAttributeBaseName is _CESIUMOVERLAY_ and this parameter is 0 (the defaults), then the texture coordinates are read from a vertex attribute named _CESIUMOVERLAY_0.
Returns
The upsampled model.

Member Data Documentation

◆ DEFAULT_TEXTURE_COORDINATE_BASE_NAME

constexpr std::string_view CesiumRasterOverlays::RasterOverlayUtilities::DEFAULT_TEXTURE_COORDINATE_BASE_NAME
staticconstexpr
Initial value:
=
"_CESIUMOVERLAY_"

Definition at line 23 of file RasterOverlayUtilities.h.


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