Skip to content

Commit 9d76cca

Browse files
committed
Change material export to public static
Change path to export target race body
1 parent 8c728c7 commit 9d76cca

File tree

1 file changed

+19
-7
lines changed
  • xivModdingFramework/Models/FileTypes

1 file changed

+19
-7
lines changed

xivModdingFramework/Models/FileTypes/Mdl.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public async Task ExportModel(TTModel model, string outputFilePath, int mtrlVari
217217
// Pop the textures out so the exporters can reference them.
218218
if (includeTextures)
219219
{
220-
await ExportMaterialsForModel(model, outputFilePath, mtrlVariant);
220+
await ExportMaterialsForModel(model, outputFilePath, _gameDirectory, mtrlVariant);
221221
}
222222

223223
// Validate the skeleton.
@@ -299,27 +299,39 @@ public async Task ExportModel(TTModel model, string outputFilePath, int mtrlVari
299299
/// <summary>
300300
/// Retrieves and exports the materials for the current model, to be used alongside ExportModel
301301
/// </summary>
302-
private async Task ExportMaterialsForModel(TTModel model, string outputFilePath, int mtrlVariant = 1)
302+
public static async Task ExportMaterialsForModel(TTModel model, string outputFilePath, DirectoryInfo gameDirectory, int mtrlVariant = 1, XivRace targetRace = XivRace.All_Races)
303303
{
304304
var modelName = Path.GetFileNameWithoutExtension(model.Source);
305305
var directory = Path.GetDirectoryName(outputFilePath);
306306

307307
// Language doesn't actually matter here.
308-
var _mtrl = new Mtrl(_gameDirectory, IOUtil.GetDataFileFromPath(model.Source), XivLanguage.None);
309-
var _tex = new Tex(_gameDirectory);
310-
var _index = new Index(_gameDirectory);
308+
var _mtrl = new Mtrl(gameDirectory, IOUtil.GetDataFileFromPath(model.Source), XivLanguage.None);
309+
var _tex = new Tex(gameDirectory);
310+
var _index = new Index(gameDirectory);
311311
var materialIdx = 0;
312312

313313

314314
foreach (var materialName in model.Materials)
315315
{
316316
try
317317
{
318+
var mdlPath = model.Source;
319+
320+
// Set source race to match so that it doesn't get replaced
321+
if (targetRace != XivRace.All_Races)
322+
{
323+
if (materialName.Contains("b0001"))
324+
{
325+
var currentRace = model.Source.Substring(model.Source.LastIndexOf('c') + 1, 4);
326+
mdlPath = model.Source.Replace(currentRace, targetRace.GetRaceCode());
327+
}
328+
}
329+
318330
// This messy sequence is ultimately to get access to _modelMaps.GetModelMaps().
319-
var mtrlPath = _mtrl.GetMtrlPath(model.Source, materialName, mtrlVariant);
331+
var mtrlPath = _mtrl.GetMtrlPath(mdlPath, materialName, mtrlVariant);
320332
var mtrlOffset = await _index.GetDataOffset(mtrlPath);
321333
var mtrl = await _mtrl.GetMtrlData(mtrlOffset, mtrlPath, 11);
322-
var modelMaps = await ModelTexture.GetModelMaps(_gameDirectory, mtrl);
334+
var modelMaps = await ModelTexture.GetModelMaps(gameDirectory, mtrl);
323335

324336
// Outgoing file names.
325337
var mtrl_prefix = directory + "\\" + Path.GetFileNameWithoutExtension(materialName.Substring(1)) + "_";

0 commit comments

Comments
 (0)