diff --git a/project/code/TMV/Model.cs b/project/code/TMV/Model.cs index bbff099..6bd182a 100644 --- a/project/code/TMV/Model.cs +++ b/project/code/TMV/Model.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.IO; using Godot; using Godot.Collections; using KeepersCompound.LGS; @@ -27,6 +28,23 @@ public partial class Model : Node3D GD.Print("UH OH"); } + // TODO: Remove this disgusting hack + var baseDir = ProjectSettings.GlobalizePath($"user://objects/tmp"); + var options = new EnumerationOptions + { + MatchCasing = MatchCasing.CaseInsensitive, + RecurseSubdirectories = true, + }; + foreach (var material in modelFile.Materials) + { + var paths = Directory.GetFiles(baseDir, material.Name, options); + if (paths.IsEmpty()) continue; + + var texture = TextureLoader.LoadTexture(paths[0]); + var saveName = material.Name.GetBaseName() + ".png"; + texture.GetImage().SavePng(ProjectSettings.GlobalizePath($"user://debug/{saveName}")); + } + var vertices = new List(); var indices = new List();