mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-09-20 06:22:12 +00:00
Fix Wii U model imports crashing
This commit is contained in:
parent
1e0ea5660e
commit
d28a032b24
11 changed files with 16 additions and 19 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -683,7 +683,7 @@ namespace Bfres.Structs
|
||||||
{
|
{
|
||||||
FMAT fmat = new FMAT();
|
FMAT fmat = new FMAT();
|
||||||
|
|
||||||
if (resFileU != null)
|
if (IsWiiU)
|
||||||
{
|
{
|
||||||
fmat.MaterialU = new ResU.Material();
|
fmat.MaterialU = new ResU.Material();
|
||||||
fmat.MaterialU.Import(settings.ExternalMaterialPath, resFileU);
|
fmat.MaterialU.Import(settings.ExternalMaterialPath, resFileU);
|
||||||
|
@ -695,7 +695,6 @@ namespace Bfres.Structs
|
||||||
fmat.Material.Import(settings.ExternalMaterialPath);
|
fmat.Material.Import(settings.ExternalMaterialPath);
|
||||||
fmat.ReadMaterial(fmat.Material);
|
fmat.ReadMaterial(fmat.Material);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fmat.Text = mat.Text;
|
fmat.Text = mat.Text;
|
||||||
//Setup placeholder textures
|
//Setup placeholder textures
|
||||||
|
@ -761,7 +760,7 @@ namespace Bfres.Structs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PluginRuntime.ftexContainers.Count > 0)
|
if (PluginRuntime.ftexContainers.Count > 0 && Parent != null)
|
||||||
{
|
{
|
||||||
foreach (var node in Parent.Parent.Nodes)
|
foreach (var node in Parent.Parent.Nodes)
|
||||||
{
|
{
|
||||||
|
@ -804,10 +803,10 @@ namespace Bfres.Structs
|
||||||
List<string> keyList = new List<string>(materials.Keys);
|
List<string> keyList = new List<string>(materials.Keys);
|
||||||
fmat.Text = Utils.RenameDuplicateString(keyList, fmat.Text);
|
fmat.Text = Utils.RenameDuplicateString(keyList, fmat.Text);
|
||||||
|
|
||||||
if (resFileU != null)
|
if (IsWiiU)
|
||||||
{
|
{
|
||||||
fmat.MaterialU.Name = Text;
|
fmat.MaterialU.Name = Text;
|
||||||
fmat.SetMaterial(fmat.MaterialU);
|
fmat.SetMaterial(fmat.MaterialU, resFileU);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -842,7 +841,7 @@ namespace Bfres.Structs
|
||||||
materials.Add(fmat.Text, fmat);
|
materials.Add(fmat.Text, fmat);
|
||||||
Nodes["FmatFolder"].Nodes.Add(fmat);
|
Nodes["FmatFolder"].Nodes.Add(fmat);
|
||||||
|
|
||||||
if (resFileU != null)
|
if (IsWiiU)
|
||||||
{
|
{
|
||||||
fmat.MaterialU = new ResU.Material();
|
fmat.MaterialU = new ResU.Material();
|
||||||
fmat.MaterialU.Name = "NewMaterial";
|
fmat.MaterialU.Name = "NewMaterial";
|
||||||
|
|
|
@ -90,7 +90,7 @@ namespace FirstPlugin
|
||||||
|
|
||||||
foreach (FMAT mat in fmdl.materials.Values)
|
foreach (FMAT mat in fmdl.materials.Values)
|
||||||
{
|
{
|
||||||
SetMaterial(mat, mat.MaterialU);
|
SetMaterial(mat, mat.MaterialU, fmdl.GetResFileU());
|
||||||
model.Materials.Add(mat.Text, mat.MaterialU);
|
model.Materials.Add(mat.Text, mat.MaterialU);
|
||||||
}
|
}
|
||||||
return model;
|
return model;
|
||||||
|
@ -396,15 +396,7 @@ namespace FirstPlugin
|
||||||
indx++;
|
indx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void CreateNewMaterial(string Name)
|
public static void SetMaterial(this FMAT m, Material mat, ResFile ResFile)
|
||||||
{
|
|
||||||
FMAT mat = new FMAT();
|
|
||||||
mat.Text = Name;
|
|
||||||
mat.MaterialU = new Material();
|
|
||||||
|
|
||||||
SetMaterial(mat, mat.MaterialU);
|
|
||||||
}
|
|
||||||
public static void SetMaterial(this FMAT m, Material mat)
|
|
||||||
{
|
{
|
||||||
mat.Name = m.Text;
|
mat.Name = m.Text;
|
||||||
|
|
||||||
|
@ -424,7 +416,7 @@ namespace FirstPlugin
|
||||||
mat.ShaderParamData = ParamData;
|
mat.ShaderParamData = ParamData;
|
||||||
|
|
||||||
WriteRenderInfo(m, mat);
|
WriteRenderInfo(m, mat);
|
||||||
WriteTextureRefs(m, mat);
|
WriteTextureRefs(m, mat, ResFile);
|
||||||
WriteShaderAssign(m.shaderassign, mat);
|
WriteShaderAssign(m.shaderassign, mat);
|
||||||
}
|
}
|
||||||
public static void ReadMaterial(this FMAT m, Material mat)
|
public static void ReadMaterial(this FMAT m, Material mat)
|
||||||
|
@ -715,7 +707,7 @@ namespace FirstPlugin
|
||||||
m.renderinfo.Add(r);
|
m.renderinfo.Add(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void WriteTextureRefs(this FMAT m, Material mat)
|
public static void WriteTextureRefs(this FMAT m, Material mat, ResFile resFile)
|
||||||
{
|
{
|
||||||
mat.TextureRefs = new List<TextureRef>();
|
mat.TextureRefs = new List<TextureRef>();
|
||||||
mat.TextureRefs.Clear();
|
mat.TextureRefs.Clear();
|
||||||
|
@ -737,7 +729,7 @@ namespace FirstPlugin
|
||||||
mat.Samplers.Add(textu.SamplerName, sampler);
|
mat.Samplers.Add(textu.SamplerName, sampler);
|
||||||
|
|
||||||
Texture texMapped = new Texture();
|
Texture texMapped = new Texture();
|
||||||
m.GetResFileU().Textures.TryGetValue(textu.Name, out texMapped);
|
resFile.Textures.TryGetValue(textu.Name, out texMapped);
|
||||||
texref.Texture = texMapped;
|
texref.Texture = texMapped;
|
||||||
|
|
||||||
mat.TextureRefs.Add(texref);
|
mat.TextureRefs.Add(texref);
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -76,6 +76,8 @@ namespace Switch_Toolbox.Library.IO
|
||||||
|
|
||||||
public void CompressData(CompressionType CompressionType, byte[] data)
|
public void CompressData(CompressionType CompressionType, byte[] data)
|
||||||
{
|
{
|
||||||
|
MessageBox.Show(data.Length.ToString());
|
||||||
|
|
||||||
switch (CompressionType)
|
switch (CompressionType)
|
||||||
{
|
{
|
||||||
case CompressionType.Yaz0:
|
case CompressionType.Yaz0:
|
||||||
|
|
|
@ -452,7 +452,11 @@ namespace Switch_Toolbox.Library.IO
|
||||||
var stream = new MemoryStream();
|
var stream = new MemoryStream();
|
||||||
using (var writer = new FileWriter(stream))
|
using (var writer = new FileWriter(stream))
|
||||||
{
|
{
|
||||||
|
|
||||||
writer.Write(data.Length);
|
writer.Write(data.Length);
|
||||||
|
|
||||||
|
|
||||||
|
MessageBox.Show(data.Length.ToString());
|
||||||
byte[] buffer = LZ4.Frame.LZ4Frame.Compress(new MemoryStream(data), LZ4.Frame.LZ4MaxBlockSize.Auto, true, true, false, false, true);
|
byte[] buffer = LZ4.Frame.LZ4Frame.Compress(new MemoryStream(data), LZ4.Frame.LZ4MaxBlockSize.Auto, true, true, false, false, true);
|
||||||
writer.Write(buffer, 0, buffer.Length);
|
writer.Write(buffer, 0, buffer.Length);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue