mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2026-05-14 15:55:40 +08:00
LodLights generator positions improvement
This commit is contained in:
@@ -2083,6 +2083,7 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
var dd = db as Drawable;
|
||||
var fd = db as FragDrawable;
|
||||
var skel = db.Skeleton;
|
||||
LightAttributes_s[] lightAttrs = null;
|
||||
Bounds b = null;
|
||||
if (dd != null)
|
||||
@@ -2092,8 +2093,10 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
else if (fd != null)
|
||||
{
|
||||
lightAttrs = fd.OwnerFragment?.LightAttributes?.data_items;
|
||||
b = fd.OwnerFragment?.PhysicsLODGroup?.PhysicsLOD1?.Bound;
|
||||
var frag = fd?.OwnerFragment;
|
||||
skel = skel ?? frag?.Drawable?.Skeleton;
|
||||
lightAttrs = frag?.LightAttributes?.data_items;
|
||||
b = frag?.PhysicsLODGroup?.PhysicsLOD1?.Bound;
|
||||
}
|
||||
if (lightAttrs == null) return;
|
||||
|
||||
@@ -2120,9 +2123,19 @@ namespace CodeWalker.GameFiles
|
||||
for (int i = 0; i < lightAttrs.Length; i++)
|
||||
{
|
||||
ints[6] = (uint)(exts + i);
|
||||
var la = lightAttrs[i];
|
||||
|
||||
var xform = Matrix.Identity;
|
||||
if ((skel != null) && (skel.BonesMap.TryGetValue(la.BoneId, out Bone bone)))
|
||||
{
|
||||
xform = bone.AbsTransform;
|
||||
}
|
||||
|
||||
var li = new LightInstance();
|
||||
li.Attributes = lightAttrs[i];
|
||||
li.Attributes = la;
|
||||
li.Hash = ComputeLightHash(ints);
|
||||
li.Position = Orientation.Multiply(xform.Multiply(la.Position)) + Position;
|
||||
li.Direction = Orientation.Multiply(xform.MultiplyRot(la.Direction));
|
||||
lightInsts[i] = li;
|
||||
}
|
||||
Lights = lightInsts;
|
||||
@@ -2200,6 +2213,8 @@ namespace CodeWalker.GameFiles
|
||||
{
|
||||
public LightAttributes_s Attributes { get; set; } //just for display purposes!
|
||||
public uint Hash { get; set; }
|
||||
public Vector3 Position { get; set; }
|
||||
public Vector3 Direction { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
@@ -1122,6 +1122,7 @@ namespace CodeWalker.GameFiles
|
||||
BonesMap[bone.Tag] = bone;
|
||||
|
||||
bone.UpdateAnimTransform();
|
||||
bone.AbsTransform = bone.AnimTransform;
|
||||
bone.BindTransformInv = (i < (TransformationsInverted?.Length ?? 0)) ? TransformationsInverted[i] : Matrix.Invert(bone.AnimTransform);
|
||||
bone.BindTransformInv.M44 = 1.0f;
|
||||
bone.UpdateSkinTransform();
|
||||
@@ -1759,6 +1760,7 @@ namespace CodeWalker.GameFiles
|
||||
public Matrix AnimTransform;//absolute world transform, animated
|
||||
public Matrix BindTransformInv;//inverse of bind pose transform
|
||||
public Matrix SkinTransform;//transform to use for skin meshes
|
||||
public Matrix AbsTransform;//original absolute transform from loaded file, calculated from bones hierarchy
|
||||
public Vector4 TransformUnk { get; set; } //unknown value (column 4) from skeleton's transform array, used for IO purposes
|
||||
|
||||
public override void Read(ResourceDataReader reader, params object[] parameters)
|
||||
|
||||
Reference in New Issue
Block a user