cesium-native 0.64.0
Loading...
Searching...
No Matches
TextureView.h
1#pragma once
2
3#include <CesiumGltf/KhrTextureTransform.h>
4#include <CesiumGltf/Sampler.h>
5#include <CesiumGltf/TextureInfo.h>
6#include <CesiumImage/ImageAsset.h>
7#include <CesiumUtility/IntrusivePointer.h>
8
9#include <vector>
10
11namespace CesiumGltf {
12
13struct Model;
14
49
94
99public:
103 TextureView() noexcept;
104
114 const Model& model,
115 const TextureInfo& textureInfo,
116 const TextureViewOptions& options = TextureViewOptions()) noexcept;
117
131 const Sampler& sampler,
132 const CesiumImage::ImageAsset& image,
133 int64_t textureCoordinateSetIndex,
134 const ExtensionKhrTextureTransform* pKhrTextureTransformExtension =
135 nullptr,
136 const TextureViewOptions& options = TextureViewOptions()) noexcept;
137
144 return this->_textureViewStatus;
145 }
146
155 int64_t getTexCoordSetIndex() const noexcept {
156 if (this->_applyTextureTransform && this->_textureTransform) {
157 return this->_textureTransform->getTexCoordSetIndex().value_or(
158 this->_texCoordSetIndex);
159 }
160 return this->_texCoordSetIndex;
161 }
162
170 const Sampler* getSampler() const noexcept { return this->_pSampler; }
171
180 const CesiumImage::ImageAsset* getImage() const noexcept {
181 if (this->_pImageCopy) {
182 return this->_pImageCopy.get();
183 }
184 return this->_pImage.get();
185 }
186
199 std::optional<KhrTextureTransform> getTextureTransform() const noexcept {
200 return this->_textureTransform;
201 }
202
209 std::vector<uint8_t> sampleNearestPixel(
210 double u,
211 double v,
212 const std::vector<int64_t>& channels) const noexcept;
213
214private:
215 TextureViewStatus _textureViewStatus;
216
217 const Sampler* _pSampler;
219 int64_t _texCoordSetIndex;
220
221 bool _applyTextureTransform;
222 std::optional<KhrTextureTransform> _textureTransform;
223
225};
226} // namespace CesiumGltf
const Sampler * getSampler() const noexcept
Get the sampler describing how to sample the data from the property's texture.
const CesiumImage::ImageAsset * getImage() const noexcept
Get the image containing this property's data. If this view was constructed with options....
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.
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 ...
Definition TextureView.h:92
@ 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.
Classes that support reading, decoding, and manipulating images.
Definition ImageAsset.h:11
glTF extension that enables shifting and scaling UV coordinates on a per-texture basis
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
A 2D image asset, including its pixel data. The image may have mipmaps, and it may be encoded in a GP...
Definition ImageAsset.h:33