cesium-native  0.41.0
KhrTextureTransform.h
1 #pragma once
2 
3 #include "CesiumGltf/ExtensionKhrTextureTransform.h"
4 
5 #include <glm/glm.hpp>
6 
7 namespace CesiumGltf {
16  Valid,
17  ErrorInvalidOffset,
18  ErrorInvalidScale
19 };
20 
26 public:
30  KhrTextureTransform() noexcept;
31 
36 
37  KhrTextureTransformStatus status() const noexcept { return this->_status; }
38 
42  glm::dvec2 offset() const noexcept { return this->_offset; }
43 
47  double rotation() const noexcept { return this->_rotation; }
48 
53  glm::dvec2 rotationSineCosine() const noexcept {
54  return this->_rotationSineCosine;
55  }
56 
60  glm::dvec2 scale() const noexcept { return this->_scale; }
61 
65  glm::dvec2 applyTransform(double u, double v) const noexcept;
66 
72  std::optional<int64_t> getTexCoordSetIndex() const noexcept {
73  return this->_texCoordSetIndex;
74  }
75 
76 private:
78  glm::dvec2 _offset;
79  double _rotation;
80  glm::dvec2 _scale;
81  std::optional<int64_t> _texCoordSetIndex;
82 
83  // Cached values of sin(rotation) and cos(rotation).
84  glm::dvec2 _rotationSineCosine;
85 };
86 
87 } // 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...
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