cesium-native 0.43.0
Loading...
Searching...
No Matches
TextureView.h
1#pragma once
2
3#include <CesiumGltf/ImageAsset.h>
4#include <CesiumGltf/KhrTextureTransform.h>
5#include <CesiumGltf/Sampler.h>
6#include <CesiumGltf/TextureInfo.h>
7#include <CesiumUtility/IntrusivePointer.h>
8
9#include <vector>
10
11namespace CesiumGltf {
12
13struct Model;
14
49
94
99public:
103 TextureView() noexcept;
104
113 const Model& model,
114 const TextureInfo& textureInfo,
115 const TextureViewOptions& options = TextureViewOptions()) noexcept;
116
130 const Sampler& sampler,
131 const ImageAsset& image,
132 int64_t textureCoordinateSetIndex,
133 const ExtensionKhrTextureTransform* pKhrTextureTransformExtension =
134 nullptr,
135 const TextureViewOptions& options = TextureViewOptions()) noexcept;
136
143 return this->_textureViewStatus;
144 }
145
154 int64_t getTexCoordSetIndex() const noexcept {
155 if (this->_applyTextureTransform && this->_textureTransform) {
156 return this->_textureTransform->getTexCoordSetIndex().value_or(
157 this->_texCoordSetIndex);
158 }
159 return this->_texCoordSetIndex;
160 }
161
169 const Sampler* getSampler() const noexcept { return this->_pSampler; }
170
179 const ImageAsset* getImage() const noexcept {
180 if (this->_pImageCopy) {
181 return this->_pImageCopy.get();
182 }
183 return this->_pImage.get();
184 }
185
198 std::optional<KhrTextureTransform> getTextureTransform() const noexcept {
199 return this->_textureTransform;
200 }
201
208 std::vector<uint8_t> sampleNearestPixel(
209 double u,
210 double v,
211 const std::vector<int64_t>& channels) const noexcept;
212
213private:
214 TextureViewStatus _textureViewStatus;
215
216 const Sampler* _pSampler;
218 int64_t _texCoordSetIndex;
219
220 bool _applyTextureTransform;
221 std::optional<KhrTextureTransform> _textureTransform;
222
224};
225} // namespace CesiumGltf
A view into the texture data of a single texture from a Model.
Definition TextureView.h:98
const Sampler * getSampler() const noexcept
Get the sampler describing how to sample the data from the property's texture.
std::optional< KhrTextureTransform > getTextureTransform() const noexcept
Get the KHR_texture_transform for this texture if it exists.
TextureViewStatus getTextureViewStatus() const noexcept
Get the status of this texture view.
TextureView() noexcept
Constructs an empty, uninitialized texture view.
const ImageAsset * getImage() const noexcept
Get the image containing this property's data. If this view was constructed with options....
int64_t getTexCoordSetIndex() const noexcept
Get the texture coordinate set index for this view. If this view was constructed with options....
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,...
A smart pointer that calls addReference and releaseReference on the controlled object.
Classes for working with glTF models.
TextureViewStatus
Indicates the status of a texture view.
Definition TextureView.h:57
@ ErrorInvalidBytesPerChannel
The image for this texture has channels that take up more than a byte. Only single-byte channels are ...
@ ErrorEmptyImage
This feature ID texture has an empty image.
@ ErrorUninitialized
This view has not yet been initialized.
@ ErrorInvalidSampler
This feature ID texture has a sampler index that doesn't exist in the glTF.
@ ErrorInvalidImage
This feature ID texture has an image index that doesn't exist in the glTF.
@ ErrorInvalidTexture
This feature ID texture has a texture index that doesn't exist in the glTF.
@ Valid
This accessor is valid and ready to use.
glTF extension that enables shifting and scaling UV coordinates on a per-texture basis
A 2D image asset, including its pixel data. The image may have mipmaps, and it may be encoded in a GP...
Definition ImageAsset.h:34
This class is not meant to be instantiated directly. Use Model instead.
Definition Model.h:14
Texture sampler properties for filtering and wrapping modes.
Definition Sampler.h:14
Reference to a texture.
Definition TextureInfo.h:14
Describes options for constructing a view on a glTF texture.
Definition TextureView.h:18
bool makeImageCopy
Whether to copy the input image.
Definition TextureView.h:47
bool applyKhrTextureTransformExtension
Whether to automatically apply the KHR_texture_transform extension to the texture view,...
Definition TextureView.h:37