From bd5eb3be5d1c1b400d14c8e119a8be52f5d6ded2 Mon Sep 17 00:00:00 2001 From: Perfare Date: Wed, 18 Apr 2018 11:17:33 +0800 Subject: [PATCH] Some improvements --- AssetStudio/AssetStudioForm.Designer.cs | 19 +++++++++---------- AssetStudio/AssetStudioForm.cs | 1 - AssetStudio/StudioClasses/ModelConverter.cs | 13 +++++++++---- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/AssetStudio/AssetStudioForm.Designer.cs b/AssetStudio/AssetStudioForm.Designer.cs index d485ad1..72c2e9c 100644 --- a/AssetStudio/AssetStudioForm.Designer.cs +++ b/AssetStudio/AssetStudioForm.Designer.cs @@ -50,6 +50,7 @@ this.exportallobjectssplitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportselectedobjectsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.exportAllObjectssplitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.exportSelectedObjectsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportSelectedObjectsWithAnimationClipToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -113,7 +114,6 @@ this.exportAnimatorwithselectedAnimationClipMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportobjectswithselectedAnimationClipMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.showOriginalFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.exportAllObjectssplitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); @@ -317,6 +317,13 @@ this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Size = new System.Drawing.Size(320, 6); // + // exportAllObjectssplitToolStripMenuItem1 + // + this.exportAllObjectssplitToolStripMenuItem1.Name = "exportAllObjectssplitToolStripMenuItem1"; + this.exportAllObjectssplitToolStripMenuItem1.Size = new System.Drawing.Size(323, 22); + this.exportAllObjectssplitToolStripMenuItem1.Text = "Export all objects (split)"; + this.exportAllObjectssplitToolStripMenuItem1.Click += new System.EventHandler(this.exportAllObjectssplitToolStripMenuItem1_Click); + // // exportSelectedObjectsToolStripMenuItem // this.exportSelectedObjectsToolStripMenuItem.Name = "exportSelectedObjectsToolStripMenuItem"; @@ -383,7 +390,6 @@ this.showTypeToolStripMenuItem.Name = "showTypeToolStripMenuItem"; this.showTypeToolStripMenuItem.Size = new System.Drawing.Size(83, 21); this.showTypeToolStripMenuItem.Text = "Show Type"; - this.showTypeToolStripMenuItem.Visible = false; // // allToolStripMenuItem // @@ -391,7 +397,7 @@ this.allToolStripMenuItem.CheckOnClick = true; this.allToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.allToolStripMenuItem.Name = "allToolStripMenuItem"; - this.allToolStripMenuItem.Size = new System.Drawing.Size(90, 22); + this.allToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.allToolStripMenuItem.Text = "All"; this.allToolStripMenuItem.Click += new System.EventHandler(this.typeToolStripMenuItem_Click); // @@ -931,13 +937,6 @@ this.showOriginalFileToolStripMenuItem.Visible = false; this.showOriginalFileToolStripMenuItem.Click += new System.EventHandler(this.showOriginalFileToolStripMenuItem_Click); // - // exportAllObjectssplitToolStripMenuItem1 - // - this.exportAllObjectssplitToolStripMenuItem1.Name = "exportAllObjectssplitToolStripMenuItem1"; - this.exportAllObjectssplitToolStripMenuItem1.Size = new System.Drawing.Size(323, 22); - this.exportAllObjectssplitToolStripMenuItem1.Text = "Export all objects (split)"; - this.exportAllObjectssplitToolStripMenuItem1.Click += new System.EventHandler(this.exportAllObjectssplitToolStripMenuItem1_Click); - // // AssetStudioForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/AssetStudio/AssetStudioForm.cs b/AssetStudio/AssetStudioForm.cs index a7820f9..48e5bc2 100644 --- a/AssetStudio/AssetStudioForm.cs +++ b/AssetStudio/AssetStudioForm.cs @@ -231,7 +231,6 @@ namespace AssetStudio showTypeToolStripMenuItem.DropDownItems.Add(typeItem); } allToolStripMenuItem.Checked = true; - showTypeToolStripMenuItem.Visible = true; StatusStripUpdate($"Finished loading {assetsfileList.Count} files with {assetListView.Items.Count} exportable assets."); treeSearch.Select(); })); diff --git a/AssetStudio/StudioClasses/ModelConverter.cs b/AssetStudio/StudioClasses/ModelConverter.cs index 6f0151c..ecc0dc5 100644 --- a/AssetStudio/StudioClasses/ModelConverter.cs +++ b/AssetStudio/StudioClasses/ModelConverter.cs @@ -226,9 +226,10 @@ 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; for (var j = mesh.m_SubMeshes[i].firstVertex; j < mesh.m_SubMeshes[i].firstVertex + mesh.m_SubMeshes[i].vertexCount; j++) { - var iVertex = new ImportedVertexWithColour(); + var iVertex = vertexColours ? new ImportedVertexWithColour() : new ImportedVertex(); //Vertices int c = 3; if (mesh.m_Vertices.Length == mesh.m_VertexCount * 4) @@ -250,15 +251,15 @@ namespace AssetStudio iVertex.Normal = new Vector3(-mesh.m_Normals[j * c], mesh.m_Normals[j * c + 1], mesh.m_Normals[j * c + 2]); } //Colors - if (mesh.m_Colors != null && mesh.m_Colors.Length > 0) + if (vertexColours) { if (mesh.m_Colors.Length == mesh.m_VertexCount * 3) { - iVertex.Colour = new Color4(mesh.m_Colors[j * 3], mesh.m_Colors[j * 3 + 1], mesh.m_Colors[j * 3 + 2], 1.0f); + ((ImportedVertexWithColour)iVertex).Colour = new Color4(mesh.m_Colors[j * 3], mesh.m_Colors[j * 3 + 1], mesh.m_Colors[j * 3 + 2], 1.0f); } else { - iVertex.Colour = new Color4(mesh.m_Colors[j * 4], mesh.m_Colors[j * 4 + 1], mesh.m_Colors[j * 4 + 2], mesh.m_Colors[j * 4 + 3]); + ((ImportedVertexWithColour)iVertex).Colour = new Color4(mesh.m_Colors[j * 4], mesh.m_Colors[j * 4 + 1], mesh.m_Colors[j * 4 + 2], mesh.m_Colors[j * 4 + 3]); } } //UV @@ -266,6 +267,10 @@ namespace AssetStudio { iVertex.UV = new[] { mesh.m_UV1[j * 2], -mesh.m_UV1[j * 2 + 1] }; } + else if (mesh.m_UV2 != null && mesh.m_UV2.Length == mesh.m_VertexCount * 2) + { + iVertex.UV = new[] { mesh.m_UV2[j * 2], -mesh.m_UV2[j * 2 + 1] }; + } //Tangent if (mesh.m_Tangents != null) {