Add basic model material texture output
This commit is contained in:
parent
d9a54b65d5
commit
8a22defe17
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
using KeepersCompound.LGS;
|
using KeepersCompound.LGS;
|
||||||
|
@ -27,6 +28,23 @@ public partial class Model : Node3D
|
||||||
GD.Print("UH OH");
|
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<Vector3>();
|
var vertices = new List<Vector3>();
|
||||||
var indices = new List<int>();
|
var indices = new List<int>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue