Skip to content

Commit e8fc9d0

Browse files
committed
Update v2.3.6.1
2 parents 6f554ea + cb1193a commit e8fc9d0

File tree

10 files changed

+265
-48
lines changed

10 files changed

+265
-48
lines changed

xivModdingFramework/Models/DataContainers/EquipmentParameter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public enum EquipmentParameterFlag
191191
BodyShowNecklace = 11,
192192
BodyShowBracelet = 12, // "Wrist[slot]" is not used in this context b/c it can be confusing with other settings.
193193
BodyShowTail = 13,
194-
BodyTriggersomeShapeData = 14,
194+
BodyDisableBreastPhysics = 14,
195195
Bit15 = 15,
196196

197197
// Byte 2 - Leg

xivModdingFramework/Models/DataContainers/MdlModelData.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,15 @@ public class MdlModelData
8080
/// </summary>
8181
public ushort ShapeDataCount { get; set; }
8282

83+
/// <summary>
84+
/// The total number of LoD
85+
/// </summary>
86+
public byte LoDCount { get; set; }
87+
8388
/// <summary>
8489
/// Unknown Usage
8590
/// </summary>
86-
public short Unknown1 { get; set; }
91+
public byte Unknown1 { get; set; }
8792

8893
/// <summary>
8994
/// Unknown Usage

