diff --git a/code/glTF2/glTF2Asset.inl b/code/glTF2/glTF2Asset.inl index 310fcde06..35f285d85 100644 --- a/code/glTF2/glTF2Asset.inl +++ b/code/glTF2/glTF2Asset.inl @@ -802,14 +802,22 @@ inline void Texture::Read(Value& obj, Asset& r) namespace { inline void SetTextureProperties(Asset& r, Value* prop, TextureInfo& out) { if (r.extensionsUsed.KHR_texture_transform) { - if (Value *extensions = FindObject(*prop, "extensions")) { + out.scale[0] = 1; + out.scale[1] = 1; + out.offset[0] = 0; + out.offset[1] = 0; + out.rotation = 0; + if (Value *extensions = FindObject(*prop, "extensions")) { if (Value *pKHR_texture_transform = FindObject(*extensions, "KHR_texture_transform")) { if (Value *array = FindArray(*pKHR_texture_transform, "offset")) { out.offset[0] = (*array)[0].GetFloat(); out.offset[1] = (*array)[1].GetFloat(); } ReadMember(*pKHR_texture_transform, "rotation", out.rotation); - ReadMember(*pKHR_texture_transform, "scale", *out.scale); + if (Value *array = FindArray(*pKHR_texture_transform, "scale")) { + out.scale[0] = (*array)[0].GetFloat(); + out.scale[1] = (*array)[1].GetFloat(); + } } } } diff --git a/code/glTF2/glTF2Importer.cpp b/code/glTF2/glTF2Importer.cpp index b3141fd96..8d88260db 100644 --- a/code/glTF2/glTF2Importer.cpp +++ b/code/glTF2/glTF2Importer.cpp @@ -206,6 +206,14 @@ inline void SetMaterialTextureProperty(std::vector& embeddedTexIdxs, Asset& uri.length = 1 + ASSIMP_itoa10(uri.data + 1, MAXLEN - 1, texIdx); } + aiUVTransform transform; + transform.mTranslation.x = prop.offset[0]; + transform.mTranslation.y = prop.offset[0]; + transform.mRotation = prop.rotation; + transform.mScaling.x = prop.scale[0]; + transform.mScaling.y = prop.scale[1]; + mat->AddProperty(&transform, 1, _AI_MATKEY_UVTRANSFORM_BASE, texType, texSlot); + mat->AddProperty(&uri, AI_MATKEY_TEXTURE(texType, texSlot)); mat->AddProperty(&prop.texCoord, 1, _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE, texType, texSlot);