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 Godot;
using KeepersCompound.LGS;
using Quaternion = System.Numerics.Quaternion;
namespace KeepersCompound.TMV;
@ -54,17 +55,27 @@ public class ModelLoader
// TODO: Traverse children properly
// TODO: Apply to normals
// TODO: Apply joints(??)
// TODO: Handle Slide joints
// !HACK: Hardcoded joint :))
var ang = float.DegreesToRadians(45);
foreach (var subObj in modelFile.Objects)
{
if (subObj.Type == 0)
{
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++)
{
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;
}
}