cesium-native 0.43.0
Loading...
Searching...
No Matches
KhrTextureTransform.h
1#pragma once
2
3#include "CesiumGltf/ExtensionKhrTextureTransform.h"
4
5#include <glm/glm.hpp>
6
7namespace CesiumGltf {
16 Valid,
17 ErrorInvalidOffset,
18 ErrorInvalidScale
19};
20
26public:
31
36
41 KhrTextureTransformStatus status() const noexcept { return this->_status; }
42
46 glm::dvec2 offset() const noexcept { return this->_offset; }
47
51 double rotation() const noexcept { return this->_rotation; }
52
57 glm::dvec2 rotationSineCosine() const noexcept {
58 return this->_rotationSineCosine;
59 }
60
64 glm::dvec2 scale() const noexcept { return this->_scale; }
65
69 glm::dvec2 applyTransform(double u, double v) const noexcept;
70
76 std::optional<int64_t> getTexCoordSetIndex() const noexcept {
77 return this->_texCoordSetIndex;
78 }
79
80private:
82 glm::dvec2 _offset;
83 double _rotation;
84 glm::dvec2 _scale;
85 std::optional<int64_t> _texCoordSetIndex;
86
87 // Cached values of sin(rotation) and cos(rotation).
88 glm::dvec2 _rotationSineCosine;
89};
90
91} // namespace CesiumGltf
A utility class that parses KHR_texture_transform parameters and transforms input texture coordinates...
glm::dvec2 rotationSineCosine() const noexcept
Gets the sine and cosine of the rotation in the texture transform. This is cached to avoid re-computi...
double rotation() const noexcept
Gets the rotation (in radians) of the texture transform.
glm::dvec2 scale() const noexcept
Gets the scale of the texture transform.
std::optional< int64_t > getTexCoordSetIndex() const noexcept
Gets the texture coordinate set index used by this texture transform. If defined, this should overrid...
KhrTextureTransformStatus status() const noexcept
The current KhrTextureTransformStatus of the transform operation.
glm::dvec2 applyTransform(double u, double v) const noexcept
Applies this texture transformation to the input coordinates.
KhrTextureTransform() noexcept
Constructs a texture transformation with identity values.
glm::dvec2 offset() const noexcept
Gets the offset of the texture transform.
Classes for working with glTF models.
KhrTextureTransformStatus
The status of a parsed KHR_texture_transform.
@ Valid
This accessor is valid and ready to use.
glTF extension that enables shifting and scaling UV coordinates on a per-texture basis