cesium-native  0.41.0
CesiumGltf::FeatureIdTextureView Class Reference

A view on the image data of FeatureIdTexture. More...

#include <CesiumGltf/FeatureIdTextureView.h>

Inheritance diagram for CesiumGltf::FeatureIdTextureView:
CesiumGltf::TextureView

Public Member Functions

 FeatureIdTextureView () noexcept
 Constructs an uninitialized and invalid view.
 
 FeatureIdTextureView (const Model &model, const FeatureIdTexture &featureIdTexture, const TextureViewOptions &options=TextureViewOptions()) noexcept
 Construct a view of the data specified by a FeatureIdTexture. More...
 
int64_t getFeatureID (double u, double v) const noexcept
 Get the feature ID from the texture at the given texture coordinates. If the texture is somehow invalid, this returns -1. More...
 
FeatureIdTextureViewStatus status () const noexcept
 Get the status of this view. More...
 
std::vector< int64_t > getChannels () const noexcept
 Get the channels of this feature ID texture. The channels represent the bytes of the actual feature ID, in little-endian order.
 
- Public Member Functions inherited from CesiumGltf::TextureView
 TextureView () noexcept
 Constructs an empty, uninitialized texture view.
 
 TextureView (const Model &model, const TextureInfo &textureInfo, const TextureViewOptions &options=TextureViewOptions()) noexcept
 Constructs a view of the texture specified by the given TextureInfo. More...
 
 TextureView (const Sampler &sampler, const ImageAsset &image, int64_t textureCoordinateSetIndex, const ExtensionKhrTextureTransform *pKhrTextureTransformExtension=nullptr, const TextureViewOptions &options=TextureViewOptions()) noexcept
 Constructs a view of the texture specified by the given Sampler and ImageAsset. More...
 
TextureViewStatus getTextureViewStatus () const noexcept
 Get the status of this texture view. More...
 
int64_t getTexCoordSetIndex () const noexcept
 Get the texture coordinate set index for this view. If this view was constructed with options.applyKhrTextureTransformExtension as true, and if the texture contains the KHR_texture_transform extension, then this will return the value from the extension since it is meant to override the original index. However, if the extension does not specify a TEXCOORD set index, then the original index of the texture is returned.
 
const SamplergetSampler () const noexcept
 Get the sampler describing how to sample the data from the property's texture. More...
 
const ImageAssetgetImage () const noexcept
 Get the image containing this property's data. If this view was constructed with options.makeImageCopy set to true, this will return a pointer to the copied image. More...
 
std::optional< KhrTextureTransformgetTextureTransform () const noexcept
 Get the KHR_texture_transform for this texture if it exists. More...
 
std::vector< uint8_t > sampleNearestPixel (double u, double v, const std::vector< int64_t > &channels) const noexcept
 Samples the image at the specified texture coordinates using NEAREST pixel filtering, returning the bytes as uint8_t values. A channels vector must be supplied to specify how many image channels are needed, and in what order the bytes should be retrieved.
 

Detailed Description

A view on the image data of FeatureIdTexture.

It provides the ability to sample the feature IDs from the FeatureIdTexture using texture coordinates.

Definition at line 74 of file FeatureIdTextureView.h.

Constructor & Destructor Documentation

◆ FeatureIdTextureView()

CesiumGltf::FeatureIdTextureView::FeatureIdTextureView ( const Model model,
const FeatureIdTexture featureIdTexture,
const TextureViewOptions options = TextureViewOptions() 
)
noexcept

Construct a view of the data specified by a FeatureIdTexture.

A feature ID texture may contain the KHR_texture_transform extension, which transforms the texture coordinates used to sample the texture. The extension may also override the TEXCOORD set index that was originally specified by the feature ID texture.

If a view is constructed with applyKhrTextureTransformExtension set to true, the view will automatically apply the texture transform to any UV coordinates used to sample the texture. If the extension defines its own TEXCOORD set index, it will override the original value.

Otherwise, if the flag is set to false, UVs will not be transformed and the original TEXCOORD set index will be preserved. The extension's values may still be retrieved using getTextureTransform, if desired.

Parameters
modelThe glTF in which to look for the feature ID texture's data.
featureIdTextureThe feature ID texture to create a view for.
applyKhrTextureTransformExtensionWhether to automatically apply the KHR_texture_transform extension to the feature ID texture, if it exists.

Member Function Documentation

◆ getFeatureID()

int64_t CesiumGltf::FeatureIdTextureView::getFeatureID ( double  u,
double  v 
) const
noexcept

Get the feature ID from the texture at the given texture coordinates. If the texture is somehow invalid, this returns -1.

Parameters
uThe u-component of the texture coordinates. Must be within [0.0, 1.0].
vThe v-component of the texture coordinates. Must be within [0.0, 1.0].
Returns
The feature ID at the nearest pixel to the texture coordinates.

◆ status()

FeatureIdTextureViewStatus CesiumGltf::FeatureIdTextureView::status ( ) const
inlinenoexcept

Get the status of this view.

If invalid, it will not be safe to sample feature IDs from this view.

Definition at line 125 of file FeatureIdTextureView.h.


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