diff --git a/CodeWalker.Core/Utils/Matrices.cs b/CodeWalker.Core/Utils/Matrices.cs index f259b6f..580b553 100644 --- a/CodeWalker.Core/Utils/Matrices.cs +++ b/CodeWalker.Core/Utils/Matrices.cs @@ -27,6 +27,14 @@ namespace CodeWalker return new Vector3(x, y, z); //this quick mul ignores W... } + public static Vector3 MultiplyRot(this Matrix m, Vector3 v) + { + float x = (((m.M11 * v.X) + (m.M21 * v.Y)) + (m.M31 * v.Z));// + m.M41; + float y = (((m.M12 * v.X) + (m.M22 * v.Y)) + (m.M32 * v.Z));// + m.M42; + float z = (((m.M13 * v.X) + (m.M23 * v.Y)) + (m.M33 * v.Z));// + m.M43; + return new Vector3(x, y, z); + //this quick mul ignores W and translation... + } public static Vector4 Multiply(this Matrix m, Vector4 v) { diff --git a/Project/Panels/GenerateLODLightsPanel.cs b/Project/Panels/GenerateLODLightsPanel.cs index 85c9860..c8b9365 100644 --- a/Project/Panels/GenerateLODLightsPanel.cs +++ b/Project/Panels/GenerateLODLightsPanel.cs @@ -177,13 +177,10 @@ namespace CodeWalker.Project.Panels var fragoffset = fdwbl?.OwnerFragmentPhys?.OwnerFragPhysLod.Unknown_30h ?? Vector4.Zero; fragoffset.W = 0.0f; - if ((fragtransforms != null))// && (fragtransformid < fragtransforms.Length)) + if ((fragtransforms != null) && (fragtransformid < fragtransforms.Length)) { - if (fragtransformid < fragtransforms.Length) - { - xform = fragtransforms[fragtransformid]; - xform.Row4 += fragoffset; - } + xform = fragtransforms[fragtransformid]; + xform.Row4 += fragoffset; } else { @@ -209,8 +206,9 @@ namespace CodeWalker.Project.Panels Vector3 lpos = new Vector3(la.PositionX, la.PositionY, la.PositionZ); Vector3 ldir = new Vector3(la.DirectionX, la.DirectionY, la.DirectionZ); Vector3 bpos = xform.Multiply(lpos); + Vector3 bdir = xform.MultiplyRot(ldir); Vector3 epos = ent.Orientation.Multiply(bpos) + ent.Position; - Vector3 edir = ent.Orientation.Multiply(ldir); + Vector3 edir = ent.Orientation.Multiply(bdir); uint r = la.ColorR; uint g = la.ColorG; @@ -218,9 +216,14 @@ namespace CodeWalker.Project.Panels uint i = (byte)Math.Min(la.Intensity*4, 255); uint c = (i << 24) + (r << 16) + (g << 8) + b; - uint h = 0; //TODO: what hash to use??? + uint h = 123456; //TODO: what hash to use??? - uint t = la.TimeFlags; + //@Calcium: + //1 = point + //2 = spot + //4 = capsule + uint type = 1; + uint t = la.TimeFlags + (type << 26); var maxext = (byte)Math.Max(Math.Max(la.ExtentX, la.ExtentY), la.ExtentZ);