From 89637591c88e9e01e722daffff2533027d71c743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=A6=E5=8F=B3=E7=9C=8B?= <1918891542@qq.com> Date: Wed, 28 Jun 2023 01:30:23 +0800 Subject: [PATCH] export more uv! --- .../Scripts/SceneExporter/ExporterMeshes.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Assets/Plugins/UnityGLTF/Runtime/Scripts/SceneExporter/ExporterMeshes.cs b/Assets/Plugins/UnityGLTF/Runtime/Scripts/SceneExporter/ExporterMeshes.cs index 59b5efa..cff7976 100644 --- a/Assets/Plugins/UnityGLTF/Runtime/Scripts/SceneExporter/ExporterMeshes.cs +++ b/Assets/Plugins/UnityGLTF/Runtime/Scripts/SceneExporter/ExporterMeshes.cs @@ -17,7 +17,7 @@ namespace UnityGLTF { private struct MeshAccessors { - public AccessorId aPosition, aNormal, aTangent, aTexcoord0, aTexcoord1, aColor0; + public AccessorId aPosition, aNormal, aTangent, aTexcoord0, aTexcoord1, aTexcoord2, aColor0; public Dictionary subMeshPrimitives; } @@ -243,7 +243,7 @@ namespace UnityGLTF if (!_meshToPrims.ContainsKey(meshObj)) { - AccessorId aPosition = null, aNormal = null, aTangent = null, aTexcoord0 = null, aTexcoord1 = null, aColor0 = null; + AccessorId aPosition = null, aNormal = null, aTangent = null, aTexcoord0 = null, aTexcoord1 = null, aTexcoord2 = null, aColor0 = null; aPosition = ExportAccessor(SchemaExtensions.ConvertVector3CoordinateSpaceAndCopy(meshObj.vertices, SchemaExtensions.CoordinateSpaceConversionScale)); @@ -259,7 +259,10 @@ namespace UnityGLTF if (meshObj.uv2.Length != 0) aTexcoord1 = ExportAccessor(SchemaExtensions.FlipTexCoordArrayVAndCopy(meshObj.uv2)); - if (settings.ExportVertexColors && meshObj.colors.Length != 0) + if (meshObj.uv3.Length != 0) + aTexcoord2 = ExportAccessor(SchemaExtensions.FlipTexCoordArrayVAndCopy(meshObj.uv3)); + + if (settings.ExportVertexColors && meshObj.colors.Length != 0) aColor0 = ExportAccessor(QualitySettings.activeColorSpace == ColorSpace.Linear ? meshObj.colors : meshObj.colors.ToLinear(), true); aPosition.Value.BufferView.Value.Target = BufferViewTarget.ArrayBuffer; @@ -267,7 +270,8 @@ namespace UnityGLTF if (aTangent != null) aTangent.Value.BufferView.Value.Target = BufferViewTarget.ArrayBuffer; if (aTexcoord0 != null) aTexcoord0.Value.BufferView.Value.Target = BufferViewTarget.ArrayBuffer; if (aTexcoord1 != null) aTexcoord1.Value.BufferView.Value.Target = BufferViewTarget.ArrayBuffer; - if (aColor0 != null) aColor0.Value.BufferView.Value.Target = BufferViewTarget.ArrayBuffer; + if (aTexcoord2 != null) aTexcoord2.Value.BufferView.Value.Target = BufferViewTarget.ArrayBuffer; + if (aColor0 != null) aColor0.Value.BufferView.Value.Target = BufferViewTarget.ArrayBuffer; _meshToPrims.Add(meshObj, new MeshAccessors() { @@ -276,7 +280,8 @@ namespace UnityGLTF aTangent = aTangent, aTexcoord0 = aTexcoord0, aTexcoord1 = aTexcoord1, - aColor0 = aColor0, + aTexcoord2 = aTexcoord2, + aColor0 = aColor0, subMeshPrimitives = new Dictionary() }); } @@ -312,7 +317,9 @@ namespace UnityGLTF primitive.Attributes.Add(SemanticProperties.TEXCOORD_0, accessors.aTexcoord0); if (accessors.aTexcoord1 != null) primitive.Attributes.Add(SemanticProperties.TEXCOORD_1, accessors.aTexcoord1); - if (accessors.aColor0 != null) + if (accessors.aTexcoord2 != null) + primitive.Attributes.Add(SemanticProperties.TEXCOORD_2, accessors.aTexcoord2); + if (accessors.aColor0 != null) primitive.Attributes.Add(SemanticProperties.COLOR_0, accessors.aColor0); primitive.Material = null;