commit 633c8e3ca79df343861da15080176f3f2c1ec2f9 Author: ktyl Date: Thu Aug 4 21:20:29 2022 +0100 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4f48ad7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# Godot-specific ignores +.import/ +export.cfg +export_presets.cfg + +# Imported translations (automatically generated from CSV files) +*.translation + +# Mono-specific ignores +.mono/ +data_*/ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..4fe87b7 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,46 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Play in Editor", + "type": "godot-mono", + "mode": "playInEditor", + "request": "launch" + }, + { + "name": "Launch", + "type": "godot-mono", + "request": "launch", + "mode": "executable", + "preLaunchTask": "build", + "executable": "/usr/bin/godot-mono", + "executableArguments": [ + "--path", + "${workspaceRoot}" + ] + }, + { + "name": "Launch (Select Scene)", + "type": "godot-mono", + "request": "launch", + "mode": "executable", + "preLaunchTask": "build", + "executable": "/usr/bin/godot-mono", + "executableArguments": [ + "--path", + "${workspaceRoot}", + "${command:SelectLaunchScene}" + ] + }, + { + "name": "Attach", + "type": "godot-mono", + "request": "attach", + "address": "localhost", + "port": 23685 + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..4da57c2 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,18 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "/usr/bin/godot-mono", + "type": "process", + "args": [ + "--build-solutions", + "--path", + "${workspaceRoot}", + "--no-window", + "-q" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/default_env.tres b/default_env.tres new file mode 100644 index 0000000..20207a4 --- /dev/null +++ b/default_env.tres @@ -0,0 +1,7 @@ +[gd_resource type="Environment" load_steps=2 format=2] + +[sub_resource type="ProceduralSky" id=1] + +[resource] +background_mode = 2 +background_sky = SubResource( 1 ) diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..c98fbb6 Binary files /dev/null and b/icon.png differ diff --git a/icon.png.import b/icon.png.import new file mode 100644 index 0000000..a4c02e6 --- /dev/null +++ b/icon.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/learnin.csproj b/learnin.csproj new file mode 100644 index 0000000..db88a8d --- /dev/null +++ b/learnin.csproj @@ -0,0 +1,5 @@ + + + net472 + + \ No newline at end of file diff --git a/learnin.sln b/learnin.sln new file mode 100644 index 0000000..4bf696c --- /dev/null +++ b/learnin.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "learnin", "learnin.csproj", "{99680112-79F2-4DCB-AC6B-3C08793C23FF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + ExportDebug|Any CPU = ExportDebug|Any CPU + ExportRelease|Any CPU = ExportRelease|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {99680112-79F2-4DCB-AC6B-3C08793C23FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {99680112-79F2-4DCB-AC6B-3C08793C23FF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {99680112-79F2-4DCB-AC6B-3C08793C23FF}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {99680112-79F2-4DCB-AC6B-3C08793C23FF}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {99680112-79F2-4DCB-AC6B-3C08793C23FF}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {99680112-79F2-4DCB-AC6B-3C08793C23FF}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + EndGlobalSection +EndGlobal diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..28f3478 --- /dev/null +++ b/project.godot @@ -0,0 +1,27 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +[application] + +config/name="learnin" +run/main_scene="res://scenes/Main.tscn" +config/icon="res://icon.png" + +[global] + +mono=true + +[physics] + +common/enable_pause_aware_picking=true + +[rendering] + +environment/default_environment="res://default_env.tres" diff --git a/scenes/Main.tscn b/scenes/Main.tscn new file mode 100644 index 0000000..beccb33 --- /dev/null +++ b/scenes/Main.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=4 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] + +[node name="Main" type="Node2D"] + +[node name="Train" parent="." instance=ExtResource( 1 )] + +[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 ) + +[node name="OrbitCamera" parent="." instance=ExtResource( 3 )] +_speed = 1.0 + +[node name="Railway" parent="." instance=ExtResource( 2 )] +script = null diff --git a/scenes/OrbitCamera.tscn b/scenes/OrbitCamera.tscn new file mode 100644 index 0000000..c9e0d8f --- /dev/null +++ b/scenes/OrbitCamera.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scripts/OrbitCamera.cs" type="Script" id=1] + +[node name="OrbitCamera" type="Spatial"] +script = ExtResource( 1 ) + +[node name="Camera" type="Camera" parent="."] +transform = Transform( 0.636065, -0.249781, 0.73009, 0, 0.946159, 0.323703, -0.771636, -0.205896, 0.601818, 8.49012, 5.30069, 6.71091 ) diff --git a/scenes/RailNode.tscn b/scenes/RailNode.tscn new file mode 100644 index 0000000..6d7e870 --- /dev/null +++ b/scenes/RailNode.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=2 format=2] + +[sub_resource type="CSharpScript" id=1] +script/source = "using Godot; +using System; + +public class RailNode : Spatial +{ + public override void _Ready() + { + + } + +// public override void _Process(float delta) +// { +// +// } +} +" + +[node name="Spatial" type="Spatial"] +script = SubResource( 1 ) diff --git a/scenes/Railway.tscn b/scenes/Railway.tscn new file mode 100644 index 0000000..730def8 --- /dev/null +++ b/scenes/Railway.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://scripts/Railway.cs" type="Script" id=1] + +[sub_resource type="Curve3D" id=1] +_data = { +"points": PoolVector3Array( 0, 0, 0, 0, 0, 0, 8.10688, -1.81506, 7.57791, 0, 0, 0, 0, 0, 0, -4.46766, -3.67929, 0.175438, 0, 0, 0, 0, 0, 0, -6.79476, 2.00362, -6.79993, 0, 0, 0, 0, 0, 0, 5.56111, 6.33345, -1.84912, 0, 0, 0, 0, 0, 0, 11.2517, 3.50708, 4.91382, 0, 0, 0, 0, 0, 0, 14.9168, -0.251479, 11.0718 ), +"tilts": PoolRealArray( 0, 0, 0, 0, 0, 0 ) +} + +[sub_resource type="SpatialMaterial" id=2] +flags_unshaded = true +vertex_color_use_as_albedo = true + +[node name="Railway" type="Path"] +curve = SubResource( 1 ) +script = ExtResource( 1 ) +_color = Color( 0, 1, 0.133333, 1 ) + +[node name="ImmediateGeometry" type="ImmediateGeometry" parent="."] +material_override = SubResource( 2 ) + +[connection signal="curve_changed" from="." to="." method="OnPathCurveChanged"] diff --git a/scenes/Train.tscn b/scenes/Train.tscn new file mode 100644 index 0000000..265da53 --- /dev/null +++ b/scenes/Train.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scripts/Train.cs" type="Script" id=1] + +[node name="Train" type="Node"] +script = ExtResource( 1 ) + +[node name="CSGBox" type="CSGBox" parent="."] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0 ) +width = 1.0 +height = 1.0 +depth = 4.0 diff --git a/scripts/OrbitCamera.cs b/scripts/OrbitCamera.cs new file mode 100644 index 0000000..2aa7677 --- /dev/null +++ b/scripts/OrbitCamera.cs @@ -0,0 +1,18 @@ +using Godot; +using System; + +public class OrbitCamera : Spatial +{ + [Export] + private float _speed; + + public override void _Ready() + { + + } + + public override void _Process(float delta) + { + Rotate(Vector3.Up, _speed * delta); + } +} diff --git a/scripts/Railway.cs b/scripts/Railway.cs new file mode 100644 index 0000000..c52a75e --- /dev/null +++ b/scripts/Railway.cs @@ -0,0 +1,53 @@ +using Godot; +using System; + +[Tool] +public class Railway : Path +{ + [Export] + private Color _color; + + [Export] + private float _gauge = 1f; + + private ImmediateGeometry _geo = null; + private Vector3[] _points = null; + + public void OnPathCurveChanged() + { + Curve.Tessellate(); + _points = Curve.GetBakedPoints(); + } + + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + base._Ready(); + + _geo = GetNode("ImmediateGeometry"); + + var m = new SpatialMaterial(); + m.VertexColorUseAsAlbedo = true; + m.FlagsUnshaded = true; + _geo.MaterialOverride = m; + + OnPathCurveChanged(); + } + + public override void _Process(float delta) + { + base._Process(delta); + + if (_geo == null) return; + if (_points == null || _points.Length == 0) return; + + _geo.Clear(); + _geo.Begin(Mesh.PrimitiveType.LineStrip); + _geo.SetColor(new Color(1, 0, 0)); + for(int i = 0; i < _points.Length; i++) + { + _geo.AddVertex(_points[i]); + } + _geo.End(); + } +} diff --git a/scripts/Tracks.cs b/scripts/Tracks.cs new file mode 100644 index 0000000..27593a2 --- /dev/null +++ b/scripts/Tracks.cs @@ -0,0 +1,22 @@ +using Godot; +using System; + +[Tool] +public class Tracks : ImmediateGeometry +{ + private SpatialMaterial _m; + + public override void _Ready() + { + // set up a material for imgui to use + _m = new SpatialMaterial(); + _m.VertexColorUseAsAlbedo = true; + _m.FlagsUnshaded = true; + this.MaterialOverride = _m; + } + + public override void _Process(float delta) + { + GD.Print("hi!"); + } +} diff --git a/scripts/Train.cs b/scripts/Train.cs new file mode 100644 index 0000000..dd405a1 --- /dev/null +++ b/scripts/Train.cs @@ -0,0 +1,16 @@ +using Godot; +using System; + +public class Train : Node +{ + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + } + +// // Called every frame. 'delta' is the elapsed time since the previous frame. +// public override void _Process(float delta) +// { +// +// } +}