Some mkagpdx model progress
This commit is contained in:
parent
15154d75b1
commit
a076fc6f92
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -11,7 +11,7 @@ using OpenTK;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
public class MKAGPDX_Model : IFileFormat
|
||||
public class MKAGPDX_Model : TreeNodeFile, IFileFormat
|
||||
{
|
||||
public FileType FileType { get; set; } = FileType.Model;
|
||||
|
||||
@ -39,9 +39,12 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
Header header;
|
||||
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
|
||||
header = new Header();
|
||||
header.Read(new FileReader(stream), this);
|
||||
}
|
||||
public void Unload()
|
||||
{
|
||||
@ -58,7 +61,14 @@ namespace FirstPlugin
|
||||
public uint Alignment { get; set; }
|
||||
public uint HeaderSize { get; set; }
|
||||
|
||||
public void Read(FileReader reader)
|
||||
public List<Material> Materials = new List<Material>();
|
||||
public List<string> TextureMaps = new List<string>();
|
||||
|
||||
public List<Node> UpperNodes = new List<Node>();
|
||||
public Tuple<Node, Node> LinkNodes; //Links two nodes for some reason
|
||||
public List<Node> LowerNodes = new List<Node>();
|
||||
|
||||
public void Read(FileReader reader, TreeNode root)
|
||||
{
|
||||
reader.ReadSignature(4, "BIKE");
|
||||
Version = reader.ReadUInt32();
|
||||
@ -68,15 +78,78 @@ namespace FirstPlugin
|
||||
HeaderSize = reader.ReadUInt32();
|
||||
uint TextureMapsCount = reader.ReadUInt32();
|
||||
uint TextureMapsOffset = reader.ReadUInt32();
|
||||
|
||||
//Seems to be a node based structure. Not %100 sure what decides which gets put into which
|
||||
uint UpperLevelNodeCount = reader.ReadUInt32();
|
||||
uint UpperLevelNodeOffset = reader.ReadUInt32();
|
||||
uint MiddleLevelNodeCount = reader.ReadUInt32();
|
||||
uint MiddleLevelNodeOffset = reader.ReadUInt32();
|
||||
uint FirstNodeOffset = reader.ReadUInt32(); //Either an offset or the total size of section up to the node
|
||||
uint LinkNodeCount = reader.ReadUInt32();
|
||||
uint LinkNodeOffset = reader.ReadUInt32();
|
||||
uint LowerLevelNodeCount = reader.ReadUInt32();
|
||||
uint LowerLevelNodeOffset = reader.ReadUInt32();
|
||||
uint Padding2 = reader.ReadUInt32();
|
||||
uint[] Unknowns = reader.ReadUInt32s(10);
|
||||
|
||||
for (int i = 0; i < MaterialCount; i++)
|
||||
{
|
||||
Material mat = new Material();
|
||||
mat.Read(reader);
|
||||
Materials.Add(mat);
|
||||
}
|
||||
|
||||
if (TextureMapsOffset != 0)
|
||||
{
|
||||
reader.SeekBegin(TextureMapsOffset);
|
||||
for (int i = 0; i < TextureMapsCount; i++)
|
||||
{
|
||||
TextureMaps.Add(reader.ReadNameOffset(false, typeof(uint)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Console.WriteLine($"MiddleLevelNodeCount {UpperLevelNodeCount}");
|
||||
Console.WriteLine($"MiddleLevelNodeOffset {UpperLevelNodeOffset}");
|
||||
|
||||
if (UpperLevelNodeCount != 0)
|
||||
{
|
||||
for (int i = 0; i < UpperLevelNodeCount; i++)
|
||||
{
|
||||
reader.SeekBegin(UpperLevelNodeOffset + (i * 8));
|
||||
|
||||
string NodeName = reader.ReadNameOffset(false, typeof(uint));
|
||||
uint Offset = reader.ReadUInt32();
|
||||
Console.WriteLine($"NodeName {NodeName} Offset {Offset}");
|
||||
|
||||
if (Offset != 0)
|
||||
{
|
||||
reader.SeekBegin(Offset);
|
||||
Node node = new Node();
|
||||
node.Text = NodeName;
|
||||
node.Read(reader);
|
||||
UpperNodes.Add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var node in UpperNodes)
|
||||
LoadChildern(UpperNodes, node, root);
|
||||
}
|
||||
|
||||
private void LoadChildern(List<Node> NodeLookup, Node Node, TreeNode root)
|
||||
{
|
||||
if (Node.ChildNode != null)
|
||||
{
|
||||
if (NodeLookup.Contains(Node.ChildNode))
|
||||
{
|
||||
int index = NodeLookup.IndexOf(Node.ChildNode);
|
||||
Node.ChildNode.Text = NodeLookup[index].Text;
|
||||
|
||||
Node.Nodes.Add(Node.ChildNode);
|
||||
LoadChildern(NodeLookup, Node.ChildNode, Node.ChildNode);
|
||||
}
|
||||
}
|
||||
|
||||
root.Nodes.Add(Node);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +168,7 @@ namespace FirstPlugin
|
||||
public float IndexRefreaction;
|
||||
public float Translucency;
|
||||
public float Unknown;
|
||||
public ushort[] TextureIndices;
|
||||
public short[] TextureIndices;
|
||||
public uint[] Unknowns;
|
||||
|
||||
public Material()
|
||||
@ -105,7 +178,7 @@ namespace FirstPlugin
|
||||
Specular = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
Shiny = 50;
|
||||
Transparency = new Vector4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
TextureIndices = new ushort[10];
|
||||
TextureIndices = new short[10];
|
||||
}
|
||||
|
||||
public void Read(FileReader reader)
|
||||
@ -127,5 +200,37 @@ namespace FirstPlugin
|
||||
Unknowns = reader.ReadUInt32s(10);
|
||||
}
|
||||
}
|
||||
|
||||
public class Node : TreeNode
|
||||
{
|
||||
public bool Visible { get; set; }
|
||||
|
||||
public Vector3 Scale { get; set; }
|
||||
public Vector3 Rotation { get; set; }
|
||||
public Vector3 Translation { get; set; }
|
||||
public byte[] Unknowns;
|
||||
public Node ChildNode { get; set; }
|
||||
|
||||
public void Read(FileReader reader)
|
||||
{
|
||||
Visible = reader.ReadUInt32() == 1;
|
||||
Scale = reader.ReadVec3();
|
||||
Rotation = reader.ReadVec3();
|
||||
Translation = reader.ReadVec3();
|
||||
Unknowns = reader.ReadBytes(16);
|
||||
uint BufferArrayOffset = reader.ReadUInt32();
|
||||
uint ChildNodeOffset = reader.ReadUInt32();
|
||||
|
||||
if (ChildNodeOffset != 0)
|
||||
{
|
||||
reader.SeekBegin(ChildNodeOffset);
|
||||
ChildNode = new Node();
|
||||
ChildNode.Read(reader);
|
||||
}
|
||||
|
||||
//After repeats a fairly similar structure, with SRT values
|
||||
//Unsure what it's used for?
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -315,6 +315,7 @@ namespace FirstPlugin
|
||||
Formats.Add(typeof(MKGPDX_PAC));
|
||||
Formats.Add(typeof(LZARC));
|
||||
Formats.Add(typeof(IGA_PAK));
|
||||
Formats.Add(typeof(MKAGPDX_Model));
|
||||
|
||||
Formats.Add(typeof(Turbo.Course_MapCamera_bin));
|
||||
Formats.Add(typeof(Turbo.PartsBIN));
|
||||
|
@ -241,6 +241,7 @@
|
||||
<Compile Include="FileFormats\Audio\Archives\BFGRP.cs" />
|
||||
<Compile Include="FileFormats\GFBMDL\GFBMDL.cs" />
|
||||
<Compile Include="FileFormats\Hashes\SAHT.cs" />
|
||||
<Compile Include="FileFormats\MKAGPDX\Model\MKAGPDX_Model.cs" />
|
||||
<Compile Include="FileFormats\Rom\RomfsNodeWrapper.cs" />
|
||||
<Compile Include="FileFormats\Shader\NSWShaderDecompile.cs" />
|
||||
<Compile Include="FileFormats\Shader\NUSHDB.cs" />
|
||||
|
Binary file not shown.
Binary file not shown.
@ -209,20 +209,6 @@
|
||||
<Compile Include="Audio\AudioFileRipper.cs" />
|
||||
<Compile Include="Audio\VGAudioFile.cs" />
|
||||
<Compile Include="Collections\SortExtensions.cs" />
|
||||
<Compile Include="Compression\SevenZip\sdk\Common\CRC.cs" />
|
||||
<Compile Include="Compression\SevenZip\sdk\Common\InBuffer.cs" />
|
||||
<Compile Include="Compression\SevenZip\sdk\Common\OutBuffer.cs" />
|
||||
<Compile Include="Compression\SevenZip\sdk\Compress\LZMA\LzmaBase.cs" />
|
||||
<Compile Include="Compression\SevenZip\sdk\Compress\LZMA\LzmaDecoder.cs" />
|
||||
<Compile Include="Compression\SevenZip\sdk\Compress\LZMA\LzmaEncoder.cs" />
|
||||
<Compile Include="Compression\SevenZip\sdk\Compress\LZ\IMatchFinder.cs" />
|
||||
<Compile Include="Compression\SevenZip\sdk\Compress\LZ\LzBinTree.cs" />
|
||||
<Compile Include="Compression\SevenZip\sdk\Compress\LZ\LzInWindow.cs" />
|
||||
<Compile Include="Compression\SevenZip\sdk\Compress\LZ\LzOutWindow.cs" />
|
||||
<Compile Include="Compression\SevenZip\sdk\Compress\RangeCoder\RangeCoder.cs" />
|
||||
<Compile Include="Compression\SevenZip\sdk\Compress\RangeCoder\RangeCoderBit.cs" />
|
||||
<Compile Include="Compression\SevenZip\sdk\Compress\RangeCoder\RangeCoderBitTree.cs" />
|
||||
<Compile Include="Compression\SevenZip\sdk\ICoder.cs" />
|
||||
<Compile Include="Compression\STLibraryCompression.cs" />
|
||||
<Compile Include="Config.cs" />
|
||||
<Compile Include="Cryptography\crc32.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user