xivModdingFramework/Models/FileTypes/Mdl.cs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@ public async Task<XivMdl> GetRawMdlData(string mdlPath, bool getOriginal = false
485485
ShapeCount = br.ReadInt16(),
486486
ShapePartCount = br.ReadInt16(),
487487
ShapeDataCount = br.ReadUInt16(),
488-
Unknown1 = br.ReadInt16(),
488+
LoDCount = br.ReadByte(),
489+
Unknown1 = br.ReadByte(),
489490
Unknown2 = br.ReadInt16(),
490491
Unknown3 = br.ReadInt16(),
491492
Unknown4 = br.ReadInt16(),
@@ -2542,7 +2543,8 @@ internal async Task<byte[]> MakeNewMdlFile(TTModel ttModel, XivMdl ogMdl, Action
25422543
modelDataBlock.AddRange(BitConverter.GetBytes(ttModel.HasShapeData ? (short)ttModel.ShapeNames.Count : (short)0));
25432544
modelDataBlock.AddRange(BitConverter.GetBytes(ttModel.HasShapeData ? (short)ttModel.ShapePartCount : (short)0));
25442545
modelDataBlock.AddRange(BitConverter.GetBytes(ttModel.HasShapeData ? (ushort)ttModel.ShapeDataCount : (ushort)0));
2545-
modelDataBlock.AddRange(BitConverter.GetBytes(ogModelData.Unknown1));
2546+
modelDataBlock.Add(1); // LoD count, set to 1 since we only use the highest LoD
2547+
modelDataBlock.Add(ogModelData.Unknown1);
25462548
modelDataBlock.AddRange(BitConverter.GetBytes(ogModelData.Unknown2));
25472549
modelDataBlock.AddRange(BitConverter.GetBytes(ogModelData.Unknown3));
25482550
modelDataBlock.AddRange(BitConverter.GetBytes(ogModelData.Unknown4));
@@ -3060,18 +3062,6 @@ internal async Task<byte[]> MakeNewMdlFile(TTModel ttModel, XivMdl ogMdl, Action
30603062
var lodNumber = 0;
30613063
foreach (var lod in ogMdl.LoDList)
30623064
{
3063-
var indexMeshNum = new Dictionary<int, int>();
3064-
3065-
// Get the index data offsets in each mesh
3066-
for (var i = 0; i < lod.MeshCount; i++)
3067-
{
3068-
var indexDataOffset = lod.MeshDataList[i].MeshInfo.IndexDataOffset;
3069-
3070-
indexMeshNum.Add(indexDataOffset, i);
3071-
}
3072-
3073-
3074-
30753065
// We only store the shape info for LoD 0.
30763066
if (lodNumber == 0)
30773067
{
@@ -3799,8 +3789,10 @@ internal async Task<byte[]> MakeNewMdlFile(TTModel ttModel, XivMdl ogMdl, Action
37993789
datHeader.AddRange(BitConverter.GetBytes((ushort)totalMeshCount));
38003790
// Material Count
38013791
datHeader.AddRange(BitConverter.GetBytes((ushort)ttModel.Materials.Count));
3792+
// LoD Count
3793+
datHeader.Add(1); // We only use the highest LoD instead of three
38023794
// Unknown 1
3803-
datHeader.AddRange(BitConverter.GetBytes((short)259));
3795+
datHeader.Add(1);
38043796
// Unknown 2
38053797
datHeader.AddRange(BitConverter.GetBytes((short)0));
38063798

xivModdingFramework/Models/ModelTextures/ModelTexture.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,18 @@ await Task.Run(() =>
414414
using (var img = Image.LoadPixelData<Rgba32>(texMapData.Normal.Data, texMapData.Normal.Width,
415415
texMapData.Normal.Height))
416416
{
417-
img.Mutate(x => x.Resize(width, height));
417+
// ImageSharp pre-multiplies the RGB by the alpha component during resize, if alpha is 0 (colourset row 0)
418+
// this ends up causing issues and destroying the RGB values resulting in an invisible preview model
419+
// https://github.com/SixLabors/ImageSharp/issues/1498#issuecomment-757519563
420+
img.Mutate(x => x.Resize(
421+
new ResizeOptions
422+
{
423+
Size = new Size(width, height),
424+
PremultiplyAlpha = false
425+
})
426+
);
418427

419-
texMapData.Normal.Data = MemoryMarshal.AsBytes(img.GetPixelSpan()).ToArray();
428+
texMapData.Normal.Data = MemoryMarshal.AsBytes(img.GetPixelMemoryGroup()[0].Span).ToArray();
420429
}
421430
}
422431

@@ -436,7 +445,7 @@ await Task.Run(() =>
436445
}
437446
img.Mutate(x => x.Resize(width, height));
438447

439-
texMapData.Diffuse.Data = MemoryMarshal.AsBytes(img.GetPixelSpan()).ToArray();
448+
texMapData.Diffuse.Data = MemoryMarshal.AsBytes(img.GetPixelMemoryGroup()[0].Span).ToArray();
440449
}
441450
}
442451

@@ -448,7 +457,7 @@ await Task.Run(() =>
448457
{
449458
img.Mutate(x => x.Resize(width, height));
450459

451-
texMapData.Specular.Data = MemoryMarshal.AsBytes(img.GetPixelSpan()).ToArray();
460+
texMapData.Specular.Data = MemoryMarshal.AsBytes(img.GetPixelMemoryGroup()[0].Span).ToArray();
452461
}
453462
}
454463
});
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace xivModdingFramework.Mods.DataContainers
5+
{
6+
public class BackupModPackData
7+
{
8+
/// <summary>
9+
/// The name of the mod pack
10+
/// </summary>
11+
public string Name { get; set; }
12+
13+
/// <summary>
14+
/// The mod pack author
15+
/// </summary>
16+
public string Author = "TexTools";
17+
18+
/// <summary>
19+
/// The mod pack version
20+
/// </summary>
21+
public Version Version = new Version("1.0.0");
22+
23+
/// <summary>
24+
/// The modpack Url
25+
/// </summary>
26+
public string Url = "";
27+
28+
/// <summary>
29+
/// The description for the mod pack
30+
/// </summary>
31+
public string Description = "";
32+
33+
/// <summary>
34+
/// The list of mods to back up
35+
/// </summary>
36+
public List<BackupModData> ModsToBackup { get; set; }
37+
}
38+
39+
public class BackupModData
40+
{
41+
/// <summary>
42+
/// Simple mod data
43+
/// </summary>
44+
public SimpleModData SimpleModData { get; set; }
45+
46+
/// <summary>
47+
/// Mod pack that the mod is a part of
48+
/// </summary>
49+
public ModPack ModPack { get; set; }
50+
}
51+
}

xivModdingFramework/Mods/DataContainers/ModList.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.Diagnostics.Contracts;
2121
using System.Security.Cryptography;
2222
using System.Text;
23+
using xivModdingFramework.General.Enums;
2324
using xivModdingFramework.Helpers;
2425

2526
namespace xivModdingFramework.Mods.DataContainers
@@ -114,6 +115,27 @@ public bool IsCustomFile()
114115
{
115116
return data.modOffset == data.originalOffset;
116117
}
118+
119+
/// <summary>
120+
/// Creates a Mod instance using the provided JSON
121+
/// </summary>
122+
/// <param name="modsJson"></param>
123+
/// <param name="sourceApplication"></param>
124+
/// <returns></returns>
125+
public static Mod MakeModFromJson(ModsJson modsJson, string sourceApplication)
126+
{
127+
return new Mod
128+
{
129+
source = sourceApplication,
130+
name = modsJson.Name,
131+
category = modsJson.Category,
132+
fullPath = modsJson.FullPath,
133+
datFile = IOUtil.GetDataFileFromPath(modsJson.FullPath).GetDataFileName(),
134+
enabled = true,
135+
modPack = modsJson.ModPackEntry,
136+
data = new Data()
137+
};
138+
}
117139
}
118140

119141
public class Data

0 commit comments

Comments
 (0)