diff --git a/src/Engine.AI/AiCommandProcessor.cs b/src/Engine.AI/AiCommandProcessor.cs index 832430e..1ee1425 100644 --- a/src/Engine.AI/AiCommandProcessor.cs +++ b/src/Engine.AI/AiCommandProcessor.cs @@ -83,6 +83,13 @@ public sealed class AiCommandProcessor .Set(new Transform(command.Position, command.Rotation, command.Scale)) .Set(mesh); + if (command.Physics) + { + var maxScale = MathF.Max(MathF.Max(command.Scale.X, command.Scale.Y), command.Scale.Z); + var rb = RigidBody.DynamicBox(new Vector3(maxScale * 0.5f), mass: maxScale * 2f); + entity.Set(rb); + } + return AiCommandResult.Ok($"Spawned entity '{command.Name}' with model '{command.ModelPath}' (id {(ulong)entity.Id})."); } diff --git a/src/Engine.AI/Commands/SpawnModelCommand.cs b/src/Engine.AI/Commands/SpawnModelCommand.cs index 310d217..c7cc5f6 100644 --- a/src/Engine.AI/Commands/SpawnModelCommand.cs +++ b/src/Engine.AI/Commands/SpawnModelCommand.cs @@ -12,4 +12,5 @@ public sealed record SpawnModelCommand : AiCommand public Vector3 Position { get; init; } = Vector3.Zero; public Quaternion Rotation { get; init; } = Quaternion.Identity; public Vector3 Scale { get; init; } = Vector3.One; + public bool Physics { get; init; } = false; } diff --git a/src/Engine.AI/Mcp/EngineMcpTools.cs b/src/Engine.AI/Mcp/EngineMcpTools.cs index d979c34..c2c151d 100644 --- a/src/Engine.AI/Mcp/EngineMcpTools.cs +++ b/src/Engine.AI/Mcp/EngineMcpTools.cs @@ -24,7 +24,8 @@ public sealed class EngineMcpTools string modelPath, [Description("Optional position as [x, y, z] (default: 0,0,0)")] IReadOnlyList? position = null, [Description("Optional rotation as [x, y, z, w] quaternion (default: identity)")] IReadOnlyList? rotation = null, - [Description("Optional scale as [x, y, z] (default: 1,1,1)")] IReadOnlyList? scale = null) + [Description("Optional scale as [x, y, z] (default: 1,1,1)")] IReadOnlyList? scale = null, + [Description("Optional: enable physics (default: false)")] bool physics = false) { var cmd = new SpawnModelCommand { @@ -32,7 +33,8 @@ public sealed class EngineMcpTools ModelPath = modelPath, Position = ToVector3(position, Vector3.Zero), Rotation = ToQuaternion(rotation, Quaternion.Identity), - Scale = ToVector3(scale, Vector3.One) + Scale = ToVector3(scale, Vector3.One), + Physics = physics }; return EnqueueAndReturnMessage(cmd);