Skip to content

Commit a47466a

Browse files
authored
Merge pull request #15 from TexTools/full_model
Merge FullModel branch to Develop
2 parents 3b3b207 + 2a48cc4 commit a47466a

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

xivModdingFramework/Models/DataContainers/ModelTextureData.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,7 @@ public class ModelTextureData
3434
public byte[] Alpha { get; set; }
3535

3636
public byte[] Emissive { get; set; }
37+
38+
public string MaterialPath { get; set; }
3739
}
3840
}

xivModdingFramework/Models/FileTypes/Mdl.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,9 @@ public static async Task ExportMaterialsForModel(TTModel model, string outputFil
326326
// Set source race to match so that it doesn't get replaced
327327
if (targetRace != XivRace.All_Races)
328328
{
329-
if (materialName.Contains("b0001"))
329+
var bodyRegex = new Regex("(b[0-9]{4})");
330+
331+
if (bodyRegex.Match(materialName).Success)
330332
{
331333
var currentRace = model.Source.Substring(model.Source.LastIndexOf('c') + 1, 4);
332334
mdlPath = model.Source.Replace(currentRace, targetRace.GetRaceCode());

xivModdingFramework/Models/Helpers/ModelModifiers.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ public static void FixUpSkinReferences(TTModel model, string newInternalPath, Ac
11821182
/// </summary>
11831183
/// <param name="model"></param>
11841184
/// <param name="newInternalPath"></param>
1185-
public static void FixUpSkinReferences(TTModel model, XivRace baseRace, Action<bool, string> loggingFunction = null)
1185+
public static void FixUpSkinReferences(TTModel model, XivRace baseRace, Action<bool, string> loggingFunction = null, string bodyReplacement = "")
11861186
{
11871187
if (loggingFunction == null)
11881188
{
@@ -1208,7 +1208,12 @@ public static void FixUpSkinReferences(TTModel model, XivRace baseRace, Action<b
12081208
m.Material = m.Material.Replace(mtrlMatch.Groups[1].Value, skinRaceString);
12091209

12101210
// Reset the body ID if we actually changed races.
1211-
m.Material = bodyRegex.Replace(m.Material, "b0001");
1211+
bodyReplacement = string.IsNullOrEmpty(bodyReplacement) ? "b0001" : bodyReplacement;
1212+
m.Material = bodyRegex.Replace(m.Material, bodyReplacement);
1213+
}
1214+
else if (bodyReplacement != "")
1215+
{
1216+
m.Material = bodyRegex.Replace(m.Material, bodyReplacement);
12121217
}
12131218
}
12141219
}

xivModdingFramework/Models/ModelTextures/ModelTexture.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ public static async Task<ModelTextureData> GetModelMaps(Tex tex, XivMtrl mtrl, C
178178
Diffuse = new byte[0],
179179
Specular = new byte[0],
180180
Emissive = new byte[0],
181-
Alpha = new byte[0]
181+
Alpha = new byte[0],
182+
MaterialPath = mtrl.MTRLPath.Substring(mtrl.MTRLPath.LastIndexOf('/'))
182183
};
183184
return empty;
184185
}
@@ -251,7 +252,8 @@ await Task.Run(() =>
251252
Diffuse = diffuseMap.ToArray(),
252253
Specular = specularMap.ToArray(),
253254
Emissive = emissiveMap.ToArray(),
254-
Alpha = alphaMap.ToArray()
255+
Alpha = alphaMap.ToArray(),
256+
MaterialPath = mtrl.MTRLPath.Substring(mtrl.MTRLPath.LastIndexOf('/'))
255257
};
256258

257259
return modelTextureData;

0 commit comments

Comments
 (0)