thief-mission-viewer/project/code/TMV/Model.cs

32 lines
856 B
C#
Raw Normal View History

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
}
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);
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);
2024-08-17 19:53:16 +00:00
}
}