diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index f71c3ad0..70e65024 100644 Binary files a/.vs/Switch_Toolbox/v15/.suo and b/.vs/Switch_Toolbox/v15/.suo differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide index 9909688e..62c8bbc8 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm index ff1badfd..add7d7e0 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal index 35fddea8..a0883630 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal differ diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/BFRES.cs b/Switch_FileFormatsMain/FileFormats/BFRES/BFRES.cs index 636d50c0..8611107c 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/BFRES.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/BFRES.cs @@ -789,6 +789,35 @@ namespace FirstPlugin LoadEditors(this); } + public BFRESGroupNode GetFTEXContainer + { + get + { + foreach (TreeNode folder in Nodes) + { + if (folder is BFRESGroupNode) + { + if (((BFRESGroupNode)folder).Type == BRESGroupType.Textures) + return (BFRESGroupNode)folder; + } + } + return null; + } + } + + public BNTX GetBNTX + { + get + { + foreach (TreeNode folder in Nodes) + { + if (folder is BNTX) + return (BNTX)folder; + } + return null; + } + } + public bool HasTextures { get diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs index 02feb57c..4756cf00 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs @@ -658,6 +658,9 @@ namespace Bfres.Structs if (!ForceSkinInfluence) shape.VertexSkinCount = obj.GetMaxSkinInfluenceCount(); + else + shape.VertexSkinCount = (byte)ForceSkinInfluenceMax; + if (shape.VertexSkinCount == 1) { @@ -1045,6 +1048,9 @@ namespace Bfres.Structs if (!ForceSkinInfluence) shape.VertexSkinCount = obj.GetMaxSkinInfluenceCount(); + else + shape.VertexSkinCount = (byte)ForceSkinInfluenceMax; + if (shape.VertexSkinCount == 1 && shape.BoneIndices.Count > 0) { diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs index 1378a2ff..697def03 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs @@ -27,10 +27,61 @@ namespace Bfres.Structs ContextMenuStrip.Items.Add(new ToolStripMenuItem("Import Object", null, Import, Keys.Control | Keys.I)); ContextMenuStrip.Items.Add(new ToolStripSeparator()); + ContextMenuStrip.Items.Add(new ToolStripMenuItem("New Empty Object", null, CreateEmpty, Keys.Control | Keys.N)); + ContextMenuStrip.Items.Add(new ToolStripSeparator()); ContextMenuStrip.Items.Add(new ToolStripMenuItem("Export All Objects", null, ExportAll, Keys.Control | Keys.A)); ContextMenuStrip.Items.Add(new ToolStripMenuItem("Clear All Objects", null, Clear, Keys.Control | Keys.C)); } + + private void CreateEmpty(object sender, EventArgs args) + { + var fmdl = ((FMDL)Parent); + List ShapeKeys = fmdl.shapes.Select(i => i.Text).ToList(); + + string NewEmptyName = Utils.RenameDuplicateString(ShapeKeys, "EmptyShape"); + + if (fmdl.GetResFileU() != null) + { + var Shape = new ResU.Shape(); + Shape.CreateEmptyMesh(); + Shape.Name = NewEmptyName; + + var VertexBuffer = new ResU.VertexBuffer(); + VertexBuffer.CreateEmptyVertexBuffer(); + + fmdl.ModelU.VertexBuffers.Add(VertexBuffer); + fmdl.ModelU.Shapes.Add(Shape.Name, Shape); + + FSHP mesh = new FSHP(); + BfresWiiU.ReadShapesVertices(mesh, Shape, VertexBuffer, (FMDL)Parent); + mesh.MaterialIndex = 0; + + fmdl.Nodes["FshpFolder"].Nodes.Add(mesh); + fmdl.shapes.Add(mesh); + } + else + { + var Shape = new Shape(); + Shape.CreateEmptyMesh(); + Shape.Name = NewEmptyName; + + var VertexBuffer = new VertexBuffer(); + VertexBuffer.CreateEmptyVertexBuffer(); + + fmdl.Model.VertexBuffers.Add(VertexBuffer); + fmdl.Model.Shapes.Add(Shape); + fmdl.Model.ShapeDict.Add(NewEmptyName); + + FSHP mesh = new FSHP(); + BfresSwitch.ReadShapesVertices(mesh, Shape, VertexBuffer, (FMDL)Parent); + mesh.MaterialIndex = 0; + + fmdl.Nodes["FshpFolder"].Nodes.Add(mesh); + fmdl.shapes.Add(mesh); + } + } + private void Clear(object sender, EventArgs args) { DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all objects? This cannot be undone!", "", MessageBoxButtons.YesNo); @@ -42,9 +93,11 @@ namespace Bfres.Structs ((FMDL)Parent).UpdateVertexData(); } } + private void ExportAll(object sender, EventArgs args) { } + private void Import(object sender, EventArgs args) { OpenFileDialog ofd = new OpenFileDialog(); diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs b/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs index 5c1e2d36..63515a6b 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs @@ -95,7 +95,6 @@ namespace FirstPlugin } foreach (Shape shp in mdl.Shapes.Values) { - VertexBuffer vertexBuffer = mdl.VertexBuffers[shp.VertexBufferIndex]; Material material = mdl.Materials[shp.MaterialIndex]; FSHP mesh = new FSHP(); diff --git a/Switch_FileFormatsMain/GL/BFRES_Render.cs b/Switch_FileFormatsMain/GL/BFRES_Render.cs index f90db9c2..54750ee9 100644 --- a/Switch_FileFormatsMain/GL/BFRES_Render.cs +++ b/Switch_FileFormatsMain/GL/BFRES_Render.cs @@ -534,11 +534,13 @@ namespace FirstPlugin // Bind the texture and create the uniform if the material has the right textures. if (hasTex) { - GL.Uniform1(shader.GetUniformLocation(name), BindTexture(shader, mattex, mat.GetResFileU() != null)); + GL.Uniform1(shader.GetUniformLocation(name), BindTexture(shader, mattex, mat, mat.GetResFileU() != null)); } } - public static int BindTexture(SF.Shader shader, MatTexture tex, bool IsWiiU) + public static int BindTexture(SF.Shader shader, MatTexture tex, FMAT material, bool IsWiiU) { + BFRES bfres = (BFRES)material.Parent.Parent.Parent.Parent; + GL.ActiveTexture(TextureUnit.Texture0 + tex.textureUnit + 1); GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.RenderableTex.TexID); @@ -548,38 +550,76 @@ namespace FirstPlugin if (IsWiiU) { + if (bfres.HasTextures) + { + var ftexCont = bfres.GetFTEXContainer; + if (ftexCont != null) + { + if (ftexCont.ResourceNodes.ContainsKey(activeTex)) + { + BindFTEX(ftexCont, tex, activeTex); + return tex.textureUnit + 1; + } + } + } + foreach (var ftexContainer in PluginRuntime.ftexContainers) { if (ftexContainer.ResourceNodes.ContainsKey(activeTex)) { - FTEX ftex = (FTEX)ftexContainer.ResourceNodes[activeTex]; - - if (ftex.RenderableTex == null || !ftex.RenderableTex.GLInitialized) - ftex.LoadOpenGLTexture(); - - BindGLTexture(tex, ftex.RenderableTex.TexID); + BindFTEX(ftexContainer, tex, activeTex); + return tex.textureUnit + 1; } } } else { + if (bfres.HasTextures) + { + var bntx = bfres.GetBNTX; + if (bntx != null) + { + if (bntx.Textures.ContainsKey(activeTex)) + { + BindBNTX(bntx, tex, activeTex); + return tex.textureUnit + 1; + } + } + } + foreach (var bntx in PluginRuntime.bntxContainers) { if (bntx.Textures.ContainsKey(activeTex)) { - if (bntx.Textures[activeTex].RenderableTex == null || - !bntx.Textures[activeTex].RenderableTex.GLInitialized) - { - bntx.Textures[activeTex].LoadOpenGLTexture(); - } - - BindGLTexture(tex, bntx.Textures[activeTex].RenderableTex.TexID); + BindBNTX(bntx, tex, activeTex); + return tex.textureUnit + 1; } } } return tex.textureUnit + 1; } + private static void BindFTEX(BFRESGroupNode ftexContainer, MatTexture tex, string activeTex) + { + FTEX ftex = (FTEX)ftexContainer.ResourceNodes[activeTex]; + + if (ftex.RenderableTex == null || !ftex.RenderableTex.GLInitialized) + ftex.LoadOpenGLTexture(); + + BindGLTexture(tex, ftex.RenderableTex.TexID); + } + + private static void BindBNTX(BNTX bntx, MatTexture tex, string activeTex) + { + if (bntx.Textures[activeTex].RenderableTex == null || + !bntx.Textures[activeTex].RenderableTex.GLInitialized) + { + bntx.Textures[activeTex].LoadOpenGLTexture(); + } + + BindGLTexture(tex, bntx.Textures[activeTex].RenderableTex.TexID); + } + private static void BindGLTexture(MatTexture tex, int texid) { // GL.ActiveTexture(TextureUnit.Texture0 + texid); diff --git a/Switch_FileFormatsMain/GUI/AAMP/AampEditor.cs b/Switch_FileFormatsMain/GUI/AAMP/AampEditor.cs index 261d8dca..64a16a2b 100644 --- a/Switch_FileFormatsMain/GUI/AAMP/AampEditor.cs +++ b/Switch_FileFormatsMain/GUI/AAMP/AampEditor.cs @@ -66,9 +66,9 @@ namespace FirstPlugin.Forms string yaml = ""; if (AampFile.aampFileV1 != null) - yaml = YamlConverter.ToYaml(AampFile.aampFileV1); + yaml = AampYamlConverter.ToYaml(AampFile.aampFileV1); else - yaml = YamlConverter.ToYaml(AampFile.aampFileV2); + yaml = AampYamlConverter.ToYaml(AampFile.aampFileV2); STForm form = new STForm(); form.Text = "YAML Text Editor"; @@ -95,9 +95,9 @@ namespace FirstPlugin.Forms string yaml = ""; if (AampFile.aampFileV1 != null) - yaml = YamlConverter.ToYaml(AampFile.aampFileV1); + yaml = AampYamlConverter.ToYaml(AampFile.aampFileV1); else - yaml = YamlConverter.ToYaml(AampFile.aampFileV2); + yaml = AampYamlConverter.ToYaml(AampFile.aampFileV2); File.WriteAllText(sfd.FileName, yaml); } diff --git a/Switch_FileFormatsMain/GUI/BFRES/Materials/BfresMaterialEditor.Designer.cs b/Switch_FileFormatsMain/GUI/BFRES/Materials/BfresMaterialEditor.Designer.cs index 384be7a2..7f0b14da 100644 --- a/Switch_FileFormatsMain/GUI/BFRES/Materials/BfresMaterialEditor.Designer.cs +++ b/Switch_FileFormatsMain/GUI/BFRES/Materials/BfresMaterialEditor.Designer.cs @@ -57,6 +57,8 @@ this.stLabel2 = new Switch_Toolbox.Library.Forms.STLabel(); this.btnAttributeInputEditor = new Switch_Toolbox.Library.Forms.STButton(); this.stLabel3 = new Switch_Toolbox.Library.Forms.STLabel(); + this.stButton1 = new Switch_Toolbox.Library.Forms.STButton(); + this.stLabel4 = new Switch_Toolbox.Library.Forms.STLabel(); this.stTabControl1.SuspendLayout(); this.tabPage2.SuspendLayout(); this.tabPage1.SuspendLayout(); @@ -114,8 +116,8 @@ // // stTabControl1 // - this.stTabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this.stTabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.stTabControl1.Controls.Add(this.tabPage2); this.stTabControl1.Controls.Add(this.tabPage1); @@ -339,10 +341,31 @@ this.stLabel3.TabIndex = 48; this.stLabel3.Text = "Attribute Inputs:"; // + // stButton1 + // + this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.stButton1.Location = new System.Drawing.Point(439, 74); + this.stButton1.Name = "stButton1"; + this.stButton1.Size = new System.Drawing.Size(75, 23); + this.stButton1.TabIndex = 51; + this.stButton1.UseVisualStyleBackColor = false; + this.stButton1.Click += new System.EventHandler(this.stButton1_Click); + // + // stLabel4 + // + this.stLabel4.AutoSize = true; + this.stLabel4.Location = new System.Drawing.Point(366, 77); + this.stLabel4.Name = "stLabel4"; + this.stLabel4.Size = new System.Drawing.Size(42, 13); + this.stLabel4.TabIndex = 50; + this.stLabel4.Text = "Presets"; + // // FMATEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.stButton1); + this.Controls.Add(this.stLabel4); this.Controls.Add(this.btnAttributeInputEditor); this.Controls.Add(this.stLabel3); this.Controls.Add(this.btnSamplerInputEditor); @@ -401,5 +424,7 @@ private Switch_Toolbox.Library.Forms.STLabel stLabel2; private Switch_Toolbox.Library.Forms.STButton btnAttributeInputEditor; private Switch_Toolbox.Library.Forms.STLabel stLabel3; + private Switch_Toolbox.Library.Forms.STButton stButton1; + private Switch_Toolbox.Library.Forms.STLabel stLabel4; } } \ No newline at end of file diff --git a/Switch_FileFormatsMain/GUI/BFRES/Materials/BfresMaterialEditor.cs b/Switch_FileFormatsMain/GUI/BFRES/Materials/BfresMaterialEditor.cs index e0205697..2f88d734 100644 --- a/Switch_FileFormatsMain/GUI/BFRES/Materials/BfresMaterialEditor.cs +++ b/Switch_FileFormatsMain/GUI/BFRES/Materials/BfresMaterialEditor.cs @@ -326,5 +326,14 @@ namespace FirstPlugin.Forms { material.shaderassign.ShaderModel = textBoxShaderModel.Text; } + + private void stButton1_Click(object sender, EventArgs e) + { + MaterialPresetDialog presetDialog = new MaterialPresetDialog(); + if (presetDialog.ShowDialog() == DialogResult.OK) + { + + } + } } } \ No newline at end of file diff --git a/Switch_FileFormatsMain/GUI/BFRES/Materials/Presets/MaterialPresetDialog.Designer.cs b/Switch_FileFormatsMain/GUI/BFRES/Materials/Presets/MaterialPresetDialog.Designer.cs new file mode 100644 index 00000000..3a1aa219 --- /dev/null +++ b/Switch_FileFormatsMain/GUI/BFRES/Materials/Presets/MaterialPresetDialog.Designer.cs @@ -0,0 +1,184 @@ +namespace FirstPlugin.Forms +{ + partial class MaterialPresetDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.stCheckBox1 = new Switch_Toolbox.Library.Forms.STCheckBox(); + this.stLabel2 = new Switch_Toolbox.Library.Forms.STLabel(); + this.stLabel1 = new Switch_Toolbox.Library.Forms.STLabel(); + this.treeViewCustom1 = new Switch_Toolbox.Library.TreeViewCustom(); + this.stLabel3 = new Switch_Toolbox.Library.Forms.STLabel(); + this.stButton1 = new Switch_Toolbox.Library.Forms.STButton(); + this.stButton2 = new Switch_Toolbox.Library.Forms.STButton(); + this.stLabel4 = new Switch_Toolbox.Library.Forms.STLabel(); + this.contentContainer.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // contentContainer + // + this.contentContainer.Controls.Add(this.stLabel4); + this.contentContainer.Controls.Add(this.stButton2); + this.contentContainer.Controls.Add(this.stButton1); + this.contentContainer.Controls.Add(this.stLabel2); + this.contentContainer.Controls.Add(this.stLabel3); + this.contentContainer.Controls.Add(this.pictureBox1); + this.contentContainer.Controls.Add(this.stCheckBox1); + this.contentContainer.Controls.Add(this.stLabel1); + this.contentContainer.Controls.Add(this.treeViewCustom1); + this.contentContainer.Size = new System.Drawing.Size(646, 489); + this.contentContainer.Controls.SetChildIndex(this.treeViewCustom1, 0); + this.contentContainer.Controls.SetChildIndex(this.stLabel1, 0); + this.contentContainer.Controls.SetChildIndex(this.stCheckBox1, 0); + this.contentContainer.Controls.SetChildIndex(this.pictureBox1, 0); + this.contentContainer.Controls.SetChildIndex(this.stLabel3, 0); + this.contentContainer.Controls.SetChildIndex(this.stLabel2, 0); + this.contentContainer.Controls.SetChildIndex(this.stButton1, 0); + this.contentContainer.Controls.SetChildIndex(this.stButton2, 0); + this.contentContainer.Controls.SetChildIndex(this.stLabel4, 0); + // + // pictureBox1 + // + this.pictureBox1.Location = new System.Drawing.Point(350, 257); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(289, 192); + this.pictureBox1.TabIndex = 4; + this.pictureBox1.TabStop = false; + // + // stCheckBox1 + // + this.stCheckBox1.AutoSize = true; + this.stCheckBox1.Enabled = false; + this.stCheckBox1.Location = new System.Drawing.Point(353, 204); + this.stCheckBox1.Name = "stCheckBox1"; + this.stCheckBox1.Size = new System.Drawing.Size(96, 17); + this.stCheckBox1.TabIndex = 3; + this.stCheckBox1.Text = "Embed Shader"; + this.stCheckBox1.UseVisualStyleBackColor = true; + // + // stLabel2 + // + this.stLabel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.stLabel2.Location = new System.Drawing.Point(350, 79); + this.stLabel2.Name = "stLabel2"; + this.stLabel2.Size = new System.Drawing.Size(289, 122); + this.stLabel2.TabIndex = 2; + this.stLabel2.Text = "Description:"; + // + // stLabel1 + // + this.stLabel1.AutoSize = true; + this.stLabel1.Location = new System.Drawing.Point(348, 37); + this.stLabel1.Name = "stLabel1"; + this.stLabel1.Size = new System.Drawing.Size(38, 13); + this.stLabel1.TabIndex = 1; + this.stLabel1.Text = "Name:"; + // + // treeViewCustom1 + // + this.treeViewCustom1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.treeViewCustom1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.treeViewCustom1.ImageIndex = 0; + this.treeViewCustom1.Location = new System.Drawing.Point(0, 25); + this.treeViewCustom1.Name = "treeViewCustom1"; + this.treeViewCustom1.SelectedImageIndex = 0; + this.treeViewCustom1.Size = new System.Drawing.Size(344, 424); + this.treeViewCustom1.TabIndex = 0; + // + // stLabel3 + // + this.stLabel3.AutoSize = true; + this.stLabel3.Location = new System.Drawing.Point(350, 241); + this.stLabel3.Name = "stLabel3"; + this.stLabel3.Size = new System.Drawing.Size(94, 13); + this.stLabel3.TabIndex = 5; + this.stLabel3.Text = "Preview (In Game)"; + // + // stButton1 + // + this.stButton1.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.stButton1.Location = new System.Drawing.Point(561, 455); + this.stButton1.Name = "stButton1"; + this.stButton1.Size = new System.Drawing.Size(75, 23); + this.stButton1.TabIndex = 11; + this.stButton1.Text = "Cancel"; + this.stButton1.UseVisualStyleBackColor = false; + // + // stButton2 + // + this.stButton2.DialogResult = System.Windows.Forms.DialogResult.OK; + this.stButton2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.stButton2.Location = new System.Drawing.Point(480, 455); + this.stButton2.Name = "stButton2"; + this.stButton2.Size = new System.Drawing.Size(75, 23); + this.stButton2.TabIndex = 12; + this.stButton2.Text = "Ok"; + this.stButton2.UseVisualStyleBackColor = false; + // + // stLabel4 + // + this.stLabel4.AutoSize = true; + this.stLabel4.Location = new System.Drawing.Point(477, 205); + this.stLabel4.Name = "stLabel4"; + this.stLabel4.Size = new System.Drawing.Size(44, 13); + this.stLabel4.TabIndex = 13; + this.stLabel4.Text = "Shader:"; + // + // MaterialPresetDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(651, 492); + this.Name = "MaterialPresetDialog"; + this.Text = "Material Presets"; + this.Load += new System.EventHandler(this.MaterialPresetDialog_Load); + this.contentContainer.ResumeLayout(false); + this.contentContainer.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Switch_Toolbox.Library.TreeViewCustom treeViewCustom1; + private Switch_Toolbox.Library.Forms.STLabel stLabel1; + private Switch_Toolbox.Library.Forms.STLabel stLabel2; + private Switch_Toolbox.Library.Forms.STCheckBox stCheckBox1; + private System.Windows.Forms.PictureBox pictureBox1; + private Switch_Toolbox.Library.Forms.STLabel stLabel3; + private Switch_Toolbox.Library.Forms.STButton stButton2; + private Switch_Toolbox.Library.Forms.STButton stButton1; + private Switch_Toolbox.Library.Forms.STLabel stLabel4; + } +} \ No newline at end of file diff --git a/Switch_FileFormatsMain/GUI/BFRES/Materials/Presets/MaterialPresetDialog.cs b/Switch_FileFormatsMain/GUI/BFRES/Materials/Presets/MaterialPresetDialog.cs new file mode 100644 index 00000000..75d8f943 --- /dev/null +++ b/Switch_FileFormatsMain/GUI/BFRES/Materials/Presets/MaterialPresetDialog.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Switch_Toolbox.Library.Forms; +using Switch_Toolbox.Library; + +namespace FirstPlugin.Forms +{ + public partial class MaterialPresetDialog : STForm + { + public MaterialPresetDialog() + { + InitializeComponent(); + } + + private void MaterialPresetDialog_Load(object sender, EventArgs e) { + ReloadMaterials(); + } + + public void ReloadMaterials() + { + string PresetPath = Path.Combine(Runtime.ExecutableDir, "Presets"); + string MaterialPath = Path.Combine(PresetPath, "Materials"); + + foreach (var directory in Directory.GetDirectories(MaterialPath)) + { + TreeNode GameFolder = new TreeNode(Path.GetFileName(directory)); + treeViewCustom1.Nodes.Add(GameFolder); + + foreach (var file in Directory.GetFiles(directory)) + { + TreeNode MaterailPreset = new TreeNode(Path.GetFileName(file)); + MaterailPreset.ImageKey = "material"; + MaterailPreset.SelectedImageKey = "material"; + + MaterailPreset.Tag = file; + GameFolder.Nodes.Add(MaterailPreset); + } + } + } + } +} diff --git a/Switch_FileFormatsMain/GUI/BFRES/Materials/Presets/MaterialPresetDialog.resx b/Switch_FileFormatsMain/GUI/BFRES/Materials/Presets/MaterialPresetDialog.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/Switch_FileFormatsMain/GUI/BFRES/Materials/Presets/MaterialPresetDialog.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Switch_FileFormatsMain/MaterialDefineConfig.cs b/Switch_FileFormatsMain/MaterialDefineConfig.cs new file mode 100644 index 00000000..f7709f30 --- /dev/null +++ b/Switch_FileFormatsMain/MaterialDefineConfig.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FirstPlugin +{ + public class MaterialDefineConfig + { + public Dictionary ParamConfigs = new Dictionary(); + public Dictionary OptionConfigs = new Dictionary(); + public Dictionary RenderInfoConfigs = new Dictionary(); + public Dictionary UserDataConfigs = new Dictionary(); + + public class ConfigEntry + { + //The original name of the parameter + public string Name { get; set; } + + //Alternate name a user can give to potentially make it easier to read + public string AlternateName { get; set; } + + //What effect the data gives. + public string Description { get; set; } + } + } +} diff --git a/Switch_FileFormatsMain/MaterialPresetConfig.cs b/Switch_FileFormatsMain/MaterialPresetConfig.cs new file mode 100644 index 00000000..78ac9ae4 --- /dev/null +++ b/Switch_FileFormatsMain/MaterialPresetConfig.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FirstPlugin +{ + public class MaterialPresetConfig + { + public List MaterialConfigs = new List(); + + public class MaterialEntry + { + //The name of the preset + public string Name { get; set; } + + //The effects of the material + public string Description { get; set; } + + //The game material belongs to + public string Game { get; set; } + + //The shader used by the material (optional) + //If a game does not use multiple shaders per bfres this is not necessary + public string ShaderPath { get; set; } + } + } +} diff --git a/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj b/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj index b014d960..0acce323 100644 --- a/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj +++ b/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj @@ -133,6 +133,9 @@ ..\Toolbox\Lib\SFGraphics.Utils.dll False + + ..\Toolbox\Lib\SharpYaml.dll + ..\Toolbox\Lib\Syroot.BinaryData.dll False @@ -266,7 +269,7 @@ AampEditor.cs - + UserControl @@ -297,6 +300,13 @@ VisObjectAddDialog.cs + + + Form + + + MaterialPresetDialog.cs + Form @@ -870,6 +880,7 @@ + @@ -882,6 +893,7 @@ + @@ -924,6 +936,9 @@ VisObjectAddDialog.cs + + MaterialPresetDialog.cs + MaterialReplaceDialog.cs diff --git a/Switch_FileFormatsMain/GUI/AAMP/YamlConverter.cs b/Switch_FileFormatsMain/YAML/YamlAamp.cs similarity index 99% rename from Switch_FileFormatsMain/GUI/AAMP/YamlConverter.cs rename to Switch_FileFormatsMain/YAML/YamlAamp.cs index 78cbee7a..01362066 100644 --- a/Switch_FileFormatsMain/GUI/AAMP/YamlConverter.cs +++ b/Switch_FileFormatsMain/YAML/YamlAamp.cs @@ -22,7 +22,7 @@ namespace FirstPlugin } } - public class YamlConverter + public class AampYamlConverter { #region V1 AAMP diff --git a/Switch_FileFormatsMain/YAML/YamlFmat.cs b/Switch_FileFormatsMain/YAML/YamlFmat.cs new file mode 100644 index 00000000..f7566574 --- /dev/null +++ b/Switch_FileFormatsMain/YAML/YamlFmat.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Bfres.Structs; +using SharpYaml; +using SharpYaml.Serialization; +using Syroot.NintenTools.NSW.Bfres; + +namespace FirstPlugin.YAML +{ + public class YamlFmat + { + public class RenderInfoConfig + { + public string Name { get; set; } + public RenderInfoType Type { get; set; } + public object Data { get; set; } + } + + public static string ToYaml(string Name, FMAT material) + { + var serializerSettings = new SerializerSettings() + { + EmitTags = false + }; + + var serializer = new Serializer(serializerSettings); + return serializer.Serialize(material); + } + } +} diff --git a/Switch_FileFormatsMain/obj/Release/AxInterop.WMPLib.dll b/Switch_FileFormatsMain/obj/Release/AxInterop.WMPLib.dll index 2dfd8cbe..841d8629 100644 Binary files a/Switch_FileFormatsMain/obj/Release/AxInterop.WMPLib.dll and b/Switch_FileFormatsMain/obj/Release/AxInterop.WMPLib.dll differ diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index 4ca6e44e..6a2285d1 100644 Binary files a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache and b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache index 08af96c0..0f369c53 100644 Binary files a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache and b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/Interop.WMPLib.dll b/Switch_FileFormatsMain/obj/Release/Interop.WMPLib.dll index 3e634092..c1e365b6 100644 Binary files a/Switch_FileFormatsMain/obj/Release/Interop.WMPLib.dll and b/Switch_FileFormatsMain/obj/Release/Interop.WMPLib.dll differ diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache index b8b18b6d..261d4861 100644 --- a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache +++ b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -fdc3ae3441a26fcd02916e04a1344635998d8023 +1619e231c2d04d36ec585863c8bb883a2a31d0e7 diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.FileListAbsolute.txt b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.FileListAbsolute.txt index b5d27ce0..45a3587e 100644 --- a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.FileListAbsolute.txt +++ b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.FileListAbsolute.txt @@ -330,3 +330,4 @@ C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Rele C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.BcresEditor.resources C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.BcresSamplerEditorSimple.resources C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.OdysseyCostumeSelector.resources +C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.MaterialPresetDialog.resources diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.GenerateResource.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.GenerateResource.cache index 0b790318..29c0ba2f 100644 Binary files a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.GenerateResource.cache and b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.GenerateResource.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache index aa827032..ccf8b162 100644 Binary files a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache and b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache differ diff --git a/Switch_Toolbox_Library/Forms/Dialogs/STErrorDialog.Designer.cs b/Switch_Toolbox_Library/Forms/Dialogs/STErrorDialog.Designer.cs index a657b56f..1f74fe43 100644 --- a/Switch_Toolbox_Library/Forms/Dialogs/STErrorDialog.Designer.cs +++ b/Switch_Toolbox_Library/Forms/Dialogs/STErrorDialog.Designer.cs @@ -79,11 +79,12 @@ // // lblMessage // - this.lblMessage.AutoSize = true; - this.lblMessage.Location = new System.Drawing.Point(68, 18); + this.lblMessage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lblMessage.Location = new System.Drawing.Point(52, 12); this.lblMessage.MaximumSize = new System.Drawing.Size(310, 0); this.lblMessage.Name = "lblMessage"; - this.lblMessage.Size = new System.Drawing.Size(35, 13); + this.lblMessage.Size = new System.Drawing.Size(288, 37); this.lblMessage.TabIndex = 5; this.lblMessage.Text = "label1"; // @@ -131,7 +132,6 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); - this.PerformLayout(); } diff --git a/Switch_Toolbox_Library/Rendering/RenderTools.cs b/Switch_Toolbox_Library/Rendering/RenderTools.cs index 3f1ff53c..079ba2af 100644 --- a/Switch_Toolbox_Library/Rendering/RenderTools.cs +++ b/Switch_Toolbox_Library/Rendering/RenderTools.cs @@ -24,16 +24,6 @@ namespace Switch_Toolbox.Library diffusepbr = null; } - public static bool PbrSamplersLoaded - { - get - { - return (diffusepbr != null && - specularpbr != null && - brdfpbr != null); - } - } - public static STGenericTexture defaulttex; public static STGenericTexture defaultTex { diff --git a/Switch_Toolbox_Library/Swizzling/GX2.cs b/Switch_Toolbox_Library/Swizzling/GX2.cs index 9a23d0ba..8d4a83c2 100644 --- a/Switch_Toolbox_Library/Swizzling/GX2.cs +++ b/Switch_Toolbox_Library/Swizzling/GX2.cs @@ -501,9 +501,6 @@ namespace Switch_Toolbox.Library if (dataSize <= 0) throw new Exception($"Image is empty!!"); - if (surfOut.depth != 1) - throw new Exception($"Unsupported Depth {surfOut.depth}!"); - uint s = (swizzle << 8); uint blkWidth, blkHeight; @@ -526,6 +523,9 @@ namespace Switch_Toolbox.Library if (TileMode == 3) tilingDepth /= 4; + if (tilingDepth != 1) + throw new Exception($"Unsupported Depth {surfOut.depth}!"); + int tiling1dLevel = 0; bool tiling1dLevelSet = false; diff --git a/Switch_Toolbox_Library/Swizzling/NewSwizzleCodeBackup.cs b/Switch_Toolbox_Library/Swizzling/NewSwizzleCodeBackup.cs index f425d733..965b4745 100644 --- a/Switch_Toolbox_Library/Swizzling/NewSwizzleCodeBackup.cs +++ b/Switch_Toolbox_Library/Swizzling/NewSwizzleCodeBackup.cs @@ -445,9 +445,6 @@ namespace Switch_Toolbox.Library.NEW if (dataSize <= 0) throw new Exception($"Image is empty!!"); - if (surfOut.depth != 1) - throw new Exception($"Unsupported Depth {surfOut.depth}!"); - uint s = (swizzle << 8); uint blkWidth, blkHeight; @@ -465,6 +462,14 @@ namespace Switch_Toolbox.Library.NEW if (TileMode == 0) TileMode = GX2.getDefaultGX2TileMode((uint)SurfaceDim, Width, Height, 1, (uint)Format, 0, 1); + uint tilingDepth = surfOut.depth; + + if (TileMode == 3) + tilingDepth /= 4; + + if (tilingDepth != 1) + throw new Exception($"Unsupported Depth {surfOut.depth}!"); + int tiling1dLevel = 0; bool tiling1dLevelSet = false; diff --git a/Toolbox/Presets/Materials/Dummy.txt b/Toolbox/Presets/Materials/Dummy.txt new file mode 100644 index 00000000..5f282702 --- /dev/null +++ b/Toolbox/Presets/Materials/Dummy.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Toolbox/Presets/Shaders/Dummy.txt b/Toolbox/Presets/Shaders/Dummy.txt new file mode 100644 index 00000000..5f282702 --- /dev/null +++ b/Toolbox/Presets/Shaders/Dummy.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Toolbox/Shader/Bfres/BFRES.vert b/Toolbox/Shader/Bfres/BFRES.vert index 24fb7934..0ca7147f 100644 --- a/Toolbox/Shader/Bfres/BFRES.vert +++ b/Toolbox/Shader/Bfres/BFRES.vert @@ -142,23 +142,25 @@ void main() vec4 position = mtxCam * objPos; + normal = vNormal; - normal = mat3(mtxMdl) * normal.xyz; if(vBone.x != -1.0) normal = normalize((skinNRM(normal.xyz, index)).xyz); if (RigidSkinning == 1) { - position = mtxCam * mtxMdl * (bones[index.x] * vec4(vPosition.xyz, 1.0)); - normal = mat3(bones[index.x]) * vNormal.xyz * 1; + position = mtxCam * mtxMdl * (bones[index.x] * vec4(vPosition.xyz, 1.0)); + normal = mat3(bones[index.x]) * normal.xyz * 1; } if (NoSkinning == 1) { - position = mtxCam * mtxMdl * (SingleBoneBindTransform * vec4(vPosition.xyz, 1.0)); - normal = mat3(SingleBoneBindTransform) * vNormal.xyz * 1; + position = mtxCam * mtxMdl * (SingleBoneBindTransform * vec4(vPosition.xyz, 1.0)); + normal = mat3(SingleBoneBindTransform) * normal.xyz * 1; } + mat3 normalMatrix = transpose(inverse(mat3(mtxMdl))); + normal = normalize(normalMatrix * normal.xyz); gl_Position = position; diff --git a/Toolbox/Toolbox.csproj b/Toolbox/Toolbox.csproj index 8e92e7bc..0e4173e6 100644 --- a/Toolbox/Toolbox.csproj +++ b/Toolbox/Toolbox.csproj @@ -456,6 +456,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -478,8 +484,6 @@ PreserveNewest - - - + \ No newline at end of file