This commit is contained in:
Perfare 2018-07-17 02:19:11 +08:00
parent 9b1e3435d6
commit adf39dde27
3 changed files with 12 additions and 12 deletions

View File

@ -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();

View File

@ -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");

View File

@ -270,7 +270,7 @@ namespace AssetStudio
ImportedMaterial iMat = ConvertMaterial(mat);
iSubmesh.Material = iMat.Name;
iSubmesh.VertexList = new List<ImportedVertex>((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();