We're actually rendering models in the mission now (badly)

This commit is contained in:
Jarrod Doyle 2024-08-24 17:36:32 +01:00
parent de4f3d6381
commit cb2f016455
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 21 additions and 6 deletions

View File

@ -94,6 +94,7 @@ public partial class Mission : Node3D
{
ClearMap();
// TODO: This shouldn't be set for things that aren't actually FMs
var fmName = FileName.GetBaseDir().GetFile();
_textureLoader = new TextureLoader(fmName);
_file = new(FileName);
@ -209,12 +210,26 @@ public partial class Mission : Node3D
continue;
}
// Let's try and place an object :)
var fmName = FileName.GetBaseDir().GetFile();
var objPath = _installPaths.GetObjectPath(fmName, modelName + ".bin");
objPath ??= _installPaths.GetObjectPath(modelName + ".bin");
var pos = brush.position.ToGodotVec3();
var cube = new CsgBox3D
var model = new Model();
model.Position = pos;
if (objPath != null)
{
Position = pos
};
AddChild(cube);
model.BuildModel("", objPath);
}
AddChild(model);
// var pos = brush.position.ToGodotVec3();
// var cube = new CsgBox3D
// {
// Position = pos
// };
// AddChild(cube);
}
}

View File

@ -14,7 +14,7 @@ public partial class Model : Node3D
modelSelector.LoadModel += BuildModel;
}
private void BuildModel(string rootPath, string modelPath)
public void BuildModel(string rootPath, string modelPath)
{
foreach (var node in GetChildren())
{
@ -28,7 +28,7 @@ public partial class Model : Node3D
return;
}
// TODO: Remove this disgusting hack
// TODO: Remove this disgusting hack. Not only is it a hack, it doesn't support custom models
var baseDir = ProjectSettings.GlobalizePath($"user://objects/tmp");
var options = new EnumerationOptions
{