Fix dae rigging for good now

This commit is contained in:
KillzXGaming 2019-04-01 15:04:16 -04:00
parent c98162622f
commit 7bd00f6de7
17 changed files with 177 additions and 20 deletions

Binary file not shown.

View file

@ -324,7 +324,7 @@ namespace FirstPlugin
{
IFileFormat file = STFileLoader.OpenFileFormat(FullName, Data,false, true, this);
if (Utils.HasInterface(file.GetType(), typeof(IEditor<>)))
if (Utils.HasInterface(file.GetType(), typeof(IEditor<>)) && !SuppressFormDialog)
{
OpenFormDialog(file);
}

View file

@ -47,19 +47,148 @@ namespace FirstPlugin
STToolStripItem EndiannessToolstrip;
STToolStripItem OdysseyPresetToolstrip;
STToolStripItem Mk8PresetToolstrip;
STToolStripItem Splatoon2PresetToolstrip;
STToolStripItem SplatoonPresetToolstrip;
STToolStripItem OtherPresetToolstrip;
public KCL()
{
OdysseyPresetToolstrip = new STToolStripItem("Mario Odyssey", PresetChanged) { Checked = true };
Mk8PresetToolstrip = new STToolStripItem("Mario Kart 8 Wii U / Deluxe", PresetChanged);
Splatoon2PresetToolstrip = new STToolStripItem("Splatoon 2", PresetChanged);
SplatoonPresetToolstrip = new STToolStripItem("Splatoon", PresetChanged);
OtherPresetToolstrip = new STToolStripItem("Other", PresetChanged);
STToolStripItem GamePresetToolstrip = new STToolStripItem("Game Preset");
GamePresetToolstrip.DropDownItems.Add(OdysseyPresetToolstrip);
GamePresetToolstrip.DropDownItems.Add(Mk8PresetToolstrip);
GamePresetToolstrip.DropDownItems.Add(Splatoon2PresetToolstrip);
GamePresetToolstrip.DropDownItems.Add(SplatoonPresetToolstrip);
GamePresetToolstrip.DropDownItems.Add(OtherPresetToolstrip);
ContextMenuStrip = new STContextMenuStrip();
ContextMenuStrip.Items.Add(new STToolStripItem("Save", Save));
ContextMenuStrip.Items.Add(GamePresetToolstrip);
ContextMenuStrip.Items.Add(new STToolStripItem("Export", Export));
ContextMenuStrip.Items.Add(new STToolStripItem("Replace", Replace));
EndiannessToolstrip = new STToolStripItem("Big Endian Mode", SwapEndianess) { Checked = true };
ContextMenuStrip.Items.Add(EndiannessToolstrip);
CanSave = true;
IFileInfo = new IFileInfo();
}
public void PresetChanged(object sender, EventArgs args)
{
OdysseyPresetToolstrip.Checked = false;
Mk8PresetToolstrip.Checked = false;
Splatoon2PresetToolstrip.Checked = false;
SplatoonPresetToolstrip.Checked = false;
OtherPresetToolstrip.Checked = false;
if (sender is STToolStipMenuItem) {
((STToolStipMenuItem)sender).Checked = true;
}
ApplyPresets(data);
}
public class Header
{
public uint Signature { get; set; }
public uint OctreeOffset { get; set; }
public uint ModelOffsetArray { get; set; }
public uint ModelCount { get; set; }
public Vector3 MinCoordinates { get; set; }
public Vector3 MaxCoordinates { get; set; }
public Vector3 CoordinateShift { get; set; }
public uint Unknown { get; set; }
public void Read(FileReader reader)
{
}
public void Write(FileWriter writer)
{
}
}
public class OctreeNode
{
public List<ushort> TriangleIndices { get; set; }
protected const uint _flagMask = 0b11000000_00000000_00000000_00000000;
public const int ChildCount = 8;
public OctreeNode[] Children { get; internal set; }
public OctreeNode(FileReader reader, long ParentOffset)
{
uint Key = reader.ReadUInt32();
long offset = ParentOffset + Key & ~_flagMask;
if ((Flags)(Key & _flagMask) == Flags.Values)
{
// Node is a leaf and key points to triangle list starting 2 bytes later.
using (reader.TemporarySeek(offset + sizeof(ushort), SeekOrigin.Begin))
{
TriangleIndices = new List<ushort>();
ushort index;
while ((index = reader.ReadUInt16()) != 0xFFFF)
{
TriangleIndices.Add(index);
}
}
}
else
{
// Node is a branch and points to 8 child nodes.
using (reader.TemporarySeek(offset, SeekOrigin.Begin))
{
OctreeNode[] children = new OctreeNode[ChildCount];
for (int i = 0; i < ChildCount; i++)
{
children[i] = new OctreeNode(reader, offset);
}
Children = children;
}
}
}
internal enum Flags : uint
{
Divide = 0b00000000_00000000_00000000_00000000,
Values = 0b10000000_00000000_00000000_00000000,
NoData = 0b11000000_00000000_00000000_00000000
}
public void Write(FileWriter writer)
{
}
}
public class Model
{
public void Read(FileReader reader)
{
}
public void Write(FileWriter writer)
{
}
}
private void ApplyPresets(byte[] Data)
{
}
public void Load(System.IO.Stream stream)
{
Text = FileName;
@ -246,6 +375,7 @@ namespace FirstPlugin
kcl = MarioKart.MK7.KCL.FromOBJ(mod);
data = kcl.Write(Endianness);
Read(data);
Renderer.UpdateVertexData();
}
}

View file

