mirror of
https://github.com/aelurum/AssetStudio.git
synced 2026-11-15 19:28:48 -05:00
Add option to dump material assets during model export
This commit is contained in:
@@ -281,7 +281,7 @@ namespace AssetStudioCLI
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void ExportFbx(IImported convert, string exportPath)
|
||||
private static void ExportFbx(ModelConverter convert, string exportPath)
|
||||
{
|
||||
var fbxSettings = new Fbx.Settings
|
||||
{
|
||||
@@ -289,8 +289,25 @@ namespace AssetStudioCLI
|
||||
ScaleFactor = CLIOptions.o_fbxScaleFactor.Value,
|
||||
ExportAllUvsAsDiffuseMaps = CLIOptions.f_fbxUvsAsDiffuseMaps.Value,
|
||||
ExportAnimations = CLIOptions.o_fbxAnimMode.Value != AnimationExportMode.Skip,
|
||||
DumpMaterials = CLIOptions.f_fbxDumpMaterials.Value,
|
||||
};
|
||||
ModelExporter.ExportFbx(exportPath, convert, fbxSettings);
|
||||
if (!fbxSettings.DumpMaterials || convert.MaterialAssetSet.Count == 0 || !File.Exists(exportPath))
|
||||
return;
|
||||
|
||||
var exportDir = Path.Combine(Path.GetDirectoryName(exportPath), "Materials");
|
||||
Directory.CreateDirectory(exportDir);
|
||||
foreach (var mat in convert.MaterialAssetSet)
|
||||
{
|
||||
var jsonDoc = mat.ToJsonDoc();
|
||||
var str = System.Text.Json.JsonSerializer.Serialize(jsonDoc, Object.JsonOptions);
|
||||
var exportFullPath = Path.Combine(exportDir, $"{mat.m_Name}.json");
|
||||
if (File.Exists(exportFullPath))
|
||||
{
|
||||
exportFullPath = Path.Combine(exportDir, $"{mat.m_Name} #{mat.GetHashCode():x}.json");
|
||||
}
|
||||
File.WriteAllText(exportFullPath, str);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ExportRawFile(AssetItem item, string exportPath)
|
||||
|
||||
Reference in New Issue
Block a user