add missing setup of texture transform in aiMaterial.
parent
74080a083a
commit
17946e26ef
|
@ -802,14 +802,22 @@ inline void Texture::Read(Value& obj, Asset& r)
|
||||||
namespace {
|
namespace {
|
||||||
inline void SetTextureProperties(Asset& r, Value* prop, TextureInfo& out) {
|
inline void SetTextureProperties(Asset& r, Value* prop, TextureInfo& out) {
|
||||||
if (r.extensionsUsed.KHR_texture_transform) {
|
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 *pKHR_texture_transform = FindObject(*extensions, "KHR_texture_transform")) {
|
||||||
if (Value *array = FindArray(*pKHR_texture_transform, "offset")) {
|
if (Value *array = FindArray(*pKHR_texture_transform, "offset")) {
|
||||||
out.offset[0] = (*array)[0].GetFloat();
|
out.offset[0] = (*array)[0].GetFloat();
|
||||||
out.offset[1] = (*array)[1].GetFloat();
|
out.offset[1] = (*array)[1].GetFloat();
|
||||||
}
|
}
|
||||||
ReadMember(*pKHR_texture_transform, "rotation", out.rotation);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,6 +206,14 @@ inline void SetMaterialTextureProperty(std::vector<int>& embeddedTexIdxs, Asset&
|
||||||
uri.length = 1 + ASSIMP_itoa10(uri.data + 1, MAXLEN - 1, texIdx);
|
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(&uri, AI_MATKEY_TEXTURE(texType, texSlot));
|
||||||
mat->AddProperty(&prop.texCoord, 1, _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE, texType, texSlot);
|
mat->AddProperty(&prop.texCoord, 1, _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE, texType, texSlot);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue