Apply dummy joint rotation

This commit is contained in:
Jarrod Doyle 2024-12-07 10:40:49 +00:00
parent 59582bdfb8
commit d83e020de0
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 12 additions and 1 deletions

View File

@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using Godot; using Godot;
using KeepersCompound.LGS; using KeepersCompound.LGS;
using Quaternion = System.Numerics.Quaternion;
namespace KeepersCompound.TMV; namespace KeepersCompound.TMV;
@ -54,6 +55,9 @@ public class ModelLoader
// TODO: Traverse children properly // TODO: Traverse children properly
// TODO: Apply to normals // TODO: Apply to normals
// TODO: Apply joints(??) // TODO: Apply joints(??)
// TODO: Handle Slide joints
// !HACK: Hardcoded joint :))
var ang = float.DegreesToRadians(45);
foreach (var subObj in modelFile.Objects) foreach (var subObj in modelFile.Objects)
{ {
if (subObj.Type == 0) if (subObj.Type == 0)
@ -61,10 +65,17 @@ public class ModelLoader
continue; continue;
} }
var translation = subObj.Transform.Translation;
var rotation = subObj.Transform;
rotation.Translation = System.Numerics.Vector3.Zero;
var jointRotation = Quaternion.CreateFromYawPitchRoll(0, ang, 0);
for (var i = subObj.PointIdx; i < subObj.PointIdx + subObj.PointCount; i++) for (var i = subObj.PointIdx; i < subObj.PointIdx + subObj.PointCount; i++)
{ {
var v = modelFile.Vertices[i]; var v = modelFile.Vertices[i];
v = System.Numerics.Vector3.Transform(v, subObj.Transform); v = System.Numerics.Vector3.Transform(v, jointRotation);
v = System.Numerics.Vector3.Transform(v, rotation);
v += translation;
modelFile.Vertices[i] = v; modelFile.Vertices[i] = v;
} }
} }