Generate LOD Lights type added

This commit is contained in:
dexy 2019-01-21 21:05:32 +11:00
parent 7f16c84360
commit 38b9b8fc0a
2 changed files with 20 additions and 9 deletions

View File

@ -27,6 +27,14 @@ namespace CodeWalker
return new Vector3(x, y, z); return new Vector3(x, y, z);
//this quick mul ignores W... //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) public static Vector4 Multiply(this Matrix m, Vector4 v)
{ {

View File

@ -177,14 +177,11 @@ namespace CodeWalker.Project.Panels
var fragoffset = fdwbl?.OwnerFragmentPhys?.OwnerFragPhysLod.Unknown_30h ?? Vector4.Zero; var fragoffset = fdwbl?.OwnerFragmentPhys?.OwnerFragPhysLod.Unknown_30h ?? Vector4.Zero;
fragoffset.W = 0.0f; fragoffset.W = 0.0f;
if ((fragtransforms != null))// && (fragtransformid < fragtransforms.Length)) if ((fragtransforms != null) && (fragtransformid < fragtransforms.Length))
{
if (fragtransformid < fragtransforms.Length)
{ {
xform = fragtransforms[fragtransformid]; xform = fragtransforms[fragtransformid];
xform.Row4 += fragoffset; xform.Row4 += fragoffset;
} }
}
else else
{ {
//when using the skeleton's matrices, they need to be transformed by parent //when using the skeleton's matrices, they need to be transformed by parent
@ -209,8 +206,9 @@ namespace CodeWalker.Project.Panels
Vector3 lpos = new Vector3(la.PositionX, la.PositionY, la.PositionZ); Vector3 lpos = new Vector3(la.PositionX, la.PositionY, la.PositionZ);
Vector3 ldir = new Vector3(la.DirectionX, la.DirectionY, la.DirectionZ); Vector3 ldir = new Vector3(la.DirectionX, la.DirectionY, la.DirectionZ);
Vector3 bpos = xform.Multiply(lpos); Vector3 bpos = xform.Multiply(lpos);
Vector3 bdir = xform.MultiplyRot(ldir);
Vector3 epos = ent.Orientation.Multiply(bpos) + ent.Position; 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 r = la.ColorR;
uint g = la.ColorG; uint g = la.ColorG;
@ -218,9 +216,14 @@ namespace CodeWalker.Project.Panels
uint i = (byte)Math.Min(la.Intensity*4, 255); uint i = (byte)Math.Min(la.Intensity*4, 255);
uint c = (i << 24) + (r << 16) + (g << 8) + b; 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); var maxext = (byte)Math.Max(Math.Max(la.ExtentX, la.ExtentY), la.ExtentZ);