1
0
mirror of synced 2024-11-27 17:00:50 +01:00

Make batch exporting for all supported wii u texture types

This commit is contained in:
KillzXGaming 2019-07-05 16:55:50 -04:00
parent e124d446e8
commit eab5c3ee55
13 changed files with 72 additions and 12 deletions

Binary file not shown.

View File

@ -43,6 +43,7 @@ namespace FirstPlugin
FFNT bffnt;
public BNTX BinaryTextureFile;
public List<Gx2ImageBlock> Gx2Textures = new List<Gx2ImageBlock>();
public void Load(System.IO.Stream stream)
{
@ -71,6 +72,7 @@ namespace FirstPlugin
surface.Text = $"Sheet_{s}";
surface.Load(tglp, s);
textureFolder.Nodes.Add(surface);
Gx2Textures.Add(surface);
}
}
}

View File

@ -321,6 +321,7 @@ namespace FirstPlugin
vert.pos = reader.ReadVec3();
vert.nrm = reader.ReadVec3();
vert.uv0 = reader.ReadVec2();
Vertices.Add(vert);
Unknowns.Add(Unknown);
}
@ -345,7 +346,7 @@ namespace FirstPlugin
{
writer.Write(Unknowns[v]);
writer.Write(Vertices[v].pos);
writer.Write(Vertices[v].nrm);
writer.Write(-Vertices[v].nrm);
writer.Write(Vertices[v].uv0);
}
else

View File

@ -168,7 +168,7 @@ namespace FirstPlugin
public MenuExt()
{
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);
}
private void Export(object sender, EventArgs args)
@ -194,7 +194,7 @@ namespace FirstPlugin
OpenFileDialog ofd = new OpenFileDialog();
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)
{
@ -203,7 +203,7 @@ namespace FirstPlugin
{
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)
continue;
@ -234,13 +234,37 @@ namespace FirstPlugin
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)
continue;
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)
{
((BFLIM)FileFormat).Export(Path.Combine(Folder, $"{FileFormat.FileName}{Extension}"));

View File

@ -111,7 +111,7 @@ namespace FirstPlugin
OpenFileDialog ofd = new OpenFileDialog();
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)
{

View File

@ -4,11 +4,19 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Switch_Toolbox.Library.Rendering;
using GL_EditorFramework.GL_Core;
using GL_EditorFramework.Interfaces;
using OpenTK;
using OpenTK.Graphics.OpenGL;
namespace FirstPlugin
{
public class GMX_Renderer : GenericModelRenderer
{
public override void OnRender(GLControl control)
{
GL.Enable(EnableCap.CullFace);
GL.CullFace(CullFaceMode.Front);
}
}
}

View File

@ -44,7 +44,14 @@ namespace Switch_Toolbox.Library
reader.Position = reader.BaseStream.Length - 18;
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;
}
}

View File

@ -375,6 +375,15 @@ namespace Paloma
Dispose(false);
}
public bool IsSupportedTGA(Stream ImageStream)
{
using (BinaryReader binReader = new BinaryReader(ImageStream, Encoding.Default, true))
{
this.LoadTGAFooterInfo(binReader);
return this.LoadTGAHeaderInfo(binReader);
}
}
/// <summary>
/// Creates a new instance of the TargaImage object with strFileName as the image loaded.
/// </summary>
@ -527,7 +536,7 @@ namespace Paloma
/// Loads the Targa Header information from the file.
/// </summary>
/// <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)
@ -563,7 +572,8 @@ namespace Paloma
default:
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();
throw new Exception(@"Error loading file, could not read file from disk.");
}
return true;
}

View File

@ -61,8 +61,6 @@ namespace Switch_Toolbox.Library.IO
{
CheckCompression(FileName, data);
MessageBox.Show((data != null).ToString());
Stream stream;
if (data != null)
stream = new MemoryStream(data);

View File

@ -153,6 +153,8 @@ namespace Switch_Toolbox.Library.Rendering
control.CurrentShader = shader;
control.UpdateModelMatrix(Matrix4.CreateScale(Runtime.previewScale) * ModelTransform);
OnRender(control);
Matrix4 camMat = control.ModelMatrix * control.CameraMatrix * control.ProjectionMatrix;
Matrix4 invertedCamera = Matrix4.Identity;
@ -175,6 +177,12 @@ namespace Switch_Toolbox.Library.Rendering
GL.Disable(EnableCap.DepthTest);
GL.Enable(EnableCap.DepthTest);
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)