From 7c786a5f4cb21ea143422aa0d19acdacd6a753bb Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sun, 22 Sep 2024 13:18:32 +0100 Subject: [PATCH] Add light objects to the light list --- KeepersCompound.Lightmapper/Program.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/KeepersCompound.Lightmapper/Program.cs b/KeepersCompound.Lightmapper/Program.cs index bdb6406..d885e7f 100644 --- a/KeepersCompound.Lightmapper/Program.cs +++ b/KeepersCompound.Lightmapper/Program.cs @@ -38,9 +38,29 @@ class Program radius = float.MaxValue }); } - } + else if (brush.media == BrList.Brush.Media.Object) + { + var id = (int)brush.brushInfo; + var light = hierarchy.GetProperty(id, "P$Light"); + var lightColor = hierarchy.GetProperty(id, "P$LightColo"); - // TODO: object lights + if (light != null) + { + lightColor ??= new PropLightColor { Hue = 0, Saturation = 0 }; + lights.Add(new Light + { + position = brush.position, + color = HsbToRgb(lightColor.Hue, lightColor.Saturation, light.Brightness), + radius = light.Brightness, + }); + } + else + { + Console.WriteLine($"no light prop apparently"); + + } + } + } } // Build embree mesh @@ -60,6 +80,8 @@ class Program var dir = Path.GetDirectoryName(misPath); var filename = Path.GetFileNameWithoutExtension(misPath); mis.Save(Path.Join(dir, $"{filename}-lit.cow")); + + Console.WriteLine($"Lit {lights.Count} light"); } // Expects Hue to be 0-360, saturation 0-1, brightness 0-255