Four randomly generated star constellations
A Godot script to generate somewhat reasonable looking star constellations. This is a @tool script, when the script is attached to a Node2D constellations can be generated in the editor with the generate check-box or button. The base generator function returns a dictionary with all the generated data which can be used for further processing or rendering.
Note that the default placeholder textures require Godot 4.3 as the base function is different in older versions. In theory this can be fixed by replacing EditorInterface.get_base_control() with get_editor_interface().get_base_control(), however I have not tested this.
GDScript source code: Download
Generator Process Outline:
- Generate random points within area.
- Calculate new bounding box based on random point locations.
- Generate Gabriel graph of points.
- Remove longest links if certain conditions apply for each end node.
- Identify groups of connected stars using flood fill.
- Re-add shortest previously removed links if their removal significantly fragmented the constellation.
- Render in 2D using
Sprite2DandLine2D
