mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 12:33:12 +00:00
Make batch exporting for all supported wii u texture types
This commit is contained in:
parent
e124d446e8
commit
eab5c3ee55
13 changed files with 72 additions and 12 deletions
Binary file not shown.
Binary file not shown.
|
@ -43,6 +43,7 @@ namespace FirstPlugin
|
||||||
|
|
||||||
FFNT bffnt;
|
FFNT bffnt;
|
||||||
public BNTX BinaryTextureFile;
|
public BNTX BinaryTextureFile;
|
||||||
|
public List<Gx2ImageBlock> Gx2Textures = new List<Gx2ImageBlock>();
|
||||||
|
|
||||||
public void Load(System.IO.Stream stream)
|
public void Load(System.IO.Stream stream)
|
||||||
{
|
{
|
||||||
|
@ -71,6 +72,7 @@ namespace FirstPlugin
|
||||||
surface.Text = $"Sheet_{s}";
|
surface.Text = $"Sheet_{s}";
|
||||||
surface.Load(tglp, s);
|
surface.Load(tglp, s);
|
||||||
textureFolder.Nodes.Add(surface);
|
textureFolder.Nodes.Add(surface);
|
||||||
|
Gx2Textures.Add(surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,6 +321,7 @@ namespace FirstPlugin
|
||||||
vert.pos = reader.ReadVec3();
|
vert.pos = reader.ReadVec3();
|
||||||
vert.nrm = reader.ReadVec3();
|
vert.nrm = reader.ReadVec3();
|
||||||
vert.uv0 = reader.ReadVec2();
|
vert.uv0 = reader.ReadVec2();
|
||||||
|
|
||||||
Vertices.Add(vert);
|
Vertices.Add(vert);
|
||||||
Unknowns.Add(Unknown);
|
Unknowns.Add(Unknown);
|
||||||
}
|
}
|
||||||
|
@ -345,7 +346,7 @@ namespace FirstPlugin
|
||||||
{
|
{
|
||||||
writer.Write(Unknowns[v]);
|
writer.Write(Unknowns[v]);
|
||||||
writer.Write(Vertices[v].pos);
|
writer.Write(Vertices[v].pos);
|
||||||
writer.Write(Vertices[v].nrm);
|
writer.Write(-Vertices[v].nrm);
|
||||||
writer.Write(Vertices[v].uv0);
|
writer.Write(Vertices[v].uv0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -168,7 +168,7 @@ namespace FirstPlugin
|
||||||
public MenuExt()
|
public MenuExt()
|
||||||
{
|
{
|
||||||
toolExt[0] = new STToolStripItem("Textures");
|
toolExt[0] = new STToolStripItem("Textures");
|
||||||
toolExt[0].DropDownItems.Add(new STToolStripItem("Batch Export (BFLIM)", Export));
|
toolExt[0].DropDownItems.Add(new STToolStripItem("Batch Export (Wii U Textures)", Export));
|
||||||
newFileExt[0] = new STToolStripItem("BFLIM From Image", CreateNew);
|
newFileExt[0] = new STToolStripItem("BFLIM From Image", CreateNew);
|
||||||
}
|
}
|
||||||
private void Export(object sender, EventArgs args)
|
private void Export(object sender, EventArgs args)
|
||||||
|
@ -194,7 +194,7 @@ namespace FirstPlugin
|
||||||
|
|
||||||
OpenFileDialog ofd = new OpenFileDialog();
|
OpenFileDialog ofd = new OpenFileDialog();
|
||||||
ofd.Multiselect = true;
|
ofd.Multiselect = true;
|
||||||
ofd.Filter = Utils.GetAllFilters(new Type[] { typeof(BFLIM), typeof(SARC) });
|
ofd.Filter = Utils.GetAllFilters(new Type[] { typeof(BFLIM), typeof(BFFNT), typeof(BFRES), typeof(PTCL), typeof(SARC) });
|
||||||
|
|
||||||
if (ofd.ShowDialog() == DialogResult.OK)
|
if (ofd.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
|
@ -203,7 +203,7 @@ namespace FirstPlugin
|
||||||
{
|
{
|
||||||
foreach (string file in ofd.FileNames)
|
foreach (string file in ofd.FileNames)
|
||||||
{
|
{
|
||||||
var FileFormat = STFileLoader.OpenFileFormat(file, new Type[] { typeof(BFLIM), typeof(SARC) });
|
var FileFormat = STFileLoader.OpenFileFormat(file, new Type[] { typeof(BFLIM), typeof(PTCL), typeof(BFFNT), typeof(SARC) });
|
||||||
if (FileFormat == null)
|
if (FileFormat == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -234,13 +234,37 @@ namespace FirstPlugin
|
||||||
|
|
||||||
foreach (var file in ((SARC)FileFormat).Files)
|
foreach (var file in ((SARC)FileFormat).Files)
|
||||||
{
|
{
|
||||||
var archiveFile = STFileLoader.OpenFileFormat(file.FileName, new Type[] { typeof(BFLIM) , typeof(SARC) }, file.FileData);
|
var archiveFile = STFileLoader.OpenFileFormat(file.FileName, new Type[] { typeof(BFLIM), typeof(BFFNT), typeof(PTCL), typeof(SARC) }, file.FileData);
|
||||||
if (archiveFile == null)
|
if (archiveFile == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SearchBinary(archiveFile, ArchiveFilePath, Extension);
|
SearchBinary(archiveFile, ArchiveFilePath, Extension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (FileFormat is BFFNT)
|
||||||
|
{
|
||||||
|
foreach (STGenericTexture texture in ((BFFNT)FileFormat).Gx2Textures)
|
||||||
|
texture.Export(Path.Combine(Folder, $"{texture.Text}{Extension}"));
|
||||||
|
}
|
||||||
|
if (FileFormat is BFRES)
|
||||||
|
{
|
||||||
|
var FtexContainer = ((BFRES)FileFormat).GetFTEXContainer;
|
||||||
|
if (FtexContainer != null)
|
||||||
|
{
|
||||||
|
foreach (var texture in FtexContainer.ResourceNodes.Values)
|
||||||
|
((FTEX)texture).Export(Path.Combine(Folder, $"{texture.Text}{Extension}"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FileFormat is PTCL)
|
||||||
|
{
|
||||||
|
if (((PTCL)FileFormat).headerU != null)
|
||||||
|
{
|
||||||
|
foreach (STGenericTexture texture in ((PTCL)FileFormat).headerU.Textures)
|
||||||
|
texture.Export(Path.Combine(Folder, $"{texture.Text}{Extension}"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (FileFormat is BFLIM)
|
if (FileFormat is BFLIM)
|
||||||
{
|
{
|
||||||
((BFLIM)FileFormat).Export(Path.Combine(Folder, $"{FileFormat.FileName}{Extension}"));
|
((BFLIM)FileFormat).Export(Path.Combine(Folder, $"{FileFormat.FileName}{Extension}"));
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace FirstPlugin
|
||||||
|
|
||||||
OpenFileDialog ofd = new OpenFileDialog();
|
OpenFileDialog ofd = new OpenFileDialog();
|
||||||
ofd.Multiselect = true;
|
ofd.Multiselect = true;
|
||||||
ofd.Filter = Utils.GetAllFilters(new Type[] { typeof(BNTX), typeof(BFRES), typeof(PTCL), typeof(SARC) });
|
ofd.Filter = Utils.GetAllFilters(new Type[] { typeof(BNTX), typeof(BFFNT), typeof(BFRES), typeof(PTCL), typeof(SARC) });
|
||||||
|
|
||||||
if (ofd.ShowDialog() == DialogResult.OK)
|
if (ofd.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,11 +4,19 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Switch_Toolbox.Library.Rendering;
|
using Switch_Toolbox.Library.Rendering;
|
||||||
|
using GL_EditorFramework.GL_Core;
|
||||||
|
using GL_EditorFramework.Interfaces;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics.OpenGL;
|
||||||
|
|
||||||
namespace FirstPlugin
|
namespace FirstPlugin
|
||||||
{
|
{
|
||||||
public class GMX_Renderer : GenericModelRenderer
|
public class GMX_Renderer : GenericModelRenderer
|
||||||
{
|
{
|
||||||
|
public override void OnRender(GLControl control)
|
||||||
|
{
|
||||||
|
GL.Enable(EnableCap.CullFace);
|
||||||
|
GL.CullFace(CullFaceMode.Front);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -44,7 +44,14 @@ namespace Switch_Toolbox.Library
|
||||||
|
|
||||||
reader.Position = reader.BaseStream.Length - 18;
|
reader.Position = reader.BaseStream.Length - 18;
|
||||||
bool IsValidMagic = reader.ReadString(10) == MagicFileConstant;
|
bool IsValidMagic = reader.ReadString(10) == MagicFileConstant;
|
||||||
return IsValidMagic || Utils.GetExtension(FileName) == ".tga";
|
bool IsTga = IsValidMagic || Utils.GetExtension(FileName) == ".tga";
|
||||||
|
if(IsTga)
|
||||||
|
{
|
||||||
|
TargaImage tga = new TargaImage();
|
||||||
|
IsTga = tga.IsSupportedTGA(stream);
|
||||||
|
stream.Position = 0;
|
||||||
|
}
|
||||||
|
return IsTga;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -375,6 +375,15 @@ namespace Paloma
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsSupportedTGA(Stream ImageStream)
|
||||||
|
{
|
||||||
|
using (BinaryReader binReader = new BinaryReader(ImageStream, Encoding.Default, true))
|
||||||
|
{
|
||||||
|
this.LoadTGAFooterInfo(binReader);
|
||||||
|
return this.LoadTGAHeaderInfo(binReader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the TargaImage object with strFileName as the image loaded.
|
/// Creates a new instance of the TargaImage object with strFileName as the image loaded.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -527,7 +536,7 @@ namespace Paloma
|
||||||
/// Loads the Targa Header information from the file.
|
/// Loads the Targa Header information from the file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="binReader">A BinaryReader that points the loaded file byte stream.</param>
|
/// <param name="binReader">A BinaryReader that points the loaded file byte stream.</param>
|
||||||
private void LoadTGAHeaderInfo(BinaryReader binReader)
|
private bool LoadTGAHeaderInfo(BinaryReader binReader)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (binReader != null && binReader.BaseStream != null && binReader.BaseStream.Length > 0 && binReader.BaseStream.CanSeek == true)
|
if (binReader != null && binReader.BaseStream != null && binReader.BaseStream.Length > 0 && binReader.BaseStream.CanSeek == true)
|
||||||
|
@ -563,7 +572,8 @@ namespace Paloma
|
||||||
|
|
||||||
default:
|
default:
|
||||||
this.ClearAll();
|
this.ClearAll();
|
||||||
throw new Exception("Targa Image only supports 8, 16, 24, or 32 bit pixel depths.");
|
return false;
|
||||||
|
// throw new Exception("Targa Image only supports 8, 16, 24, or 32 bit pixel depths.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -676,6 +686,8 @@ namespace Paloma
|
||||||
this.ClearAll();
|
this.ClearAll();
|
||||||
throw new Exception(@"Error loading file, could not read file from disk.");
|
throw new Exception(@"Error loading file, could not read file from disk.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,6 @@ namespace Switch_Toolbox.Library.IO
|
||||||
{
|
{
|
||||||
CheckCompression(FileName, data);
|
CheckCompression(FileName, data);
|
||||||
|
|
||||||
MessageBox.Show((data != null).ToString());
|
|
||||||
|
|
||||||
Stream stream;
|
Stream stream;
|
||||||
if (data != null)
|
if (data != null)
|
||||||
stream = new MemoryStream(data);
|
stream = new MemoryStream(data);
|
||||||
|
|
|
@ -153,6 +153,8 @@ namespace Switch_Toolbox.Library.Rendering
|
||||||
control.CurrentShader = shader;
|
control.CurrentShader = shader;
|
||||||
control.UpdateModelMatrix(Matrix4.CreateScale(Runtime.previewScale) * ModelTransform);
|
control.UpdateModelMatrix(Matrix4.CreateScale(Runtime.previewScale) * ModelTransform);
|
||||||
|
|
||||||
|
OnRender(control);
|
||||||
|
|
||||||
Matrix4 camMat = control.ModelMatrix * control.CameraMatrix * control.ProjectionMatrix;
|
Matrix4 camMat = control.ModelMatrix * control.CameraMatrix * control.ProjectionMatrix;
|
||||||
|
|
||||||
Matrix4 invertedCamera = Matrix4.Identity;
|
Matrix4 invertedCamera = Matrix4.Identity;
|
||||||
|
@ -175,6 +177,12 @@ namespace Switch_Toolbox.Library.Rendering
|
||||||
GL.Disable(EnableCap.DepthTest);
|
GL.Disable(EnableCap.DepthTest);
|
||||||
GL.Enable(EnableCap.DepthTest);
|
GL.Enable(EnableCap.DepthTest);
|
||||||
GL.Enable(EnableCap.CullFace);
|
GL.Enable(EnableCap.CullFace);
|
||||||
|
GL.CullFace(CullFaceMode.Back);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnRender(GLControl control)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetBoneUniforms(GLControl control, ShaderProgram shader, STSkeleton Skeleton, STGenericObject mesh)
|
private static void SetBoneUniforms(GLControl control, ShaderProgram shader, STSkeleton Skeleton, STGenericObject mesh)
|
||||||
|
|
Loading…
Reference in a new issue