improved model export

This commit is contained in:
Perfare
2019-07-16 04:33:37 +08:00
parent e001dff3de
commit 50c17c2ec4
5 changed files with 317 additions and 418 deletions

View File

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
@ -29,6 +28,21 @@ namespace AssetStudio
public int Count => children.Count;
public string Path
{
get
{
var frame = this;
var path = frame.Name;
while (frame.Parent != null)
{
frame = frame.Parent;
path = frame.Name + "/" + path;
}
return path;
}
}
public ImportedFrame(int childrenCount = 0)
{
children = new List<ImportedFrame>(childrenCount);
@ -48,19 +62,15 @@ namespace AssetStudio
public ImportedFrame FindFrameByPath(string path)
{
var splitPath = path.Split('/');
if (Name != splitPath[0])
throw new Exception($"Couldn't find path {path}");
var curFrame = this;
for (int i = 1; i < splitPath.Length; i++)
var name = path.Substring(path.LastIndexOf('/') + 1);
foreach (var frame in FindChilds(name))
{
curFrame = curFrame.FindChild(splitPath[i], false);
if (curFrame == null)
if (frame.Path.EndsWith(path, StringComparison.Ordinal))
{
throw new Exception($"Couldn't find path {path}");
return frame;
}
}
return curFrame;
return null;
}
public ImportedFrame FindFrame(string name)
@ -265,27 +275,6 @@ namespace AssetStudio
return null;
}
public static ImportedMesh FindMesh(ImportedFrame frame, List<ImportedMesh> importedMeshList)
{
var framePath = frame.Name;
var root = frame;
while (root.Parent != null)
{
root = root.Parent;
framePath = root.Name + "/" + framePath;
}
foreach (var mesh in importedMeshList)
{
if (mesh.Path == framePath)
{
return mesh;
}
}
return null;
}
public static ImportedMaterial FindMaterial(string name, List<ImportedMaterial> importedMats)
{
foreach (var mat in importedMats)