32 lines
856 B
C#
32 lines
856 B
C#
using Godot;
|
|
using KeepersCompound.TMV.UI;
|
|
|
|
namespace KeepersCompound.TMV;
|
|
|
|
public partial class Model : Node3D
|
|
{
|
|
public override void _Ready()
|
|
{
|
|
var resourceSelector = GetNode<Control>("%ResourceSelector") as ResourceSelector;
|
|
resourceSelector.ResourceSelected += BuildModel;
|
|
}
|
|
|
|
public void BuildModel(string campaignName, string modelPath)
|
|
{
|
|
foreach (var node in GetChildren())
|
|
{
|
|
node.QueueFree();
|
|
}
|
|
|
|
Context.Instance.SetCampaign(campaignName);
|
|
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);
|
|
}
|
|
AddChild(model);
|
|
}
|
|
}
|