1
0
mirror of synced 2024-11-12 02:00:50 +01:00

More fixes.

Fix loop error for 3DW stage files when creating the string table.
Fix converting yaml so it uses the custom syntax flow/tags.
Fix AAMP version issues for v1.
Add support for loading empty byaml files so data can be added onto them.
Fix bone importing issue with assimp.
This commit is contained in:
KillzXGaming 2020-02-07 15:50:52 -05:00
parent 93aa26efcf
commit ede5c62031
13 changed files with 1114 additions and 83 deletions

View File

@ -750,9 +750,9 @@ namespace Bfres.Structs
genericBone.Position.Y,
genericBone.Position.Z);
EulerRotation = new OpenTK.Vector3(
genericBone.Rotation.X,
genericBone.Rotation.Y,
genericBone.Rotation.Z);
genericBone.EulerRotation.X,
genericBone.EulerRotation.Y,
genericBone.EulerRotation.Z);
Scale = new OpenTK.Vector3(
genericBone.Scale.X,
genericBone.Scale.Y,
@ -770,7 +770,10 @@ namespace Bfres.Structs
{
BoneU.Position = new Syroot.Maths.Vector3F(Position.X, Position.Y, Position.Z);
BoneU.Scale = new Syroot.Maths.Vector3F(Scale.X, Scale.Y, Scale.Z);
BoneU.Rotation = new Syroot.Maths.Vector4F(Rotation.X, Rotation.Y, Rotation.Z, Rotation.W);
if (RotationType == BoneRotationType.Euler)
BoneU.Rotation = new Syroot.Maths.Vector4F(EulerRotation.X, EulerRotation.Y, EulerRotation.Z, 1.0f);
else
BoneU.Rotation = new Syroot.Maths.Vector4F(Rotation.X, Rotation.Y, Rotation.Z, Rotation.W);
BoneU.Name = Text;
BoneU.Flags = FlagVisible ? ResU.BoneFlags.Visible : 0;
BoneU.ParentIndex = (short)parentIndex;
@ -783,7 +786,10 @@ namespace Bfres.Structs
{
Bone.Position = new Syroot.Maths.Vector3F(Position.X, Position.Y, Position.Z);
Bone.Scale = new Syroot.Maths.Vector3F(Scale.X, Scale.Y, Scale.Z);
Bone.Rotation = new Syroot.Maths.Vector4F(Rotation.X, Rotation.Y, Rotation.Z, Rotation.W);
if (RotationType == BoneRotationType.Euler)
Bone.Rotation = new Syroot.Maths.Vector4F(EulerRotation.X, EulerRotation.Y, EulerRotation.Z, 1.0f);
else
Bone.Rotation = new Syroot.Maths.Vector4F(Rotation.X, Rotation.Y, Rotation.Z, Rotation.W);
Bone.Name = Text;
Bone.Flags = FlagVisible ? BoneFlags.Visible : 0;
Bone.ParentIndex = (short)parentIndex;

View File

@ -32,7 +32,7 @@ namespace FirstPlugin
using (var reader = new Toolbox.Library.IO.FileReader(stream, true))
{
//File too small to have any data
if (stream.Length <= 16)
if (stream.Length <= 8)
return false;
if (reader.CheckSignature(2, "BY") || reader.CheckSignature(2, "YB"))

View File

@ -26,7 +26,7 @@ namespace FirstPlugin
public static string ToYaml(ByamlExt.Byaml.BymlFileData data)
{
var settings = new SerializerSettings()
/*var settings = new SerializerSettings()
{
EmitTags = false,
EmitAlias = false,
@ -44,7 +44,7 @@ namespace FirstPlugin
settings.RegisterTagMapping("!ll", typeof(long));
var serializer = new Serializer(settings);
return serializer.Serialize(data);
return serializer.Serialize(data);*/
NodePaths.Clear();
refNodeId = 0;

View File

@ -131,7 +131,7 @@ namespace FirstPlugin
public void Load(System.IO.Stream stream)
{
CanSave = false;
CanSave = true;
Renderer = new CMB_Renderer();
DrawableContainer.Drawables.Add(Renderer);
@ -646,8 +646,6 @@ namespace FirstPlugin
public LUTSChunk LUTSChunk;
public VertexAttributesChunk VertexAttributesChunk;
public ushort[] Indices;
public void Read(FileReader reader, Header header)
{
uint numIndices = reader.ReadUInt32();
@ -935,7 +933,7 @@ namespace FirstPlugin
VertexAttributesChunk.Write(writer, header);
}
if (Indices != null && Indices.Length > 0)
if (SkeletalMeshChunk != null && SkeletalMeshChunk.ShapeChunk.SeperateShapes.Count > 0)
{
writer.WriteUint32Offset(pos + (_offsetPos += 4));
@ -946,8 +944,6 @@ namespace FirstPlugin
{
foreach (var subprim in prim.Primatives) //Note 3DS usually only has one sub primative
{
subprim.Indices = new uint[subprim.IndexCount];
writer.SeekBegin(indexBufferPos + subprim.Offset);
switch (subprim.IndexType)
@ -970,6 +966,7 @@ namespace FirstPlugin
}
}
}
writer.Align(64);
}
if (TextureChunk != null && TextureChunk.Textures.Count > 0)
@ -978,10 +975,7 @@ namespace FirstPlugin
writer.WriteUint32Offset(pos + (_offsetPos += 4));
//Save image data
foreach (var tex in TextureChunk.Textures)
{
writer.SeekBegin(tex.DataOffset + dataStart);
writer.Write(tex.ImageData);
}
}
}
}
@ -1016,13 +1010,13 @@ namespace FirstPlugin
if (MeshChunk != null)
{
writer.WriteUint32Offset(_offsetPos);
writer.WriteUint32Offset(_offsetPos, pos);
MeshChunk.Write(writer, header);
}
if (ShapeChunk != null)
{
writer.WriteUint32Offset(_offsetPos + 4);
writer.WriteUint32Offset(_offsetPos + 4, pos);
ShapeChunk.Write(writer, header);
}
@ -1056,14 +1050,13 @@ namespace FirstPlugin
mesh.SepdIndex = reader.ReadUInt16();
mesh.MaterialIndex = reader.ReadByte();
mesh.ID = reader.ReadByte();
Meshes.Add(mesh);
if (header.Version == CMBVersion.OOT3DS)
mesh.unks = reader.ReadBytes(1);
else if (header.Version == CMBVersion.MM3DS)
mesh.unks = reader.ReadBytes(9);
if (header.Version == CMBVersion.MM3DS)
mesh.unks = reader.ReadBytes(8);
else if (header.Version >= CMBVersion.LM3DS)
mesh.unks = reader.ReadBytes(85);
mesh.unks = reader.ReadBytes(84);
Console.WriteLine($"SepdIndex {mesh.SepdIndex}");
Console.WriteLine($"MaterialIndex { mesh.MaterialIndex}");
@ -1080,9 +1073,11 @@ namespace FirstPlugin
writer.Write(Unknown);
for (int i = 0; i < Meshes.Count; i++) {
writer.Write(Meshes[i].unks);
writer.Write(Meshes[i].SepdIndex);
writer.Write(Meshes[i].MaterialIndex);
writer.Write(Meshes[i].ID);
if (Meshes[i].unks != null)
writer.Write(Meshes[i].unks);
}
long endPos = writer.Position;
@ -1097,6 +1092,7 @@ namespace FirstPlugin
public ushort SepdIndex { get; set; }
public byte MaterialIndex { get; set; }
public byte ID { get; set; }
}
}
@ -1138,7 +1134,7 @@ namespace FirstPlugin
writer.Write(new ushort[SeperateShapes.Count]);
for (int i = 0; i < SeperateShapes.Count; i++)
{
writer.WriteUint16Offset(offsetPos, pos);
writer.WriteUint16Offset(offsetPos + (i * 2), pos);
SeperateShapes[i].Write(writer, header);
}
@ -1166,6 +1162,7 @@ namespace FirstPlugin
public List<PrimativesChunk> Primatives = new List<PrimativesChunk>();
public ushort boneDimension;
public ushort Unknown;
private byte[] unks;
@ -1195,7 +1192,7 @@ namespace FirstPlugin
BoneWeights = ReadVertexAttrib(reader);
boneDimension = reader.ReadUInt16();
reader.ReadUInt16(); //padding
Unknown = reader.ReadUInt16();
ushort[] Offsets = reader.ReadUInt16s((int)count);
@ -1214,7 +1211,7 @@ namespace FirstPlugin
writer.WriteSignature(Magic);
writer.Write(uint.MaxValue); //section size
writer.Write(Primatives.Count);
writer.Write((ushort)Primatives.Count);
writer.Write(unks);
WriteVertexAttrib(writer, Position);
WriteVertexAttrib(writer, Normal);
@ -1227,7 +1224,17 @@ namespace FirstPlugin
WriteVertexAttrib(writer, TexCoord2);
WriteVertexAttrib(writer, BoneIndices);
WriteVertexAttrib(writer, BoneWeights);
WriteVertexAttrib(writer, Tangent);
writer.Write((ushort)boneDimension);
writer.Write((ushort)Unknown);
long offsetPos = writer.Position;
writer.Write(new ushort[Primatives.Count]);
writer.Write((ushort)0);
for (int i = 0; i < Primatives.Count; i++)
{
writer.WriteUint16Offset(offsetPos + (i * 2), pos);
Primatives[i].Write(writer, header);
}
long endPos = writer.Position;
using (writer.TemporarySeek(pos + 4, System.IO.SeekOrigin.Begin)) {
@ -1426,7 +1433,7 @@ namespace FirstPlugin
reader.ReadSignature(4, Magic);
uint sectionSize = reader.ReadUInt32();
data = reader.getSection((uint)reader.Position, sectionSize);
data = reader.getSection((uint)reader.Position, sectionSize - 8);
}
public void Write(FileWriter writer, Header header)
@ -1462,6 +1469,8 @@ namespace FirstPlugin
public uint MaxIndex;
private byte[] data;
public void Read(FileReader reader, Header header)
{
StartPosition = reader.Position;
@ -1481,6 +1490,8 @@ namespace FirstPlugin
Texcoord2Slice = ReadSlice(reader);
BoneIndicesSlice = ReadSlice(reader);
BoneWeightsSlice = ReadSlice(reader);
data = reader.ReadBytes((int)(sectionSize - 76));
}
public void Write(FileWriter writer, Header header)
@ -1502,6 +1513,8 @@ namespace FirstPlugin
WriteSlice(writer, BoneIndicesSlice);
WriteSlice(writer, BoneWeightsSlice);
writer.Write(data);
long endPos = writer.Position;
using (writer.TemporarySeek(pos + 4, System.IO.SeekOrigin.Begin)) {
writer.Write((uint)(endPos - pos));
@ -1560,20 +1573,27 @@ namespace FirstPlugin
public void Write(FileWriter writer, Header header)
{
long pos = writer.Position;
writer.WriteSignature(Magic);
writer.Write(uint.MaxValue);//SectionSize
writer.Write(Bones.Count);
writer.Write(Unknown);
for (int i = 0; i < Bones.Count; i++)
{
writer.Write(Bones[i].ID);
writer.Write(Bones[i].ParentIndex);
writer.Write((ushort)Bones[i].ID);
writer.Write((short)Bones[i].ParentIndex);
writer.Write(Bones[i].Scale);
writer.Write(Bones[i].Rotation);
writer.Write(Bones[i].Translation);
if (header.Version >= CMBVersion.MM3DS)
writer.Write(Bones[i].Unknown);
}
long endPos = writer.Position;
using (writer.TemporarySeek(pos + 4, System.IO.SeekOrigin.Begin)) {
writer.Write((uint)(endPos - pos));
}
}
}
@ -1613,8 +1633,7 @@ namespace FirstPlugin
writer.Write(data);
long endPos = writer.Position;
using (writer.TemporarySeek(pos + 4, System.IO.SeekOrigin.Begin))
{
using (writer.TemporarySeek(pos + 4, System.IO.SeekOrigin.Begin)) {
writer.Write((uint)(endPos - pos));
}
}
@ -1641,7 +1660,7 @@ namespace FirstPlugin
Console.WriteLine($"materialSize {materialSize.ToString("x")}");
textureCombinerSettingsTableOffs = (int)(pos + (count * materialSize));
textureCombinerSettingsTableOffs = (int)(pos + 12 + (count * materialSize));
for (int i = 0; i < count; i++)
{
@ -1659,9 +1678,34 @@ namespace FirstPlugin
writer.WriteSignature(Magic);
writer.Write(uint.MaxValue);//SectionSize
writer.Write(Materials.Count);
for (int i = 0; i < Materials.Count; i++)
Materials[i].Write(writer, header);
for (int i = 0; i < Materials.Count; i++) {
foreach (var combiner in Materials[i].TextureCombiners)
{
writer.Write(combiner.combineRGB, false);
writer.Write(combiner.combineAlpha, false);
writer.Write(combiner.scaleRGB, false);
writer.Write(combiner.scaleAlpha, false);
writer.Write(combiner.bufferInputRGB, false);
writer.Write(combiner.bufferInputAlpha, false);
writer.Write(combiner.source0RGB, false);
writer.Write(combiner.source1RGB, false);
writer.Write(combiner.source2RGB, false);
writer.Write(combiner.op0RGB, false);
writer.Write(combiner.op1RGB, false);
writer.Write(combiner.op2RGB, false);
writer.Write(combiner.source0Alpha, false);
writer.Write(combiner.source1Alpha, false);
writer.Write(combiner.source2Alpha, false);
writer.Write(combiner.op0Alpha, false);
writer.Write(combiner.op1Alpha, false);
writer.Write(combiner.op2Alpha, false);
writer.Write(combiner.constantIndex);
}
}
long endPos = writer.Position;
using (writer.TemporarySeek(pos + 4, System.IO.SeekOrigin.Begin)) {
@ -1697,11 +1741,14 @@ namespace FirstPlugin
public CullMode CullMode { get; set; }
public bool IsPolygonOffsetEnabled { get; set; }
public uint PolygonOffset { get; set; }
public ushort PolygonOffset { get; set; }
public TextureMap[] TextureMaps { get; set; }
public TextureMatrix[] TextureMaticies { get; set; }
public ushort LightSetIndex { get; set; }
public ushort FogIndex { get; set; }
public List<TextureCombiner> TextureCombiners { get; set; }
public STColor8[] ConstantColors { get; set; }
@ -2078,9 +2125,8 @@ namespace FirstPlugin
public uint fresnelSamplerScale;
}
public uint Unknown1 { get; set; }
public ushort Unknown2 { get; set; }
public ushort Unknown3 { get; set; }
public uint TotalUsedTextures { get; set; }
public uint TotalUsedTextureCoords { get; set; }
public void Read(FileReader reader, Header header, MaterialChunk materialChunkParent)
{
@ -2104,13 +2150,11 @@ namespace FirstPlugin
CullMode = reader.ReadEnum<CullMode>(true); //byte
IsPolygonOffsetEnabled = reader.ReadBoolean(); //byte
PolygonOffset = reader.ReadUInt16();
PolygonOffset = IsPolygonOffsetEnabled ? PolygonOffset / 0x10000 : 0;
Unknown1 = reader.ReadUInt32();
Unknown2 = reader.ReadUInt16();
Unknown3 = reader.ReadUInt16();
PolygonOffset = IsPolygonOffsetEnabled ? (ushort)((int)PolygonOffset / 0x10000) : (ushort)0;
TotalUsedTextures = reader.ReadUInt32();
TotalUsedTextureCoords = reader.ReadUInt32();
//Texture bind data
// reader.SeekBegin(pos + 0x10);
for (int j = 0; j < 3; j++)
{
TextureMaps[j] = new TextureMap();
@ -2128,13 +2172,19 @@ namespace FirstPlugin
TextureMaps[j].borderColorA = reader.ReadByte();
}
LightSetIndex = reader.ReadUInt16();
FogIndex = reader.ReadUInt16();
for (int j = 0; j < 3; j++)
{
TextureMaticies[j] = new TextureMatrix();
TextureMaticies[j].Flags = reader.ReadUInt32();
TextureMaticies[j].Scale = reader.ReadVec2SY();
TextureMaticies[j].Translate = reader.ReadVec2SY();
TextureMaticies[j].Rotate = reader.ReadSingle();
TextureMaticies[j].Translate = reader.ReadVec2SY();
TextureMaticies[j].MatrixMode = reader.ReadByte();
TextureMaticies[j].ReferenceCamera = reader.ReadByte();
TextureMaticies[j].MappingMethod = reader.ReadByte();
TextureMaticies[j].CoordinateIndex = reader.ReadByte();
}
long dataPos = reader.Position;
@ -2291,11 +2341,9 @@ namespace FirstPlugin
writer.Write(CullMode, true);
writer.Write(IsPolygonOffsetEnabled);
writer.Write(PolygonOffset);
writer.Write(Unknown1);
writer.Write(Unknown2);
writer.Write(Unknown3);
writer.Write(TotalUsedTextures);
writer.Write(TotalUsedTextureCoords);
writer.SeekBegin(pos + 0x10);
for (int j = 0; j < 3; j++)
{
writer.Write(TextureMaps[j].TextureIndex);
@ -2304,19 +2352,26 @@ namespace FirstPlugin
writer.Write((ushort)TextureMaps[j].MagFiler);
writer.Write((ushort)TextureMaps[j].WrapS);
writer.Write((ushort)TextureMaps[j].WrapT);
writer.Write((ushort)TextureMaps[j].LodBias);
writer.Write(TextureMaps[j].MinLOD);
writer.Write(TextureMaps[j].LodBias);
writer.Write(TextureMaps[j].borderColorR);
writer.Write(TextureMaps[j].borderColorG);
writer.Write(TextureMaps[j].borderColorB);
writer.Write(TextureMaps[j].borderColorA);
}
writer.Write(LightSetIndex);
writer.Write(FogIndex);
for (int j = 0; j < 3; j++)
{
writer.Write(TextureMaticies[j].Flags);
writer.Write(TextureMaticies[j].Scale);
writer.Write(TextureMaticies[j].Translate);
writer.Write(TextureMaticies[j].Rotate);
writer.Write(TextureMaticies[j].Translate);
writer.Write(TextureMaticies[j].MatrixMode);
writer.Write(TextureMaticies[j].ReferenceCamera);
writer.Write(TextureMaticies[j].MappingMethod);
writer.Write(TextureMaticies[j].CoordinateIndex);
}
writer.Write(data);
@ -2369,10 +2424,14 @@ namespace FirstPlugin
public class TextureMatrix
{
public uint Flags { get; set; }
public Syroot.Maths.Vector2F Scale { get; set; }
public Syroot.Maths.Vector2F Translate { get; set; }
public float Rotate { get; set; }
public byte MatrixMode { get; set; }
public byte ReferenceCamera { get; set; }
public byte MappingMethod { get; set; }
public byte CoordinateIndex { get; set; }
}
public class TextureMap

View File

@ -79,7 +79,7 @@ namespace Grezzo.CmbEnums
_4 = 0x04,
};
public enum CombineBufferInputDMP
public enum CombineBufferInputDMP : ushort
{
PREVIOUS = 0x8578,
PREVIOUS_BUFFER = 0x8579,
@ -113,7 +113,7 @@ namespace Grezzo.CmbEnums
ONE_MINUS_SRC_B = 0x8585,
};
public enum FresnelSelector
public enum FresnelSelector : ushort
{
No = 25280,
Pri = 25281,

View File

@ -170,42 +170,38 @@ namespace FirstPlugin
DataOffset = reader.ReadUInt32();
Name = reader.ReadString(16).TrimEnd('\0');
PicaFormat = ToPica(Format);
PicaFormat = FormatList[Format];
}
public void Write(FileWriter writer)
{
TextureFormat Format = TextureFormat.A8;
TextureFormat format = FormatList.FirstOrDefault(x => x.Value == PicaFormat).Key;
writer.Write(ImageSize);
writer.Write(MaxLevel);
writer.Write(Unknown);
writer.Write((ushort)Width);
writer.Write((ushort)Height);
writer.Write(Format, true);
writer.Write(DataOffset);
writer.Write(format, true);
writer.Write(DataOffset);
writer.WriteString(Name, 16);
}
private static CTR_3DS.PICASurfaceFormat ToPica(TextureFormat format)
{
switch (format)
private static Dictionary<TextureFormat, CTR_3DS.PICASurfaceFormat> FormatList =
new Dictionary<TextureFormat, CTR_3DS.PICASurfaceFormat>()
{
case TextureFormat.A8: return CTR_3DS.PICASurfaceFormat.A8;
case TextureFormat.ETC1: return CTR_3DS.PICASurfaceFormat.ETC1;
case TextureFormat.ETC1A4: return CTR_3DS.PICASurfaceFormat.ETC1A4;
case TextureFormat.L4: return CTR_3DS.PICASurfaceFormat.L4;
case TextureFormat.L8: return CTR_3DS.PICASurfaceFormat.L8;
case TextureFormat.LA8: return CTR_3DS.PICASurfaceFormat.LA8;
case TextureFormat.RGB565: return CTR_3DS.PICASurfaceFormat.RGB565;
case TextureFormat.RGBA4444: return CTR_3DS.PICASurfaceFormat.RGBA4;
case TextureFormat.RGBA5551: return CTR_3DS.PICASurfaceFormat.RGBA5551;
case TextureFormat.RGBA8: return CTR_3DS.PICASurfaceFormat.RGBA8;
case TextureFormat.RGB8: return CTR_3DS.PICASurfaceFormat.RGB8;
default:
throw new Exception($"Unsupported format! {format}");
}
}
{ TextureFormat.A8, CTR_3DS.PICASurfaceFormat.A8 },
{ TextureFormat.ETC1, CTR_3DS.PICASurfaceFormat.ETC1 },
{ TextureFormat.ETC1A4, CTR_3DS.PICASurfaceFormat.ETC1A4 },
{ TextureFormat.L4, CTR_3DS.PICASurfaceFormat.L4 },
{ TextureFormat.L8, CTR_3DS.PICASurfaceFormat.L8 },
{ TextureFormat.LA8, CTR_3DS.PICASurfaceFormat.LA8 },
{ TextureFormat.RGB565, CTR_3DS.PICASurfaceFormat.RGB565 },
{ TextureFormat.RGBA4444, CTR_3DS.PICASurfaceFormat.RGBA4 },
{ TextureFormat.RGBA5551, CTR_3DS.PICASurfaceFormat.RGBA5551 },
{ TextureFormat.RGBA8, CTR_3DS.PICASurfaceFormat.RGBA8 },
{ TextureFormat.RGB8, CTR_3DS.PICASurfaceFormat.RGB8 },
};
}
public class TextureWrapper : STGenericTexture

