diff --git a/project.godot b/project.godot index 28f3478..f0c8898 100644 --- a/project.godot +++ b/project.godot @@ -8,6 +8,442 @@ config_version=4 +_global_script_classes=[ { +"base": "Reference", +"class": "IVAssetInitializer", +"language": "GDScript", +"path": "res://ivoyager/initializers/asset_initializer.gd" +}, { +"base": "Reference", +"class": "IVAsteroidGroup", +"language": "GDScript", +"path": "res://ivoyager/tree_refs/asteroid_group.gd" +}, { +"base": "Spatial", +"class": "IVBody", +"language": "GDScript", +"path": "res://ivoyager/tree_nodes/body.gd" +}, { +"base": "Reference", +"class": "IVBodyBuilder", +"language": "GDScript", +"path": "res://ivoyager/prog_builders/body_builder.gd" +}, { +"base": "Reference", +"class": "IVBodyList", +"language": "GDScript", +"path": "res://ivoyager/tree_refs/body_list.gd" +}, { +"base": "Reference", +"class": "IVCacheManager", +"language": "GDScript", +"path": "res://ivoyager/prog_refs/cache_manager.gd" +}, { +"base": "PopupPanel", +"class": "IVCachedItemsPopup", +"language": "GDScript", +"path": "res://ivoyager/gui_admin/cached_items_popup.gd" +}, { +"base": "Camera", +"class": "IVCamera", +"language": "GDScript", +"path": "res://ivoyager/tree_nodes/camera.gd" +}, { +"base": "Node", +"class": "IVCameraHandler", +"language": "GDScript", +"path": "res://ivoyager/prog_nodes/camera_handler.gd" +}, { +"base": "Reference", +"class": "IVComposition", +"language": "GDScript", +"path": "res://ivoyager/tree_refs/composition.gd" +}, { +"base": "Reference", +"class": "IVCompositionBuilder", +"language": "GDScript", +"path": "res://ivoyager/prog_builders/composition_builder.gd" +}, { +"base": "PopupPanel", +"class": "IVCreditsPopup", +"language": "GDScript", +"path": "res://ivoyager/gui_admin/credits_popup.gd" +}, { +"base": "Reference", +"class": "IVDebug", +"language": "GDScript", +"path": "res://ivoyager/static/debug.gd" +}, { +"base": "Reference", +"class": "IVEnums", +"language": "GDScript", +"path": "res://ivoyager/static/enums.gd" +}, { +"base": "Reference", +"class": "IVEnvironmentBuilder", +"language": "GDScript", +"path": "res://ivoyager/prog_builders/environment_builder.gd" +}, { +"base": "Reference", +"class": "IVFiles", +"language": "GDScript", +"path": "res://ivoyager/static/files.gd" +}, { +"base": "Reference", +"class": "IVFontManager", +"language": "GDScript", +"path": "res://ivoyager/prog_refs/font_manager.gd" +}, { +"base": "Label", +"class": "IVHUDLabel", +"language": "GDScript", +"path": "res://ivoyager/tree_nodes/hud_label.gd" +}, { +"base": "MeshInstance", +"class": "IVHUDOrbit", +"language": "GDScript", +"path": "res://ivoyager/tree_nodes/hud_orbit.gd" +}, { +"base": "MeshInstance", +"class": "IVHUDPoints", +"language": "GDScript", +"path": "res://ivoyager/tree_nodes/hud_points.gd" +}, { +"base": "Reference", +"class": "IVHUDsBuilder", +"language": "GDScript", +"path": "res://ivoyager/prog_builders/huds_builder.gd" +}, { +"base": "Node", +"class": "IVHUDsManager", +"language": "GDScript", +"path": "res://ivoyager/prog_nodes/huds_manager.gd" +}, { +"base": "IVCachedItemsPopup", +"class": "IVHotkeysPopup", +"language": "GDScript", +"path": "res://ivoyager/gui_admin/hotkeys_popup.gd" +}, { +"base": "Reference", +"class": "IVIOManager", +"language": "GDScript", +"path": "res://ivoyager/prog_refs/io_manager.gd" +}, { +"base": "IVCacheManager", +"class": "IVInputMapManager", +"language": "GDScript", +"path": "res://ivoyager/prog_refs/input_map_manager.gd" +}, { +"base": "Spatial", +"class": "IVLPoint", +"language": "GDScript", +"path": "res://ivoyager/tree_nodes/l_point.gd" +}, { +"base": "Reference", +"class": "IVLagrangePointBuilder", +"language": "GDScript", +"path": "res://ivoyager/prog_builders/lagrange_point_builder.gd" +}, { +"base": "Reference", +"class": "IVLightBuilder", +"language": "GDScript", +"path": "res://ivoyager/prog_builders/light_builder.gd" +}, { +"base": "FileDialog", +"class": "IVLoadDialog", +"language": "GDScript", +"path": "res://ivoyager/gui_admin/load_dialog.gd" +}, { +"base": "Reference", +"class": "IVLogInitializer", +"language": "GDScript", +"path": "res://ivoyager/initializers/log_initializer.gd" +}, { +"base": "Reference", +"class": "IVMainMenuManager", +"language": "GDScript", +"path": "res://ivoyager/prog_refs/main_menu_manager.gd" +}, { +"base": "Popup", +"class": "IVMainMenuPopup", +"language": "GDScript", +"path": "res://ivoyager/gui_admin/main_menu_popup.gd" +}, { +"base": "ProgressBar", +"class": "IVMainProgBar", +"language": "GDScript", +"path": "res://ivoyager/gui_admin/main_prog_bar.gd" +}, { +"base": "Reference", +"class": "IVMath", +"language": "GDScript", +"path": "res://ivoyager/static/math.gd" +}, { +"base": "Reference", +"class": "IVMinorBodiesBuilder", +"language": "GDScript", +"path": "res://ivoyager/prog_builders/minor_bodies_builder.gd" +}, { +"base": "Node", +"class": "IVMinorBodiesManager", +"language": "GDScript", +"path": "res://ivoyager/prog_nodes/minor_bodies_manager.gd" +}, { +"base": "Reference", +"class": "IVModelBuilder", +"language": "GDScript", +"path": "res://ivoyager/prog_builders/model_builder.gd" +}, { +"base": "Reference", +"class": "IVModelController", +"language": "GDScript", +"path": "res://ivoyager/tree_refs/model_controller.gd" +}, { +"base": "ConfirmationDialog", +"class": "IVOneUseConfirm", +"language": "GDScript", +"path": "res://ivoyager/gui_admin/one_use_confirm.gd" +}, { +"base": "IVCachedItemsPopup", +"class": "IVOptionsPopup", +"language": "GDScript", +"path": "res://ivoyager/gui_admin/options_popup.gd" +}, { +"base": "Reference", +"class": "IVOrbit", +"language": "GDScript", +"path": "res://ivoyager/tree_refs/orbit.gd" +}, { +"base": "Reference", +"class": "IVOrbitBuilder", +"language": "GDScript", +"path": "res://ivoyager/prog_builders/orbit_builder.gd" +}, { +"base": "Node", +"class": "IVPointsManager", +"language": "GDScript", +"path": "res://ivoyager/prog_nodes/points_manager.gd" +}, { +"base": "Control", +"class": "IVProjectionSurface", +"language": "GDScript", +"path": "res://ivoyager/tree_nodes/projection_surface.gd" +}, { +"base": "Reference", +"class": "IVQuantityFormatter", +"language": "GDScript", +"path": "res://ivoyager/prog_refs/quantity_formatter.gd" +}, { +"base": "Reference", +"class": "IVRangeValue", +"language": "GDScript", +"path": "res://ivoyager/tree_refs/range_value.gd" +}, { +"base": "PopupPanel", +"class": "IVRichTextPopup", +"language": "GDScript", +"path": "res://ivoyager/gui_admin/rich_text_popup.gd" +}, { +"base": "Reference", +"class": "IVRingsBuilder", +"language": "GDScript", +"path": "res://ivoyager/prog_builders/rings_builder.gd" +}, { +"base": "Reference", +"class": "IVSaveBuilder", +"language": "GDScript", +"path": "res://ivoyager/prog_builders/save_builder.gd" +}, { +"base": "FileDialog", +"class": "IVSaveDialog", +"language": "GDScript", +"path": "res://ivoyager/gui_admin/save_dialog.gd" +}, { +"base": "Node", +"class": "IVSaveManager", +"language": "GDScript", +"path": "res://ivoyager/prog_nodes/save_manager.gd" +}, { +"base": "Node", +"class": "IVScheduler", +"language": "GDScript", +"path": "res://ivoyager/prog_nodes/scheduler.gd" +}, { +"base": "Reference", +"class": "IVSelection", +"language": "GDScript", +"path": "res://ivoyager/tree_refs/selection.gd" +}, { +"base": "Reference", +"class": "IVSelectionBuilder", +"language": "GDScript", +"path": "res://ivoyager/prog_builders/selection_builder.gd" +}, { +"base": "Node", +"class": "IVSelectionManager", +"language": "GDScript", +"path": "res://ivoyager/tree_nodes/selection_manager.gd" +}, { +"base": "IVCacheManager", +"class": "IVSettingsManager", +"language": "GDScript", +"path": "res://ivoyager/prog_refs/settings_manager.gd" +}, { +"base": "Reference", +"class": "IVSleepManager", +"language": "GDScript", +"path": "res://ivoyager/prog_refs/sleep_manager.gd" +}, { +"base": "Node", +"class": "IVStateManager", +"language": "GDScript", +"path": "res://ivoyager/prog_nodes/state_manager.gd" +}, { +"base": "Reference", +"class": "IVSystemBuilder", +"language": "GDScript", +"path": "res://ivoyager/prog_builders/system_builder.gd" +}, { +"base": "Reference", +"class": "IVTableImporter", +"language": "GDScript", +"path": "res://ivoyager/initializers/table_importer.gd" +}, { +"base": "Reference", +"class": "IVTableReader", +"language": "GDScript", +"path": "res://ivoyager/prog_refs/table_reader.gd" +}, { +"base": "Reference", +"class": "IVThemeManager", +"language": "GDScript", +"path": "res://ivoyager/prog_refs/theme_manager.gd" +}, { +"base": "Node", +"class": "IVTimekeeper", +"language": "GDScript", +"path": "res://ivoyager/prog_nodes/timekeeper.gd" +}, { +"base": "Reference", +"class": "IVTranslationImporter", +"language": "GDScript", +"path": "res://ivoyager/initializers/translation_importer.gd" +}, { +"base": "Reference", +"class": "IVUnits", +"language": "GDScript", +"path": "res://ivoyager/static/units.gd" +}, { +"base": "Reference", +"class": "IVUtils", +"language": "GDScript", +"path": "res://ivoyager/static/utils.gd" +}, { +"base": "Reference", +"class": "IVView", +"language": "GDScript", +"path": "res://ivoyager/tree_refs/view.gd" +}, { +"base": "Reference", +"class": "IVVisualsHelper", +"language": "GDScript", +"path": "res://ivoyager/prog_refs/visuals_helper.gd" +}, { +"base": "Reference", +"class": "IVWidgets", +"language": "GDScript", +"path": "res://ivoyager/static/widgets.gd" +}, { +"base": "Reference", +"class": "IVWikiInitializer", +"language": "GDScript", +"path": "res://ivoyager/initializers/wiki_initializer.gd" +}, { +"base": "Reference", +"class": "IVWikiManager", +"language": "GDScript", +"path": "res://ivoyager/prog_refs/wiki_manager.gd" +}, { +"base": "Node", +"class": "IVWindowManager", +"language": "GDScript", +"path": "res://ivoyager/prog_nodes/window_manager.gd" +} ] +_global_script_class_icons={ +"IVAssetInitializer": "", +"IVAsteroidGroup": "", +"IVBody": "", +"IVBodyBuilder": "", +"IVBodyList": "", +"IVCacheManager": "", +"IVCachedItemsPopup": "", +"IVCamera": "", +"IVCameraHandler": "", +"IVComposition": "", +"IVCompositionBuilder": "", +"IVCreditsPopup": "", +"IVDebug": "", +"IVEnums": "", +"IVEnvironmentBuilder": "", +"IVFiles": "", +"IVFontManager": "", +"IVHUDLabel": "", +"IVHUDOrbit": "", +"IVHUDPoints": "", +"IVHUDsBuilder": "", +"IVHUDsManager": "", +"IVHotkeysPopup": "", +"IVIOManager": "", +"IVInputMapManager": "", +"IVLPoint": "", +"IVLagrangePointBuilder": "", +"IVLightBuilder": "", +"IVLoadDialog": "", +"IVLogInitializer": "", +"IVMainMenuManager": "", +"IVMainMenuPopup": "", +"IVMainProgBar": "", +"IVMath": "", +"IVMinorBodiesBuilder": "", +"IVMinorBodiesManager": "", +"IVModelBuilder": "", +"IVModelController": "", +"IVOneUseConfirm": "", +"IVOptionsPopup": "", +"IVOrbit": "", +"IVOrbitBuilder": "", +"IVPointsManager": "", +"IVProjectionSurface": "", +"IVQuantityFormatter": "", +"IVRangeValue": "", +"IVRichTextPopup": "", +"IVRingsBuilder": "", +"IVSaveBuilder": "", +"IVSaveDialog": "", +"IVSaveManager": "", +"IVScheduler": "", +"IVSelection": "", +"IVSelectionBuilder": "", +"IVSelectionManager": "", +"IVSettingsManager": "", +"IVSleepManager": "", +"IVStateManager": "", +"IVSystemBuilder": "", +"IVTableImporter": "", +"IVTableReader": "", +"IVThemeManager": "", +"IVTimekeeper": "", +"IVTranslationImporter": "", +"IVUnits": "", +"IVUtils": "", +"IVView": "", +"IVVisualsHelper": "", +"IVWidgets": "", +"IVWikiInitializer": "", +"IVWikiManager": "", +"IVWindowManager": "" +} + [application] config/name="learnin" diff --git a/scenes/Main.tscn b/scenes/Main.tscn index 990a849..a269a98 100644 --- a/scenes/Main.tscn +++ b/scenes/Main.tscn @@ -1,19 +1,15 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=3 format=2] -[ext_resource path="res://scenes/Train.tscn" type="PackedScene" id=1] -[ext_resource path="res://scenes/Railway.tscn" type="PackedScene" id=2] [ext_resource path="res://scenes/OrbitCamera.tscn" type="PackedScene" id=3] +[ext_resource path="res://scenes/OrbitSystem.tscn" type="PackedScene" id=4] [node name="Main" type="Node2D"] [node name="DirectionalLight" type="DirectionalLight" parent="."] transform = Transform( 0.515898, 0.606099, -0.605386, -0.393123, 0.795389, 0.461314, 0.76112, -2.26831e-08, 0.648611, 0, 0, 0 ) +visible = false -[node name="OrbitCamera" parent="." instance=ExtResource( 3 )] +[node name="Camera" parent="." instance=ExtResource( 3 )] _speed = 0.5 -[node name="Railway" parent="." instance=ExtResource( 2 )] - -[node name="Train" parent="." instance=ExtResource( 1 )] -_speed = 5.0 -_railwayPath = NodePath("../Railway") +[node name="Orbit System" parent="." instance=ExtResource( 4 )] diff --git a/scripts/orbits/Orbit.cs b/scripts/orbits/Orbit.cs new file mode 100644 index 0000000..0aca13e --- /dev/null +++ b/scripts/orbits/Orbit.cs @@ -0,0 +1,12 @@ +using Godot; +using System; + +public class Orbit +{ + public Orbit(PointMass a, PointMass b) + { + + } + + // ellipse +} diff --git a/scripts/orbits/OrbitSystem.cs b/scripts/orbits/OrbitSystem.cs index 358ad53..12e2531 100644 --- a/scripts/orbits/OrbitSystem.cs +++ b/scripts/orbits/OrbitSystem.cs @@ -26,7 +26,9 @@ public class OrbitSystem : Node, IMassive, ILocation public float Mass { get; } = 1; - private ImmediateGeometry _orbit; + private Orbit _orbit; + + private ImmediateGeometry _orbitGeometry; public override void _Ready() { @@ -39,35 +41,40 @@ public class OrbitSystem : Node, IMassive, ILocation DrawOrbit(); } + private void InitOrbit() + { + + } + private void DrawOrbit() { int steps = 100; - _orbit.Clear(); - _orbit.Begin(Mesh.PrimitiveType.LineLoop); - _orbit.SetColor(new Color(1, 0, 0)); + _orbitGeometry.Clear(); + _orbitGeometry.Begin(Mesh.PrimitiveType.LineLoop); + _orbitGeometry.SetColor(new Color(1, 0, 0)); for (int i = 0; i < steps; i++) { float t = i / (float)steps; float a = t * Mathf.Tau; - _orbit.AddVertex(new Vector3 + _orbitGeometry.AddVertex(new Vector3 { x = Mathf.Sin(a), z = Mathf.Cos(a) }); } - _orbit.End(); + _orbitGeometry.End(); } private void InitGeometry() { - _orbit = new ImmediateGeometry(); + _orbitGeometry = new ImmediateGeometry(); var m = new SpatialMaterial(); m.VertexColorUseAsAlbedo = true; m.FlagsUnshaded = true; - _orbit.MaterialOverride = m; - AddChild(_orbit); + _orbitGeometry.MaterialOverride = m; + AddChild(_orbitGeometry); } private void InitPointMasses() diff --git a/scripts/orbits/Planet.cs b/scripts/orbits/Planet.cs index c93a33a..877455f 100644 --- a/scripts/orbits/Planet.cs +++ b/scripts/orbits/Planet.cs @@ -1,7 +1,7 @@ using Godot; using System; -public class Planet : Node +public class Planet : Node, IMassive { [Export] public float Mass { get; set; } diff --git a/scripts/orbits/PointMass.cs b/scripts/orbits/PointMass.cs index bb277c1..bbeaa14 100644 --- a/scripts/orbits/PointMass.cs +++ b/scripts/orbits/PointMass.cs @@ -1,6 +1,6 @@ using Godot; -struct PointMass : IMassive, ILocation +public struct PointMass : IMassive, ILocation { public float Mass => _massive == null ? _mass : _massive.Mass; public Vector3 Position => _spatial.Translation; diff --git a/scripts/orbits/math/Double2.cs b/scripts/orbits/math/Double2.cs new file mode 100644 index 0000000..942f746 --- /dev/null +++ b/scripts/orbits/math/Double2.cs @@ -0,0 +1,8 @@ +using Godot; +using System; + +public struct Double2 +{ + public double x; + public double y; +} \ No newline at end of file diff --git a/scripts/orbits/math/Ellipse.cs b/scripts/orbits/math/Ellipse.cs new file mode 100644 index 0000000..64751e7 --- /dev/null +++ b/scripts/orbits/math/Ellipse.cs @@ -0,0 +1,34 @@ +using Godot; +using System; + +public struct Ellipse +{ + public double a { get => SemiMajorAxis; set => SemiMajorAxis = value; } + public double SemiMajorAxis { get; set; } + + public double e { get => Eccentricity; set => Eccentricity = value; } + public double Eccentricity { get; set; } + + public double b => SemiMajorAxis; + public double SemiMinorAxis => Math.Sqrt(Apisides.max * Apisides.min); + + private Apisides Apisides => new Apisides(a, e); + + public Ellipse(double a = 1, double e = 0) + { + SemiMajorAxis = a; + Eccentricity = e; + } +} + +public struct Apisides +{ + public readonly double min; + public readonly double max; + + public Apisides(double a, double e) + { + min = a * (1 - e); + max = a * (1 + e); + } +} \ No newline at end of file