From 407d205f56fe608f4ed635544a35a49bd87cbedb Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 17 Sep 2021 20:47:09 +0900 Subject: [PATCH] =?UTF-8?q?vrm-1.0=20=E3=81=AE=20import/export=20=E3=81=A7?= =?UTF-8?q?=20TextureTransformBind=20=E3=81=AE=E5=A4=89=E6=8F=9B=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM10/Runtime/IO/ExpressionExtensions.cs | 6 ++++-- Assets/VRM10/Runtime/IO/Vrm10Exporter.cs | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/ExpressionExtensions.cs b/Assets/VRM10/Runtime/IO/ExpressionExtensions.cs index e9cb156a2..efba8431b 100644 --- a/Assets/VRM10/Runtime/IO/ExpressionExtensions.cs +++ b/Assets/VRM10/Runtime/IO/ExpressionExtensions.cs @@ -50,13 +50,15 @@ namespace UniVRM10 var binding = default(UniVRM10.MaterialUVBinding?); if (material != null) { + var (scale, offset) = UniGLTF.TextureTransform.VerticalFlipScaleOffset(new Vector2(bind.Scale[0], bind.Scale[1]), new Vector2(bind.Offset[0], bind.Offset[1])); + try { binding = new UniVRM10.MaterialUVBinding { MaterialName = material.name, // 名前で持つべき - Scaling = new Vector2(bind.Scale[0], bind.Scale[1]), - Offset = new Vector2(bind.Offset[0], bind.Offset[1]), + Scaling = scale, + Offset = offset, }; } catch (Exception) diff --git a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs index 34e6ba50c..87b870501 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs @@ -550,11 +550,12 @@ namespace UniVRM10 UniGLTF.Extensions.VRMC_vrm.TextureTransformBind ExportTextureTransformBinding(MaterialUVBinding binding, Func getIndex) { + var (scale, offset) = TextureTransform.VerticalFlipScaleOffset(binding.Scaling, binding.Offset); return new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind { Material = getIndex(binding.MaterialName), - Offset = new float[] { binding.Offset.x, binding.Offset.y }, - Scale = new float[] { binding.Scaling.x, binding.Scaling.y }, + Offset = new float[] { offset.x, offset.y }, + Scale = new float[] { scale.x, scale.y }, }; }