diff --git a/KeepersCompound.LGS/Database/Chunks/LmParams.cs b/KeepersCompound.LGS/Database/Chunks/LmParams.cs new file mode 100644 index 0000000..5cd4dc2 --- /dev/null +++ b/KeepersCompound.LGS/Database/Chunks/LmParams.cs @@ -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); + } +} \ No newline at end of file diff --git a/KeepersCompound.LGS/Database/File.cs b/KeepersCompound.LGS/Database/File.cs index f036600..94aa49a 100644 --- a/KeepersCompound.LGS/Database/File.cs +++ b/KeepersCompound.LGS/Database/File.cs @@ -150,6 +150,7 @@ public class DbFile "TXLIST" => new TxList(), "WREXT" => new WorldRep(), "BRLIST" => new BrList(), + "LM_PARAM" => new LmParams(), "RENDPARAMS" => new RendParams(), "P$ModelName" => new PropertyChunk(), "P$Scale" => new PropertyChunk(),