From 0be79c4dbc3c97517bfb9d196c011cb75878016f Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 12 May 2022 16:43:41 +0900 Subject: [PATCH] =?UTF-8?q?index=20=E3=83=95=E3=82=A9=E3=83=BC=E3=83=9E?= =?UTF-8?q?=E3=83=83=E3=83=88=20uint8=20=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runtime/UniGLTF/IO/BufferAccessor.cs | 3 +++ Assets/VRM10/Runtime/IO/Model/MeshImporter.cs | 27 +++++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/BufferAccessor.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/BufferAccessor.cs index 43e4a6273..6ead44a56 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/BufferAccessor.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/BufferAccessor.cs @@ -157,6 +157,9 @@ namespace UniGLTF } switch (ComponentType) { + case AccessorValueType.UNSIGNED_BYTE: + return ArrayManager.Convert(Bytes, (byte x) => (int)x); + case AccessorValueType.UNSIGNED_SHORT: return ArrayManager.Convert(Bytes.Reinterpret(1), (ushort x) => (int)x); diff --git a/Assets/VRM10/Runtime/IO/Model/MeshImporter.cs b/Assets/VRM10/Runtime/IO/Model/MeshImporter.cs index d27a78e76..bf33aed6b 100644 --- a/Assets/VRM10/Runtime/IO/Model/MeshImporter.cs +++ b/Assets/VRM10/Runtime/IO/Model/MeshImporter.cs @@ -65,16 +65,27 @@ namespace UniVRM10 // Indexを更新 switch (src.IndexBuffer.ComponentType) { + case AccessorValueType.UNSIGNED_BYTE: + { + var intIndices = src.IndexBuffer.GetAsIntArray(); + mesh.SetIndexBufferParams(intIndices.Length, IndexFormat.UInt32); + mesh.SetIndexBufferData(intIndices, 0, 0, intIndices.Length); + break; + } case AccessorValueType.UNSIGNED_SHORT: - var shortIndices = src.IndexBuffer.Bytes.Reinterpret(1); - mesh.SetIndexBufferParams(shortIndices.Length, IndexFormat.UInt16); - mesh.SetIndexBufferData(shortIndices, 0, 0, shortIndices.Length); - break; + { + var shortIndices = src.IndexBuffer.Bytes.Reinterpret(1); + mesh.SetIndexBufferParams(shortIndices.Length, IndexFormat.UInt16); + mesh.SetIndexBufferData(shortIndices, 0, 0, shortIndices.Length); + break; + } case AccessorValueType.UNSIGNED_INT: - var intIndices = src.IndexBuffer.Bytes.Reinterpret(1); - mesh.SetIndexBufferParams(intIndices.Length, IndexFormat.UInt32); - mesh.SetIndexBufferData(intIndices, 0, 0, intIndices.Length); - break; + { + var intIndices = src.IndexBuffer.Bytes.Reinterpret(1); + mesh.SetIndexBufferParams(intIndices.Length, IndexFormat.UInt32); + mesh.SetIndexBufferData(intIndices, 0, 0, intIndices.Length); + break; + } default: throw new NotImplementedException(); }