Skip to content

Commit db5e4e4

Browse files
authored
Merge pull request #85 from Glorou/master
Adding support for input embeded textures
2 parents be8c840 + f3747f6 commit db5e4e4

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

xivModdingFramework/Models/DataContainers/TTModel.cs

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,25 +1741,42 @@ public static async Task<TTModel> LoadFromFile(string filePath, Action<bool, str
17411741
}
17421742
}
17431743
}
1744-
db.Close();
1745-
}
17461744

1747-
// Try to make sure the DB is properly unlocked.'
1745+
//Load Mats if applicable
1746+
query = "select * from materials order by material_id";
1747+
using (var cmd = new SQLiteCommand(query, db))
1748+
{
1749+
using (var reader = new CacheReader(cmd.ExecuteReader()))
1750+
{
1751+
while (reader.NextRow())
1752+
{
1753+
var matNum = reader.GetInt32("material_id");
1754+
var materialPath = reader.GetString("name");
1755+
model.MeshGroups[matNum].Material = materialPath;
1756+
}
1757+
}
1758+
1759+
XivCache.WaitForSqlCleanup();
1760+
db.Close();
1761+
}
17481762

1749-
XivCache.WaitForSqlCleanup();
1763+
// Try to make sure the DB is properly unlocked.'
17501764

1751-
model.UVState = UVAddressingSpace.Standard;
1765+
XivCache.WaitForSqlCleanup();
17521766

1753-
// Convert the model to FFXIV's internal weirdness.
1754-
ModelModifiers.MakeImportReady(model, settings.ShiftImportUV, loggingFunction);
1767+
model.UVState = UVAddressingSpace.Standard;
17551768

1756-
await ModelModifiers.CalculateTangents(model, loggingFunction);
1769+
// Convert the model to FFXIV's internal weirdness.
1770+
ModelModifiers.MakeImportReady(model, settings.ShiftImportUV, loggingFunction);
17571771

1758-
await ModelModifiers.ConvertFlowData(model, loggingFunction);
1772+
await ModelModifiers.CalculateTangents(model, loggingFunction);
17591773

1760-
ModelModifiers.CleanWeights(model, loggingFunction);
1774+
await ModelModifiers.ConvertFlowData(model, loggingFunction);
17611775

1762-
return model;
1776+
ModelModifiers.CleanWeights(model, loggingFunction);
1777+
1778+
return model;
1779+
}
17631780
}
17641781

17651782
private static void MigrateImportDb(SQLiteConnection db)

xivModdingFramework/Models/FileTypes/Mdl.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,10 +1921,13 @@ public static async Task<long> ImportModel(string externalFile, string internalF
19211921
/// <exception cref="InvalidDataException"></exception>
19221922
public static async Task<byte[]> FileToUncompressedMdl(string externalPath, string internalPath, ModelImportOptions options = null, ModTransaction tx = null)
19231923
{
1924-
1924+
bool applyOptions = false;
19251925
if (options == null)
19261926
{
19271927
options = new ModelImportOptions();
1928+
} else
1929+
{
1930+
applyOptions = true;
19281931
}
19291932

19301933
if (options.LoggingFunction == null)
@@ -2011,7 +2014,7 @@ await Task.Run(async () =>
20112014
}
20122015
else
20132016
{
2014-
ttModel = await LoadExternalModel(externalPath, options, false);
2017+
ttModel = await LoadExternalModel(externalPath, options, applyOptions);
20152018
}
20162019
#endregion
20172020

0 commit comments

Comments
 (0)