@ -39,6 +39,8 @@ namespace FirstPlugin
public void Load(System.IO.Stream stream)
{
Text = FileName;
FFNT bffnt = new FFNT();
bffnt.Read(new FileReader(stream));
@ -50,6 +52,7 @@ namespace FirstPlugin
SheetEntry sheet = new SheetEntry();
sheet.data = texture;
sheet.Text = "Sheet" + i++;
Nodes.Add(sheet);
}
}
public void Unload()

View file

@ -35,6 +35,8 @@ namespace FirstPlugin
bool pathSupport;
ushort bymlVer;
bool useMuunt = true;
public ByamlEditor(System.Collections.IEnumerable by, bool _pathSupport, ushort _ver, ByteOrder defaultOrder = ByteOrder.LittleEndian, bool IsSaveDialog = false, BYAML byaml = null)
{
InitializeComponent();
@ -49,7 +51,7 @@ namespace FirstPlugin
stPanel1.Dock = DockStyle.Fill;
}
/* if (byaml.FileName == "course_muunt.byaml")
if (byaml.FileName == "course_muunt.byaml" && useMuunt)
{
pathSupport = true;
@ -60,7 +62,7 @@ namespace FirstPlugin
editor.LoadCourseInfo(by, byaml.FilePath);
stPanel1.Controls.Add(editor);
return;
}*/
}
byteOrder = defaultOrder;

View file

@ -31,7 +31,7 @@ namespace FirstPlugin.Forms
scene = new CourseMuuntScene(by);
if (File.Exists($"{CourseFolder}/course_model.szs"))
{
// scene.AddRenderableBfres($"{CourseFolder}/course_model.szs");
scene.AddRenderableBfres($"{CourseFolder}/course_model.szs");
scene.AddRenderableKcl($"{CourseFolder}/course.kcl");
@ -42,13 +42,13 @@ namespace FirstPlugin.Forms
kcl.Renderer.UpdateVertexData();
}
/* foreach (var bfres in scene.BfresObjects)
foreach (var bfres in scene.BfresObjects)
{
viewport.AddDrawable(bfres.BFRESRender);
bfres.BFRESRender.UpdateVertexData();
bfres.BFRESRender.UpdateTextureMaps();
}*/
}
viewport.LoadObjects();
}

View file

@ -411,9 +411,6 @@ namespace Switch_Toolbox.Library
}
}
foreach (Bone b in msh.Bones)
Console.WriteLine(b.VertexWeights.Count);
if (msh.HasBones)
return msh.Bones.Max(b => b.VertexWeightCount);

View file

@ -22,6 +22,19 @@ namespace Switch_Toolbox.Library
SaveMaterials(scene, model, FileName, Textures);
SaveMeshes(scene, model, skeleton, FileName, NodeArray);
foreach (var mesh in scene.Meshes)
{
STConsole.WriteLine(mesh.Name);
}
foreach (var mat in scene.Materials)
{
foreach (var slot in mat.GetMaterialTextures(TextureType.Diffuse))
{
STConsole.WriteLine("Diffuse " + slot.FilePath);
}
}
using (var v = new AssimpContext())
{
string ext = System.IO.Path.GetExtension(FileName);
@ -36,10 +49,25 @@ namespace Switch_Toolbox.Library
if (ext == ".ply")
formatID = "ply";
if (v.ExportFile(scene, FileName, formatID, PostProcessSteps.ValidateDataStructure))
if (v.ExportFile(scene, FileName, formatID))
MessageBox.Show($"Exported {FileName} Successfuly!");
else
MessageBox.Show($"Failed to export {FileName}!");
Scene newScene = v.ImportFile(FileName);
foreach (var mesh in newScene.Meshes)
{
STConsole.WriteLine(mesh.Name);
}
foreach (var mat in newScene.Materials)
{
foreach (var slot in mat.GetMaterialTextures(TextureType.Diffuse))
{
STConsole.WriteLine("Diffuse " + slot.FilePath);
}
}
}
}
@ -101,16 +129,14 @@ namespace Switch_Toolbox.Library
}
//Check if the max amount of weights is higher than the current bone id
if (v.boneWeights.Count > j)
if (v.boneWeights.Count > j && v.boneWeights[j] > 0)
{
if (v.boneWeights[j] <= 0)
mesh.Bones[boneInd].VertexWeights.Add(new VertexWeight(vertexID, 1));
else if (v.boneWeights[j] <= 1)
if (v.boneWeights[j] <= 1)
mesh.Bones[boneInd].VertexWeights.Add(new VertexWeight(vertexID, v.boneWeights[j]));
else
mesh.Bones[boneInd].VertexWeights.Add(new VertexWeight(vertexID, 1));
}
else
else if ( v.boneWeights[j] > 0)
mesh.Bones[boneInd].VertexWeights.Add(new VertexWeight(vertexID, 1));
}
}

View file

@ -38,7 +38,6 @@
<ItemGroup>
<Reference Include="AssimpNet, Version=4.1.0.0, Culture=neutral, PublicKeyToken=0d51b391f59f42a6, processorArchitecture=MSIL">
<HintPath>..\packages\AssimpNet.4.1.0\lib\net40\AssimpNet.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Be.Windows.Forms.HexBox">
<HintPath>..\Toolbox\Lib\Be.Windows.Forms.HexBox.dll</HintPath>

View file

@ -13,6 +13,8 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -234,9 +236,7 @@
<Content Include="Lib\aamp_hashed_names.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Lib\AssimpNet.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Lib\AssimpNet.dll" />
<Content Include="Lib\BarsLibrary.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>