View File

@ -11,16 +11,987 @@ namespace LayoutBXLYT
{
public class FLYT
{
private static ColorRGBA WhiteRGBA => new ColorRGBA() { r = 255, g = 255, b = 255, a = 255 };
private static ColorRGBA BlackRGBA => new ColorRGBA() { r = 0, g = 0, b = 0, a = 0 };
public static BFLYT.Header FromXml(string text)
{
BFLYT.Header header = new BFLYT.Header();
XmlSerializer serializer = new XmlSerializer(typeof(XmlRoot));
XmlRoot flyt = (XmlRoot)serializer.Deserialize(new StringReader(text));
var layout = flyt.body.lyt;
//Do layout screen settings
header.LayoutInfo = new BFLYT.LYT1();
var layoutSize = ConvertVector2(layout.screenSetting.layoutSize);
header.LayoutInfo.Name = "";
header.LayoutInfo.Width = layoutSize.X;
header.LayoutInfo.Height = layoutSize.Y;
header.LayoutInfo.DrawFromCenter = layout.screenSetting.origin == "Normal";
//Setup root pane
header.RootPane = new BFLYT.PAN1();
header.RootPane.Width = layoutSize.X;
header.RootPane.Height = layoutSize.Y;
header.RootPane.Name = layout.paneHierarchy.paneTree[0].name;
//Go through each pane set
Dictionary<string, BFLYT.PAN1> PaneSet = new Dictionary<string, BFLYT.PAN1>();
foreach (var pane in layout.paneSet)
PaneSet.Add(pane.name, ParsePane(pane, header));
//Go through the tree
foreach (var node in layout.paneHierarchy.paneTree)
LoadTree(PaneSet, header.RootPane, node);
header.RootGroup = new BFLYT.GRP1();
return header;
}
private static void LoadTree(Dictionary<string, BFLYT.PAN1> PaneSet, BasePane parentPane, PaneTree tree)
{
foreach (var node in tree.paneTree)
{
var childPane = PaneSet[node.name];
childPane.Parent = parentPane;
parentPane.Childern.Add(childPane);
LoadTree(PaneSet, childPane, node);
}
}
private static BFLYT.PAN1 ParsePane(Pane pane, BFLYT.Header header)
{
BFLYT.PAN1 pan1 = new BFLYT.PAN1();
/* switch (pane.kind)
{
case "Picture":
pan1 = new BFLYT.PIC1(header);
ParsePicturePane(ref pan1, (PicturePane)pane.Items[0],ref header);
break;
case "TextBox":
pan1 = new BFLYT.TXT1();
break;
case "Parts":
pan1 = new BFLYT.PRT1();
break;
case "Null":
pan1 = new BFLYT.PAN1();
break;
default:
throw new Exception("Unknown pane type found! " + pane.kind);
}*/
ParsePane(ref pan1, pane);
return pan1;
}
private static void ParsePane(ref BFLYT.PAN1 pan1, Pane pane)
{
var size = ConvertVector2(pane.size);
string originX = pane.basePositionType.x;
string originY = pane.basePositionType.y;
string parentX = pane.parentRelativePositionType.x;
string parentY = pane.parentRelativePositionType.y;
pan1.Name = pane.name;
pan1.Width = size.X;
pan1.Height = size.Y;
pan1.Scale = ConvertVector2(pane.scale);
pan1.Translate = ConvertVector3(pane.translate);
pan1.Rotate = ConvertVector3(pane.rotate);
pan1.Visible = true;
if (originX == "Center")
pan1.originX = OriginX.Center;
if (originX == "Left")
pan1.originX = OriginX.Left;
if (originX == "Right")
pan1.originX = OriginX.Right;
if (originY == "Top")
pan1.originY = OriginY.Top;
if (originY == "Center")
pan1.originY = OriginY.Center;
if (originY == "Bottom")
pan1.originY = OriginY.Bottom;
if (parentX == "Center")
pan1.ParentOriginX = OriginX.Center;
if (parentX == "Left")
pan1.ParentOriginX = OriginX.Left;
if (parentX == "Right")
pan1.ParentOriginX = OriginX.Right;
if (parentY == "Top")
pan1.ParentOriginY = OriginY.Top;
if (parentY == "Center")
pan1.ParentOriginY = OriginY.Center;
if (parentY == "Bottom")
pan1.ParentOriginY = OriginY.Bottom;
}
private static void ParsePicturePane(ref BFLYT.PAN1 pan1, PicturePane pane, ref BFLYT.Header header)
{
var pic1 = (BFLYT.PIC1)pan1;
var mat = new BFLYT.Material(pan1.Name, header);
pic1.MaterialIndex = AddMaterial(ref header, mat);
}
private static ushort AddMaterial(ref BFLYT.Header header, BFLYT.Material mat)
{
if (header.MaterialList == null)
header.MaterialList = new BFLYT.MAT1();
header.MaterialList.Materials.Add(mat);
return (ushort)header.MaterialList.Materials.IndexOf(mat);
}
public static Syroot.Maths.Vector4F ConvertVector4(Vector4 value)
{
float X = 0, Y = 0, Z = 0, W = 0;
float.TryParse(value.x, out X);
float.TryParse(value.y, out Y);
float.TryParse(value.z, out Z);
float.TryParse(value.w, out W);
return new Syroot.Maths.Vector4F(X, Y, Z, W);
}
public static Syroot.Maths.Vector3F ConvertVector3(Vector3 value)
{
float X = 0, Y = 0, Z = 0;
float.TryParse(value.x, out X);
float.TryParse(value.y, out Y);
float.TryParse(value.z, out Z);
return new Syroot.Maths.Vector3F(X, Y, Z);
}
public static Syroot.Maths.Vector2F ConvertVector2(Vector2 value)
{
float X = 0, Y = 0;
float.TryParse(value.x, out X);
float.TryParse(value.y, out Y);
return new Syroot.Maths.Vector2F(X, Y);
}
public static string ToXml(BFLYT.Header header)
{
XmlRoot root = new XmlRoot();
root.head = new Head();
root.body = new Body();
root.body.lyt = new Layout();
return "";
var generator = new Generator();
root.head.generator = generator;
generator.name = "ST";
generator.version = "1.0"
;
var create = new Create();
root.head.create = create;
create.date = DateTime.Now.ToString("yyyy-MM-ddThh:mm:ss");
BinaryInfo info = new BinaryInfo();
info.layout.name = header.LayoutInfo.Name;
info.version.major = (byte)header.VersionMajor;
info.version.minor = (byte)header.VersionMinor;
info.version.micro = (byte)header.VersionMicro;
info.version.micro2 = (byte)header.VersionMicro2;
root.head.binaryInfo = info;
var layout = new Layout();
root.body.lyt = layout;
List<Pane> panes = new List<Pane>();
layout.paneSet = panes;
layout.paneHierarchy.paneTree = new List<PaneTree>();
var paneTreeRoot = new PaneTree() { name = header.RootPane.Name };
LoadPaneTree(header.RootPane, paneTreeRoot);
layout.paneHierarchy.paneTree.Add(paneTreeRoot);
var screenSettings = new ScreenSettings();
screenSettings.layoutSize.x = header.LayoutInfo.Width.ToString();
screenSettings.layoutSize.y = header.LayoutInfo.Height.ToString();
if (header.LayoutInfo.DrawFromCenter)
screenSettings.origin = "Normal";
else
screenSettings.origin = "Classic";
screenSettings.backGround.color.r = 169;
screenSettings.backGround.color.g = 169;
screenSettings.backGround.color.b = 169;
screenSettings.backGround.color.a = 255;
screenSettings.grid = new Grid();
screenSettings.grid.color.r = 128;
screenSettings.grid.color.g = 128;
screenSettings.grid.color.b = 128;
screenSettings.grid.color.a = 128;
layout.screenSetting = screenSettings;
layout.metrics.totalPaneCount = header.TotalPaneCount();
int i = 0;
foreach (var pane in header.GetPanes())
{
if (i > 0) //Skip root
{
var basePane = new Pane();
if (pane is BFLYT.PIC1)
{
basePane.kind = "Picture";
basePane.Items = new object[1];
basePane.Items[0] = new PicturePane();
}
else if (pane is BFLYT.TXT1)
basePane.kind = "TextBox";
else if (pane is BFLYT.WND1)
basePane.kind = "Window";
else if (pane is BFLYT.PRT1)
basePane.kind = "Parts";
else
basePane.kind = "Null";
basePane.name = pane.Name;
basePane.translate.x = pane.Translate.X.ToString();
basePane.translate.y = pane.Translate.Y.ToString();
basePane.translate.z = pane.Translate.Z.ToString();
basePane.rotate.x = pane.Rotate.X.ToString();
basePane.rotate.y = pane.Rotate.Y.ToString();
basePane.rotate.z = pane.Rotate.Z.ToString();
basePane.scale.x = pane.Scale.X.ToString();
basePane.scale.y = pane.Scale.Y.ToString();
basePane.size.x = pane.Width.ToString();
basePane.size.y = pane.Height.ToString();
basePane.influencedAlpha = pane.InfluenceAlpha;
basePane.basePositionType.x = $"{pane.originX.ToString()}";
basePane.basePositionType.y = $"{pane.originY.ToString()}";
basePane.parentRelativePositionType.x = $"{pane.ParentOriginX}";
basePane.parentRelativePositionType.y = $"{pane.ParentOriginY}";
panes.Add(basePane);
if (pane is BFLYT.PIC1)
{
var pictureBflytPane = pane as BFLYT.PIC1;
var pictureBasePane = basePane.Items[0] as PicturePane;
pictureBasePane.vtxColRT = ToColorRGBA(pictureBflytPane.ColorTopRight);
pictureBasePane.vtxColLT = ToColorRGBA(pictureBflytPane.ColorTopLeft);
pictureBasePane.vtxColRB = ToColorRGBA(pictureBflytPane.ColorBottomRight);
pictureBasePane.vtxColLB = ToColorRGBA(pictureBflytPane.ColorBottomLeft);
foreach (var texCoord in pictureBflytPane.TexCoords)
{
var uvs = new TexCoord();
uvs.texLT.s = texCoord.TopLeft.X;
uvs.texLT.t = texCoord.TopLeft.Y;
uvs.texRT.s = texCoord.TopRight.X;
uvs.texRT.t = texCoord.TopRight.Y;
uvs.texLB.s = texCoord.BottomLeft.X;
uvs.texLB.t = texCoord.BottomLeft.Y;
uvs.texRB.s = texCoord.BottomRight.X;
uvs.texRB.t = texCoord.BottomRight.Y;
pictureBasePane.texCoord.Add(uvs);
}
pictureBasePane.material = SetMaterialData((BFLYT.Material)pictureBflytPane.Material);
pictureBasePane.materialCtr = SetMaterialCtrData((BFLYT.Material)pictureBflytPane.Material);
}
}
i++;
}
XmlWriterSettings settings = new XmlWriterSettings
{
Encoding = Encoding.UTF8,
Indent = true,
IndentChars = " ",
};
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
XmlDocument doc = new XmlDocument();
XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0", null, null);
xmldecl.Encoding = "UTF-8";
xmldecl.Standalone = "yes";
var stringWriter = new StringWriter();
XmlSerializer serializer = new XmlSerializer(typeof(XmlRoot));
XmlWriter output = XmlWriter.Create(stringWriter, settings);
serializer.Serialize(output, root, ns);
return stringWriter.ToString();
}
private static MaterialCtr SetMaterialCtrData(BFLYT.Material material)
{
MaterialCtr mat = new MaterialCtr();
mat.name = material.Name;
mat.tevColReg = BlackRGBA;
mat.tevConstReg = new ColorRGBA[6];
mat.tevConstReg[0] = WhiteRGBA;
mat.tevConstReg[1] = WhiteRGBA;
mat.tevConstReg[2] = WhiteRGBA;
mat.tevConstReg[3] = WhiteRGBA;
mat.tevConstReg[4] = WhiteRGBA;
mat.tevConstReg[5] = WhiteRGBA;
mat.texMatrix = new List<TexMatrix>();
if (material.TextureMaps != null)
{
for (int i = 0; i < material.TextureMaps.Length; i++)
{
var texMap = new TexMap();
texMap.imageName = material.TextureMaps[i].Name;
texMap.wrap_s = material.TextureMaps[i].WrapModeU.ToString();
texMap.wrap_t = material.TextureMaps[i].WrapModeU.ToString();
mat.texMap.Add(texMap);
}
}
mat.blendMode = new BlendMode();
mat.blendMode.blendOp = "Add";
mat.blendMode.srcFactor = "SrcAlpha";
mat.blendMode.dstFactor = "InvSrcAlpha";
if (material.TextureTransforms != null)
{
for (int i = 0; i < material.TextureTransforms.Length; i++)
{
var texMatrix = new TexMatrix();
texMatrix.rotate = material.TextureTransforms[i].Rotate;
texMatrix.translate.x = material.TextureTransforms[i].Translate.X.ToString();
texMatrix.translate.y = material.TextureTransforms[i].Translate.Y.ToString();
texMatrix.scale.x = material.TextureTransforms[i].Scale.X.ToString();
texMatrix.scale.y = material.TextureTransforms[i].Scale.Y.ToString();
mat.texMatrix.Add(texMatrix);
}
}
else
mat.texMatrix.Add(new TexMatrix());
if (material.TextureTransforms != null)
{
for (int i = 0; i < material.TexCoords.Length; i++)
{
var texCoordGen = new TexCoordGen();
texCoordGen.srcParam = material.TexCoords[i].Source.ToString();
mat.texCoordGen.Add(texCoordGen);
}
}
else
mat.texCoordGen.Add(new TexCoordGen());
if (material.BlendMode != null)
{
mat.blendMode.blendOp = BlendOperations[material.BlendMode.BlendOp];
mat.blendMode.dstFactor = BlendFactors[material.BlendMode.DestFactor];
mat.blendMode.srcFactor = BlendFactors[material.BlendMode.SourceFactor];
}
if (material.AlphaCompare != null)
{
mat.alphaCompare.comp = ((CompareMode)material.AlphaCompare.CompareMode).ToString();
mat.alphaCompare.reference = material.AlphaCompare.Value;
}
mat.tevStageNum = 1;
return mat;
}
enum CompareMode
{
Never = 0,
Less = 1,
LEqual = 2,
Equal = 3,
NEqual = 4,
GEqual = 5,
Greater = 6,
Always = 7,
}
private static Dictionary<BxlytBlendMode.GX2LogicOp, string> LogicalOperations = new Dictionary<BxlytBlendMode.GX2LogicOp, string>()
{
{BxlytBlendMode.GX2LogicOp.Disable, "None" },
{BxlytBlendMode.GX2LogicOp.NoOp, "NoOp" },
{BxlytBlendMode.GX2LogicOp.Clear, "Clear" },
{BxlytBlendMode.GX2LogicOp.Set, "Set" },
{BxlytBlendMode.GX2LogicOp.Copy, "Copy" },
{BxlytBlendMode.GX2LogicOp.InvCopy, "InvCopy" },
{BxlytBlendMode.GX2LogicOp.Inv, "Inv" },
{BxlytBlendMode.GX2LogicOp.And, "And" },
{BxlytBlendMode.GX2LogicOp.Nand, "Nand" },
{BxlytBlendMode.GX2LogicOp.Or, "Or" },
{BxlytBlendMode.GX2LogicOp.Xor, "Xor" },
{BxlytBlendMode.GX2LogicOp.Equiv, "Equiv" },
{BxlytBlendMode.GX2LogicOp.RevAnd, "RevAnd" },
{BxlytBlendMode.GX2LogicOp.RevOr, "RevOr" },
{BxlytBlendMode.GX2LogicOp.InvOr, "InvOr" },
};
private static Dictionary<BxlytBlendMode.GX2BlendOp, string> BlendOperations = new Dictionary<BxlytBlendMode.GX2BlendOp, string>()
{
{BxlytBlendMode.GX2BlendOp.Disable, "None" },
{BxlytBlendMode.GX2BlendOp.Add, "Add" },
{BxlytBlendMode.GX2BlendOp.Subtract, "Subtract" },
{BxlytBlendMode.GX2BlendOp.ReverseSubtract, "ReverseSubtract" },
{BxlytBlendMode.GX2BlendOp.SelectMin, "SelectMin" },
{BxlytBlendMode.GX2BlendOp.SelectMax, "SelectMax" },
};
private static Dictionary<BxlytBlendMode.GX2BlendFactor, string> BlendFactors = new Dictionary<BxlytBlendMode.GX2BlendFactor, string>()
{
{BxlytBlendMode.GX2BlendFactor.Factor0, "V0" },
{BxlytBlendMode.GX2BlendFactor.Factor1, "V1_0" },
{BxlytBlendMode.GX2BlendFactor.DestColor, "DstClr" },
{BxlytBlendMode.GX2BlendFactor.DestInvColor, "InvDstClr" },
{BxlytBlendMode.GX2BlendFactor.SourceAlpha, "SrcAlpha" },
{BxlytBlendMode.GX2BlendFactor.SourceInvAlpha, "InvSrcAlpha" },
{BxlytBlendMode.GX2BlendFactor.DestAlpha, "DstAlpha" },
{BxlytBlendMode.GX2BlendFactor.DestInvAlpha, "InvDstAlpha" },
{BxlytBlendMode.GX2BlendFactor.SourceColor, "SrcClr" },
{BxlytBlendMode.GX2BlendFactor.SourceInvColor, "InvSrcClr" },
};
private static Material SetMaterialData(BFLYT.Material material)
{
Material mat = new Material();
mat.name = material.Name;
mat.blackColor = ToColorRGB(material.BlackColor);
mat.whiteColor = ToColorRGB(material.WhiteColor);
if (material.IndParameter != null)
{
mat.hsbAdjustment.hOffset = material.IndParameter.Rotation;
mat.hsbAdjustment.bScale = material.IndParameter.ScaleX;
mat.hsbAdjustment.sScale = material.IndParameter.ScaleY;
}
if (material.TextureMaps != null)
{
for (int i = 0; i < material.TextureMaps.Length; i++)
{
var texMap = new TexMap();
texMap.imageName = material.TextureMaps[i].Name;
texMap.wrap_s = material.TextureMaps[i].WrapModeU.ToString();
texMap.wrap_t = material.TextureMaps[i].WrapModeU.ToString();
mat.texMap.Add(texMap);
}
}
if (material.TextureTransforms != null)
{
for (int i = 0; i < material.TextureTransforms.Length; i++)
{
var texMatrix = new TexMatrix();
texMatrix.rotate = material.TextureTransforms[i].Rotate;
texMatrix.translate.x = material.TextureTransforms[i].Translate.X.ToString();
texMatrix.translate.y = material.TextureTransforms[i].Translate.Y.ToString();
texMatrix.scale.x = material.TextureTransforms[i].Scale.X.ToString();
texMatrix.scale.y = material.TextureTransforms[i].Scale.Y.ToString();
mat.texMatrix.Add(texMatrix);
}
}
else
mat.texMatrix.Add(new TexMatrix());
if (material.TextureTransforms != null)
{
for (int i = 0; i < material.TexCoords.Length; i++)
{
var texCoordGen = new TexCoordGen();
texCoordGen.srcParam = material.TexCoords[i].Source.ToString();
mat.texCoordGen.Add(texCoordGen);
}
}
else
mat.texCoordGen.Add(new TexCoordGen());
return mat;
}
private static ColorRGB ToColorRGB(Toolbox.Library.STColor8 color)
{
ColorRGB col = new ColorRGB();
col.r = color.R;
col.g = color.G;
col.b = color.B;
return col;
}
private static ColorRGBA ToColorRGBA(Toolbox.Library.STColor8 color)
{
ColorRGBA col = new ColorRGBA();
col.r = color.R;
col.g = color.G;
col.b = color.B;
col.a = color.A;
return col;
}
private static void LoadPaneTree(BasePane parentPane, PaneTree paneEntry)
{
if (parentPane.Childern != null && parentPane.Childern.Count > 0)
paneEntry.paneTree = new List<PaneTree>();
foreach (var child in parentPane.Childern)
{
var paneTreeChild = new PaneTree() { name = child.Name };
paneEntry.paneTree.Add(paneTreeChild);
LoadPaneTree(child, paneTreeChild);
}
}
[XmlRootAttribute("nw4f_layout")]
public class XmlRoot
{
[XmlAttribute]
public string version = "1.5.16";
public Head head = new Head();
public Body body = new Body();
}
public class BinaryInfo
{
public BinaryLayout layout = new BinaryLayout();
public BinaryVersion version = new BinaryVersion();
}
public class BinaryLayout
{
[XmlAttribute]
public string name = "";
}
public class BinaryVersion
{
[XmlAttribute]
public byte major;
[XmlAttribute]
public byte minor;
[XmlAttribute]
public byte micro;
[XmlAttribute]
public byte micro2;
}
public class Head
{
public Create create = new Create();
public Title title = new Title();
public Comment comment = new Comment();
public Generator generator = new Generator();
public BinaryInfo binaryInfo = new BinaryInfo();
}
public class Comment
{
}
public class Title
{
}
public class Create
{
[XmlAttribute]
public string user = "";
[XmlAttribute]
public string host = "";
[XmlAttribute]
public string date = "";
[XmlAttribute]
public string source = "";
}
public class Generator
{
[XmlAttribute]
public string name = "";
[XmlAttribute]
public string version = "";
}
public class Body
{
public Layout lyt = new Layout();
}
public class Layout
{
[XmlArrayItem("pane")]
public List<Pane> paneSet = new List<Pane>();
public PaneHiearchy paneHierarchy = new PaneHiearchy();
public Groups groupSet = new Groups();
public ScreenSettings screenSetting = new ScreenSettings();
public FontFile[] fontFile = new FontFile[0];
public TextureFile[] textureFilenew = new TextureFile[0];
public Metrics metrics = new Metrics();
public UserData userData = new UserData();
}
public class PicturePane
{
[XmlAttribute]
public bool detailSetting = true;
public ColorRGBA vtxColLT = new ColorRGBA();
public ColorRGBA vtxColRT = new ColorRGBA();
public ColorRGBA vtxColLB = new ColorRGBA();
public ColorRGBA vtxColRB = new ColorRGBA();
public List<TexCoord> texCoord = new List<TexCoord>();
public Material material = new Material();
public MaterialCtr materialCtr = new MaterialCtr();
}
public class TexCoord
{
public TexCoordST texLT = new TexCoordST();
public TexCoordST texRT = new TexCoordST();
public TexCoordST texLB = new TexCoordST();
public TexCoordST texRB = new TexCoordST();
}
public class Material
{
[XmlAttribute]
public string name = "";
public ColorRGB blackColor = new ColorRGB();
public ColorRGB whiteColor = new ColorRGB();
public HsbAdjustment hsbAdjustment = new HsbAdjustment();
public List<TexMap> texMap = new List<TexMap>();
public List<TexMatrix> texMatrix = new List<TexMatrix>();
public List<TexCoordGen> texCoordGen = new List<TexCoordGen>();
public TexStage textureStage = new TexStage();
}
public class MaterialCtr
{
[XmlAttribute]
public string name = "";
[XmlAttribute]
public int tevStageNum = 0;
[XmlAttribute]
public bool useDefaultBlendSettings = true;
[XmlAttribute]
public bool useDefaultAlphaTestSettings = true;
public ColorRGBA tevColReg = new ColorRGBA();
[XmlArrayItem("tevConstReg")]
public ColorRGBA[] tevConstReg;
public List<TexMap> texMap = new List<TexMap>();
public List<TexMatrix> texMatrix = new List<TexMatrix>();
public List<TexCoordGen> texCoordGen = new List<TexCoordGen>();
public AlphaCompare alphaCompare = new AlphaCompare();
public BlendMode blendMode = new BlendMode();
public BlendModeAlpha blendModeAlpha = new BlendModeAlpha();
}
public class AlphaCompare
{
[XmlAttribute]
public string comp = "Always";
[XmlAttribute("ref")]
public float reference = 0;
}
public class BlendMode
{
[XmlAttribute]
public string type = "Blend";
[XmlAttribute]
public string srcFactor = "SrcAlpha";
[XmlAttribute]
public string dstFactor = "InvSrcAlpha";
[XmlAttribute]
public string blendOp = "Add";
}
public class BlendModeAlpha
{
[XmlAttribute]
public string type = "None";
}
public class HsbAdjustment
{
[XmlAttribute]
public float hOffset = 0;
[XmlAttribute]
public float sScale = 1;
[XmlAttribute]
public float bScale = 1;
}
public class TexMap
{
[XmlAttribute]
public string imageName = "";
[XmlAttribute]
public string wrap_s = "Clamp";
[XmlAttribute]
public string wrap_t = "Clamp";
}
public class TexCoordGen
{
[XmlAttribute]
public string srcParam = "Tex0";
public Vector2 projectionScale = new Vector2() { x = "1", y = "1" };
public Vector2 projectionTrans = new Vector2() { x = "0", y = "0" };
}
public class TexStage
{
[XmlAttribute]
public string texMap = "0";
}
public class TexMatrix
{
[XmlAttribute]
public float rotate = 0;
public Vector2 scale = new Vector2();
public Vector2 translate = new Vector2();
}
public class TextureFile
{
[XmlAttribute]
public string imagePath = "";
[XmlAttribute]
public string format = "";
}
public class FontFile
{
[XmlAttribute]
public string path = "";
[XmlAttribute]
public string name = "";
}
public class Pane
{
[XmlAttribute]
public string kind = "";
[XmlAttribute]
public string name = "";
[XmlAttribute]
public bool influencedAlpha;
public Comment comment = new Comment();
public Vector2 basePositionType = new Vector2();
public Vector2 parentRelativePositionType = new Vector2();
public Vector3 translate = new Vector3();
public Vector3 rotate = new Vector3();
public Vector2 scale = new Vector2();
public Vector2 size = new Vector2();
private object[] items;
[XmlElement("picture", typeof(PicturePane))]
public object[] Items
{
get { return items; }
set { items = value; }
}
public UserDataPane userData = new UserDataPane();
}
public class UserDataPane
{
[XmlElement("string")]
public XmlString UserString = new XmlString();
}
public class XmlString
{
[XmlAttribute]
public string name = "";
}
public class TextboxPane : Pane
{
}
public class PaneHiearchy
{
public List<PaneTree> paneTree = new List<PaneTree>();
}
public class PaneTree
{
[XmlAttribute]
public string name = "";
[XmlArrayItem("paneTree")]
public List<PaneTree> paneTree;
}
public class Groups
{
}
public class ScreenSettings
{
[XmlAttribute]
public string origin = "Normal";
public Vector2 layoutSize = new Vector2();
public Background backGround = new Background();
public Grid grid = new Grid();
}
public class Background
{
public ColorRGBA color = new ColorRGBA();
}
public class Grid
{
[XmlAttribute]
public float thickLineInterval = 40;
[XmlAttribute]
public float thinDivisionNum = 4;
[XmlAttribute]
public bool visible = true;
[XmlAttribute]
public string moveMethod = "None";
public ColorRGBA color = new ColorRGBA();
}
public class Metrics
{
public int totalPaneCount = 0;
public int totalPixelCount = 0;
}
public class UserData
{
}
public class TexCoordST
{
[XmlAttribute]
public float s = 0;
[XmlAttribute]
public float t = 0;
}
public class Vector2
{
[XmlAttribute]
public string x = "";
[XmlAttribute]
public string y = "";
}
public class Vector3
{
[XmlAttribute]
public string x = "";
[XmlAttribute]
public string y = "";
[XmlAttribute]
public string z = "";
}
public class Vector4
{
[XmlAttribute]
public string x = "";
[XmlAttribute]
public string y = "";
[XmlAttribute]
public string z = "";
[XmlAttribute]
public string w = "";
}
public class ColorRGB
{
[XmlAttribute]
public int r = 0;
[XmlAttribute]
public int g = 0;
[XmlAttribute]
public int b = 0;
}
public class ColorRGBA
{
[XmlAttribute]
public int r = 0;
[XmlAttribute]
public int g = 0;
[XmlAttribute]
public int b = 0;
[XmlAttribute]
public int a = 0;
}
}
}

View File

@ -595,9 +595,7 @@ namespace Toolbox.Library
STConsole.WriteLine($"position {position}");
STConsole.WriteLine($"-".Repeat(30));
var rotEular = STMath.ToEulerAngles(rotation);
bone.Transform = transformMat;
bone.FromTransform(transformMat);
}
else
{

View File

@ -113,7 +113,8 @@ namespace Toolbox.Library
{
Scale = transform.ExtractScale();
Position = transform.ExtractTranslation();
Rotation = transform.ExtractRotation();
rotation = transform.ExtractRotation();
eulerRotation = STMath.ToEulerAngles(rotation);
}
//Used for shifting models with the bones in the shader

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.