Add LmParams parsing

This commit is contained in:
Jarrod Doyle 2024-10-29 17:28:01 +00:00
parent ca017e3f7b
commit ff91ad567b
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,73 @@
namespace KeepersCompound.LGS.Database.Chunks;
public enum SoftnessMode
{
Standard,
HighFourPoint,
HighFivePoint,
HighNinePoint,
MediumFourPoint,
MediumFivePoint,
MediumNinePoint,
LowFourPoint,
}
public class LmParams : IChunk
{
public enum LightingMode
{
Quick,
Raycast,
Objcast,
}
public enum DepthMode
{
Lm16,
Lm32,
Lm32x,
}
public ChunkHeader Header { get; set; }
public float Attenuation { get; set; }
public float Saturation { get; set; }
public LightingMode ShadowType { get; set; }
public SoftnessMode ShadowSoftness { get; set; }
public float CenterWeight { get; set; }
public DepthMode ShadowDepth { get; set; }
public bool LightmappedWater { get; set; }
public int LightmapScale { get; set; }
private int _dataSize;
private uint _unknown;
public void ReadData(BinaryReader reader, DbFile.TableOfContents.Entry entry)
{
_dataSize = reader.ReadInt32();
Attenuation = reader.ReadSingle();
Saturation = reader.ReadSingle();
ShadowType = (LightingMode)reader.ReadUInt32();
ShadowSoftness = (SoftnessMode)reader.ReadUInt32();
CenterWeight = reader.ReadSingle();
ShadowDepth = (DepthMode)reader.ReadUInt32();
LightmappedWater = reader.ReadBoolean();
reader.ReadBytes(3);
LightmapScale = reader.ReadInt32();
_unknown = reader.ReadUInt32();
}
public void WriteData(BinaryWriter writer)
{
writer.Write(_dataSize);
writer.Write(Attenuation);
writer.Write(Saturation);
writer.Write((uint)ShadowType);
writer.Write((uint)ShadowSoftness);
writer.Write(CenterWeight);
writer.Write((uint)ShadowDepth);
writer.Write(LightmappedWater);
writer.Write(new byte[3]);
writer.Write(LightmapScale);
writer.Write(_unknown);
}
}

View File

@ -150,6 +150,7 @@ public class DbFile
"TXLIST" => new TxList(), "TXLIST" => new TxList(),
"WREXT" => new WorldRep(), "WREXT" => new WorldRep(),
"BRLIST" => new BrList(), "BRLIST" => new BrList(),
"LM_PARAM" => new LmParams(),
"RENDPARAMS" => new RendParams(), "RENDPARAMS" => new RendParams(),
"P$ModelName" => new PropertyChunk<PropLabel>(), "P$ModelName" => new PropertyChunk<PropLabel>(),
"P$Scale" => new PropertyChunk<PropVector>(), "P$Scale" => new PropertyChunk<PropVector>(),