From 0c5085a7fa9d60c2350806023b9d29e842d12326 Mon Sep 17 00:00:00 2001 From: Aada Date: Mon, 2 Mar 2026 13:52:26 +0200 Subject: [PATCH] initial commit --- .editorconfig | 4 + .gitattributes | 42 ++ .gitignore | 3 + .idea/.idea.adatonic/.idea/.gitignore | 13 + .idea/.idea.adatonic/.idea/encodings.xml | 4 + .idea/.idea.adatonic/.idea/indexLayout.xml | 8 + Main.cs | 139 ++++ Main.cs.uid | 1 + MainScene.tscn | 199 ++++++ Oct.cs | 147 +++++ Oct.cs.uid | 1 + PlanetBase.glb | 3 + PlanetBase.glb.import | 54 ++ PlanetBase.obj | 3 + PlanetBase.obj.import | 25 + PlanetFormer.cs | 676 +++++++++++++++++++ PlanetFormer.cs.uid | 1 + PlanetGenerator.cs | 317 +++++++++ PlanetGenerator.cs.uid | 1 + PlanetHelper.cs | 734 +++++++++++++++++++++ PlanetHelper.cs.uid | 1 + PlanetLow.mtl | 2 + PlanetLow.obj | 3 + PlanetLow.obj.import | 25 + PlanetMed.obj | 3 + PlanetMed.obj.import | 25 + Projector.cs | 64 ++ Projector.cs.uid | 1 + World.cs | 65 ++ World.cs.uid | 1 + adatonic.csproj | 7 + adatonic.sln | 19 + adatonic.sln.DotSettings.user | 6 + icon.svg | 3 + icon.svg.import | 43 ++ icosphere.obj | 3 + icosphere.obj.import | 25 + map.gdshader | 23 + map.gdshader.uid | 1 + map.tres | 12 + planet.gdshader | 32 + planet.gdshader.uid | 1 + planet.tres | 13 + planet_gradient.tres | 5 + project.godot | 53 ++ simple_gradient.tres | 5 + sphere.tres | 18 + world.tscn | 49 ++ 48 files changed, 2883 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .idea/.idea.adatonic/.idea/.gitignore create mode 100644 .idea/.idea.adatonic/.idea/encodings.xml create mode 100644 .idea/.idea.adatonic/.idea/indexLayout.xml create mode 100644 Main.cs create mode 100644 Main.cs.uid create mode 100644 MainScene.tscn create mode 100644 Oct.cs create mode 100644 Oct.cs.uid create mode 100644 PlanetBase.glb create mode 100644 PlanetBase.glb.import create mode 100644 PlanetBase.obj create mode 100644 PlanetBase.obj.import create mode 100644 PlanetFormer.cs create mode 100644 PlanetFormer.cs.uid create mode 100644 PlanetGenerator.cs create mode 100644 PlanetGenerator.cs.uid create mode 100644 PlanetHelper.cs create mode 100644 PlanetHelper.cs.uid create mode 100644 PlanetLow.mtl create mode 100644 PlanetLow.obj create mode 100644 PlanetLow.obj.import create mode 100644 PlanetMed.obj create mode 100644 PlanetMed.obj.import create mode 100644 Projector.cs create mode 100644 Projector.cs.uid create mode 100644 World.cs create mode 100644 World.cs.uid create mode 100644 adatonic.csproj create mode 100644 adatonic.sln create mode 100644 adatonic.sln.DotSettings.user create mode 100644 icon.svg create mode 100644 icon.svg.import create mode 100644 icosphere.obj create mode 100644 icosphere.obj.import create mode 100644 map.gdshader create mode 100644 map.gdshader.uid create mode 100644 map.tres create mode 100644 planet.gdshader create mode 100644 planet.gdshader.uid create mode 100644 planet.tres create mode 100644 planet_gradient.tres create mode 100644 project.godot create mode 100644 simple_gradient.tres create mode 100644 sphere.tres create mode 100644 world.tscn diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f28239b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*] +charset = utf-8 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..7d826c8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,42 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf + +# Git LFS Tracking (Assets) + +# 3D Models +*.fbx filter=lfs diff=lfs merge=lfs -text +*.gltf filter=lfs diff=lfs merge=lfs -text +*.glb filter=lfs diff=lfs merge=lfs -text +*.blend filter=lfs diff=lfs merge=lfs -text +*.obj filter=lfs diff=lfs merge=lfs -text + +# Images +*.png filter=lfs diff=lfs merge=lfs -text +*.svg filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.gif filter=lfs diff=lfs merge=lfs -text +*.tga filter=lfs diff=lfs merge=lfs -text +*.webp filter=lfs diff=lfs merge=lfs -text +*.exr filter=lfs diff=lfs merge=lfs -text +*.hdr filter=lfs diff=lfs merge=lfs -text +*.dds filter=lfs diff=lfs merge=lfs -text + +# Audio +*.mp3 filter=lfs diff=lfs merge=lfs -text +*.wav filter=lfs diff=lfs merge=lfs -text +*.ogg filter=lfs diff=lfs merge=lfs -text + +# Font & Icon +*.ttf filter=lfs diff=lfs merge=lfs -text +*.otf filter=lfs diff=lfs merge=lfs -text +*.ico filter=lfs diff=lfs merge=lfs -text + +# Godot LFS Specific +*.scn filter=lfs diff=lfs merge=lfs -text +*.res filter=lfs diff=lfs merge=lfs -text +*.material filter=lfs diff=lfs merge=lfs -text +*.anim filter=lfs diff=lfs merge=lfs -text +*.mesh filter=lfs diff=lfs merge=lfs -text +*.lmbake filter=lfs diff=lfs merge=lfs -text + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0af181c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Godot 4+ specific ignores +.godot/ +/android/ diff --git a/.idea/.idea.adatonic/.idea/.gitignore b/.idea/.idea.adatonic/.idea/.gitignore new file mode 100644 index 0000000..ca5d0e9 --- /dev/null +++ b/.idea/.idea.adatonic/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/projectSettingsUpdater.xml +/contentModel.xml +/.idea.adatonic.iml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.adatonic/.idea/encodings.xml b/.idea/.idea.adatonic/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.adatonic/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.adatonic/.idea/indexLayout.xml b/.idea/.idea.adatonic/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.adatonic/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Main.cs b/Main.cs new file mode 100644 index 0000000..6a0b529 --- /dev/null +++ b/Main.cs @@ -0,0 +1,139 @@ +#nullable enable +using Godot; +using System; +using System.Globalization; +using System.Linq; +using Godot.Collections; + +public partial class Main : Control +{ + private bool _moving = false; + [Export] + private Node3D _yawNode; + [Export] + private Node3D _pitchNode; + [Export] + private Camera3D _cameraNode; + + [Export] private float _moveSensitivity = 1f/500f; + [Export] private float _zoomSensitivity = 1f; + + [Export] private MeshInstance3D _meshInstance; + [Export] private Node3D World; + [Export] private TextureRect _textureRect; + + private PlanetHelper.VertexData? _vertex = null; + private PlanetHelper.PlateData? _plate = null; + + private PlanetHelper _planetHelper; + public override void _Ready() + { + _planetHelper = new PlanetHelper(_meshInstance, _textureRect); + UpdateStats(); + } + + private const float RayLength = 1000.0f; + public override void _Input(InputEvent @event) + { + if (@event is InputEventMouseButton mouseEvent) + { + if (mouseEvent.ButtonIndex == MouseButton.Left) + { + _moving = mouseEvent.Pressed; + } + if (mouseEvent.ButtonIndex == MouseButton.WheelUp) + { + _cameraNode.Position += new Vector3(0, 0, _zoomSensitivity); + } + + if (mouseEvent.ButtonIndex == MouseButton.WheelDown) + { + _cameraNode.Position -= new Vector3(0, 0, _zoomSensitivity); + } + } + else if (@event is InputEventMouseMotion motionEvent && _moving) + { + _yawNode.RotateY(-motionEvent.ScreenRelative.X * _moveSensitivity); + _pitchNode.RotateX(-motionEvent.ScreenRelative.Y * _moveSensitivity); + } + } + + public void Tab(int tab) + { + if (tab == 1) + { + Projector.GatherPoints(_planetHelper); + _textureRect.Texture = Projector.Render(_planetHelper); + } + } + + public override void _Process(double delta) + { + if (Input.IsActionJustPressed("mouse_secondary")) + { + var from = _cameraNode.ProjectRayOrigin(GetViewport().GetMousePosition()); + var to = from + _cameraNode.ProjectRayNormal(GetViewport().GetMousePosition()) * RayLength; + var result = World.GetWorld3D().DirectSpaceState.IntersectRay(PhysicsRayQueryParameters3D.Create(from, to)); + if (result.Count > 0) + { + Vector3? pos = result["position"].AsVector3(); + if (pos != null) + { + GD.Print($"Hit: '{pos}'"); + var closest = _planetHelper.Octree.SearchNearest(pos ?? Vector3.Zero)?.Id; + if (closest != null) + { + _vertex = _planetHelper.Vertices.Single(v => v.Id == closest); + if (_planetHelper.Plates.Count > 0 && _vertex.PlateId != -1) + _plate = _planetHelper.Plates[_vertex.PlateId]; + else + _plate = null; + UpdateStats(); + } + } + } + } + + if (Input.IsActionJustPressed("spacebar")) + { + _planetHelper.Advance = true; + } + if (Input.IsActionJustPressed("enter")) + { + _planetHelper.AutoRun = true; + } + _planetHelper.Process(); + } + public void UpdateStats() + { + if (_vertex != null) + { + var height = -9000f * (0.5f - _vertex.Height) * 2f; + GetNode