using Godot; // Dev tool (not shipped gameplay): renders a few overview screenshots of the playground to // user-supplied paths. godot-mono --path . tools/playground_shots.tscn -- public partial class PlaygroundShots : Node3D { private int _frame; private int _shot; private Camera3D _cam; private string _dir = "user://"; private readonly (Vector3 Pos, Vector3 Look)[] _views = { (new Vector3(0f, 9f, 14f), new Vector3(0f, 0f, -1f)), (new Vector3(3f, 4f, 3f), new Vector3(9f, 1f, -4f)), (new Vector3(-2f, 3.5f, 4f), new Vector3(-7f, 1f, -1f)), (new Vector3(0f, 2.5f, 11f), new Vector3(1f, 0.6f, 7f)), // The crag: from spawn eye height, from the side, the route up close, looking down from the summit. (new Vector3(0f, 1.7f, 2.5f), new Vector3(-1f, 9f, -14f)), (new Vector3(22f, 14f, 4f), new Vector3(0f, 12f, -16f)), (new Vector3(-1f, 12f, -6f), new Vector3(-1f, 12f, -15f)), (new Vector3(-0.8f, 27.7f, -16.4f), new Vector3(1.5f, 0f, -6f)), }; public override void _Ready() { foreach (string a in OS.GetCmdlineUserArgs()) _dir = a; AddChild(new DirectionalLight3D { DirectionalShadowMaxDistance = 60f, RotationDegrees = new Vector3(-50f, -30f, 0f), ShadowEnabled = true }); AddChild(new WorldEnvironment { Environment = new Environment { BackgroundMode = Environment.BGMode.Color, BackgroundColor = new Color(0.55f, 0.65f, 0.8f), AmbientLightSource = Environment.AmbientSource.Color, AmbientLightColor = new Color(0.5f, 0.5f, 0.55f) } }); StaticBody3D floor = new(); floor.AddChild(new CollisionShape3D { Shape = new BoxShape3D { Size = new Vector3(80, 0.1f, 80) }, Position = new Vector3(0, -0.05f, 0) }); floor.AddChild(new MeshInstance3D { Mesh = new PlaneMesh { Size = new Vector2(80, 80) } }); AddChild(floor); AddChild(new Playground()); AddChild(new Crag()); _cam = new Camera3D { Current = true }; AddChild(_cam); SetView(); } private void SetView() => _cam.LookAtFromPosition(_views[_shot].Pos, _views[_shot].Look); public override void _Process(double delta) { if (++_frame < 30) return; GetViewport().GetTexture().GetImage().SavePng($"{_dir}/view{_shot}.png"); _frame = 0; if (++_shot >= _views.Length) { GetTree().Quit(); return; } SetView(); } }