diff options
author | Sabrina Shanman <cosmic@lindenlab.com> | 2022-11-02 20:10:04 +0000 |
---|---|---|
committer | Sabrina Shanman <cosmic@lindenlab.com> | 2022-11-02 20:10:04 +0000 |
commit | 81011a318e7cd1e4ef5bfb1f2cc52274c7d78b8a (patch) | |
tree | 22f022676dd453143d3758c52572228f71782f42 /indra/llprimitive | |
parent | 106b1a6e6add67f7770d508d8be1d0eff77ebd32 (diff) | |
parent | 9e7b725c15ea0bfea5246eb81dd7a100b7ac5b6b (diff) |
Merged in SL-18485 (pull request #1183)
SL-18485: Render GLTF materials with extension KHR_texture_transform with approprate texture transforms
Diffstat (limited to 'indra/llprimitive')
-rw-r--r-- | indra/llprimitive/llgltfmaterial.cpp | 22 | ||||
-rw-r--r-- | indra/llprimitive/llgltfmaterial.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp index c76f547570..6d23cb8039 100644 --- a/indra/llprimitive/llgltfmaterial.cpp +++ b/indra/llprimitive/llgltfmaterial.cpp @@ -39,6 +39,28 @@ const char* GLTF_FILE_EXTENSION_TRANSFORM_ROTATION = "rotation"; // special UUID that indicates a null UUID in override data static const LLUUID GLTF_OVERRIDE_NULL_UUID = LLUUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); +// https://github.com/KhronosGroup/glTF/tree/main/extensions/3.0/Khronos/KHR_texture_transform +LLMatrix3 LLGLTFMaterial::TextureTransform::asMatrix() +{ + LLMatrix3 scale; + scale.mMatrix[0][0] = mScale[0]; + scale.mMatrix[1][1] = mScale[1]; + + LLMatrix3 rotation; + const F32 cos_r = cos(mRotation); + const F32 sin_r = sin(mRotation); + rotation.mMatrix[0][0] = cos_r; + rotation.mMatrix[0][1] = sin_r; + rotation.mMatrix[1][0] = -sin_r; + rotation.mMatrix[1][1] = cos_r; + + LLMatrix3 offset; + offset.mMatrix[2][0] = mOffset[0]; + offset.mMatrix[2][1] = mOffset[1]; + + return offset * rotation * scale; +} + LLGLTFMaterial::LLGLTFMaterial(const LLGLTFMaterial& rhs) { *this = rhs; diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index 9489837de7..60116fd423 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -28,6 +28,7 @@ #include "llrefcount.h" #include "llmemory.h" +#include "m3math.h" #include "v4color.h" #include "v3color.h" #include "v2math.h" @@ -53,6 +54,8 @@ public: LLVector2 mOffset = { 0.f, 0.f }; LLVector2 mScale = { 1.f, 1.f }; F32 mRotation = 0.f; + + LLMatrix3 asMatrix(); }; enum AlphaMode |