Starto to add material presets. Add option to add empty meshes

This commit is contained in:
KillzXGaming 2019-05-30 15:28:43 -04:00
parent 62a4d9f9c6
commit 3b4bb242c5
36 changed files with 675 additions and 53 deletions

Binary file not shown.

View file

@ -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

View file

@ -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)
{

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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)
{
}
}
}
}

View file

@ -0,0 +1,184 @@
namespace FirstPlugin.Forms
{
partial class MaterialPresetDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View file

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

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -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<string, ConfigEntry> ParamConfigs = new Dictionary<string, ConfigEntry>();
public Dictionary<string, ConfigEntry> OptionConfigs = new Dictionary<string, ConfigEntry>();
public Dictionary<string, ConfigEntry> RenderInfoConfigs = new Dictionary<string, ConfigEntry>();
public Dictionary<string, ConfigEntry> UserDataConfigs = new Dictionary<string, ConfigEntry>();
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; }
}
}
}

View file

@ -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<string> MaterialConfigs = new List<string>();
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; }
}
}
}

View file

@ -133,6 +133,9 @@
<HintPath>..\Toolbox\Lib\SFGraphics.Utils.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="SharpYaml">
<HintPath>..\Toolbox\Lib\SharpYaml.dll</HintPath>
</Reference>
<Reference Include="Syroot.BinaryData">
<HintPath>..\Toolbox\Lib\Syroot.BinaryData.dll</HintPath>
<Private>False</Private>
@ -266,7 +269,7 @@
<Compile Include="GUI\AAMP\AampEditor.Designer.cs">
<DependentUpon>AampEditor.cs</DependentUpon>
</Compile>
<Compile Include="GUI\AAMP\YamlConverter.cs" />
<Compile Include="YAML\YamlAamp.cs" />
<Compile Include="GUI\BCRES\BfresEditor.cs">
<SubType>UserControl</SubType>
</Compile>
@ -297,6 +300,13 @@
<Compile Include="GUI\BFRES\BoneVisualAnims\VisObjectAddDialog.Designer.cs">
<DependentUpon>VisObjectAddDialog.cs</DependentUpon>
</Compile>
<Compile Include="MaterialDefineConfig.cs" />
<Compile Include="GUI\BFRES\Materials\Presets\MaterialPresetDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\BFRES\Materials\Presets\MaterialPresetDialog.Designer.cs">
<DependentUpon>MaterialPresetDialog.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BFRES\Materials\MaterialReplaceDialog.cs">
<SubType>Form</SubType>
</Compile>
@ -870,6 +880,7 @@
<Compile Include="GUI\TextureUI\Importers\GX2\CreateGx2Texture.cs" />
<Compile Include="GUI\TextureUI\Importers\BNTX\TextureImporterSettings.cs" />
<Compile Include="Main.cs" />
<Compile Include="MaterialPresetConfig.cs" />
<Compile Include="NodeWrappers\Archives\BFRESWrapper.cs" />
<Compile Include="NodeWrappers\BfresFilters.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -882,6 +893,7 @@
<Compile Include="XML\BfresMaterial2XML.cs" />
<Compile Include="XML\Bfsha2Xml.cs" />
<Compile Include="XML\Sharc2XML.cs" />
<Compile Include="YAML\YamlFmat.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\InjectTexErrored.dds" />
@ -924,6 +936,9 @@
<EmbeddedResource Include="GUI\BFRES\BoneVisualAnims\VisObjectAddDialog.resx">
<DependentUpon>VisObjectAddDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFRES\Materials\Presets\MaterialPresetDialog.resx">
<DependentUpon>MaterialPresetDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFRES\Materials\MaterialReplaceDialog.resx">
<DependentUpon>MaterialReplaceDialog.cs</DependentUpon>
</EmbeddedResource>

View file

@ -22,7 +22,7 @@ namespace FirstPlugin
}
}
public class YamlConverter
public class AampYamlConverter
{
#region V1 AAMP

View file

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

View file

@ -1 +1 @@
fdc3ae3441a26fcd02916e04a1344635998d8023
1619e231c2d04d36ec585863c8bb883a2a31d0e7

View file

@ -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

View file

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

View file

@ -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
{

View file

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

View file

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

View file

@ -0,0 +1 @@


View file

@ -0,0 +1 @@


View file

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

View file

@ -456,6 +456,12 @@
<Content Include="LZ4.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Presets\Materials\Dummy.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Presets\Shaders\Dummy.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Presets\UserData.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@ -478,8 +484,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="Presets\Materials\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>