Fix bone export/importing on wii u
This commit is contained in:
parent
c000dca5e2
commit
46f069adb8
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -415,7 +415,10 @@ namespace Bfres.Structs
|
|||||||
|
|
||||||
if (sfd.ShowDialog() == DialogResult.OK)
|
if (sfd.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
Bone.Export(sfd.FileName, GetResFile());
|
if (BoneU != null)
|
||||||
|
BoneU.Export(sfd.FileName, GetResFileU());
|
||||||
|
else
|
||||||
|
Bone.Export(sfd.FileName, GetResFile());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Replace()
|
public void Replace()
|
||||||
@ -425,8 +428,16 @@ namespace Bfres.Structs
|
|||||||
|
|
||||||
if (ofd.ShowDialog() == DialogResult.OK)
|
if (ofd.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
Bone.Import(ofd.FileName);
|
if (BoneU != null)
|
||||||
Bone.Name = Text;
|
{
|
||||||
|
BoneU.Import(ofd.FileName, GetResFileU());
|
||||||
|
BoneU.Name = Text;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Bone.Import(ofd.FileName);
|
||||||
|
Bone.Name = Text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -722,12 +722,19 @@ namespace FirstPlugin
|
|||||||
surf.pitch = 0;
|
surf.pitch = 0;
|
||||||
surf.data = data;
|
surf.data = data;
|
||||||
surf.numMips = MipCount;
|
surf.numMips = MipCount;
|
||||||
surf.mipOffset = new uint[0];
|
surf.mipOffset = new uint[MipCount];
|
||||||
surf.mipData = null;
|
surf.mipData = null;
|
||||||
surf.tileMode = TileMode;
|
surf.tileMode = TileMode;
|
||||||
surf.swizzle = Swizzle;
|
surf.swizzle = Swizzle;
|
||||||
surf.imageSize = ImageSize;
|
surf.imageSize = ImageSize;
|
||||||
|
|
||||||
|
// GX2.GenerateMipSurfaceData(surf);
|
||||||
|
|
||||||
|
foreach (var mipoffset in surf.mipOffset)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"mipoffset {mipoffset}");
|
||||||
|
}
|
||||||
|
|
||||||
var surfaces = GX2.Decode(surf);
|
var surfaces = GX2.Decode(surf);
|
||||||
return surfaces[ArrayLevel][MipLevel];
|
return surfaces[ArrayLevel][MipLevel];
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -429,6 +429,57 @@ namespace Switch_Toolbox.Library
|
|||||||
Console.WriteLine($"tileType {surf.tileType}");
|
Console.WriteLine($"tileType {surf.tileType}");
|
||||||
Console.WriteLine($"tileIndex {surf.tileIndex}");
|
Console.WriteLine($"tileIndex {surf.tileIndex}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void GenerateMipSurfaceData(GX2Surface surface)
|
||||||
|
{
|
||||||
|
var surfOut = getSurfaceInfo((GX2SurfaceFormat)surface.format, surface.width, surface.height, 1, 1, surface.tileMode, 0, 0);
|
||||||
|
|
||||||
|
uint blkWidth, blkHeight;
|
||||||
|
if (GX2.IsFormatBCN((GX2SurfaceFormat)surface.format))
|
||||||
|
{
|
||||||
|
blkWidth = 4;
|
||||||
|
blkHeight = 4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
blkWidth = 1;
|
||||||
|
blkHeight = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint bpp = GX2.surfaceGetBitsPerPixel((uint)surface.format) >> 3;
|
||||||
|
|
||||||
|
surface.mipOffset = new uint[surface.numMips];
|
||||||
|
uint imageSize = (uint)surfOut.surfSize;
|
||||||
|
uint alignment = surfOut.baseAlign;
|
||||||
|
uint mipSize = 0;
|
||||||
|
|
||||||
|
for (int mipLevel = 0; mipLevel < surface.numMips; mipLevel++)
|
||||||
|
{
|
||||||
|
var result = TextureHelper.GetCurrentMipSize(surface.width, surface.height, blkWidth, blkHeight, bpp, mipLevel);
|
||||||
|
|
||||||
|
uint offset = result.Item1;
|
||||||
|
uint size = result.Item2;
|
||||||
|
|
||||||
|
byte[] data_ = new byte[size];
|
||||||
|
|
||||||
|
if (mipLevel != 0)
|
||||||
|
{
|
||||||
|
surfOut = GX2.getSurfaceInfo((GX2SurfaceFormat)surface.format, surface.width, surface.height, 1, 1, surface.tileMode, 0, mipLevel);
|
||||||
|
|
||||||
|
if (mipLevel == 1)
|
||||||
|
surface.mipOffset[mipLevel] = imageSize;
|
||||||
|
else
|
||||||
|
surface.mipOffset[mipLevel] = mipSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
data_ = Utils.CombineByteArray(data_, new byte[surfOut.surfSize - size]);
|
||||||
|
byte[] dataAlignBytes = new byte[RoundUp(mipSize, surfOut.baseAlign) - mipSize];
|
||||||
|
|
||||||
|
if (mipLevel != 0)
|
||||||
|
mipSize += (uint)(surfOut.surfSize + dataAlignBytes.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool DebugSurface = false;
|
static bool DebugSurface = false;
|
||||||
|
|
||||||
public static GX2Surface CreateGx2Texture(byte[] imageData, string Name, uint TileMode, uint AAMode,
|
public static GX2Surface CreateGx2Texture(byte[] imageData, string Name, uint TileMode, uint AAMode,
|
||||||
@ -685,7 +736,10 @@ namespace Switch_Toolbox.Library
|
|||||||
surfInfo = getSurfaceInfo((GX2SurfaceFormat)tex.format, tex.width, tex.height, tex.depth, (uint)tex.dim, (uint)tex.tileMode, (uint)tex.aa, mipLevel);
|
surfInfo = getSurfaceInfo((GX2SurfaceFormat)tex.format, tex.width, tex.height, tex.depth, (uint)tex.dim, (uint)tex.tileMode, (uint)tex.aa, mipLevel);
|
||||||
data = new byte[surfInfo.surfSize];
|
data = new byte[surfInfo.surfSize];
|
||||||
|
|
||||||
Array.Copy(tex.mipData, (uint)mipOffset, data, 0, surfInfo.surfSize);
|
if (tex.data == tex.mipData)
|
||||||
|
Array.Copy(tex.mipData, (uint)mipOffset, data, 0, surfInfo.surfSize);
|
||||||
|
else
|
||||||
|
Array.Copy(tex.mipData, (uint)mipOffset, data, 0, surfInfo.surfSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Array.Copy(tex.data, (uint)dataOffset, data, 0, size);
|
Array.Copy(tex.data, (uint)dataOffset, data, 0, size);
|
||||||
|
Loading…
Reference in New Issue
Block a user