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

Cleanup and fixes

This commit is contained in:
KillzXGaming 2019-05-04 21:20:47 -04:00
parent 0fc310380b
commit 758e922183
9 changed files with 13 additions and 47 deletions

Binary file not shown.

View File

@ -149,7 +149,7 @@ namespace Bfres.Structs
}
}
public void NewModel()
public FMDL NewModel(bool AddTreeNode = true)
{
FMDL fmdl = new FMDL();
@ -205,7 +205,10 @@ namespace Bfres.Structs
((BFRES)Parent).AddSkeletonDrawable(fmdl.Skeleton);
}
AddNode(fmdl, "NewModel");
if (AddTreeNode)
AddNode(fmdl, "NewModel");
return fmdl;
}
public void NewExternalFile()
@ -256,49 +259,10 @@ namespace Bfres.Structs
switch (Type)
{
case BRESGroupType.Models:
FMDL fmdl = new FMDL();
FMDL fmdl = NewModel(false);
fmdl.Text = ResourceName;
if (IsWiiU)
{
fmdl.ModelU = new ResU.Model();
fmdl.ModelU.Name = ResourceName;
fmdl.ModelU.Shapes.Add("", new ResU.Shape());
fmdl.ModelU.Materials.Add("", new ResU.Material());
fmdl.ModelU.VertexBuffers.Add(new ResU.VertexBuffer());
var skeleton = new ResU.Skeleton();
//Create skeleton with empty bone
skeleton.Bones.Add("Root", new ResU.Bone() { Name = "Root" });
fmdl.ModelU.Skeleton = skeleton;
BfresWiiU.ReadModel(fmdl, fmdl.ModelU);
((BFRES)Parent).AddSkeletonDrawable(fmdl.Skeleton);
}
else
{
fmdl.Model = new ResNX.Model();
fmdl.Model.Name = ResourceName;
fmdl.Model.Shapes.Add(new ResNX.Shape());
fmdl.Model.VertexBuffers.Add(new ResNX.VertexBuffer());
//Create skeleton with empty bone
var skeleton = new ResNX.Skeleton();
skeleton.Bones.Add(new ResNX.Bone() { Name = "Root" });
fmdl.Model.Skeleton = skeleton;
BfresSwitch.ReadModel(fmdl, fmdl.Model);
((BFRES)Parent).AddSkeletonDrawable(fmdl.Skeleton);
}
fmdl.Replace(FileName, resFileNX, resFileU);
Nodes.Add(fmdl);
fmdl.UpdateVertexData();
AddNode(fmdl);
break;
case BRESGroupType.SkeletalAnim:
FSKA fska = new FSKA();

View File

@ -28,6 +28,9 @@ namespace Bfres.Structs
public ResFile GetResFile()
{
if (Parent == null || Parent.Parent == null)
return null;
//ResourceFile -> FMDL -> Model Folder -> this
return ((BFRES)Parent.Parent).resFile;
}
@ -1049,7 +1052,8 @@ namespace Bfres.Structs
UpdateEditor();
}
public void UpdateEditor(){
((BFRES)Parent.Parent).LoadEditors(this);
if (Parent != null)
((BFRES)Parent.Parent).LoadEditors(this);
}
private void CreateSkeleton()

View File

@ -187,7 +187,7 @@ namespace FirstPlugin.Forms
{
Drawables.Remove(draw);
if (!Runtime.UseOpenGL || !Runtime.DisplayViewport)
if (!Runtime.UseOpenGL || !Runtime.DisplayViewport || viewport == null)
{
IsLoaded = false;
RemovedDrawables.Add(draw);

View File

@ -107,7 +107,6 @@ namespace Switch_Toolbox.Library
if (parent.MeshCount > 0)
{
STConsole.WriteLine($"Use Transform Matrix {UseTransformMatrix}");
STConsole.WriteLine($"Transform node {parent.Name}");
STConsole.WriteLine($"Translation {worldTK.ExtractTranslation()}");
@ -118,7 +117,6 @@ namespace Switch_Toolbox.Library
foreach (int index in parent.MeshIndices)
objects.Add(CreateGenericObject(scene.Meshes[index], index, worldTK));
foreach (Node child in parent.Children)
BuildNode(child, ref world);
}