1
0
mirror of synced 2025-02-20 12:41:10 +01:00

Add option to clear LOD meshes

This commit is contained in:
KillzXGaming 2019-04-30 21:15:56 -04:00
parent 18d891e1a0
commit 9b1d36666b
9 changed files with 53 additions and 3 deletions

Binary file not shown.

View File

@ -111,6 +111,10 @@ namespace Bfres.Structs
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Rename", null, Rename, Keys.Control | Keys.N));
ContextMenuStrip.Items.Add(new ToolStripSeparator());
ToolStripMenuItem lodMenu = new ToolStripMenuItem("Level Of Detail");
lodMenu.DropDownItems.Add(new ToolStripMenuItem("Clear LOD Meshes", null, ClearLODMeshes));
ContextMenuStrip.Items.Add(lodMenu);
ToolStripMenuItem uvMenu = new ToolStripMenuItem("UVs");
uvMenu.DropDownItems.Add(new ToolStripMenuItem("Flip (Vertical)", null, FlipUvsVertical));
uvMenu.DropDownItems.Add(new ToolStripMenuItem("Flip (Horizontal)", null, FlipUvsHorizontal));
@ -182,6 +186,21 @@ namespace Bfres.Structs
UpdateVertexData();
Cursor.Current = Cursors.Default;
}
private void ClearLODMeshes(object sender, EventArgs args)
{
Cursor.Current = Cursors.WaitCursor;
//Clear all but first base mesh
for (int i = 0; i < lodMeshes.Count; i++)
{
if (i != 0)
lodMeshes.Remove(lodMeshes[i]);
}
SaveVertexBuffer();
UpdateVertexData();
Cursor.Current = Cursors.Default;
}
private void RecalculateNormals(object sender, EventArgs args)
{
Cursor.Current = Cursors.WaitCursor;

View File

@ -236,11 +236,11 @@ namespace Switch_Toolbox.Library.Forms
}
public void Maximize()
{
MaximumSize = Screen.FromControl(this).WorkingArea.Size;
WindowState = FormWindowState.Maximized;
if (IsMdiChild)
MDIMaximized();
MaximumSize = Screen.FromControl(this).WorkingArea.Size;
WindowState = FormWindowState.Maximized;
}
private void CheckWindowState()
{

View File

@ -81,6 +81,9 @@ namespace Switch_Toolbox.Library.IO
case CompressionType.Gzip:
data = STLibraryCompression.GZIP.Compress(data);
break;
case CompressionType.Zlib:
data = STLibraryCompression.ZLIB.Compress(data, 2);
break;
default:
MessageBox.Show($"Compression Type {CompressionType} not supported!!");
break;
@ -330,6 +333,31 @@ namespace Switch_Toolbox.Library.IO
}
}
public static byte[] Compress(byte[] b, uint Position = 0)
{
//Set position and write the first 2 bytes if necessary
MemoryStream mem = new MemoryStream();
using (var decompressedStream = new FileWriter(new MemoryStream()))
{
if (Position == 2)
{
decompressedStream.Write(0x780A);
decompressedStream.Write(b);
}
}
var output = new MemoryStream();
using (var decompressedStream = new MemoryStream(mem.ToArray()))
{
decompressedStream.Position = Position;
using (var zipStream = new DeflateStream(output, CompressionMode.Compress))
{
decompressedStream.CopyTo(zipStream);
return output.ToArray();
}
}
}
public static void CopyStream(System.IO.Stream input, System.IO.Stream output)
{
byte[] buffer = new byte[2000];

View File

@ -33,6 +33,7 @@ namespace Toolbox
form.MdiParent = this;
form.Show();
IFileFormat activeFile;
if (form is ObjectEditor)
@ -915,7 +916,9 @@ namespace Toolbox
if (this.ActiveMdiChild.Tag == null)
{
if (Runtime.MaximizeMdiWindow && ActiveMdiChild.WindowState != FormWindowState.Maximized)
{
((STForm)this.ActiveMdiChild).Maximize();
}
int tpIndex = 0;
foreach (TabPage tpCheck in tabForms.TabPages)