Add parameters class to textures to configure how to display the texture
This commit is contained in:
parent
c0e40462cc
commit
f599ea9b41
Binary file not shown.
@ -47,6 +47,15 @@ namespace FirstPlugin.LuigisMansion.DarkMoon
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAfterAdded()
|
||||
{
|
||||
if (!DrawablesLoaded)
|
||||
{
|
||||
ObjectEditor.AddContainer(DrawableContainer);
|
||||
DrawablesLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public List<ChunkDataEntry> chunkEntries = new List<ChunkDataEntry>();
|
||||
|
||||
public bool IsCompressed = false;
|
||||
|
@ -95,19 +95,12 @@ namespace FirstPlugin.LuigisMansion.DarkMoon
|
||||
viewport.Dock = DockStyle.Fill;
|
||||
}
|
||||
|
||||
if (!DataDictionary.DrawablesLoaded)
|
||||
{
|
||||
ObjectEditor.AddContainer(DataDictionary.DrawableContainer);
|
||||
DataDictionary.DrawablesLoaded = true;
|
||||
}
|
||||
|
||||
viewport.ReloadDrawables(DataDictionary.DrawableContainer);
|
||||
LibraryGUI.LoadEditor(viewport);
|
||||
|
||||
viewport.Text = Text;
|
||||
}
|
||||
}
|
||||
|
||||
public LM2_Model(LM2_DICT dict)
|
||||
{
|
||||
DataDictionary = dict;
|
||||
@ -254,14 +247,6 @@ namespace FirstPlugin.LuigisMansion.DarkMoon
|
||||
genericObj.TransformPosition(new Vector3(0), new Vector3(-90, 0, 0), new Vector3(1));
|
||||
}
|
||||
}
|
||||
|
||||
//Flip all the UVs
|
||||
for (int v = 0; v < genericObj.vertices.Count; v++)
|
||||
{
|
||||
genericObj.vertices[v].uv0 = new Vector2(genericObj.vertices[v].uv0.X, 1 - genericObj.vertices[v].uv0.Y);
|
||||
genericObj.vertices[v].uv1 = new Vector2(genericObj.vertices[v].uv1.X, 1 - genericObj.vertices[v].uv1.Y);
|
||||
genericObj.vertices[v].uv2 = new Vector2(genericObj.vertices[v].uv2.X, 1 - genericObj.vertices[v].uv2.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +95,9 @@ namespace FirstPlugin.LuigisMansion.DarkMoon
|
||||
|
||||
MipCount = 1;
|
||||
Format = CTR_3DS.ConvertPICAToGenericFormat((CTR_3DS.PICASurfaceFormat)FormatCtr);
|
||||
|
||||
Parameters = new ImageParameters();
|
||||
Parameters.FlipY = true;
|
||||
}
|
||||
|
||||
public override void OnClick(TreeView treeview)
|
||||
|
@ -164,6 +164,8 @@ namespace FirstPlugin.Forms
|
||||
var image = ActiveFile.FontSection.TextureGlyph.GetImageSheet(ImageIndex);
|
||||
bool IsBntx = ActiveFile.FontSection.TextureGlyph.BinaryTextureFile != null;
|
||||
|
||||
image.Parameters.FlipY = true;
|
||||
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = image.ReplaceFilter;
|
||||
ofd.Multiselect = false;
|
||||
@ -188,15 +190,12 @@ namespace FirstPlugin.Forms
|
||||
var image = ActiveFile.FontSection.TextureGlyph.GetImageSheet(ImageIndex);
|
||||
bool IsBntx = ActiveFile.FontSection.TextureGlyph.BinaryTextureFile != null;
|
||||
|
||||
var args = new STGenericTexture.ImageExportArguments()
|
||||
{
|
||||
FlipY = true,
|
||||
};
|
||||
image.Parameters.FlipY = true;
|
||||
|
||||
if (IsBntx)
|
||||
image.ExportArrayImage(ImageIndex, args);
|
||||
image.ExportArrayImage(ImageIndex);
|
||||
else
|
||||
image.ExportImage(args);
|
||||
image.ExportImage();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,6 +396,8 @@ namespace Toolbox.Library.Forms
|
||||
LoadChannelEditor(image);
|
||||
}
|
||||
|
||||
if (ActiveTexture.Parameters.FlipY)
|
||||
image.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
|
||||
if (image != null)
|
||||
{
|
||||
|
@ -59,6 +59,9 @@ namespace Toolbox.Library
|
||||
AlphaChannel = STChannelType.Alpha;
|
||||
}
|
||||
|
||||
//A class that configs how the image should output (on display, and on export/replace)
|
||||
public ImageParameters Parameters = new ImageParameters();
|
||||
|
||||
public bool IsCubemap
|
||||
{
|
||||
get
|
||||
@ -676,12 +679,7 @@ namespace Toolbox.Library
|
||||
Export(FileName);
|
||||
}
|
||||
|
||||
public class ImageExportArguments
|
||||
{
|
||||
public bool FlipY = false;
|
||||
}
|
||||
|
||||
public void ExportArrayImage(int ArrayIndex = 0, ImageExportArguments Arguments = null)
|
||||
public void ExportArrayImage(int ArrayIndex = 0)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.FileName = Text;
|
||||
@ -690,11 +688,11 @@ namespace Toolbox.Library
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Export(sfd.FileName, true, false, ArrayIndex, 0, Arguments);
|
||||
Export(sfd.FileName, true, false, ArrayIndex, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void ExportImage(ImageExportArguments Arguments = null)
|
||||
public void ExportImage()
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.FileName = Text;
|
||||
@ -703,12 +701,12 @@ namespace Toolbox.Library
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Export(sfd.FileName, false, false, 0,0,Arguments);
|
||||
Export(sfd.FileName, false, false, 0,0);
|
||||
}
|
||||
}
|
||||
|
||||
public void Export(string FileName, bool ExportSurfaceLevel = false,
|
||||
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0, ImageExportArguments Arguments = null)
|
||||
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0)
|
||||
{
|
||||
string ext = Path.GetExtension(FileName);
|
||||
ext = ext.ToLower();
|
||||
@ -716,19 +714,18 @@ namespace Toolbox.Library
|
||||
switch (ext)
|
||||
{
|
||||
case ".dds":
|
||||
SaveDDS(FileName, ExportSurfaceLevel, ExportMipMapLevel, SurfaceLevel, MipLevel, Arguments);
|
||||
SaveDDS(FileName, ExportSurfaceLevel, ExportMipMapLevel, SurfaceLevel, MipLevel);
|
||||
break;
|
||||
case ".astc":
|
||||
SaveASTC(FileName, ExportSurfaceLevel, ExportMipMapLevel, SurfaceLevel, MipLevel, Arguments);
|
||||
SaveASTC(FileName, ExportSurfaceLevel, ExportMipMapLevel, SurfaceLevel, MipLevel);
|
||||
break;
|
||||
default:
|
||||
SaveBitMap(FileName, ExportSurfaceLevel, ExportMipMapLevel, SurfaceLevel, MipLevel, Arguments);
|
||||
SaveBitMap(FileName, ExportSurfaceLevel, ExportMipMapLevel, SurfaceLevel, MipLevel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void SaveASTC(string FileName, bool ExportSurfaceLevel = false,
|
||||
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0,
|
||||
ImageExportArguments Arguments = null)
|
||||
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0)
|
||||
{
|
||||
List<Surface> surfaces = null;
|
||||
if (ExportSurfaceLevel)
|
||||
@ -747,14 +744,12 @@ namespace Toolbox.Library
|
||||
File.WriteAllBytes(FileName, atsc.Save());
|
||||
}
|
||||
public void SaveTGA(string FileName, bool ExportSurfaceLevel = false,
|
||||
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0,
|
||||
ImageExportArguments Arguments = null)
|
||||
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0)
|
||||
{
|
||||
|
||||
}
|
||||
public void SaveBitMap(string FileName, bool ExportSurfaceLevel = false,
|
||||
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0,
|
||||
ImageExportArguments Arguments = null)
|
||||
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0)
|
||||
{
|
||||
STProgressBar progressBar = new STProgressBar();
|
||||
progressBar.Task = "Exporting Image Data...";
|
||||
@ -804,7 +799,7 @@ namespace Toolbox.Library
|
||||
BitmapExtension.SetChannel(bitMap, RedChannel, GreenChannel, BlueChannel, AlphaChannel);
|
||||
}
|
||||
|
||||
if (Arguments != null && Arguments.FlipY)
|
||||
if (Parameters.FlipY)
|
||||
bitMap.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
|
||||
bitMap.Save(FileName);
|
||||
@ -814,8 +809,7 @@ namespace Toolbox.Library
|
||||
progressBar.Close();
|
||||
}
|
||||
public void SaveDDS(string FileName, bool ExportSurfaceLevel = false,
|
||||
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0,
|
||||
ImageExportArguments Arguments = null)
|
||||
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0)
|
||||
{
|
||||
List<Surface> surfaces = null;
|
||||
if (ExportSurfaceLevel)
|
13
Switch_Toolbox_Library/Generics/Texture/ImageParameters.cs
Normal file
13
Switch_Toolbox_Library/Generics/Texture/ImageParameters.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Toolbox.Library
|
||||
{
|
||||
public class ImageParameters
|
||||
{
|
||||
public bool FlipY { get; set; }
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -232,6 +232,7 @@
|
||||
<Compile Include="Forms\SceneSelector.Designer.cs">
|
||||
<DependentUpon>SceneSelector.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Generics\Texture\ImageParameters.cs" />
|
||||
<Compile Include="Interfaces\IMeshContainer.cs" />
|
||||
<Compile Include="Interfaces\ITextureContainer.cs" />
|
||||
<Compile Include="IO\Extensions\UintExtension.cs" />
|
||||
@ -586,12 +587,12 @@
|
||||
</Compile>
|
||||
<Compile Include="Generics\BoundingBox.cs" />
|
||||
<Compile Include="Generics\GenericBitmapTexture.cs" />
|
||||
<Compile Include="Generics\GenericMaterial.cs" />
|
||||
<Compile Include="Generics\GenericMatTexture.cs" />
|
||||
<Compile Include="Generics\Materials\GenericMaterial.cs" />
|
||||
<Compile Include="Generics\Materials\GenericMatTexture.cs" />
|
||||
<Compile Include="Generics\GenericModel.cs" />
|
||||
<Compile Include="Generics\GenericObject.cs" />
|
||||
<Compile Include="Generics\GenericPolygonGroup.cs" />
|
||||
<Compile Include="Generics\GenericTexture.cs" />
|
||||
<Compile Include="Generics\Texture\GenericTexture.cs" />
|
||||
<Compile Include="Generics\OpenGLTexture.cs" />
|
||||
<Compile Include="Interfaces\ICompressionFormat.cs" />
|
||||
<Compile Include="Interfaces\IDirectoryNode.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user