From 633c8e3ca79df343861da15080176f3f2c1ec2f9 Mon Sep 17 00:00:00 2001 From: ktyl Date: Thu, 4 Aug 2022 21:20:29 +0100 Subject: [PATCH] initial commit --- .gitignore | 11 +++++++++ .vscode/launch.json | 46 ++++++++++++++++++++++++++++++++++ .vscode/tasks.json | 18 ++++++++++++++ default_env.tres | 7 ++++++ icon.png | Bin 0 -> 3305 bytes icon.png.import | 35 ++++++++++++++++++++++++++ learnin.csproj | 5 ++++ learnin.sln | 19 ++++++++++++++ project.godot | 27 ++++++++++++++++++++ scenes/Main.tscn | 18 ++++++++++++++ scenes/OrbitCamera.tscn | 9 +++++++ scenes/RailNode.tscn | 22 +++++++++++++++++ scenes/Railway.tscn | 23 +++++++++++++++++ scenes/Train.tscn | 12 +++++++++ scripts/OrbitCamera.cs | 18 ++++++++++++++ scripts/Railway.cs | 53 ++++++++++++++++++++++++++++++++++++++++ scripts/Tracks.cs | 22 +++++++++++++++++ scripts/Train.cs | 16 ++++++++++++ 18 files changed, 361 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 default_env.tres create mode 100644 icon.png create mode 100644 icon.png.import create mode 100644 learnin.csproj create mode 100644 learnin.sln create mode 100644 project.godot create mode 100644 scenes/Main.tscn create mode 100644 scenes/OrbitCamera.tscn create mode 100644 scenes/RailNode.tscn create mode 100644 scenes/Railway.tscn create mode 100644 scenes/Train.tscn create mode 100644 scripts/OrbitCamera.cs create mode 100644 scripts/Railway.cs create mode 100644 scripts/Tracks.cs create mode 100644 scripts/Train.cs 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 0000000000000000000000000000000000000000..c98fbb601c83c81ec8c22b1dba7d1d57c62b323c GIT binary patch literal 3305 zcmVNc=P)Px>qe(&U$es`gSqKCHF-lq>v1vga#%UF>TTrLR zW%{UNJKZi|Pj@Rc9GyPBD1CamMMf6SL~V^ag9~Vzut^L^0!Tv0LK0FTdnJ`x->EF(MZ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zO^*g(+T?Hq0n%ebkyIin(R#FM6&9;^6WJU5R)By&tZQ6PV zS^MWhqtcj}7)kON#>?4Gv(K#2=6mv)5;@W->l(1q*>9t&xfesIn$&3j4WxkffXaq0 zwwBkAD2vjoi4E8CK;cwoC3#wO!|}v-XOJ`obIo05{&DMQIRyHAd5@%-0xA%uA0UK2qng>xb(kvMzX)7t^ z);-|T`mgSsHKM$+a{!w|Mt5QLwD>sA+;u-+k%z_ZL?el$#&|kX?ygLfm zxZ^Fo^bOhx)w*6In?vS{Q|uk08cKRK}t+0ukQSCOyP$^HEC+zzX51M#=e-?*xHWMDRcLdIV41daHy{HimwDo z6!_O=*(}MK!YeyJpmgu(cF1tpEv}m;0s8{4z4HlHyMxDncn8zs!g+OXEk`CeEj}9N zq#Ag1$#jyV_5AjYQg*!mS->;`S^;iU)ih9D+eks)H2z`1RHny;F<^CEwk+}d^k^Ph zl);*XQ|ayL;rZWh=fA(G2#AJz1&r&as9I8S@9m3Owftrb5n*)pTluK^9LHOFIo{G2 zG}l$9R*{<+L2hCsOJ~Lt6Q-rRub*8X{*4{)e}>%=_&DxOFeq1LRia4Yyj*Tyynw>F zxkKf(MiaG0*L|V-^Zhtvg-(-|F0&1rU8bqab*n5TT8~C860O$|6Rt%P1=1(EjIQZ% z;Y^PU2VC*~^2!sG?mbBPS0~0yd-+086)+rHjhfk6>CB$t`o%;=kdYF9NwiKkwbIpN z;_FlOuHQHHSZ&@fUuSI-S*t`DjsiIB z{=1M@JKVC$a8z{2;xCPfRb{~T>uo#5rL4L+z9n`rSUt3Tt nAZ`TZm+q1gPVN84&*%Ra7her>#-hHS00000NkvXXu0mjf|6N@O literal 0 HcmV?d00001 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) +// { +// +// } +}