From 59582bdfb83eafc71b08a6a12cb6236fcdf6fe4a Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sat, 7 Dec 2024 10:05:12 +0000 Subject: [PATCH] Initial basic sub object transformation --- project/code/TMV/ModelLoader.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/project/code/TMV/ModelLoader.cs b/project/code/TMV/ModelLoader.cs index 385a5af..efbe88a 100644 --- a/project/code/TMV/ModelLoader.cs +++ b/project/code/TMV/ModelLoader.cs @@ -49,6 +49,25 @@ public class ModelLoader GD.Print($"Failed to load model file: {modelPath}"); return null; } + + // Transform subobjs + // TODO: Traverse children properly + // TODO: Apply to normals + // TODO: Apply joints(??) + foreach (var subObj in modelFile.Objects) + { + if (subObj.Type == 0) + { + continue; + } + + for (var i = subObj.PointIdx; i < subObj.PointIdx + subObj.PointCount; i++) + { + var v = modelFile.Vertices[i]; + v = System.Numerics.Vector3.Transform(v, subObj.Transform); + modelFile.Vertices[i] = v; + } + } var materials = new List(); foreach (var material in modelFile.Materials)