KCL library fixes

This commit is contained in:
KillzXGaming 2019-08-08 18:04:15 -04:00
parent 855037d21c
commit 9df93a02af
7 changed files with 31 additions and 5 deletions

View file

@ -13,6 +13,7 @@ using Toolbox.Library.IO;
using Toolbox.Library.Forms;
using GL_EditorFramework.EditorDrawables;
using FirstPlugin.Forms;
using static GL_EditorFramework.EditorDrawables.EditorSceneBase;
namespace FirstPlugin
{
@ -313,7 +314,7 @@ namespace FirstPlugin
}
}
public KCLRendering Renderer = null ;
public KCLRendering Renderer;
bool DrawablesLoaded = false;
public override void OnClick(TreeView treeView)
{

View file

@ -113,14 +113,16 @@ namespace FirstPlugin
TEX_FORMAT.RGB565,
TEX_FORMAT.RGB5A3,
TEX_FORMAT.RGBA32,
TEX_FORMAT.C4,
TEX_FORMAT.C8,
TEX_FORMAT.C14X2,
TEX_FORMAT.CMPR,
};
}
}
public Decode_Gamecube.TextureFormats DolphinTextureFormat
{
get { return Decode_Gamecube.FromGenericFormat(Format); }
}
public override bool CanEdit { get; set; } = false;
@ -135,7 +137,7 @@ namespace FirstPlugin
//Gets decoded automatically
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
{
return ImageData;
return Decode_Gamecube.GetMipLevel(ImageData, Width, Height, MipCount, (uint)MipLevel, DolphinTextureFormat);
}

View file

@ -188,6 +188,29 @@ namespace Toolbox.Library
}
#endregion
#region MethodsHelpers
public static byte[] GetMipLevel(byte[] ImageData, uint Width, uint Height, uint MipCount, uint MipLevel, TextureFormats format)
{
uint offset = 0;
for (int m = 0; m < MipCount; m++)
{
uint width = (uint)Math.Max(1, Width >> m);
uint height = (uint)Math.Max(1, Height >> m);
uint size = (uint)Decode_Gamecube.GetDataSize(format, (int)width, (int)height);
if (MipLevel == m)
return Utils.SubArray(ImageData, offset, size);
offset += size;
}
return ImageData;
}
#endregion
#region Decoding
private static readonly int[] Bpp = { 4, 8, 8, 16, 16, 16, 32, 0, 4, 8, 16, 0, 0, 0, 4 };

Binary file not shown.

Binary file not shown.