From adf39dde276a622e194692b5fdcc5b42d63421c4 Mon Sep 17 00:00:00 2001 From: Perfare Date: Tue, 17 Jul 2018 02:19:11 +0800 Subject: [PATCH] Fixed #225 --- AssetStudio/AssetStudioForm.cs | 20 ++++++++++---------- AssetStudio/StudioClasses/FBXExporter.cs | 2 +- AssetStudio/StudioClasses/ModelConverter.cs | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/AssetStudio/AssetStudioForm.cs b/AssetStudio/AssetStudioForm.cs index 32713f1..49f405b 100644 --- a/AssetStudio/AssetStudioForm.cs +++ b/AssetStudio/AssetStudioForm.cs @@ -941,15 +941,7 @@ namespace AssetStudio } #endregion #region Colors - if (m_Mesh.m_Colors == null || m_Mesh.m_Colors.Length == 0) - { - colorData = new Vector4[m_Mesh.m_VertexCount]; - for (int c = 0; c < m_Mesh.m_VertexCount; c++) - { - colorData[c] = new Vector4(0.5f, 0.5f, 0.5f, 1.0f); - } - } - else if (m_Mesh.m_Colors.Length == m_Mesh.m_VertexCount * 3) + if (m_Mesh.m_Colors != null && m_Mesh.m_Colors.Length == m_Mesh.m_VertexCount * 3) { colorData = new Vector4[m_Mesh.m_VertexCount]; for (int c = 0; c < m_Mesh.m_VertexCount; c++) @@ -961,7 +953,7 @@ namespace AssetStudio 1.0f); } } - else + else if (m_Mesh.m_Colors != null && m_Mesh.m_Colors.Length == m_Mesh.m_VertexCount * 4) { colorData = new Vector4[m_Mesh.m_VertexCount]; for (int c = 0; c < m_Mesh.m_VertexCount; c++) @@ -973,6 +965,14 @@ namespace AssetStudio m_Mesh.m_Colors[c * 4 + 3]); } } + else + { + colorData = new Vector4[m_Mesh.m_VertexCount]; + for (int c = 0; c < m_Mesh.m_VertexCount; c++) + { + colorData[c] = new Vector4(0.5f, 0.5f, 0.5f, 1.0f); + } + } #endregion glControl1.Visible = true; createVAO(); diff --git a/AssetStudio/StudioClasses/FBXExporter.cs b/AssetStudio/StudioClasses/FBXExporter.cs index a98a203..f099d50 100644 --- a/AssetStudio/StudioClasses/FBXExporter.cs +++ b/AssetStudio/StudioClasses/FBXExporter.cs @@ -803,7 +803,7 @@ namespace AssetStudio #endregion #region Colors - if ((bool)Properties.Settings.Default["exportColors"] && m_Mesh.m_Colors != null && m_Mesh.m_Colors.Length > 0) + if ((bool)Properties.Settings.Default["exportColors"] && m_Mesh.m_Colors != null && (m_Mesh.m_Colors.Length == m_Mesh.m_VertexCount * 3 || m_Mesh.m_Colors.Length == m_Mesh.m_VertexCount * 4)) { ob.Append("\n\t\tLayerElementColor: 0 {"); ob.Append("\n\t\t\tVersion: 101"); diff --git a/AssetStudio/StudioClasses/ModelConverter.cs b/AssetStudio/StudioClasses/ModelConverter.cs index d95d300..719a475 100644 --- a/AssetStudio/StudioClasses/ModelConverter.cs +++ b/AssetStudio/StudioClasses/ModelConverter.cs @@ -270,7 +270,7 @@ namespace AssetStudio ImportedMaterial iMat = ConvertMaterial(mat); iSubmesh.Material = iMat.Name; iSubmesh.VertexList = new List((int)submesh.vertexCount); - var vertexColours = mesh.m_Colors != null && mesh.m_Colors.Length > 0; + var vertexColours = mesh.m_Colors != null && (mesh.m_Colors.Length == mesh.m_VertexCount * 3 || mesh.m_Colors.Length == mesh.m_VertexCount * 4); for (var j = mesh.m_SubMeshes[i].firstVertex; j < mesh.m_SubMeshes[i].firstVertex + mesh.m_SubMeshes[i].vertexCount; j++) { var iVertex = vertexColours ? new ImportedVertexWithColour() : new ImportedVertex();