2024-08-17 19:53:16 +00:00
|
|
|
using Godot;
|
|
|
|
using KeepersCompound.TMV.UI;
|
|
|
|
|
|
|
|
namespace KeepersCompound.TMV;
|
|
|
|
|
|
|
|
public partial class Model : Node3D
|
|
|
|
{
|
|
|
|
public override void _Ready()
|
|
|
|
{
|
2024-09-05 18:44:19 +00:00
|
|
|
var resourceSelector = GetNode<Control>("%ResourceSelector") as ResourceSelector;
|
|
|
|
resourceSelector.ResourceSelected += BuildModel;
|
2024-08-17 19:53:16 +00:00
|
|
|
}
|
|
|
|
|
2024-09-05 16:32:29 +00:00
|
|
|
public void BuildModel(string campaignName, string modelPath)
|
2024-08-17 19:53:16 +00:00
|
|
|
{
|
|
|
|
foreach (var node in GetChildren())
|
|
|
|
{
|
|
|
|
node.QueueFree();
|
|
|
|
}
|
|
|
|
|
2024-09-19 20:16:07 +00:00
|
|
|
Context.Instance.SetCampaign(campaignName);
|
2024-12-07 12:39:25 +00:00
|
|
|
var model = new Node3D();
|
|
|
|
var meshDetails = Context.Instance.ModelLoader.Load(modelPath);
|
|
|
|
var meshes = ModelLoader.TransformMeshes([0, 0, 0, 0, 0, 0], meshDetails);
|
|
|
|
foreach (var meshInstance in meshes)
|
|
|
|
{
|
|
|
|
model.AddChild(meshInstance);
|
|
|
|
}
|
2024-09-05 16:32:29 +00:00
|
|
|
AddChild(model);
|
2024-08-17 19:53:16 +00:00
|
|
|
}
|
|
|
|
}
|