diff --git a/.gitattributes b/.gitattributes index 55cab133643a2a73e083373d2106533678d0edd5..f5ece5afb7aa08fd9eb9c83947a77fb85be1b765 100644 --- a/.gitattributes +++ b/.gitattributes @@ -56,3 +56,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text # Video files - compressed *.mp4 filter=lfs diff=lfs merge=lfs -text *.webm filter=lfs diff=lfs merge=lfs -text +alps_field_2k.hdr filter=lfs diff=lfs merge=lfs -text diff --git a/AIController3D.gd b/AIController3D.gd new file mode 100644 index 0000000000000000000000000000000000000000..1b1620b05262241837da426d018a716446a4796f --- /dev/null +++ b/AIController3D.gd @@ -0,0 +1,45 @@ +extends AIController3D + + +func get_obs(): + if _player.cur_goal == null: + _player.game_over() + var goal_vector = to_local(_player.cur_goal.position) + var goal_distance = goal_vector.length() + goal_vector = goal_vector.normalized() + goal_distance = clamp(goal_distance, 0.0, 50.0) + + var next_goal = _player.environment.get_next_goal(_player.cur_goal) + var next_goal_vector = to_local(next_goal.position) + var next_goal_distance = next_goal_vector.length() + next_goal_vector = next_goal_vector.normalized() + next_goal_distance = clamp(next_goal_distance, 0.0, 50.0) + + var obs = [ + goal_vector.x, + goal_vector.y, + goal_vector.z, + goal_distance / 50.0, + next_goal_vector.x, + next_goal_vector.y, + next_goal_vector.z, + next_goal_distance / 50.0 + ] + + return {"obs": obs} + + +func get_action_space(): + return { + "pitch": {"size": 1, "action_type": "continuous"}, + "turn": {"size": 1, "action_type": "continuous"} + } + + +func set_action(action): + _player.turn_input = action["turn"][0] + _player.pitch_input = action["pitch"][0] + + +func get_reward(): + return reward diff --git a/FlyBy.csproj b/FlyBy.csproj new file mode 100644 index 0000000000000000000000000000000000000000..d6e80431553b474825ae104f3d71f06c3dd56786 --- /dev/null +++ b/FlyBy.csproj @@ -0,0 +1,10 @@ + + + net6.0 + true + GodotRLAgents + + + + + \ No newline at end of file diff --git a/FlyBy.gd b/FlyBy.gd new file mode 100644 index 0000000000000000000000000000000000000000..1fdfd150c86f84de629699a2156c0f752bfb575c --- /dev/null +++ b/FlyBy.gd @@ -0,0 +1,24 @@ +extends Node3D + +var goals = null + + +# Called when the node enters the scene tree for the first time. +func _ready(): + goals = $Goals.get_children() + + +func get_next_goal(current_goal): + if current_goal == null: + return goals[0] + var index = null + for i in len(goals): + if goals[i] == current_goal: + index = (i + 1) % len(goals) + break + + return goals[index] + + +func get_last_goal(): + return goals[-1] diff --git a/FlyBy.onnx b/FlyBy.onnx new file mode 100644 index 0000000000000000000000000000000000000000..0d837c7820753dcbe4f60bdfe878029cb7729abd --- /dev/null +++ b/FlyBy.onnx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:933de1f9ca8317c0efde301a441582ebe0ac338f7d9020c3d816631530628ddd +size 21197 diff --git a/FlyBy.sln b/FlyBy.sln new file mode 100644 index 0000000000000000000000000000000000000000..d8b58a0e0a1f74a7eac7fa70bacfd017016f906f --- /dev/null +++ b/FlyBy.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33530.505 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Godot RL Agents", "Godot RL Agents.csproj", "{055E8CBC-A3EC-41A8-BC53-EC3010682AE4}" +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 + {055E8CBC-A3EC-41A8-BC53-EC3010682AE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {055E8CBC-A3EC-41A8-BC53-EC3010682AE4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {055E8CBC-A3EC-41A8-BC53-EC3010682AE4}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {055E8CBC-A3EC-41A8-BC53-EC3010682AE4}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {055E8CBC-A3EC-41A8-BC53-EC3010682AE4}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {055E8CBC-A3EC-41A8-BC53-EC3010682AE4}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/FlyBy.tscn b/FlyBy.tscn new file mode 100644 index 0000000000000000000000000000000000000000..b6fabe92e56df0114e7737c6e985d6cedfd351db --- /dev/null +++ b/FlyBy.tscn @@ -0,0 +1,312 @@ +[gd_scene load_steps=20 format=3 uid="uid://duev7xgoc7kvq"] + +[ext_resource type="Script" path="res://addons/godot_rl_agents/sync.gd" id="1"] +[ext_resource type="Script" path="res://GameArea.gd" id="2"] +[ext_resource type="Texture2D" uid="uid://cc7fd3cl63ky1" path="res://alps_field_2k.hdr" id="2_retnu"] +[ext_resource type="PackedScene" uid="uid://bjx0dykb8q6kf" path="res://Goal.tscn" id="3"] +[ext_resource type="Script" path="res://FlyBy.gd" id="4"] +[ext_resource type="PackedScene" uid="uid://3xxv82w5v8bo" path="res://Plane.tscn" id="5"] +[ext_resource type="Texture2D" uid="uid://bddbiy7gwtdyh" path="res://concrete_wall_004_diff_1k.jpg" id="7_mnp35"] +[ext_resource type="Texture2D" uid="uid://bj56jsr1idhhk" path="res://concrete_wall_004_ao_1k.jpg" id="8_mhe64"] +[ext_resource type="Texture2D" uid="uid://ow81638q14o" path="res://concrete_wall_004_arm_1k.jpg" id="9_1x60u"] +[ext_resource type="Texture2D" uid="uid://drkdgeq22xo2f" path="res://concrete_wall_004_nor_gl_1k.jpg" id="10_x6htc"] + +[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_88xh0"] +panorama = ExtResource("2_retnu") + +[sub_resource type="Sky" id="Sky_bna3a"] +sky_material = SubResource("PanoramaSkyMaterial_88xh0") + +[sub_resource type="Environment" id="Environment_1r6xt"] +background_mode = 2 +sky = SubResource("Sky_bna3a") +ambient_light_source = 3 +reflected_light_source = 2 + +[sub_resource type="StandardMaterial3D" id="1"] +transparency = 1 +albedo_color = Color(0.372549, 0.0823529, 0.109804, 0.705882) + +[sub_resource type="StandardMaterial3D" id="2"] +albedo_color = Color(0.0862745, 0.211765, 0.12549, 1) +uv1_scale = Vector3(0.5, 0.5, 0.5) +uv1_triplanar = true + +[sub_resource type="StandardMaterial3D" id="3"] +albedo_color = Color(0.0196078, 0.0313726, 0.0313726, 1) + +[sub_resource type="BoxShape3D" id="4"] +size = Vector3(500, 102, 502) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_lnswx"] +albedo_texture = ExtResource("7_mnp35") +metallic = 1.0 +metallic_texture = ExtResource("9_1x60u") +roughness_texture = ExtResource("9_1x60u") +normal_enabled = true +normal_texture = ExtResource("10_x6htc") +ao_enabled = true +ao_texture = ExtResource("8_mhe64") +uv1_scale = Vector3(10, 10, 10) + +[sub_resource type="BoxMesh" id="5"] +material = SubResource("StandardMaterial3D_lnswx") +size = Vector3(500, 100, 2) + +[node name="FlyBy" type="Node3D"] +script = ExtResource("4") + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(0.837719, 0.472938, -0.273051, -0.199304, 0.730284, 0.653424, 0.508434, -0.492966, 0.706031, -138.049, 226.704, 0) +shadow_enabled = true + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_1r6xt") + +[node name="Goals" type="Node" parent="."] + +[node name="Goal" parent="Goals" instance=ExtResource("3")] +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 21, 35, -74) + +[node name="Goal2" parent="Goals" instance=ExtResource("3")] +transform = Transform3D(0.965926, 0.258819, 1.13133e-08, 0, -4.37114e-08, 1, 0.258819, -0.965926, -4.2222e-08, 64, 35, -149) + +[node name="Goal3" parent="Goals" instance=ExtResource("3")] +transform = Transform3D(-5.96046e-08, 1, 4.37113e-08, 0, -4.37114e-08, 1, 1, 5.96046e-08, 2.30926e-14, 118, 54, -203) + +[node name="Goal4" parent="Goals" instance=ExtResource("3")] +transform = Transform3D(-0.707107, 0.707107, 3.09086e-08, 0, -4.37114e-08, 1, 0.707107, 0.707107, 3.09086e-08, 201, 42, -156) + +[node name="Goal5" parent="Goals" instance=ExtResource("3")] +transform = Transform3D(-1, 5.96046e-08, 2.30926e-14, 0, -4.37114e-08, 1, 5.96046e-08, 1, 4.37113e-08, 230, 35, -63) + +[node name="Goal6" parent="Goals" instance=ExtResource("3")] +transform = Transform3D(-1, -2.98023e-08, 1.77636e-15, 0, -4.37114e-08, 1, -2.98023e-08, 1, 4.37114e-08, 216, 17, 48) + +[node name="Goal7" parent="Goals" instance=ExtResource("3")] +transform = Transform3D(-0.866026, -0.5, -2.18557e-08, 0, -4.37114e-08, 1, -0.5, 0.866026, 3.78551e-08, 169, 40, 147) + +[node name="Goal8" parent="Goals" instance=ExtResource("3")] +transform = Transform3D(0.258819, -0.965926, -4.2222e-08, 0, -4.37114e-08, 1, -0.965926, -0.258819, -1.13133e-08, 74, 30, 181) + +[node name="Goal9" parent="Goals" instance=ExtResource("3")] +transform = Transform3D(-2.98023e-07, -1, -4.37113e-08, 0, -4.37114e-08, 1, -1, 2.98023e-07, -4.08562e-14, 10, 45, 133) + +[node name="Goal10" parent="Goals" instance=ExtResource("3")] +transform = Transform3D(-0.5, -0.866025, -3.78552e-08, 0, -4.37114e-08, 1, -0.866025, 0.5, 2.18557e-08, -54, 16, 171) + +[node name="Goal11" parent="Goals" instance=ExtResource("3")] +transform = Transform3D(0.5, -0.866026, -3.78551e-08, 0, -4.37114e-08, 1, -0.866026, -0.5, -2.18557e-08, -132, 20, 166) + +[node name="Goal12" parent="Goals" instance=ExtResource("3")] +transform = Transform3D(1, -2.38419e-07, 4.26326e-14, 0, -4.37114e-08, 1, -2.38419e-07, -1, -4.37113e-08, -159, 35, 99) +material = SubResource("1") + +[node name="Goal13" parent="Goals" instance=ExtResource("3")] +transform = Transform3D(0.5, 0.866026, 3.78551e-08, 0, -4.37114e-08, 1, 0.866026, -0.5, -2.18556e-08, -123, 35, 22) +material = SubResource("1") + +[node name="Goal14" parent="Goals" instance=ExtResource("3")] +transform = Transform3D(0.707107, 0.707107, 3.09086e-08, 0, -4.37114e-08, 1, 0.707107, -0.707107, -3.09085e-08, -43, 35, -7) +material = SubResource("1") + +[node name="Columns" type="CSGCombiner3D" parent="."] + +[node name="CSGBox3D" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 35, -7.6325, 0) +size = Vector3(1000, 1, 1000) +material = SubResource("2") + +[node name="CSGBox2" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 48, 25, -81) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox3" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -84, 25, -38) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox16" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -83, 25, 31) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox17" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -58, 25, 31) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox18" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -163, 25, 31) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox19" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -185, 25, 113) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox20" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -130, 25, 92) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox4" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 142, 25, 112) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox13" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 212, 25, 165) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox14" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 245, 25, 107) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox12" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 157, 25, 70) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox5" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12, 25, 187) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox15" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 129, 25, 215) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox6" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 25, -80) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox21" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 25, -80) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox7" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 125, 25, -164) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox11" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 185, 25, -218) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox10" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 74, 25, -226) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox8" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -74, 25, 91) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="CSGBox9" type="CSGBox3D" parent="Columns"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 102, 25, 130) +size = Vector3(10, 100, 10) +material = SubResource("3") + +[node name="GameArea" type="Area3D" parent="."] +script = ExtResource("2") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="GameArea"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 35, 41, 1) +shape = SubResource("4") + +[node name="Sync" type="Node" parent="."] +script = ExtResource("1") + +[node name="Plane" parent="." instance=ExtResource("5")] +transform = Transform3D(-0.372224, 0.0145406, -0.928029, 0, 0.999877, 0.0156663, 0.928143, 0.00583138, -0.372178, -111.001, 77.3255, -109.24) +turn_acc = 4.0 + +[node name="Plane2" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 27, 0) +turn_acc = 4.0 + +[node name="Plane3" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 27, 0) +turn_acc = 4.0 + +[node name="Plane4" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 27, 0) +turn_acc = 4.0 + +[node name="Plane5" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 27, 0) +turn_acc = 4.0 + +[node name="Plane6" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 27, 0) +turn_acc = 4.0 + +[node name="Plane7" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 27, 0) +turn_acc = 4.0 + +[node name="Plane8" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 27, 0) +turn_acc = 4.0 + +[node name="Plane9" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 27, 0) +turn_acc = 4.0 + +[node name="Plane10" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 27, 0) +turn_acc = 4.0 + +[node name="Plane11" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 27, 0) +turn_acc = 4.0 + +[node name="Plane12" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 27, 0) +turn_acc = 4.0 + +[node name="Plane13" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 27, 0) +turn_acc = 4.0 + +[node name="Plane14" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 27, 0) +turn_acc = 4.0 + +[node name="Plane15" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 14, 27, -1) +turn_acc = 4.0 + +[node name="Plane16" parent="." instance=ExtResource("5")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 14, 27, -1) +turn_acc = 4.0 + +[node name="Walls" type="Node" parent="."] + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Walls"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 36, -24.1131, 252) +mesh = SubResource("5") + +[node name="MeshInstance2" type="MeshInstance3D" parent="Walls"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 35, -24.1131, -251) +mesh = SubResource("5") + +[node name="MeshInstance3" type="MeshInstance3D" parent="Walls"] +transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -215, -24.1131, 1) +mesh = SubResource("5") + +[node name="MeshInstance4" type="MeshInstance3D" parent="Walls"] +transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 285, -24.1131, -2) +mesh = SubResource("5") + +[connection signal="body_exited" from="GameArea" to="GameArea" method="_on_GameArea_body_exited"] diff --git a/GameArea.gd b/GameArea.gd new file mode 100644 index 0000000000000000000000000000000000000000..6e825d4e34ce0b352a3823f65a5cd11bc2ececa8 --- /dev/null +++ b/GameArea.gd @@ -0,0 +1,5 @@ +extends Area3D + + +func _on_GameArea_body_exited(body): + body.exited_game_area() diff --git a/Goal.gd b/Goal.gd new file mode 100644 index 0000000000000000000000000000000000000000..db4473d734f0478deef97501d270c35b8de21127 --- /dev/null +++ b/Goal.gd @@ -0,0 +1,6 @@ +extends CSGTorus3D + + + +func _on_Area_body_entered(body): + body.goal_reached(self) diff --git a/Goal.tscn b/Goal.tscn new file mode 100644 index 0000000000000000000000000000000000000000..a0faefd582db9b6db818110b71bc4dc17a951775 --- /dev/null +++ b/Goal.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=4 format=3 uid="uid://bjx0dykb8q6kf"] + +[ext_resource type="Script" path="res://Goal.gd" id="1"] + +[sub_resource type="StandardMaterial3D" id="1"] +transparency = 1 +albedo_color = Color(0.372549, 0.0823529, 0.109804, 0.705882) + +[sub_resource type="CylinderShape3D" id="2"] +height = 1.0 +radius = 5.0 + +[node name="Goal" type="CSGTorus3D"] +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 34, 11) +inner_radius = 8.0 +outer_radius = 10.0 +sides = 32 +ring_sides = 12 +material = SubResource("1") +script = ExtResource("1") + +[node name="Area3D" type="Area3D" parent="."] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"] +shape = SubResource("2") + +[connection signal="body_entered" from="Area3D" to="." method="_on_Area_body_entered"] diff --git a/Plane.gd b/Plane.gd new file mode 100644 index 0000000000000000000000000000000000000000..261debb173fd2b0681b231894a1e6087a5dbdbda --- /dev/null +++ b/Plane.gd @@ -0,0 +1,122 @@ +extends CharacterBody3D + +# Maximum airspeed +var max_flight_speed = 30 +# Turn rate +@export var turn_speed = 5.0 +@export var level_speed = 12.0 +@export var turn_acc = 4.0 +# Climb/dive rate +var pitch_speed = 2.0 +# Wings "autolevel" speed +# Throttle change speed +var throttle_delta = 30 +# Acceleration/deceleration +var acceleration = 6.0 +# Current speed +var forward_speed = 0 +# Throttle input speed +var target_speed = 0 + +#var velocity = Vector3.ZERO +var found_goal = false +var exited_arena = false +var cur_goal = null +@onready var environment = get_parent() +@onready var ai_controller = $AIController3D +# ------- # +var turn_input = 0 +var pitch_input = 0 +var best_goal_distance := 10000.0 +var transform_backup = null + + +func _ready(): + ai_controller.init(self) + transform_backup = transform + + +func game_over(): + cur_goal = environment.get_next_goal(null) + transform_backup = transform_backup + position.x = 0 + randf_range(-2, 2) + position.y = 27 + randf_range(-2, 2) + position.z = 0 + randf_range(-2, 2) + velocity = Vector3.ZERO + rotation = Vector3.ZERO + found_goal = false + exited_arena = false + best_goal_distance = to_local(cur_goal.position).length() + ai_controller.reset() + + +func update_reward(): + ai_controller.reward -= 0.01 # step penalty + ai_controller.reward += shaping_reward() + + +func shaping_reward(): + var s_reward = 0.0 + var goal_distance = to_local(cur_goal.position).length() + if goal_distance < best_goal_distance: + s_reward += best_goal_distance - goal_distance + best_goal_distance = goal_distance + + s_reward /= 1.0 + return s_reward + + +func set_heuristic(heuristic): + self._heuristic = heuristic + + +func _physics_process(delta): + if ai_controller.needs_reset: + game_over() + return + + if cur_goal == null: + game_over() + set_input() + if Input.is_action_just_pressed("r_key"): + game_over() + # Rotate the transform based checked the input values + transform.basis = transform.basis.rotated( + transform.basis.x.normalized(), pitch_input * pitch_speed * delta + ) + transform.basis = transform.basis.rotated(Vector3.UP, turn_input * turn_speed * delta) + $PlaneModel.rotation.z = lerp($PlaneModel.rotation.z, -float(turn_input), level_speed * delta) + $PlaneModel.rotation.x = lerp($PlaneModel.rotation.x, -float(pitch_input), level_speed * delta) + + # Movement is always forward + velocity = -transform.basis.z.normalized() * max_flight_speed + # Handle landing/taking unchecked + set_velocity(velocity) + set_up_direction(Vector3.UP) + move_and_slide() + update_reward() + + +func set_input(): + if ai_controller.heuristic == "model": + return + else: + turn_input = ( + Input.get_action_strength("roll_left") - Input.get_action_strength("roll_right") + ) + pitch_input = ( + Input.get_action_strength("pitch_up") - Input.get_action_strength("pitch_down") + ) + + +func goal_reached(goal): + if goal == cur_goal: + ai_controller.reward += 100.0 + cur_goal = environment.get_next_goal(cur_goal) + + +func exited_game_area(): + ai_controller.done = true + ai_controller.reward -= 10.0 + exited_arena = true + game_over() diff --git a/Plane.tscn b/Plane.tscn new file mode 100644 index 0000000000000000000000000000000000000000..4de34d72e5e853e0df2deb201bdeb9e00b095bd5 --- /dev/null +++ b/Plane.tscn @@ -0,0 +1,28 @@ +[gd_scene load_steps=5 format=3 uid="uid://3xxv82w5v8bo"] + +[ext_resource type="Script" path="res://Plane.gd" id="2"] +[ext_resource type="PackedScene" uid="uid://bo7tjnr5viqq" path="res://cartoon_plane/scene.gltf" id="2_0hy0d"] +[ext_resource type="Script" path="res://AIController3D.gd" id="3_y1d1w"] + +[sub_resource type="CylinderShape3D" id="27"] +height = 7.77792 + +[node name="Plane" type="CharacterBody3D"] +collision_mask = 2 +script = ExtResource("2") +turn_speed = 2.0 +level_speed = 2.0 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +transform = Transform3D(1, 0, 0, 0, -0.00176279, -0.999998, 0, 0.999998, -0.00176279, 0, -0.43198, 0.299141) +shape = SubResource("27") + +[node name="PlaneModel" parent="." instance=ExtResource("2_0hy0d")] +transform = Transform3D(-0.01, 0, -8.74228e-10, 0, 0.01, 0, 8.74228e-10, 0, -0.01, 0, 0, 0) + +[node name="Camera3D" type="Camera3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 21.4392) + +[node name="AIController3D" type="Node3D" parent="." groups=["AGENT"]] +script = ExtResource("3_y1d1w") +reset_after = 200000 diff --git a/PlaneModel.gd b/PlaneModel.gd new file mode 100644 index 0000000000000000000000000000000000000000..b42b800dbffa58cf3ed335c9ada7784b82036174 --- /dev/null +++ b/PlaneModel.gd @@ -0,0 +1,9 @@ +extends Node3D + + +@onready var anim = $AnimationPlayer + +# Called when the node enters the scene tree for the first time. +func _ready(): + get_node("AnimationPlayer").get_animation("Main")#.set_loop(true) + anim.play("Main") diff --git a/PlaneModel.tscn b/PlaneModel.tscn new file mode 100644 index 0000000000000000000000000000000000000000..dad0c5dfe43709b3b455f8be02ae9695b04fb374 --- /dev/null +++ b/PlaneModel.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://cartoon_plane/scene.gltf" type="PackedScene" id=1] + +[node name="PlaneModel" instance=ExtResource( 1 )] +transform = Transform3D( 0.01, 0, 0, 0, 0.01, 0, 0, 0, 0.01, 0, 0, 0 ) + +[node name="RootNode (gltf orientation matrix)" parent="." index="0"] +transform = Transform3D( -1, 8.74228e-08, 3.82137e-15, 0, -4.37114e-08, 1, 8.74228e-08, 1, 4.37114e-08, 0, 0, 0 ) + +[node name="Propeller_1" parent="RootNode (gltf orientation matrix)/RootNode (model correction matrix)/12cc6a9ff2ae45b08826ba235d9cb8b7fbx/Node/RootNode" index="0"] +transform = Transform3D( -0.791092, -0.611698, 0, 0.611698, -0.791092, 0, 0, 0, 1, 0.873349, -46.0248, 401.434 ) + +[node name="Physical_Sky" parent="RootNode (gltf orientation matrix)/RootNode (model correction matrix)/12cc6a9ff2ae45b08826ba235d9cb8b7fbx/Node/RootNode" index="1"] +transform = Transform3D( 0.879922, 0.00248785, -0.475112, 0.0222404, 0.998674, 0.0464192, 0.474598, -0.051412, 0.8787, 0, 0, 0 ) +visible = false + +[node name="Shadow_Plane" parent="RootNode (gltf orientation matrix)/RootNode (model correction matrix)/12cc6a9ff2ae45b08826ba235d9cb8b7fbx/Node/RootNode/Physical_Sky" index="1"] +visible = false diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9dfa4eb4b81f5aa01f42a15d61c8808db7725243 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +--- +library_name: godot-rl +tags: +- deep-reinforcement-learning +- reinforcement-learning +- godot-rl +- environments +- video-games +--- + +A RL environment called FlyBy for the Godot Game Engine. + +This environment was created with: https://github.com/edbeeching/godot_rl_agents + + +## Downloading the environment + +After installing Godot RL Agents, download the environment with: + +``` +gdrl.env_from_hub -r jtatman/godot_rl_FlyBy +``` + + + diff --git a/addons/godot_rl_agents/controller/ai_controller_2d.gd b/addons/godot_rl_agents/controller/ai_controller_2d.gd new file mode 100644 index 0000000000000000000000000000000000000000..0f3b67c3141078f5fbbe0a271a1d076179783415 --- /dev/null +++ b/addons/godot_rl_agents/controller/ai_controller_2d.gd @@ -0,0 +1,113 @@ +extends Node2D +class_name AIController2D + +enum ControlModes { INHERIT_FROM_SYNC, HUMAN, TRAINING, ONNX_INFERENCE, RECORD_EXPERT_DEMOS } +@export var control_mode: ControlModes = ControlModes.INHERIT_FROM_SYNC +@export var onnx_model_path := "" +@export var reset_after := 1000 + +@export_group("Record expert demos mode options") +## Path where the demos will be saved. The file can later be used for imitation learning. +@export var expert_demo_save_path: String +## The action that erases the last recorded episode from the currently recorded data. +@export var remove_last_episode_key: InputEvent +## Action will be repeated for n frames. Will introduce control lag if larger than 1. +## Can be used to ensure that action_repeat on inference and training matches +## the recorded demonstrations. +@export var action_repeat: int = 1 + +var onnx_model: ONNXModel + +var heuristic := "human" +var done := false +var reward := 0.0 +var n_steps := 0 +var needs_reset := false + +var _player: Node2D + + +func _ready(): + add_to_group("AGENT") + + +func init(player: Node2D): + _player = player + + +#-- Methods that need implementing using the "extend script" option in Godot --# +func get_obs() -> Dictionary: + assert(false, "the get_obs method is not implemented when extending from ai_controller") + return {"obs": []} + + +func get_reward() -> float: + assert(false, "the get_reward method is not implemented when extending from ai_controller") + return 0.0 + + +func get_action_space() -> Dictionary: + assert( + false, + "the get get_action_space method is not implemented when extending from ai_controller" + ) + return { + "example_actions_continous": {"size": 2, "action_type": "continuous"}, + "example_actions_discrete": {"size": 2, "action_type": "discrete"}, + } + + +func set_action(action) -> void: + assert(false, "the get set_action method is not implemented when extending from ai_controller") + + +#-----------------------------------------------------------------------------# + + +#-- Methods that sometimes need implementing using the "extend script" option in Godot --# +# Only needed if you are recording expert demos with this AIController +func get_action() -> Array: + assert(false, "the get set_action method is not implemented in extended AIController but demo_recorder is used") + return [] + +# -----------------------------------------------------------------------------# + +func _physics_process(delta): + n_steps += 1 + if n_steps > reset_after: + needs_reset = true + + +func get_obs_space(): + # may need overriding if the obs space is complex + var obs = get_obs() + return { + "obs": {"size": [len(obs["obs"])], "space": "box"}, + } + + +func reset(): + n_steps = 0 + needs_reset = false + + +func reset_if_done(): + if done: + reset() + + +func set_heuristic(h): + # sets the heuristic from "human" or "model" nothing to change here + heuristic = h + + +func get_done(): + return done + + +func set_done_false(): + done = false + + +func zero_reward(): + reward = 0.0 diff --git a/addons/godot_rl_agents/controller/ai_controller_3d.gd b/addons/godot_rl_agents/controller/ai_controller_3d.gd new file mode 100644 index 0000000000000000000000000000000000000000..089d63ceaf9ff1f37f6f6f4fff5e84451a5a4545 --- /dev/null +++ b/addons/godot_rl_agents/controller/ai_controller_3d.gd @@ -0,0 +1,114 @@ +extends Node3D +class_name AIController3D + +enum ControlModes { INHERIT_FROM_SYNC, HUMAN, TRAINING, ONNX_INFERENCE, RECORD_EXPERT_DEMOS } +@export var control_mode: ControlModes = ControlModes.INHERIT_FROM_SYNC +@export var onnx_model_path := "" +@export var reset_after := 1000 + +@export_group("Record expert demos mode options") +## Path where the demos will be saved. The file can later be used for imitation learning. +@export var expert_demo_save_path: String +## The action that erases the last recorded episode from the currently recorded data. +@export var remove_last_episode_key: InputEvent +## Action will be repeated for n frames. Will introduce control lag if larger than 1. +## Can be used to ensure that action_repeat on inference and training matches +## the recorded demonstrations. +@export var action_repeat: int = 1 + +var onnx_model: ONNXModel + +var heuristic := "human" +var done := false +var reward := 0.0 +var n_steps := 0 +var needs_reset := false + +var _player: Node3D + + +func _ready(): + add_to_group("AGENT") + + +func init(player: Node3D): + _player = player + + +#-- Methods that need implementing using the "extend script" option in Godot --# +func get_obs() -> Dictionary: + assert(false, "the get_obs method is not implemented when extending from ai_controller") + return {"obs": []} + + +func get_reward() -> float: + assert(false, "the get_reward method is not implemented when extending from ai_controller") + return 0.0 + + +func get_action_space() -> Dictionary: + assert( + false, + "the get get_action_space method is not implemented when extending from ai_controller" + ) + return { + "example_actions_continous": {"size": 2, "action_type": "continuous"}, + "example_actions_discrete": {"size": 2, "action_type": "discrete"}, + } + + +func set_action(action) -> void: + assert(false, "the get set_action method is not implemented when extending from ai_controller") + + +#-----------------------------------------------------------------------------# + + +#-- Methods that sometimes need implementing using the "extend script" option in Godot --# +# Only needed if you are recording expert demos with this AIController +func get_action() -> Array: + assert(false, "the get set_action method is not implemented in extended AIController but demo_recorder is used") + return [] + +# -----------------------------------------------------------------------------# + + +func _physics_process(delta): + n_steps += 1 + if n_steps > reset_after: + needs_reset = true + + +func get_obs_space(): + # may need overriding if the obs space is complex + var obs = get_obs() + return { + "obs": {"size": [len(obs["obs"])], "space": "box"}, + } + + +func reset(): + n_steps = 0 + needs_reset = false + + +func reset_if_done(): + if done: + reset() + + +func set_heuristic(h): + # sets the heuristic from "human" or "model" nothing to change here + heuristic = h + + +func get_done(): + return done + + +func set_done_false(): + done = false + + +func zero_reward(): + reward = 0.0 diff --git a/addons/godot_rl_agents/godot_rl_agents.gd b/addons/godot_rl_agents/godot_rl_agents.gd new file mode 100644 index 0000000000000000000000000000000000000000..e4fe13693a598c808aca1b64051d1c0c70783296 --- /dev/null +++ b/addons/godot_rl_agents/godot_rl_agents.gd @@ -0,0 +1,16 @@ +@tool +extends EditorPlugin + + +func _enter_tree(): + # Initialization of the plugin goes here. + # Add the new type with a name, a parent type, a script and an icon. + add_custom_type("Sync", "Node", preload("sync.gd"), preload("icon.png")) + #add_custom_type("RaycastSensor2D2", "Node", preload("raycast_sensor_2d.gd"), preload("icon.png")) + + +func _exit_tree(): + # Clean-up of the plugin goes here. + # Always remember to remove it from the engine when deactivated. + remove_custom_type("Sync") + #remove_custom_type("RaycastSensor2D2") diff --git a/addons/godot_rl_agents/icon.png b/addons/godot_rl_agents/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ccb4ca000e3e1cf659fe367ab5bff67c1eb3467d --- /dev/null +++ b/addons/godot_rl_agents/icon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e3a8bc372d3313ce1ede4e7554472e37b322178b9488bfb709e296585abd3c44 +size 198 diff --git a/addons/godot_rl_agents/onnx/csharp/ONNXInference.cs b/addons/godot_rl_agents/onnx/csharp/ONNXInference.cs new file mode 100644 index 0000000000000000000000000000000000000000..0741f0f263f34fffc44993e2b11a7544b0384ca1 --- /dev/null +++ b/addons/godot_rl_agents/onnx/csharp/ONNXInference.cs @@ -0,0 +1,103 @@ +using Godot; +using Microsoft.ML.OnnxRuntime; +using Microsoft.ML.OnnxRuntime.Tensors; +using System.Collections.Generic; +using System.Linq; + +namespace GodotONNX +{ + /// + public partial class ONNXInference : GodotObject + { + + private InferenceSession session; + /// + /// Path to the ONNX model. Use Initialize to change it. + /// + private string modelPath; + private int batchSize; + + private SessionOptions SessionOpt; + + //init function + /// + public void Initialize(string Path, int BatchSize) + { + modelPath = Path; + batchSize = BatchSize; + SessionOpt = SessionConfigurator.MakeConfiguredSessionOptions(); + session = LoadModel(modelPath); + + } + /// + public Godot.Collections.Dictionary> RunInference(Godot.Collections.Array obs, int state_ins) + { + //Current model: Any (Godot Rl Agents) + //Expects a tensor of shape [batch_size, input_size] type float named obs and a tensor of shape [batch_size] type float named state_ins + + //Fill the input tensors + // create span from inputSize + var span = new float[obs.Count]; //There's probably a better way to do this + for (int i = 0; i < obs.Count; i++) + { + span[i] = obs[i]; + } + + IReadOnlyCollection inputs = new List + { + NamedOnnxValue.CreateFromTensor("obs", new DenseTensor(span, new int[] { batchSize, obs.Count })), + NamedOnnxValue.CreateFromTensor("state_ins", new DenseTensor(new float[] { state_ins }, new int[] { batchSize })) + }; + IReadOnlyCollection outputNames = new List { "output", "state_outs" }; //ONNX is sensible to these names, as well as the input names + + IDisposableReadOnlyCollection results; + //We do not use "using" here so we get a better exception explaination later + try + { + results = session.Run(inputs, outputNames); + } + catch (OnnxRuntimeException e) + { + //This error usually means that the model is not compatible with the input, beacause of the input shape (size) + GD.Print("Error at inference: ", e); + return null; + } + //Can't convert IEnumerable to Variant, so we have to convert it to an array or something + Godot.Collections.Dictionary> output = new Godot.Collections.Dictionary>(); + DisposableNamedOnnxValue output1 = results.First(); + DisposableNamedOnnxValue output2 = results.Last(); + Godot.Collections.Array output1Array = new Godot.Collections.Array(); + Godot.Collections.Array output2Array = new Godot.Collections.Array(); + + foreach (float f in output1.AsEnumerable()) + { + output1Array.Add(f); + } + + foreach (float f in output2.AsEnumerable()) + { + output2Array.Add(f); + } + + output.Add(output1.Name, output1Array); + output.Add(output2.Name, output2Array); + + //Output is a dictionary of arrays, ex: { "output" : [0.1, 0.2, 0.3, 0.4, ...], "state_outs" : [0.5, ...]} + results.Dispose(); + return output; + } + /// + public InferenceSession LoadModel(string Path) + { + using Godot.FileAccess file = FileAccess.Open(Path, Godot.FileAccess.ModeFlags.Read); + byte[] model = file.GetBuffer((int)file.GetLength()); + //file.Close(); file.Dispose(); //Close the file, then dispose the reference. + return new InferenceSession(model, SessionOpt); //Load the model + } + public void FreeDisposables() + { + session.Dispose(); + SessionOpt.Dispose(); + } + } +} diff --git a/addons/godot_rl_agents/onnx/csharp/SessionConfigurator.cs b/addons/godot_rl_agents/onnx/csharp/SessionConfigurator.cs new file mode 100644 index 0000000000000000000000000000000000000000..ad7a41cfee0dc3d497d9c1d03bd0752b09d49f3a --- /dev/null +++ b/addons/godot_rl_agents/onnx/csharp/SessionConfigurator.cs @@ -0,0 +1,131 @@ +using Godot; +using Microsoft.ML.OnnxRuntime; + +namespace GodotONNX +{ + /// + + public static class SessionConfigurator + { + public enum ComputeName + { + CUDA, + ROCm, + DirectML, + CoreML, + CPU + } + + /// + public static SessionOptions MakeConfiguredSessionOptions() + { + SessionOptions sessionOptions = new(); + SetOptions(sessionOptions); + return sessionOptions; + } + + private static void SetOptions(SessionOptions sessionOptions) + { + sessionOptions.LogSeverityLevel = OrtLoggingLevel.ORT_LOGGING_LEVEL_WARNING; + ApplySystemSpecificOptions(sessionOptions); + } + + /// + static public void ApplySystemSpecificOptions(SessionOptions sessionOptions) + { + //Most code for this function is verbose only, the only reason it exists is to track + //implementation progress of the different compute APIs. + + //December 2022: CUDA is not working. + + string OSName = OS.GetName(); //Get OS Name + + //ComputeName ComputeAPI = ComputeCheck(); //Get Compute API + // //TODO: Get CPU architecture + + //Linux can use OpenVINO (C#) on x64 and ROCm on x86 (GDNative/C++) + //Windows can use OpenVINO (C#) on x64 + //TODO: try TensorRT instead of CUDA + //TODO: Use OpenVINO for Intel Graphics + + // Temporarily using CPU on all platforms to avoid errors detected with DML + ComputeName ComputeAPI = ComputeName.CPU; + + //match OS and Compute API + GD.Print($"OS: {OSName} Compute API: {ComputeAPI}"); + + // CPU is set by default without appending necessary + // sessionOptions.AppendExecutionProvider_CPU(0); + + /* + switch (OSName) + { + case "Windows": //Can use CUDA, DirectML + if (ComputeAPI is ComputeName.CUDA) + { + //CUDA + //sessionOptions.AppendExecutionProvider_CUDA(0); + //sessionOptions.AppendExecutionProvider_DML(0); + } + else if (ComputeAPI is ComputeName.DirectML) + { + //DirectML + //sessionOptions.AppendExecutionProvider_DML(0); + } + break; + case "X11": //Can use CUDA, ROCm + if (ComputeAPI is ComputeName.CUDA) + { + //CUDA + //sessionOptions.AppendExecutionProvider_CUDA(0); + } + if (ComputeAPI is ComputeName.ROCm) + { + //ROCm, only works on x86 + //Research indicates that this has to be compiled as a GDNative plugin + //GD.Print("ROCm not supported yet, using CPU."); + //sessionOptions.AppendExecutionProvider_CPU(0); + } + break; + case "macOS": //Can use CoreML + if (ComputeAPI is ComputeName.CoreML) + { //CoreML + //TODO: Needs testing + //sessionOptions.AppendExecutionProvider_CoreML(0); + //CoreML on ARM64, out of the box, on x64 needs .tar file from GitHub + } + break; + default: + GD.Print("OS not Supported."); + break; + } + */ + } + + + /// + public static ComputeName ComputeCheck() + { + string adapterName = Godot.RenderingServer.GetVideoAdapterName(); + //string adapterVendor = Godot.RenderingServer.GetVideoAdapterVendor(); + adapterName = adapterName.ToUpper(new System.Globalization.CultureInfo("")); + //TODO: GPU vendors for MacOS, what do they even use these days? + + if (adapterName.Contains("INTEL")) + { + return ComputeName.DirectML; + } + if (adapterName.Contains("AMD") || adapterName.Contains("RADEON")) + { + return ComputeName.DirectML; + } + if (adapterName.Contains("NVIDIA")) + { + return ComputeName.CUDA; + } + + GD.Print("Graphics Card not recognized."); //Should use CPU + return ComputeName.CPU; + } + } +} diff --git a/addons/godot_rl_agents/onnx/csharp/docs/ONNXInference.xml b/addons/godot_rl_agents/onnx/csharp/docs/ONNXInference.xml new file mode 100644 index 0000000000000000000000000000000000000000..91b07d607dc89f11e957e13758d8c0ee4fb72be8 --- /dev/null +++ b/addons/godot_rl_agents/onnx/csharp/docs/ONNXInference.xml @@ -0,0 +1,31 @@ + + + + + The main ONNXInference Class that handles the inference process. + + + + + Starts the inference process. + + Path to the ONNX model, expects a path inside resources. + How many observations will the model recieve. + + + + Runs the given input through the model and returns the output. + + Dictionary containing all observations. + How many different agents are creating these observations. + A Dictionary of arrays, containing instructions based on the observations. + + + + Loads the given model into the inference process, using the best Execution provider available. + + Path to the ONNX model, expects a path inside resources. + InferenceSession ready to run. + + + \ No newline at end of file diff --git a/addons/godot_rl_agents/onnx/csharp/docs/SessionConfigurator.xml b/addons/godot_rl_agents/onnx/csharp/docs/SessionConfigurator.xml new file mode 100644 index 0000000000000000000000000000000000000000..f160c02f0d4cab92e10f799b6f4c5a71d4d6c0f2 --- /dev/null +++ b/addons/godot_rl_agents/onnx/csharp/docs/SessionConfigurator.xml @@ -0,0 +1,29 @@ + + + + + The main SessionConfigurator Class that handles the execution options and providers for the inference process. + + + + + Creates a SessionOptions with all available execution providers. + + SessionOptions with all available execution providers. + + + + Appends any execution provider available in the current system. + + + This function is mainly verbose for tracking implementation progress of different compute APIs. + + + + + Checks for available GPUs. + + An integer identifier for each compute platform. + + + \ No newline at end of file diff --git a/addons/godot_rl_agents/onnx/wrapper/ONNX_wrapper.gd b/addons/godot_rl_agents/onnx/wrapper/ONNX_wrapper.gd new file mode 100644 index 0000000000000000000000000000000000000000..d573582b995a2b8fe05553f7cf58fb2e3b58d482 --- /dev/null +++ b/addons/godot_rl_agents/onnx/wrapper/ONNX_wrapper.gd @@ -0,0 +1,27 @@ +extends Resource +class_name ONNXModel +var inferencer_script = load("res://addons/godot_rl_agents/onnx/csharp/ONNXInference.cs") + +var inferencer = null + + +# Must provide the path to the model and the batch size +func _init(model_path, batch_size): + inferencer = inferencer_script.new() + inferencer.Initialize(model_path, batch_size) + + +# This function is the one that will be called from the game, +# requires the observation as an array and the state_ins as an int +# returns an Array containing the action the model takes. +func run_inference(obs: Array, state_ins: int) -> Dictionary: + if inferencer == null: + printerr("Inferencer not initialized") + return {} + return inferencer.RunInference(obs, state_ins) + + +func _notification(what): + if what == NOTIFICATION_PREDELETE: + inferencer.FreeDisposables() + inferencer.free() diff --git a/addons/godot_rl_agents/plugin.cfg b/addons/godot_rl_agents/plugin.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b1bc988c80e3fe68e6d4279691fd5892e5ef323d --- /dev/null +++ b/addons/godot_rl_agents/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="GodotRLAgents" +description="Custom nodes for the godot rl agents toolkit " +author="Edward Beeching" +version="0.1" +script="godot_rl_agents.gd" diff --git a/addons/godot_rl_agents/sensors/sensors_2d/ExampleRaycastSensor2D.tscn b/addons/godot_rl_agents/sensors/sensors_2d/ExampleRaycastSensor2D.tscn new file mode 100644 index 0000000000000000000000000000000000000000..5edb6c7fc9da56e625d57185bdbafdbcc3fc67c5 --- /dev/null +++ b/addons/godot_rl_agents/sensors/sensors_2d/ExampleRaycastSensor2D.tscn @@ -0,0 +1,48 @@ +[gd_scene load_steps=5 format=3 uid="uid://ddeq7mn1ealyc"] + +[ext_resource type="Script" path="res://addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.gd" id="1"] + +[sub_resource type="GDScript" id="2"] +script/source = "extends Node2D + + + +func _physics_process(delta: float) -> void: + print(\"step start\") + +" + +[sub_resource type="GDScript" id="1"] +script/source = "extends RayCast2D + +var steps = 1 + +func _physics_process(delta: float) -> void: + print(\"processing raycast\") + steps += 1 + if steps % 2: + force_raycast_update() + + print(is_colliding()) +" + +[sub_resource type="CircleShape2D" id="3"] + +[node name="ExampleRaycastSensor2D" type="Node2D"] +script = SubResource("2") + +[node name="ExampleAgent" type="Node2D" parent="."] +position = Vector2(573, 314) +rotation = 0.286234 + +[node name="RaycastSensor2D" type="Node2D" parent="ExampleAgent"] +script = ExtResource("1") + +[node name="TestRayCast2D" type="RayCast2D" parent="."] +script = SubResource("1") + +[node name="StaticBody2D" type="StaticBody2D" parent="."] +position = Vector2(1, 52) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] +shape = SubResource("3") diff --git a/addons/godot_rl_agents/sensors/sensors_2d/GridSensor2D.gd b/addons/godot_rl_agents/sensors/sensors_2d/GridSensor2D.gd new file mode 100644 index 0000000000000000000000000000000000000000..da170ba93919a8f28510ea8fc1ab876fe5876d34 --- /dev/null +++ b/addons/godot_rl_agents/sensors/sensors_2d/GridSensor2D.gd @@ -0,0 +1,235 @@ +@tool +extends ISensor2D +class_name GridSensor2D + +@export var debug_view := false: + get: + return debug_view + set(value): + debug_view = value + _update() + +@export_flags_2d_physics var detection_mask := 0: + get: + return detection_mask + set(value): + detection_mask = value + _update() + +@export var collide_with_areas := false: + get: + return collide_with_areas + set(value): + collide_with_areas = value + _update() + +@export var collide_with_bodies := true: + get: + return collide_with_bodies + set(value): + collide_with_bodies = value + _update() + +@export_range(1, 200, 0.1) var cell_width := 20.0: + get: + return cell_width + set(value): + cell_width = value + _update() + +@export_range(1, 200, 0.1) var cell_height := 20.0: + get: + return cell_height + set(value): + cell_height = value + _update() + +@export_range(1, 21, 2, "or_greater") var grid_size_x := 3: + get: + return grid_size_x + set(value): + grid_size_x = value + _update() + +@export_range(1, 21, 2, "or_greater") var grid_size_y := 3: + get: + return grid_size_y + set(value): + grid_size_y = value + _update() + +var _obs_buffer: PackedFloat64Array +var _rectangle_shape: RectangleShape2D +var _collision_mapping: Dictionary +var _n_layers_per_cell: int + +var _highlighted_cell_color: Color +var _standard_cell_color: Color + + +func get_observation(): + return _obs_buffer + + +func _update(): + if Engine.is_editor_hint(): + if is_node_ready(): + _spawn_nodes() + + +func _ready() -> void: + _set_colors() + + if Engine.is_editor_hint(): + if get_child_count() == 0: + _spawn_nodes() + else: + _spawn_nodes() + + +func _set_colors() -> void: + _standard_cell_color = Color(100.0 / 255.0, 100.0 / 255.0, 100.0 / 255.0, 100.0 / 255.0) + _highlighted_cell_color = Color(255.0 / 255.0, 100.0 / 255.0, 100.0 / 255.0, 100.0 / 255.0) + + +func _get_collision_mapping() -> Dictionary: + # defines which layer is mapped to which cell obs index + var total_bits = 0 + var collision_mapping = {} + for i in 32: + var bit_mask = 2 ** i + if (detection_mask & bit_mask) > 0: + collision_mapping[i] = total_bits + total_bits += 1 + + return collision_mapping + + +func _spawn_nodes(): + for cell in get_children(): + cell.name = "_%s" % cell.name # Otherwise naming below will fail + cell.queue_free() + + _collision_mapping = _get_collision_mapping() + #prints("collision_mapping", _collision_mapping, len(_collision_mapping)) + # allocate memory for the observations + _n_layers_per_cell = len(_collision_mapping) + _obs_buffer = PackedFloat64Array() + _obs_buffer.resize(grid_size_x * grid_size_y * _n_layers_per_cell) + _obs_buffer.fill(0) + #prints(len(_obs_buffer), _obs_buffer ) + + _rectangle_shape = RectangleShape2D.new() + _rectangle_shape.set_size(Vector2(cell_width, cell_height)) + + var shift := Vector2( + -(grid_size_x / 2) * cell_width, + -(grid_size_y / 2) * cell_height, + ) + + for i in grid_size_x: + for j in grid_size_y: + var cell_position = Vector2(i * cell_width, j * cell_height) + shift + _create_cell(i, j, cell_position) + + +func _create_cell(i: int, j: int, position: Vector2): + var cell := Area2D.new() + cell.position = position + cell.name = "GridCell %s %s" % [i, j] + cell.modulate = _standard_cell_color + + if collide_with_areas: + cell.area_entered.connect(_on_cell_area_entered.bind(i, j)) + cell.area_exited.connect(_on_cell_area_exited.bind(i, j)) + + if collide_with_bodies: + cell.body_entered.connect(_on_cell_body_entered.bind(i, j)) + cell.body_exited.connect(_on_cell_body_exited.bind(i, j)) + + cell.collision_layer = 0 + cell.collision_mask = detection_mask + cell.monitorable = true + add_child(cell) + cell.set_owner(get_tree().edited_scene_root) + + var col_shape := CollisionShape2D.new() + col_shape.shape = _rectangle_shape + col_shape.name = "CollisionShape2D" + cell.add_child(col_shape) + col_shape.set_owner(get_tree().edited_scene_root) + + if debug_view: + var quad = MeshInstance2D.new() + quad.name = "MeshInstance2D" + var quad_mesh = QuadMesh.new() + + quad_mesh.set_size(Vector2(cell_width, cell_height)) + + quad.mesh = quad_mesh + cell.add_child(quad) + quad.set_owner(get_tree().edited_scene_root) + + +func _update_obs(cell_i: int, cell_j: int, collision_layer: int, entered: bool): + for key in _collision_mapping: + var bit_mask = 2 ** key + if (collision_layer & bit_mask) > 0: + var collison_map_index = _collision_mapping[key] + + var obs_index = ( + (cell_i * grid_size_x * _n_layers_per_cell) + + (cell_j * _n_layers_per_cell) + + collison_map_index + ) + #prints(obs_index, cell_i, cell_j) + if entered: + _obs_buffer[obs_index] += 1 + else: + _obs_buffer[obs_index] -= 1 + + +func _toggle_cell(cell_i: int, cell_j: int): + var cell = get_node_or_null("GridCell %s %s" % [cell_i, cell_j]) + + if cell == null: + print("cell not found, returning") + + var n_hits = 0 + var start_index = (cell_i * grid_size_x * _n_layers_per_cell) + (cell_j * _n_layers_per_cell) + for i in _n_layers_per_cell: + n_hits += _obs_buffer[start_index + i] + + if n_hits > 0: + cell.modulate = _highlighted_cell_color + else: + cell.modulate = _standard_cell_color + + +func _on_cell_area_entered(area: Area2D, cell_i: int, cell_j: int): + #prints("_on_cell_area_entered", cell_i, cell_j) + _update_obs(cell_i, cell_j, area.collision_layer, true) + if debug_view: + _toggle_cell(cell_i, cell_j) + #print(_obs_buffer) + + +func _on_cell_area_exited(area: Area2D, cell_i: int, cell_j: int): + #prints("_on_cell_area_exited", cell_i, cell_j) + _update_obs(cell_i, cell_j, area.collision_layer, false) + if debug_view: + _toggle_cell(cell_i, cell_j) + + +func _on_cell_body_entered(body: Node2D, cell_i: int, cell_j: int): + #prints("_on_cell_body_entered", cell_i, cell_j) + _update_obs(cell_i, cell_j, body.collision_layer, true) + if debug_view: + _toggle_cell(cell_i, cell_j) + + +func _on_cell_body_exited(body: Node2D, cell_i: int, cell_j: int): + #prints("_on_cell_body_exited", cell_i, cell_j) + _update_obs(cell_i, cell_j, body.collision_layer, false) + if debug_view: + _toggle_cell(cell_i, cell_j) diff --git a/addons/godot_rl_agents/sensors/sensors_2d/ISensor2D.gd b/addons/godot_rl_agents/sensors/sensors_2d/ISensor2D.gd new file mode 100644 index 0000000000000000000000000000000000000000..67669a1d71a3e37d780b396633951d7d1ac79edb --- /dev/null +++ b/addons/godot_rl_agents/sensors/sensors_2d/ISensor2D.gd @@ -0,0 +1,25 @@ +extends Node2D +class_name ISensor2D + +var _obs: Array = [] +var _active := false + + +func get_observation(): + pass + + +func activate(): + _active = true + + +func deactivate(): + _active = false + + +func _update_observation(): + pass + + +func reset(): + pass diff --git a/addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.gd b/addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.gd new file mode 100644 index 0000000000000000000000000000000000000000..9bb54ede90a6f6ffd5e65d89bf1bd561bc0832ed --- /dev/null +++ b/addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.gd @@ -0,0 +1,118 @@ +@tool +extends ISensor2D +class_name RaycastSensor2D + +@export_flags_2d_physics var collision_mask := 1: + get: + return collision_mask + set(value): + collision_mask = value + _update() + +@export var collide_with_areas := false: + get: + return collide_with_areas + set(value): + collide_with_areas = value + _update() + +@export var collide_with_bodies := true: + get: + return collide_with_bodies + set(value): + collide_with_bodies = value + _update() + +@export var n_rays := 16.0: + get: + return n_rays + set(value): + n_rays = value + _update() + +@export_range(5, 3000, 5.0) var ray_length := 200: + get: + return ray_length + set(value): + ray_length = value + _update() +@export_range(5, 360, 5.0) var cone_width := 360.0: + get: + return cone_width + set(value): + cone_width = value + _update() + +@export var debug_draw := true: + get: + return debug_draw + set(value): + debug_draw = value + _update() + +var _angles = [] +var rays := [] + + +func _update(): + if Engine.is_editor_hint(): + if debug_draw: + _spawn_nodes() + else: + for ray in get_children(): + if ray is RayCast2D: + remove_child(ray) + + +func _ready() -> void: + _spawn_nodes() + + +func _spawn_nodes(): + for ray in rays: + ray.queue_free() + rays = [] + + _angles = [] + var step = cone_width / (n_rays) + var start = step / 2 - cone_width / 2 + + for i in n_rays: + var angle = start + i * step + var ray = RayCast2D.new() + ray.set_target_position( + Vector2(ray_length * cos(deg_to_rad(angle)), ray_length * sin(deg_to_rad(angle))) + ) + ray.set_name("node_" + str(i)) + ray.enabled = false + ray.collide_with_areas = collide_with_areas + ray.collide_with_bodies = collide_with_bodies + ray.collision_mask = collision_mask + add_child(ray) + rays.append(ray) + + _angles.append(start + i * step) + + +func get_observation() -> Array: + return self.calculate_raycasts() + + +func calculate_raycasts() -> Array: + var result = [] + for ray in rays: + ray.enabled = true + ray.force_raycast_update() + var distance = _get_raycast_distance(ray) + result.append(distance) + ray.enabled = false + return result + + +func _get_raycast_distance(ray: RayCast2D) -> float: + if !ray.is_colliding(): + return 0.0 + + var distance = (global_position - ray.get_collision_point()).length() + distance = clamp(distance, 0.0, ray_length) + return (ray_length - distance) / ray_length diff --git a/addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.tscn b/addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.tscn new file mode 100644 index 0000000000000000000000000000000000000000..5ca402c08305efedbfc6afd0a1893a0ca2e11cfd --- /dev/null +++ b/addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.tscn @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=3 uid="uid://drvfihk5esgmv"] + +[ext_resource type="Script" path="res://addons/godot_rl_agents/sensors/sensors_2d/RaycastSensor2D.gd" id="1"] + +[node name="RaycastSensor2D" type="Node2D"] +script = ExtResource("1") +n_rays = 17.0 diff --git a/addons/godot_rl_agents/sensors/sensors_3d/ExampleRaycastSensor3D.tscn b/addons/godot_rl_agents/sensors/sensors_3d/ExampleRaycastSensor3D.tscn new file mode 100644 index 0000000000000000000000000000000000000000..a8057c7619cbb835709d2704074b0d5ebfa00a0c --- /dev/null +++ b/addons/godot_rl_agents/sensors/sensors_3d/ExampleRaycastSensor3D.tscn @@ -0,0 +1,6 @@ +[gd_scene format=3 uid="uid://biu787qh4woik"] + +[node name="ExampleRaycastSensor3D" type="Node3D"] + +[node name="Camera3D" type="Camera3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.804183, 0, 2.70146) diff --git a/addons/godot_rl_agents/sensors/sensors_3d/GridSensor3D.gd b/addons/godot_rl_agents/sensors/sensors_3d/GridSensor3D.gd new file mode 100644 index 0000000000000000000000000000000000000000..03593cc04d74ce0d0f16a4518e59b9309a09a5a7 --- /dev/null +++ b/addons/godot_rl_agents/sensors/sensors_3d/GridSensor3D.gd @@ -0,0 +1,258 @@ +@tool +extends ISensor3D +class_name GridSensor3D + +@export var debug_view := false: + get: + return debug_view + set(value): + debug_view = value + _update() + +@export_flags_3d_physics var detection_mask := 0: + get: + return detection_mask + set(value): + detection_mask = value + _update() + +@export var collide_with_areas := false: + get: + return collide_with_areas + set(value): + collide_with_areas = value + _update() + +@export var collide_with_bodies := false: + # NOTE! The sensor will not detect StaticBody3D, add an area to static bodies to detect them + get: + return collide_with_bodies + set(value): + collide_with_bodies = value + _update() + +@export_range(0.1, 2, 0.1) var cell_width := 1.0: + get: + return cell_width + set(value): + cell_width = value + _update() + +@export_range(0.1, 2, 0.1) var cell_height := 1.0: + get: + return cell_height + set(value): + cell_height = value + _update() + +@export_range(1, 21, 2, "or_greater") var grid_size_x := 3: + get: + return grid_size_x + set(value): + grid_size_x = value + _update() + +@export_range(1, 21, 2, "or_greater") var grid_size_z := 3: + get: + return grid_size_z + set(value): + grid_size_z = value + _update() + +var _obs_buffer: PackedFloat64Array +var _box_shape: BoxShape3D +var _collision_mapping: Dictionary +var _n_layers_per_cell: int + +var _highlighted_box_material: StandardMaterial3D +var _standard_box_material: StandardMaterial3D + + +func get_observation(): + return _obs_buffer + + +func reset(): + _obs_buffer.fill(0) + + +func _update(): + if Engine.is_editor_hint(): + if is_node_ready(): + _spawn_nodes() + + +func _ready() -> void: + _make_materials() + + if Engine.is_editor_hint(): + if get_child_count() == 0: + _spawn_nodes() + else: + _spawn_nodes() + + +func _make_materials() -> void: + if _highlighted_box_material != null and _standard_box_material != null: + return + + _standard_box_material = StandardMaterial3D.new() + _standard_box_material.set_transparency(1) # ALPHA + _standard_box_material.albedo_color = Color( + 100.0 / 255.0, 100.0 / 255.0, 100.0 / 255.0, 100.0 / 255.0 + ) + + _highlighted_box_material = StandardMaterial3D.new() + _highlighted_box_material.set_transparency(1) # ALPHA + _highlighted_box_material.albedo_color = Color( + 255.0 / 255.0, 100.0 / 255.0, 100.0 / 255.0, 100.0 / 255.0 + ) + + +func _get_collision_mapping() -> Dictionary: + # defines which layer is mapped to which cell obs index + var total_bits = 0 + var collision_mapping = {} + for i in 32: + var bit_mask = 2 ** i + if (detection_mask & bit_mask) > 0: + collision_mapping[i] = total_bits + total_bits += 1 + + return collision_mapping + + +func _spawn_nodes(): + for cell in get_children(): + cell.name = "_%s" % cell.name # Otherwise naming below will fail + cell.queue_free() + + _collision_mapping = _get_collision_mapping() + #prints("collision_mapping", _collision_mapping, len(_collision_mapping)) + # allocate memory for the observations + _n_layers_per_cell = len(_collision_mapping) + _obs_buffer = PackedFloat64Array() + _obs_buffer.resize(grid_size_x * grid_size_z * _n_layers_per_cell) + _obs_buffer.fill(0) + #prints(len(_obs_buffer), _obs_buffer ) + + _box_shape = BoxShape3D.new() + _box_shape.set_size(Vector3(cell_width, cell_height, cell_width)) + + var shift := Vector3( + -(grid_size_x / 2) * cell_width, + 0, + -(grid_size_z / 2) * cell_width, + ) + + for i in grid_size_x: + for j in grid_size_z: + var cell_position = Vector3(i * cell_width, 0.0, j * cell_width) + shift + _create_cell(i, j, cell_position) + + +func _create_cell(i: int, j: int, position: Vector3): + var cell := Area3D.new() + cell.position = position + cell.name = "GridCell %s %s" % [i, j] + + if collide_with_areas: + cell.area_entered.connect(_on_cell_area_entered.bind(i, j)) + cell.area_exited.connect(_on_cell_area_exited.bind(i, j)) + + if collide_with_bodies: + cell.body_entered.connect(_on_cell_body_entered.bind(i, j)) + cell.body_exited.connect(_on_cell_body_exited.bind(i, j)) + +# cell.body_shape_entered.connect(_on_cell_body_shape_entered.bind(i, j)) +# cell.body_shape_exited.connect(_on_cell_body_shape_exited.bind(i, j)) + + cell.collision_layer = 0 + cell.collision_mask = detection_mask + cell.monitorable = true + cell.input_ray_pickable = false + add_child(cell) + cell.set_owner(get_tree().edited_scene_root) + + var col_shape := CollisionShape3D.new() + col_shape.shape = _box_shape + col_shape.name = "CollisionShape3D" + cell.add_child(col_shape) + col_shape.set_owner(get_tree().edited_scene_root) + + if debug_view: + var box = MeshInstance3D.new() + box.name = "MeshInstance3D" + var box_mesh = BoxMesh.new() + + box_mesh.set_size(Vector3(cell_width, cell_height, cell_width)) + box_mesh.material = _standard_box_material + + box.mesh = box_mesh + cell.add_child(box) + box.set_owner(get_tree().edited_scene_root) + + +func _update_obs(cell_i: int, cell_j: int, collision_layer: int, entered: bool): + for key in _collision_mapping: + var bit_mask = 2 ** key + if (collision_layer & bit_mask) > 0: + var collison_map_index = _collision_mapping[key] + + var obs_index = ( + (cell_i * grid_size_x * _n_layers_per_cell) + + (cell_j * _n_layers_per_cell) + + collison_map_index + ) + #prints(obs_index, cell_i, cell_j) + if entered: + _obs_buffer[obs_index] += 1 + else: + _obs_buffer[obs_index] -= 1 + + +func _toggle_cell(cell_i: int, cell_j: int): + var cell = get_node_or_null("GridCell %s %s" % [cell_i, cell_j]) + + if cell == null: + print("cell not found, returning") + + var n_hits = 0 + var start_index = (cell_i * grid_size_x * _n_layers_per_cell) + (cell_j * _n_layers_per_cell) + for i in _n_layers_per_cell: + n_hits += _obs_buffer[start_index + i] + + var cell_mesh = cell.get_node_or_null("MeshInstance3D") + if n_hits > 0: + cell_mesh.mesh.material = _highlighted_box_material + else: + cell_mesh.mesh.material = _standard_box_material + + +func _on_cell_area_entered(area: Area3D, cell_i: int, cell_j: int): + #prints("_on_cell_area_entered", cell_i, cell_j) + _update_obs(cell_i, cell_j, area.collision_layer, true) + if debug_view: + _toggle_cell(cell_i, cell_j) + #print(_obs_buffer) + + +func _on_cell_area_exited(area: Area3D, cell_i: int, cell_j: int): + #prints("_on_cell_area_exited", cell_i, cell_j) + _update_obs(cell_i, cell_j, area.collision_layer, false) + if debug_view: + _toggle_cell(cell_i, cell_j) + + +func _on_cell_body_entered(body: Node3D, cell_i: int, cell_j: int): + #prints("_on_cell_body_entered", cell_i, cell_j) + _update_obs(cell_i, cell_j, body.collision_layer, true) + if debug_view: + _toggle_cell(cell_i, cell_j) + + +func _on_cell_body_exited(body: Node3D, cell_i: int, cell_j: int): + #prints("_on_cell_body_exited", cell_i, cell_j) + _update_obs(cell_i, cell_j, body.collision_layer, false) + if debug_view: + _toggle_cell(cell_i, cell_j) diff --git a/addons/godot_rl_agents/sensors/sensors_3d/ISensor3D.gd b/addons/godot_rl_agents/sensors/sensors_3d/ISensor3D.gd new file mode 100644 index 0000000000000000000000000000000000000000..aca3c2db480c5f61058d565ae4652916af4c51ad --- /dev/null +++ b/addons/godot_rl_agents/sensors/sensors_3d/ISensor3D.gd @@ -0,0 +1,25 @@ +extends Node3D +class_name ISensor3D + +var _obs: Array = [] +var _active := false + + +func get_observation(): + pass + + +func activate(): + _active = true + + +func deactivate(): + _active = false + + +func _update_observation(): + pass + + +func reset(): + pass diff --git a/addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.gd b/addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.gd new file mode 100644 index 0000000000000000000000000000000000000000..1037e970c3dccd26c6b987533115d12fca790549 --- /dev/null +++ b/addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.gd @@ -0,0 +1,21 @@ +extends Node3D +class_name RGBCameraSensor3D +var camera_pixels = null + +@onready var camera_texture := $Control/TextureRect/CameraTexture as Sprite2D +@onready var sub_viewport := $SubViewport as SubViewport + + +func get_camera_pixel_encoding(): + return camera_texture.get_texture().get_image().get_data().hex_encode() + + +func get_camera_shape() -> Array: + assert( + sub_viewport.size.x >= 36 and sub_viewport.size.y >= 36, + "SubViewport size must be 36x36 or larger." + ) + if sub_viewport.transparent_bg: + return [4, sub_viewport.size.y, sub_viewport.size.x] + else: + return [3, sub_viewport.size.y, sub_viewport.size.x] diff --git a/addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.tscn b/addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.tscn new file mode 100644 index 0000000000000000000000000000000000000000..052b5577db16ab7d25f5f473a539b3099f400db8 --- /dev/null +++ b/addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.tscn @@ -0,0 +1,41 @@ +[gd_scene load_steps=3 format=3 uid="uid://baaywi3arsl2m"] + +[ext_resource type="Script" path="res://addons/godot_rl_agents/sensors/sensors_3d/RGBCameraSensor3D.gd" id="1"] + +[sub_resource type="ViewportTexture" id="1"] +viewport_path = NodePath("SubViewport") + +[node name="RGBCameraSensor3D" type="Node3D"] +script = ExtResource("1") + +[node name="RemoteTransform3D" type="RemoteTransform3D" parent="."] +remote_path = NodePath("../SubViewport/Camera3D") + +[node name="SubViewport" type="SubViewport" parent="."] +size = Vector2i(32, 32) +render_target_update_mode = 3 + +[node name="Camera3D" type="Camera3D" parent="SubViewport"] +near = 0.5 + +[node name="Control" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="TextureRect" type="ColorRect" parent="Control"] +layout_mode = 0 +offset_left = 1096.0 +offset_top = 534.0 +offset_right = 1114.0 +offset_bottom = 552.0 +scale = Vector2(10, 10) +color = Color(0.00784314, 0.00784314, 0.00784314, 1) + +[node name="CameraTexture" type="Sprite2D" parent="Control/TextureRect"] +texture = SubResource("1") +offset = Vector2(9, 9) +flip_v = true diff --git a/addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.gd b/addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.gd new file mode 100644 index 0000000000000000000000000000000000000000..1357529f9232c3323316212cc84042bde1afb6f2 --- /dev/null +++ b/addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.gd @@ -0,0 +1,185 @@ +@tool +extends ISensor3D +class_name RayCastSensor3D +@export_flags_3d_physics var collision_mask = 1: + get: + return collision_mask + set(value): + collision_mask = value + _update() +@export_flags_3d_physics var boolean_class_mask = 1: + get: + return boolean_class_mask + set(value): + boolean_class_mask = value + _update() + +@export var n_rays_width := 6.0: + get: + return n_rays_width + set(value): + n_rays_width = value + _update() + +@export var n_rays_height := 6.0: + get: + return n_rays_height + set(value): + n_rays_height = value + _update() + +@export var ray_length := 10.0: + get: + return ray_length + set(value): + ray_length = value + _update() + +@export var cone_width := 60.0: + get: + return cone_width + set(value): + cone_width = value + _update() + +@export var cone_height := 60.0: + get: + return cone_height + set(value): + cone_height = value + _update() + +@export var collide_with_areas := false: + get: + return collide_with_areas + set(value): + collide_with_areas = value + _update() + +@export var collide_with_bodies := true: + get: + return collide_with_bodies + set(value): + collide_with_bodies = value + _update() + +@export var class_sensor := false + +var rays := [] +var geo = null + + +func _update(): + if Engine.is_editor_hint(): + if is_node_ready(): + _spawn_nodes() + + +func _ready() -> void: + if Engine.is_editor_hint(): + if get_child_count() == 0: + _spawn_nodes() + else: + _spawn_nodes() + + +func _spawn_nodes(): + print("spawning nodes") + for ray in get_children(): + ray.queue_free() + if geo: + geo.clear() + #$Lines.remove_points() + rays = [] + + var horizontal_step = cone_width / (n_rays_width) + var vertical_step = cone_height / (n_rays_height) + + var horizontal_start = horizontal_step / 2 - cone_width / 2 + var vertical_start = vertical_step / 2 - cone_height / 2 + + var points = [] + + for i in n_rays_width: + for j in n_rays_height: + var angle_w = horizontal_start + i * horizontal_step + var angle_h = vertical_start + j * vertical_step + #angle_h = 0.0 + var ray = RayCast3D.new() + var cast_to = to_spherical_coords(ray_length, angle_w, angle_h) + ray.set_target_position(cast_to) + + points.append(cast_to) + + ray.set_name("node_" + str(i) + " " + str(j)) + ray.enabled = true + ray.collide_with_bodies = collide_with_bodies + ray.collide_with_areas = collide_with_areas + ray.collision_mask = collision_mask + add_child(ray) + ray.set_owner(get_tree().edited_scene_root) + rays.append(ray) + ray.force_raycast_update() + + +# if Engine.editor_hint: +# _create_debug_lines(points) + + +func _create_debug_lines(points): + if not geo: + geo = ImmediateMesh.new() + add_child(geo) + + geo.clear() + geo.begin(Mesh.PRIMITIVE_LINES) + for point in points: + geo.set_color(Color.AQUA) + geo.add_vertex(Vector3.ZERO) + geo.add_vertex(point) + geo.end() + + +func display(): + if geo: + geo.display() + + +func to_spherical_coords(r, inc, azimuth) -> Vector3: + return Vector3( + r * sin(deg_to_rad(inc)) * cos(deg_to_rad(azimuth)), + r * sin(deg_to_rad(azimuth)), + r * cos(deg_to_rad(inc)) * cos(deg_to_rad(azimuth)) + ) + + +func get_observation() -> Array: + return self.calculate_raycasts() + + +func calculate_raycasts() -> Array: + var result = [] + for ray in rays: + ray.set_enabled(true) + ray.force_raycast_update() + var distance = _get_raycast_distance(ray) + + result.append(distance) + if class_sensor: + var hit_class: float = 0 + if ray.get_collider(): + var hit_collision_layer = ray.get_collider().collision_layer + hit_collision_layer = hit_collision_layer & collision_mask + hit_class = (hit_collision_layer & boolean_class_mask) > 0 + result.append(float(hit_class)) + ray.set_enabled(false) + return result + + +func _get_raycast_distance(ray: RayCast3D) -> float: + if !ray.is_colliding(): + return 0.0 + + var distance = (global_transform.origin - ray.get_collision_point()).length() + distance = clamp(distance, 0.0, ray_length) + return (ray_length - distance) / ray_length diff --git a/addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.tscn b/addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.tscn new file mode 100644 index 0000000000000000000000000000000000000000..35f9796596b2fb79bfcfe31e3d3a9637d9008e55 --- /dev/null +++ b/addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=2 format=3 uid="uid://b803cbh1fmy66"] + +[ext_resource type="Script" path="res://addons/godot_rl_agents/sensors/sensors_3d/RaycastSensor3D.gd" id="1"] + +[node name="RaycastSensor3D" type="Node3D"] +script = ExtResource("1") +n_rays_width = 4.0 +n_rays_height = 2.0 +ray_length = 11.0 + +[node name="node_1 0" type="RayCast3D" parent="."] +target_position = Vector3(-1.38686, -2.84701, 10.5343) + +[node name="node_1 1" type="RayCast3D" parent="."] +target_position = Vector3(-1.38686, 2.84701, 10.5343) + +[node name="node_2 0" type="RayCast3D" parent="."] +target_position = Vector3(1.38686, -2.84701, 10.5343) + +[node name="node_2 1" type="RayCast3D" parent="."] +target_position = Vector3(1.38686, 2.84701, 10.5343) + +[node name="node_3 0" type="RayCast3D" parent="."] +target_position = Vector3(4.06608, -2.84701, 9.81639) + +[node name="node_3 1" type="RayCast3D" parent="."] +target_position = Vector3(4.06608, 2.84701, 9.81639) diff --git a/addons/godot_rl_agents/sync.gd b/addons/godot_rl_agents/sync.gd new file mode 100644 index 0000000000000000000000000000000000000000..ed9cf0a9c0baf9a512bf1536b4f92544b29aa9e1 --- /dev/null +++ b/addons/godot_rl_agents/sync.gd @@ -0,0 +1,540 @@ +extends Node + +# --fixed-fps 2000 --disable-render-loop + +enum ControlModes { HUMAN, TRAINING, ONNX_INFERENCE } +@export var control_mode: ControlModes = ControlModes.TRAINING +@export_range(1, 10, 1, "or_greater") var action_repeat := 8 +@export_range(0, 10, 0.1, "or_greater") var speed_up := 1.0 +@export var onnx_model_path := "" + +# Onnx model stored for each requested path +var onnx_models: Dictionary + +@onready var start_time = Time.get_ticks_msec() + +const MAJOR_VERSION := "0" +const MINOR_VERSION := "7" +const DEFAULT_PORT := "11008" +const DEFAULT_SEED := "1" +var stream: StreamPeerTCP = null +var connected = false +var message_center +var should_connect = true + +var all_agents: Array +var agents_training: Array +var agents_inference: Array +var agents_heuristic: Array + +## For recording expert demos +var agent_demo_record: Node +## Stores recorded trajectories +var demo_trajectories: Array +## A trajectory includes obs: Array, acts: Array, terminal (set in Python env instead) +var current_demo_trajectory: Array + +var need_to_send_obs = false +var args = null +var initialized = false +var just_reset = false +var onnx_model = null +var n_action_steps = 0 + +var _action_space: Dictionary +var _action_space_inference: Array[Dictionary] = [] +var _obs_space: Dictionary + + +# Called when the node enters the scene tree for the first time. +func _ready(): + await get_tree().root.ready + get_tree().set_pause(true) + _initialize() + await get_tree().create_timer(1.0).timeout + get_tree().set_pause(false) + + +func _initialize(): + _get_agents() + args = _get_args() + Engine.physics_ticks_per_second = _get_speedup() * 60 # Replace with function body. + Engine.time_scale = _get_speedup() * 1.0 + prints( + "physics ticks", + Engine.physics_ticks_per_second, + Engine.time_scale, + _get_speedup(), + speed_up + ) + + _set_heuristic("human", all_agents) + + _initialize_training_agents() + _initialize_inference_agents() + _initialize_demo_recording() + + _set_seed() + _set_action_repeat() + initialized = true + + +func _initialize_training_agents(): + if agents_training.size() > 0: + _obs_space = agents_training[0].get_obs_space() + _action_space = agents_training[0].get_action_space() + connected = connect_to_server() + if connected: + _set_heuristic("model", agents_training) + _handshake() + _send_env_info() + else: + push_warning( + "Couldn't connect to Python server, using human controls instead. ", + "Did you start the training server using e.g. `gdrl` from the console?" + ) + + +func _initialize_inference_agents(): + if agents_inference.size() > 0: + if control_mode == ControlModes.ONNX_INFERENCE: + assert( + FileAccess.file_exists(onnx_model_path), + "Onnx Model Path set on Sync node does not exist: %s" % onnx_model_path + ) + onnx_models[onnx_model_path] = ONNXModel.new(onnx_model_path, 1) + + for agent in agents_inference: + _action_space_inference.append(agent.get_action_space()) + + var agent_onnx_model: ONNXModel + if agent.onnx_model_path.is_empty(): + assert( + onnx_models.has(onnx_model_path), + ( + "Node %s has no onnx model path set " % agent.get_path() + + "and sync node's control mode is not set to OnnxInference. " + + "Either add the path to the AIController, " + + "or if you want to use the path set on sync node instead, " + + "set control mode to OnnxInference." + ) + ) + prints( + "Info: AIController %s" % agent.get_path(), + "has no onnx model path set.", + "Using path set on the sync node instead." + ) + agent_onnx_model = onnx_models[onnx_model_path] + else: + if not onnx_models.has(agent.onnx_model_path): + assert( + FileAccess.file_exists(agent.onnx_model_path), + ( + "Onnx Model Path set on %s node does not exist: %s" + % [agent.get_path(), agent.onnx_model_path] + ) + ) + onnx_models[agent.onnx_model_path] = ONNXModel.new(agent.onnx_model_path, 1) + agent_onnx_model = onnx_models[agent.onnx_model_path] + + agent.onnx_model = agent_onnx_model + _set_heuristic("model", agents_inference) + + +func _initialize_demo_recording(): + if agent_demo_record: + InputMap.add_action("RemoveLastDemoEpisode") + InputMap.action_add_event( + "RemoveLastDemoEpisode", agent_demo_record.remove_last_episode_key + ) + current_demo_trajectory.resize(2) + current_demo_trajectory[0] = [] + current_demo_trajectory[1] = [] + agent_demo_record.heuristic = "demo_record" + + +func _physics_process(_delta): + # two modes, human control, agent control + # pause tree, send obs, get actions, set actions, unpause tree + + _demo_record_process() + + if n_action_steps % action_repeat != 0: + n_action_steps += 1 + return + + n_action_steps += 1 + + _training_process() + _inference_process() + _heuristic_process() + + +func _training_process(): + if connected: + get_tree().set_pause(true) + + if just_reset: + just_reset = false + var obs = _get_obs_from_agents(agents_training) + + var reply = {"type": "reset", "obs": obs} + _send_dict_as_json_message(reply) + # this should go straight to getting the action and setting it checked the agent, no need to perform one phyics tick + get_tree().set_pause(false) + return + + if need_to_send_obs: + need_to_send_obs = false + var reward = _get_reward_from_agents() + var done = _get_done_from_agents() + #_reset_agents_if_done() # this ensures the new observation is from the next env instance : NEEDS REFACTOR + + var obs = _get_obs_from_agents(agents_training) + + var reply = {"type": "step", "obs": obs, "reward": reward, "done": done} + _send_dict_as_json_message(reply) + + var handled = handle_message() + + +func _inference_process(): + if agents_inference.size() > 0: + var obs: Array = _get_obs_from_agents(agents_inference) + var actions = [] + + for agent_id in range(0, agents_inference.size()): + var action = agents_inference[agent_id].onnx_model.run_inference( + obs[agent_id]["obs"], 1.0 + ) + action["output"] = clamp_array(action["output"], -1.0, 1.0) + var action_dict = _extract_action_dict( + action["output"], _action_space_inference[agent_id] + ) + actions.append(action_dict) + + _set_agent_actions(actions, agents_inference) + _reset_agents_if_done(agents_inference) + get_tree().set_pause(false) + + +func _demo_record_process(): + if not agent_demo_record: + return + + if Input.is_action_just_pressed("RemoveLastDemoEpisode"): + print("[Sync script][Demo recorder] Removing last recorded episode.") + demo_trajectories.remove_at(demo_trajectories.size() - 1) + print("Remaining episode count: %d" % demo_trajectories.size()) + + if n_action_steps % agent_demo_record.action_repeat != 0: + return + + var obs_dict: Dictionary = agent_demo_record.get_obs() + + # Get the current obs from the agent + assert( + obs_dict.has("obs"), + "Demo recorder needs an 'obs' key in get_obs() returned dictionary to record obs from." + ) + current_demo_trajectory[0].append(obs_dict.obs) + + # Get the action applied for the current obs from the agent + agent_demo_record.set_action() + var acts = agent_demo_record.get_action() + + var terminal = agent_demo_record.get_done() + # Record actions only for non-terminal states + if terminal: + agent_demo_record.set_done_false() + else: + current_demo_trajectory[1].append(acts) + + if terminal: + #current_demo_trajectory[2].append(true) + demo_trajectories.append(current_demo_trajectory.duplicate(true)) + print("[Sync script][Demo recorder] Recorded episode count: %d" % demo_trajectories.size()) + current_demo_trajectory[0].clear() + current_demo_trajectory[1].clear() + + +func _heuristic_process(): + for agent in agents_heuristic: + _reset_agents_if_done(agents_heuristic) + + +func _extract_action_dict(action_array: Array, action_space: Dictionary): + var index = 0 + var result = {} + for key in action_space.keys(): + var size = action_space[key]["size"] + if action_space[key]["action_type"] == "discrete": + result[key] = round(action_array[index]) + else: + result[key] = action_array.slice(index, index + size) + index += size + + return result + + +## For AIControllers that inherit mode from sync, sets the correct mode. +func _set_agent_mode(agent: Node): + var agent_inherits_mode: bool = agent.control_mode == agent.ControlModes.INHERIT_FROM_SYNC + + if agent_inherits_mode: + match control_mode: + ControlModes.HUMAN: + agent.control_mode = agent.ControlModes.HUMAN + ControlModes.TRAINING: + agent.control_mode = agent.ControlModes.TRAINING + ControlModes.ONNX_INFERENCE: + agent.control_mode = agent.ControlModes.ONNX_INFERENCE + + +func _get_agents(): + all_agents = get_tree().get_nodes_in_group("AGENT") + for agent in all_agents: + _set_agent_mode(agent) + + if agent.control_mode == agent.ControlModes.TRAINING: + agents_training.append(agent) + elif agent.control_mode == agent.ControlModes.ONNX_INFERENCE: + agents_inference.append(agent) + elif agent.control_mode == agent.ControlModes.HUMAN: + agents_heuristic.append(agent) + elif agent.control_mode == agent.ControlModes.RECORD_EXPERT_DEMOS: + assert( + not agent_demo_record, + "Currently only a single AIController can be used for recording expert demos." + ) + agent_demo_record = agent + + +func _set_heuristic(heuristic, agents: Array): + for agent in agents: + agent.set_heuristic(heuristic) + + +func _handshake(): + print("performing handshake") + + var json_dict = _get_dict_json_message() + assert(json_dict["type"] == "handshake") + var major_version = json_dict["major_version"] + var minor_version = json_dict["minor_version"] + if major_version != MAJOR_VERSION: + print("WARNING: major verison mismatch ", major_version, " ", MAJOR_VERSION) + if minor_version != MINOR_VERSION: + print("WARNING: minor verison mismatch ", minor_version, " ", MINOR_VERSION) + + print("handshake complete") + + +func _get_dict_json_message(): + # returns a dictionary from of the most recent message + # this is not waiting + while stream.get_available_bytes() == 0: + stream.poll() + if stream.get_status() != 2: + print("server disconnected status, closing") + get_tree().quit() + return null + + OS.delay_usec(10) + + var message = stream.get_string() + var json_data = JSON.parse_string(message) + + return json_data + + +func _send_dict_as_json_message(dict): + stream.put_string(JSON.stringify(dict, "", false)) + + +func _send_env_info(): + var json_dict = _get_dict_json_message() + assert(json_dict["type"] == "env_info") + + var message = { + "type": "env_info", + "observation_space": _obs_space, + "action_space": _action_space, + "n_agents": len(agents_training) + } + _send_dict_as_json_message(message) + + +func connect_to_server(): + print("Waiting for one second to allow server to start") + OS.delay_msec(1000) + print("trying to connect to server") + stream = StreamPeerTCP.new() + + # "localhost" was not working on windows VM, had to use the IP + var ip = "127.0.0.1" + var port = _get_port() + var connect = stream.connect_to_host(ip, port) + stream.set_no_delay(true) # TODO check if this improves performance or not + stream.poll() + # Fetch the status until it is either connected (2) or failed to connect (3) + while stream.get_status() < 2: + stream.poll() + return stream.get_status() == 2 + + +func _get_args(): + print("getting command line arguments") + var arguments = {} + for argument in OS.get_cmdline_args(): + print(argument) + if argument.find("=") > -1: + var key_value = argument.split("=") + arguments[key_value[0].lstrip("--")] = key_value[1] + else: + # Options without an argument will be present in the dictionary, + # with the value set to an empty string. + arguments[argument.lstrip("--")] = "" + + return arguments + + +func _get_speedup(): + print(args) + return args.get("speedup", str(speed_up)).to_float() + + +func _get_port(): + return args.get("port", DEFAULT_PORT).to_int() + + +func _set_seed(): + var _seed = args.get("env_seed", DEFAULT_SEED).to_int() + seed(_seed) + + +func _set_action_repeat(): + action_repeat = args.get("action_repeat", str(action_repeat)).to_int() + + +func disconnect_from_server(): + stream.disconnect_from_host() + + +func handle_message() -> bool: + # get json message: reset, step, close + var message = _get_dict_json_message() + if message["type"] == "close": + print("received close message, closing game") + get_tree().quit() + get_tree().set_pause(false) + return true + + if message["type"] == "reset": + print("resetting all agents") + _reset_agents() + just_reset = true + get_tree().set_pause(false) + #print("resetting forcing draw") +# RenderingServer.force_draw() +# var obs = _get_obs_from_agents() +# print("obs ", obs) +# var reply = { +# "type": "reset", +# "obs": obs +# } +# _send_dict_as_json_message(reply) + return true + + if message["type"] == "call": + var method = message["method"] + var returns = _call_method_on_agents(method) + var reply = {"type": "call", "returns": returns} + print("calling method from Python") + _send_dict_as_json_message(reply) + return handle_message() + + if message["type"] == "action": + var action = message["action"] + _set_agent_actions(action, agents_training) + need_to_send_obs = true + get_tree().set_pause(false) + return true + + print("message was not handled") + return false + + +func _call_method_on_agents(method): + var returns = [] + for agent in all_agents: + returns.append(agent.call(method)) + + return returns + + +func _reset_agents_if_done(agents = all_agents): + for agent in agents: + if agent.get_done(): + agent.set_done_false() + + +func _reset_agents(agents = all_agents): + for agent in agents: + agent.needs_reset = true + #agent.reset() + + +func _get_obs_from_agents(agents: Array = all_agents): + var obs = [] + for agent in agents: + obs.append(agent.get_obs()) + return obs + + +func _get_reward_from_agents(agents: Array = agents_training): + var rewards = [] + for agent in agents: + rewards.append(agent.get_reward()) + agent.zero_reward() + return rewards + + +func _get_done_from_agents(agents: Array = agents_training): + var dones = [] + for agent in agents: + var done = agent.get_done() + if done: + agent.set_done_false() + dones.append(done) + return dones + + +func _set_agent_actions(actions, agents: Array = all_agents): + for i in range(len(actions)): + agents[i].set_action(actions[i]) + + +func clamp_array(arr: Array, min: float, max: float): + var output: Array = [] + for a in arr: + output.append(clamp(a, min, max)) + return output + + +## Save recorded export demos on window exit (Close window instead of "Stop" button in Godot Editor) +func _notification(what): + if not agent_demo_record: + return + + if what == NOTIFICATION_PREDELETE: + var json_string = JSON.stringify(demo_trajectories, "", false) + var file = FileAccess.open(agent_demo_record.expert_demo_save_path, FileAccess.WRITE) + + if not file: + var error: Error = FileAccess.get_open_error() + assert(not error, "There was an error opening the file: %d" % error) + + file.store_line(json_string) + var error = file.get_error() + assert(not error, "There was an error after trying to write to the file: %d" % error) diff --git a/alps_field_2k.hdr b/alps_field_2k.hdr new file mode 100644 index 0000000000000000000000000000000000000000..c402571f6e32e335d363034882c90b0c0a013583 --- /dev/null +++ b/alps_field_2k.hdr @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:90ef5a4e0c46d0177a06406b59142a6bb426176a85c195fa23d2e443383a9e12 +size 6531494 diff --git a/cartoon_plane/Body.material b/cartoon_plane/Body.material new file mode 100644 index 0000000000000000000000000000000000000000..442ac394b6fe8b6fbb07b20818c68fc2078af5a4 Binary files /dev/null and b/cartoon_plane/Body.material differ diff --git a/cartoon_plane/Cube_1_3__0.material b/cartoon_plane/Cube_1_3__0.material new file mode 100644 index 0000000000000000000000000000000000000000..1b2bc35673583f9ee72bca27438e6186edf9f44d Binary files /dev/null and b/cartoon_plane/Cube_1_3__0.material differ diff --git a/cartoon_plane/Glass.material b/cartoon_plane/Glass.material new file mode 100644 index 0000000000000000000000000000000000000000..b8b03e57545d930b5ef4a2623e57e9e0103105b0 Binary files /dev/null and b/cartoon_plane/Glass.material differ diff --git a/cartoon_plane/material.material b/cartoon_plane/material.material new file mode 100644 index 0000000000000000000000000000000000000000..532889f8cf5bc71a23cf85fd6e76363ee4fad1db Binary files /dev/null and b/cartoon_plane/material.material differ diff --git a/cartoon_plane/material_3.material b/cartoon_plane/material_3.material new file mode 100644 index 0000000000000000000000000000000000000000..7fb001d73e54132c51f9538b13c27f77d150d8cc Binary files /dev/null and b/cartoon_plane/material_3.material differ diff --git a/cartoon_plane/scene.bin b/cartoon_plane/scene.bin new file mode 100644 index 0000000000000000000000000000000000000000..d8273305e7700599f5d84d6fad6d5722f2fea113 --- /dev/null +++ b/cartoon_plane/scene.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:69acdd991464940059d06172ab3c298f11b312f5d924bef1ba3f8b4a35ba2032 +size 216896 diff --git a/cartoon_plane/scene.gltf b/cartoon_plane/scene.gltf new file mode 100644 index 0000000000000000000000000000000000000000..e3a22ca5c90cd4f71b729a115a12d551e512c4d5 --- /dev/null +++ b/cartoon_plane/scene.gltf @@ -0,0 +1,3208 @@ +{ + "accessors": [ + { + "bufferView": 2, + "componentType": 5126, + "count": 163, + "max": [ + 12.949999809265137, + 12.070835113525391, + 16.631193161010742 + ], + "min": [ + -10.476770401000977, + -12.561528205871582, + -10.497358322143555 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 1956, + "componentType": 5126, + "count": 163, + "max": [ + 0.7753106951713562, + 0.91143244504928589, + 0.28564080595970154 + ], + "min": [ + -0.95833677053451538, + -0.91143244504928589, + -1 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "componentType": 5126, + "count": 163, + "max": [ + 0.95105659961700439, + 0.8090171217918396, + 2.4478199023292291e-08, + 1 + ], + "min": [ + -1, + -1, + -2.7669146973607894e-08, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "componentType": 5126, + "count": 163, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "componentType": 5125, + "count": 435, + "max": [ + 162 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 3912, + "componentType": 5126, + "count": 168, + "max": [ + 69.045951843261719, + 115.68470764160156, + 1.6864264011383057 + ], + "min": [ + -131.32583618164062, + -115.68470764160156, + -3.4447975158691406 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 5928, + "componentType": 5126, + "count": 168, + "max": [ + 1, + 0.99593973159790039, + 0.99936956167221069 + ], + "min": [ + -1, + -0.99593973159790039, + -0.99936956167221069 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 2608, + "componentType": 5126, + "count": 168, + "max": [ + 0.99999493360519409, + 0.92716342210769653, + 0.99593979120254517, + 1 + ], + "min": [ + -0.99999487400054932, + -0.92672520875930786, + -1, + -1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 1304, + "componentType": 5126, + "count": 168, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 1740, + "componentType": 5125, + "count": 252, + "max": [ + 167 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 7944, + "componentType": 5126, + "count": 74, + "max": [ + -0.37032601237297058, + 4.978886604309082, + -2.5330522060394287 + ], + "min": [ + -2.423985481262207, + -16.757600784301758, + -4.5867118835449219 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 8832, + "componentType": 5126, + "count": 74, + "max": [ + 0.96592593193054199, + 1, + 0.96592593193054199 + ], + "min": [ + -0.96592593193054199, + -1, + -0.96592593193054199 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 5296, + "componentType": 5126, + "count": 74, + "max": [ + 1, + 4.1499621418179872e-24, + 0.96592593193054199, + 1 + ], + "min": [ + -1, + -9.3374238909908813e-24, + -0.96592587232589722, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 2648, + "componentType": 5126, + "count": 74, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 2748, + "componentType": 5125, + "count": 144, + "max": [ + 73 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 9720, + "componentType": 5126, + "count": 168, + "max": [ + -103.08991241455078, + -37.86639404296875, + -0.033820558339357376 + ], + "min": [ + -124.04102325439453, + -92.227767944335938, + -2.9683210849761963 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 11736, + "componentType": 5126, + "count": 168, + "max": [ + 1, + 1, + 1 + ], + "min": [ + -1, + -1, + -1 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 6480, + "componentType": 5126, + "count": 168, + "max": [ + 1, + 0.99937671422958374, + 1, + 1 + ], + "min": [ + -1, + -0.99937677383422852, + -1, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 3240, + "componentType": 5126, + "count": 168, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 3324, + "componentType": 5125, + "count": 252, + "max": [ + 167 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 13752, + "componentType": 5126, + "count": 386, + "max": [ + 10.651838302612305, + 7.7758417129516602, + 10.651838302612305 + ], + "min": [ + -10.651838302612305, + -7.7758417129516602, + -10.651838302612305 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 18384, + "componentType": 5126, + "count": 386, + "max": [ + 0.96592593193054199, + 1, + 0.96592593193054199 + ], + "min": [ + -0.96592593193054199, + -1, + -0.96592593193054199 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 9168, + "componentType": 5126, + "count": 386, + "max": [ + 1, + 3.6031600814112608e-08, + 1, + 1 + ], + "min": [ + -1, + -4.9005969060544885e-08, + -0.96592593193054199, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 4584, + "componentType": 5126, + "count": 386, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 4332, + "componentType": 5125, + "count": 576, + "max": [ + 385 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 23016, + "componentType": 5126, + "count": 74, + "max": [ + -0.69157510995864868, + 9.2979526519775391, + -4.7304153442382812 + ], + "min": [ + -4.526735782623291, + -31.294424057006836, + -8.5655755996704102 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 23904, + "componentType": 5126, + "count": 74, + "max": [ + 0.96592593193054199, + 1, + 0.96592593193054199 + ], + "min": [ + -0.96592593193054199, + -1, + -0.96592593193054199 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 15344, + "componentType": 5126, + "count": 74, + "max": [ + 1, + 6.6666974310416953e-24, + 0.96592593193054199, + 1 + ], + "min": [ + -1, + -3.4205967316382915e-24, + -0.96592587232589722, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 7672, + "componentType": 5126, + "count": 74, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 6636, + "componentType": 5125, + "count": 144, + "max": [ + 73 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 24792, + "componentType": 5126, + "count": 158, + "max": [ + -192.51797485351562, + -70.714591979980469, + -0.063159093260765076 + ], + "min": [ + -231.6436767578125, + -172.23316955566406, + -5.5432696342468262 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 26688, + "componentType": 5126, + "count": 158, + "max": [ + 1, + 1, + 1 + ], + "min": [ + -1, + -1, + -1 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 16528, + "componentType": 5126, + "count": 158, + "max": [ + 1, + 0.99937677383422852, + 1, + 1 + ], + "min": [ + -1, + -0.99937683343887329, + -1, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 8264, + "componentType": 5126, + "count": 158, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 7212, + "componentType": 5125, + "count": 252, + "max": [ + 157 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 28584, + "componentType": 5126, + "count": 386, + "max": [ + 19.892055511474609, + 14.521201133728027, + 19.892055511474609 + ], + "min": [ + -19.892055511474609, + -14.521201133728027, + -19.892055511474609 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 33216, + "componentType": 5126, + "count": 386, + "max": [ + 0.96592593193054199, + 1, + 0.96592593193054199 + ], + "min": [ + -0.96592593193054199, + -1, + -0.96592593193054199 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 19056, + "componentType": 5126, + "count": 386, + "max": [ + 1, + 4.1396436500917844e-08, + 1, + 1 + ], + "min": [ + -1, + -7.2341222789873427e-08, + -0.96592593193054199, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 9528, + "componentType": 5126, + "count": 386, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 8220, + "componentType": 5125, + "count": 576, + "max": [ + 385 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 37848, + "componentType": 5126, + "count": 74, + "max": [ + -0.69157510995864868, + 9.2979526519775391, + -4.7304153442382812 + ], + "min": [ + -4.526735782623291, + -31.294424057006836, + -8.5655755996704102 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 38736, + "componentType": 5126, + "count": 74, + "max": [ + 0.96592593193054199, + 1, + 0.96592593193054199 + ], + "min": [ + -0.96592593193054199, + -1, + -0.96592593193054199 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 25232, + "componentType": 5126, + "count": 74, + "max": [ + 1, + 6.6666974310416953e-24, + 0.96592593193054199, + 1 + ], + "min": [ + -1, + -3.4205967316382915e-24, + -0.96592587232589722, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 12616, + "componentType": 5126, + "count": 74, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 10524, + "componentType": 5125, + "count": 144, + "max": [ + 73 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 39624, + "componentType": 5126, + "count": 158, + "max": [ + -192.51797485351562, + -70.714591979980469, + -0.063159093260765076 + ], + "min": [ + -231.6436767578125, + -172.23316955566406, + -5.5432696342468262 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 41520, + "componentType": 5126, + "count": 158, + "max": [ + 1, + 1, + 1 + ], + "min": [ + -1, + -1, + -1 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 26416, + "componentType": 5126, + "count": 158, + "max": [ + 1, + 0.99937677383422852, + 1, + 1 + ], + "min": [ + -1, + -0.99937683343887329, + -1, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 13208, + "componentType": 5126, + "count": 158, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 11100, + "componentType": 5125, + "count": 252, + "max": [ + 157 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 43416, + "componentType": 5126, + "count": 386, + "max": [ + 19.892055511474609, + 14.521201133728027, + 19.892055511474609 + ], + "min": [ + -19.892055511474609, + -14.521201133728027, + -19.892055511474609 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 48048, + "componentType": 5126, + "count": 386, + "max": [ + 0.96592593193054199, + 1, + 0.96592593193054199 + ], + "min": [ + -0.96592593193054199, + -1, + -0.96592593193054199 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 28944, + "componentType": 5126, + "count": 386, + "max": [ + 1, + 4.1396436500917844e-08, + 1, + 1 + ], + "min": [ + -1, + -7.2341222789873427e-08, + -0.96592593193054199, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 14472, + "componentType": 5126, + "count": 386, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 12108, + "componentType": 5125, + "count": 576, + "max": [ + 385 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 52680, + "componentType": 5126, + "count": 56, + "max": [ + 87.186851501464844, + -26.638965606689453, + 299.34503173828125 + ], + "min": [ + 48.678955078125, + -30.55317497253418, + 232.06298828125 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 53352, + "componentType": 5126, + "count": 56, + "max": [ + 0.98992806673049927, + 1, + 0.98992806673049927 + ], + "min": [ + -0.98992806673049927, + -1, + -0.98992806673049927 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 35120, + "componentType": 5126, + "count": 56, + "max": [ + 0.98992812633514404, + 0.0073813591152429581, + 0.98467016220092773, + 1 + ], + "min": [ + -0.98992806673049927, + -0.0089176241308450699, + -0.98467016220092773, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 17560, + "componentType": 5126, + "count": 56, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 14412, + "componentType": 5125, + "count": 84, + "max": [ + 55 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 54024, + "componentType": 5126, + "count": 56, + "max": [ + 87.186851501464844, + -32.165931701660156, + 299.34503173828125 + ], + "min": [ + 48.678955078125, + -36.08013916015625, + 232.06298828125 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 54696, + "componentType": 5126, + "count": 56, + "max": [ + 0.98992806673049927, + 1, + 0.98992806673049927 + ], + "min": [ + -0.98992806673049927, + -1, + -0.98992806673049927 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 36016, + "componentType": 5126, + "count": 56, + "max": [ + 0.98992812633514404, + 0.0073813600465655327, + 0.98467016220092773, + 1 + ], + "min": [ + -0.98992806673049927, + -0.0089175542816519737, + -0.98467016220092773, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 18008, + "componentType": 5126, + "count": 56, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 14748, + "componentType": 5125, + "count": 84, + "max": [ + 55 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 55368, + "componentType": 5126, + "count": 56, + "max": [ + 87.186851501464844, + -37.051544189453125, + 299.34503173828125 + ], + "min": [ + 48.678955078125, + -40.965751647949219, + 232.06298828125 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 56040, + "componentType": 5126, + "count": 56, + "max": [ + 0.98992806673049927, + 1, + 0.98992806673049927 + ], + "min": [ + -0.98992806673049927, + -1, + -0.98992806673049927 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 36912, + "componentType": 5126, + "count": 56, + "max": [ + 0.98992812633514404, + 0.0073827789165079594, + 0.98467016220092773, + 1 + ], + "min": [ + -0.98992806673049927, + -0.0089190937578678131, + -0.98467016220092773, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 18456, + "componentType": 5126, + "count": 56, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 15084, + "componentType": 5125, + "count": 84, + "max": [ + 55 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 56712, + "componentType": 5126, + "count": 56, + "max": [ + 87.186851501464844, + -26.638965606689453, + 299.34503173828125 + ], + "min": [ + 48.678955078125, + -30.55317497253418, + 232.06298828125 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 57384, + "componentType": 5126, + "count": 56, + "max": [ + 0.98992806673049927, + 1, + 0.98992806673049927 + ], + "min": [ + -0.98992806673049927, + -1, + -0.98992806673049927 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 37808, + "componentType": 5126, + "count": 56, + "max": [ + 0.98992812633514404, + 0.0073813591152429581, + 0.98467016220092773, + 1 + ], + "min": [ + -0.98992806673049927, + -0.0089176241308450699, + -0.98467016220092773, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 18904, + "componentType": 5126, + "count": 56, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 15420, + "componentType": 5125, + "count": 84, + "max": [ + 55 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 58056, + "componentType": 5126, + "count": 56, + "max": [ + 87.186851501464844, + -32.165931701660156, + 299.34503173828125 + ], + "min": [ + 48.678955078125, + -36.08013916015625, + 232.06298828125 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 58728, + "componentType": 5126, + "count": 56, + "max": [ + 0.98992806673049927, + 1, + 0.98992806673049927 + ], + "min": [ + -0.98992806673049927, + -1, + -0.98992806673049927 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 38704, + "componentType": 5126, + "count": 56, + "max": [ + 0.98992812633514404, + 0.0073813600465655327, + 0.98467016220092773, + 1 + ], + "min": [ + -0.98992806673049927, + -0.0089175542816519737, + -0.98467016220092773, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 19352, + "componentType": 5126, + "count": 56, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 15756, + "componentType": 5125, + "count": 84, + "max": [ + 55 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 59400, + "componentType": 5126, + "count": 56, + "max": [ + 87.186851501464844, + -37.051544189453125, + 299.34503173828125 + ], + "min": [ + 48.678955078125, + -40.965751647949219, + 232.06298828125 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 60072, + "componentType": 5126, + "count": 56, + "max": [ + 0.98992806673049927, + 1, + 0.98992806673049927 + ], + "min": [ + -0.98992806673049927, + -1, + -0.98992806673049927 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 39600, + "componentType": 5126, + "count": 56, + "max": [ + 0.98992812633514404, + 0.0073827789165079594, + 0.98467016220092773, + 1 + ], + "min": [ + -0.98992806673049927, + -0.0089190937578678131, + -0.98467016220092773, + 1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 19800, + "componentType": 5126, + "count": 56, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 16092, + "componentType": 5125, + "count": 84, + "max": [ + 55 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 60744, + "componentType": 5126, + "count": 529, + "max": [ + 417.94387817382812, + 99.216903686523438, + 398.960693359375 + ], + "min": [ + -417.86929321289062, + -95.718612670898438, + -393.07296752929688 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 67092, + "componentType": 5126, + "count": 529, + "max": [ + 1, + 0.99993491172790527, + 0.99861770868301392 + ], + "min": [ + -1, + -0.99995923042297363, + -0.99959629774093628 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 40496, + "componentType": 5126, + "count": 529, + "max": [ + 1, + 0.99503612518310547, + 0.98400908708572388, + 1 + ], + "min": [ + -1, + -0.93140757083892822, + -0.99999719858169556, + -1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 20248, + "componentType": 5126, + "count": 529, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 16428, + "componentType": 5125, + "count": 972, + "max": [ + 528 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 73440, + "componentType": 5126, + "count": 244, + "max": [ + 434.4974365234375, + 99.216903686523438, + 398.960693359375 + ], + "min": [ + -434.42288208007812, + -112.64717864990234, + -393.07296752929688 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 76368, + "componentType": 5126, + "count": 244, + "max": [ + 0.99999499320983887, + 0.99967437982559204, + 0.96623903512954712 + ], + "min": [ + -0.99999505281448364, + -0.99965155124664307, + -0.99979156255722046 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 48960, + "componentType": 5126, + "count": 244, + "max": [ + 1, + 0.99794167280197144, + 0.95789152383804321, + 1 + ], + "min": [ + -1, + -0.99984729290008545, + -0.9979901909828186, + -1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 24480, + "componentType": 5126, + "count": 244, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 20316, + "componentType": 5125, + "count": 420, + "max": [ + 243 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 79296, + "componentType": 5126, + "count": 16, + "max": [ + 72.184349060058594, + 87.669517517089844, + 225.43736267089844 + ], + "min": [ + -72.109786987304688, + -11.801899909973145, + 6.5268120765686035 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 79488, + "componentType": 5126, + "count": 16, + "max": [ + 0.94465756416320801, + 0.99961799383163452, + 0.87517642974853516 + ], + "min": [ + -0.99990540742874146, + -0.95777672529220581, + -0.59132260084152222 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 52864, + "componentType": 5126, + "count": 16, + "max": [ + 0.99952733516693115, + 0.39090055227279663, + 0.018440555781126022, + 1 + ], + "min": [ + -0.99994564056396484, + -0.1586826890707016, + -0.99664419889450073, + -1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 26432, + "componentType": 5126, + "count": 16, + "max": [ + 0.97632133960723877, + 0.98159992694854736 + ], + "min": [ + 0.013218616135418415, + 0.5194861888885498 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 21996, + "componentType": 5125, + "count": 24, + "max": [ + 15 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 79680, + "componentType": 5126, + "count": 120, + "max": [ + 359.43194580078125, + -52.727996826171875, + 234.7813720703125 + ], + "min": [ + -359.35739135742188, + -85.97186279296875, + 4.0965709686279297 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 81120, + "componentType": 5126, + "count": 120, + "max": [ + 0.98549240827560425, + 0.99958568811416626, + 0.99996495246887207 + ], + "min": [ + -0.92871010303497314, + -0.99781399965286255, + -0.99984771013259888 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 53120, + "componentType": 5126, + "count": 120, + "max": [ + 1, + 0.061126749962568283, + 0.99963241815567017, + 1 + ], + "min": [ + -0.99977493286132812, + -0.99864476919174194, + -0.97820085287094116, + -1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 26560, + "componentType": 5126, + "count": 120, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 22092, + "componentType": 5125, + "count": 180, + "max": [ + 119 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 82560, + "componentType": 5126, + "count": 275, + "max": [ + 0.050080213695764542, + 99.216903686523438, + 398.960693359375 + ], + "min": [ + -417.86929321289062, + -95.718612670898438, + -393.07296752929688 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 85860, + "componentType": 5126, + "count": 275, + "max": [ + 1, + 0.99992120265960693, + 0.99861770868301392 + ], + "min": [ + -1, + -0.99995225667953491, + -0.99959629774093628 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 55040, + "componentType": 5126, + "count": 275, + "max": [ + 1, + 0.99503612518310547, + 0.9840090274810791, + 1 + ], + "min": [ + -1, + -0.93140757083892822, + -0.99999719858169556, + -1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 27520, + "componentType": 5126, + "count": 275, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 22812, + "componentType": 5125, + "count": 486, + "max": [ + 274 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 89160, + "componentType": 5126, + "count": 121, + "max": [ + 0.031271640211343765, + 99.216903686523438, + 398.960693359375 + ], + "min": [ + -434.42288208007812, + -112.64717864990234, + -393.07296752929688 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 90612, + "componentType": 5126, + "count": 121, + "max": [ + 0.18651074171066284, + 0.99967437982559204, + 0.96623897552490234 + ], + "min": [ + -0.99999505281448364, + -0.99965155124664307, + -0.99979156255722046 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 59440, + "componentType": 5126, + "count": 121, + "max": [ + 1, + 0.99720406532287598, + 0.95789152383804321, + 1 + ], + "min": [ + -0.99976450204849243, + -0.99984729290008545, + -0.99799007177352905, + -1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 29720, + "componentType": 5126, + "count": 121, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 24756, + "componentType": 5125, + "count": 210, + "max": [ + 120 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 92064, + "componentType": 5126, + "count": 8, + "max": [ + -4.3827910423278809, + 87.669517517089844, + 225.43736267089844 + ], + "min": [ + -72.109786987304688, + -11.801899909973145, + 6.5268120765686035 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 92160, + "componentType": 5126, + "count": 8, + "max": [ + 0, + 0.45346537232398987, + 0.89127397537231445 + ], + "min": [ + -0.97785824537277222, + 0.1951594352722168, + -0.075538128614425659 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 61376, + "componentType": 5126, + "count": 8, + "max": [ + 0.058859270066022873, + 0, + 0, + -1 + ], + "min": [ + -1, + -0.15251168608665466, + -0.99502462148666382, + -1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 30688, + "componentType": 5126, + "count": 8, + "max": [ + 0.97632133960723877, + 0.98159992694854736 + ], + "min": [ + 0.013218616135418415, + 0.5194861888885498 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 25596, + "componentType": 5125, + "count": 12, + "max": [ + 7 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 92256, + "componentType": 5126, + "count": 60, + "max": [ + -63.003810882568359, + -52.727996826171875, + 234.7813720703125 + ], + "min": [ + -359.35739135742188, + -85.97186279296875, + 4.0965709686279297 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 92976, + "componentType": 5126, + "count": 60, + "max": [ + 0.99946296215057373, + 0.99798387289047241, + 0.9749215841293335 + ], + "min": [ + -0.99926775693893433, + -0.96400362253189087, + -0.99917972087860107 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 61504, + "componentType": 5126, + "count": 60, + "max": [ + 0.99996131658554077, + 0.24199792742729187, + 0.97319614887237549, + 1 + ], + "min": [ + -0.96364772319793701, + -0.99789917469024658, + -0.97976201772689819, + -1 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 30752, + "componentType": 5126, + "count": 60, + "max": [ + 1, + 1 + ], + "min": [ + 0, + 0 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 25644, + "componentType": 5125, + "count": 90, + "max": [ + 59 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 4, + "componentType": 5126, + "count": 175, + "max": [ + 3 + ], + "min": [ + 0 + ], + "type": "SCALAR" + }, + { + "bufferView": 5, + "componentType": 5126, + "count": 175, + "max": [ + 0, + 0, + 0.99452191591262817, + 1 + ], + "min": [ + 0, + 0, + -0.86602538824081421, + -0.5 + ], + "type": "VEC4" + } + ], + "animations": [ + { + "channels": [ + { + "sampler": 0, + "target": { + "node": 5, + "path": "rotation" + } + } + ], + "name": "Main", + "samplers": [ + { + "input": 125, + "interpolation": "LINEAR", + "output": 126 + } + ] + } + ], + "asset": { + "extras": { + "author": "antonmoek (https://sketchfab.com/antonmoek)", + "license": "CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)", + "source": "https://sketchfab.com/models/f312ec9f87794bdd83630a3bc694d8ea", + "title": "Cartoon Plane" + }, + "generator": "Sketchfab-3.34.6", + "version": "2.0" + }, + "bufferViews": [ + { + "buffer": 0, + "byteLength": 26004, + "byteOffset": 0, + "name": "floatBufferViews", + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 31232, + "byteOffset": 26004, + "byteStride": 8, + "name": "floatBufferViews", + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 93696, + "byteOffset": 57236, + "byteStride": 12, + "name": "floatBufferViews", + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 62464, + "byteOffset": 150932, + "byteStride": 16, + "name": "floatBufferViews", + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 700, + "byteOffset": 213396, + "name": "floatBufferViews" + }, + { + "buffer": 0, + "byteLength": 2800, + "byteOffset": 214096, + "byteStride": 16, + "name": "floatBufferViews" + } + ], + "buffers": [ + { + "byteLength": 216896, + "uri": "scene.bin" + } + ], + "materials": [ + { + "doubleSided": true, + "emissiveFactor": [ + 0, + 0, + 0 + ], + "name": "Cube_1_3__0", + "pbrMetallicRoughness": { + "baseColorFactor": [ + 1, + 1, + 1, + 1 + ], + "metallicFactor": 0, + "roughnessFactor": 0.59999999999999998 + } + }, + { + "doubleSided": true, + "emissiveFactor": [ + 0, + 0, + 0 + ], + "name": "material", + "pbrMetallicRoughness": { + "baseColorFactor": [ + 1, + 0.0096157397000000006, + 0.1496889756, + 1 + ], + "metallicFactor": 0, + "roughnessFactor": 0.59999999999999998 + } + }, + { + "doubleSided": true, + "emissiveFactor": [ + 0, + 0, + 0 + ], + "name": "Body", + "pbrMetallicRoughness": { + "baseColorFactor": [ + 1, + 0.86990751550000001, + 0.81930244399999996, + 1 + ], + "metallicFactor": 0.40000000000000002, + "roughnessFactor": 0.59999999999999998 + } + }, + { + "doubleSided": true, + "emissiveFactor": [ + 0, + 0, + 0 + ], + "name": "material_3", + "pbrMetallicRoughness": { + "baseColorFactor": [ + 0.0094488200000000001, + 0.0275591, + 0.10000000000000001, + 1 + ], + "metallicFactor": 0, + "roughnessFactor": 0.59999999999999998 + } + }, + { + "doubleSided": true, + "emissiveFactor": [ + 0, + 0, + 0 + ], + "name": "Glass", + "pbrMetallicRoughness": { + "baseColorFactor": [ + 0.021520143799999999, + 0.0201165003, + 0.034218421399999997, + 1 + ], + "metallicFactor": 0, + "roughnessFactor": 0.53000000000000003 + } + } + ], + "meshes": [ + { + "name": "Propeller_1_Red_0", + "primitives": [ + { + "attributes": { + "NORMAL": 1, + "POSITION": 0, + "TANGENT": 2, + "TEXCOORD_0": 3 + }, + "indices": 4, + "material": 1, + "mode": 4 + } + ] + }, + { + "name": "Propeller_1_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 6, + "POSITION": 5, + "TANGENT": 7, + "TEXCOORD_0": 8 + }, + "indices": 9, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "Cylinder_1_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 11, + "POSITION": 10, + "TANGENT": 12, + "TEXCOORD_0": 13 + }, + "indices": 14, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "WheelCarcas_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 16, + "POSITION": 15, + "TANGENT": 17, + "TEXCOORD_0": 18 + }, + "indices": 19, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "Wheel_Gum_0", + "primitives": [ + { + "attributes": { + "NORMAL": 21, + "POSITION": 20, + "TANGENT": 22, + "TEXCOORD_0": 23 + }, + "indices": 24, + "material": 3, + "mode": 4 + } + ] + }, + { + "name": "Cylinder_1_2_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 26, + "POSITION": 25, + "TANGENT": 27, + "TEXCOORD_0": 28 + }, + "indices": 29, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "WheelCarcas_2_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 31, + "POSITION": 30, + "TANGENT": 32, + "TEXCOORD_0": 33 + }, + "indices": 34, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "Wheel_2_Gum_0", + "primitives": [ + { + "attributes": { + "NORMAL": 36, + "POSITION": 35, + "TANGENT": 37, + "TEXCOORD_0": 38 + }, + "indices": 39, + "material": 3, + "mode": 4 + } + ] + }, + { + "name": "Cylinder_1_3_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 41, + "POSITION": 40, + "TANGENT": 42, + "TEXCOORD_0": 43 + }, + "indices": 44, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "WheelCarcas_3_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 46, + "POSITION": 45, + "TANGENT": 47, + "TEXCOORD_0": 48 + }, + "indices": 49, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "Wheel_4_Gum_0", + "primitives": [ + { + "attributes": { + "NORMAL": 51, + "POSITION": 50, + "TANGENT": 52, + "TEXCOORD_0": 53 + }, + "indices": 54, + "material": 3, + "mode": 4 + } + ] + }, + { + "name": "Cube_2_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 56, + "POSITION": 55, + "TANGENT": 57, + "TEXCOORD_0": 58 + }, + "indices": 59, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "Cube_1_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 61, + "POSITION": 60, + "TANGENT": 62, + "TEXCOORD_0": 63 + }, + "indices": 64, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "Cube_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 66, + "POSITION": 65, + "TANGENT": 67, + "TEXCOORD_0": 68 + }, + "indices": 69, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "Cube_2_2_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 71, + "POSITION": 70, + "TANGENT": 72, + "TEXCOORD_0": 73 + }, + "indices": 74, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "Cube_1_2_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 76, + "POSITION": 75, + "TANGENT": 77, + "TEXCOORD_0": 78 + }, + "indices": 79, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "Cube_2_3_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 81, + "POSITION": 80, + "TANGENT": 82, + "TEXCOORD_0": 83 + }, + "indices": 84, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "Cube_1_3_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 86, + "POSITION": 85, + "TANGENT": 87, + "TEXCOORD_0": 88 + }, + "indices": 89, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "Cube_1_3_Red_0", + "primitives": [ + { + "attributes": { + "NORMAL": 91, + "POSITION": 90, + "TANGENT": 92, + "TEXCOORD_0": 93 + }, + "indices": 94, + "material": 1, + "mode": 4 + } + ] + }, + { + "name": "Cube_1_3_Glass_0", + "primitives": [ + { + "attributes": { + "NORMAL": 96, + "POSITION": 95, + "TANGENT": 97, + "TEXCOORD_0": 98 + }, + "indices": 99, + "material": 4, + "mode": 4 + } + ] + }, + { + "name": "Cube_1_3__0", + "primitives": [ + { + "attributes": { + "NORMAL": 101, + "POSITION": 100, + "TANGENT": 102, + "TEXCOORD_0": 103 + }, + "indices": 104, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Cube_3_Body_0", + "primitives": [ + { + "attributes": { + "NORMAL": 106, + "POSITION": 105, + "TANGENT": 107, + "TEXCOORD_0": 108 + }, + "indices": 109, + "material": 2, + "mode": 4 + } + ] + }, + { + "name": "Cube_3_Red_0", + "primitives": [ + { + "attributes": { + "NORMAL": 111, + "POSITION": 110, + "TANGENT": 112, + "TEXCOORD_0": 113 + }, + "indices": 114, + "material": 1, + "mode": 4 + } + ] + }, + { + "name": "Cube_3_Glass_0", + "primitives": [ + { + "attributes": { + "NORMAL": 116, + "POSITION": 115, + "TANGENT": 117, + "TEXCOORD_0": 118 + }, + "indices": 119, + "material": 4, + "mode": 4 + } + ] + }, + { + "name": "Cube_3__0", + "primitives": [ + { + "attributes": { + "NORMAL": 121, + "POSITION": 120, + "TANGENT": 122, + "TEXCOORD_0": 123 + }, + "indices": 124, + "material": 0, + "mode": 4 + } + ] + } + ], + "nodes": [ + { + "children": [ + 1 + ], + "name": "RootNode (gltf orientation matrix)", + "rotation": [ + -0.70710678118654746, + -0, + -0, + 0.70710678118654757 + ] + }, + { + "children": [ + 2 + ], + "name": "RootNode (model correction matrix)" + }, + { + "children": [ + 3 + ], + "matrix": [ + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + -1, + 0, + 0, + 0, + 0, + 0, + 1 + ], + "name": "12cc6a9ff2ae45b08826ba235d9cb8b7.fbx" + }, + { + "children": [ + 4 + ], + "name": "" + }, + { + "children": [ + 5, + 8, + 13 + ], + "name": "RootNode" + }, + { + "children": [ + 6, + 7 + ], + "name": "Propeller_1", + "translation": [ + 0.87334871292114258, + -46.024806976318359, + 401.43350219726562 + ] + }, + { + "mesh": 0, + "name": "Propeller_1_Red_0" + }, + { + "mesh": 1, + "name": "Propeller_1_Body_0" + }, + { + "children": [ + 9, + 12 + ], + "name": "Physical_Sky", + "rotation": [ + -0.025235366076231003, + -0.24497584998607635, + 0.0050951233133673668, + 0.96918731927871704 + ] + }, + { + "children": [ + 10, + 11 + ], + "name": "Sky_Null", + "rotation": [ + -9.6296497219361793e-35, + 5.5511151231257827e-17, + 1.7347234759768071e-18, + 1 + ], + "translation": [ + 195.25096130371094, + 64.4552001953125, + 239.44844055175781 + ] + }, + { + "name": "Sun", + "rotation": [ + -0.17988117039203644, + -0.030783185735344887, + -0.0056319795548915863, + 0.98319041728973389 + ], + "translation": [ + -8659.806640625, + 52407.35546875, + 138158.203125 + ] + }, + { + "name": "Moon", + "rotation": [ + -0.041607432067394257, + -0.76001834869384766, + -0.048896394670009613, + 0.64672273397445679 + ], + "translation": [ + -3951.258544921875, + 517.194091796875, + -640.604736328125 + ] + }, + { + "name": "Shadow_Plane", + "rotation": [ + -3.4694469519536142e-18, + 5.5511151231257827e-17, + 1.7347234759768071e-18, + 1 + ], + "translation": [ + 1.9895196601282805e-13, + 10000, + 3.4106051316484809e-13 + ] + }, + { + "children": [ + 14, + 21, + 28, + 35, + 42, + 49 + ], + "name": "Plane", + "translation": [ + -2.5442404747009277, + -22.783651351928711, + 0 + ] + }, + { + "children": [ + 15, + 17, + 19 + ], + "name": "Wheel_Back", + "rotation": [ + 0.084529757499694824, + -0.0008930605836212635, + -0.01052663940936327, + 0.99636495113372803 + ], + "translation": [ + 3.2151377201080322, + -59.613082885742188, + -256.31814575195312 + ] + }, + { + "children": [ + 16 + ], + "name": "Cylinder_1", + "rotation": [ + -0.5, + -0.5, + -0.5, + 0.5 + ], + "translation": [ + 6.5183935165405273, + -27.543468475341797, + -1.7053025658242404e-13 + ] + }, + { + "mesh": 2, + "name": "Cylinder_1_Body_0" + }, + { + "children": [ + 18 + ], + "name": "WheelCarcas", + "rotation": [ + 1.7554505758210904e-36, + -3.2779658070858577e-19, + 5.3553050112402912e-18, + 1 + ], + "translation": [ + 114.38583374023438, + 59.170185089111328, + -8.5265128291212022e-14 + ] + }, + { + "mesh": 3, + "name": "WheelCarcas_Body_0" + }, + { + "children": [ + 20 + ], + "name": "Wheel", + "rotation": [ + 1.096210767028243e-17, + 8.6640510360998597e-18, + -0.7071068286895752, + 0.7071068286895752 + ], + "translation": [ + 0.62235832214355469, + -32.489803314208984, + -2.8421709430404007e-14 + ] + }, + { + "mesh": 4, + "name": "Wheel_Gum_0" + }, + { + "children": [ + 22, + 24, + 26 + ], + "name": "Wheel_1", + "rotation": [ + 0, + 0, + 0.16323453187942505, + 0.9865872859954834 + ], + "translation": [ + 81.309646606445312, + -76.375755310058594, + 232.74148559570312 + ] + }, + { + "children": [ + 23 + ], + "name": "Cylinder_1_2", + "rotation": [ + 0.5, + 0.5, + 0.5, + -0.5 + ], + "translation": [ + 12.172945976257324, + -51.436775207519531, + 0 + ] + }, + { + "mesh": 5, + "name": "Cylinder_1_2_Body_0" + }, + { + "children": [ + 25 + ], + "name": "WheelCarcas_2", + "rotation": [ + 0, + -0, + -2.7755575615628914e-17, + 1 + ], + "translation": [ + 213.61283874511719, + 110.49892425537109, + 0 + ] + }, + { + "mesh": 6, + "name": "WheelCarcas_2_Body_0" + }, + { + "children": [ + 27 + ], + "name": "Wheel_2", + "rotation": [ + 0, + -0, + -0.7071068286895752, + 0.7071068286895752 + ], + "translation": [ + 1.1622394323348999, + -60.673938751220703, + 0 + ] + }, + { + "mesh": 7, + "name": "Wheel_2_Gum_0" + }, + { + "children": [ + 29, + 31, + 33 + ], + "name": "Wheel_3", + "rotation": [ + 0, + -0, + -0.16122730076313019, + 0.98691731691360474 + ], + "translation": [ + -81.572341918945312, + -76.375755310058594, + 232.74148559570312 + ] + }, + { + "children": [ + 30 + ], + "name": "Cylinder_1_3", + "rotation": [ + -0.5, + -0.5, + -0.5, + 0.5 + ], + "translation": [ + 12.172945976257324, + -51.436775207519531, + 0 + ] + }, + { + "mesh": 8, + "name": "Cylinder_1_3_Body_0" + }, + { + "children": [ + 32 + ], + "name": "WheelCarcas_3", + "translation": [ + 213.61283874511719, + 110.49892425537109, + 0 + ] + }, + { + "mesh": 9, + "name": "WheelCarcas_3_Body_0" + }, + { + "children": [ + 34 + ], + "name": "Wheel_4", + "rotation": [ + 0, + 0, + -0.7071068286895752, + 0.7071068286895752 + ], + "translation": [ + 1.1622394323348999, + -60.673938751220703, + 0 + ] + }, + { + "mesh": 10, + "name": "Wheel_4_Gum_0" + }, + { + "children": [ + 36, + 38, + 40 + ], + "name": "Air_motor_right", + "rotation": [ + 0, + 0, + 1, + -6.1232342629258393e-17 + ], + "translation": [ + 5.773159728050814e-15, + -45.567302703857422, + 0 + ] + }, + { + "children": [ + 37 + ], + "name": "Cube_2" + }, + { + "mesh": 11, + "name": "Cube_2_Body_0" + }, + { + "children": [ + 39 + ], + "name": "Cube_1" + }, + { + "mesh": 12, + "name": "Cube_1_Body_0" + }, + { + "children": [ + 41 + ], + "name": "Cube" + }, + { + "mesh": 13, + "name": "Cube_Body_0" + }, + { + "children": [ + 43, + 45, + 47 + ], + "name": "Air_motor_left", + "translation": [ + -2.6645352591003757e-15, + 22.783651351928711, + 0 + ] + }, + { + "children": [ + 44 + ], + "name": "Cube_2_2" + }, + { + "mesh": 14, + "name": "Cube_2_2_Body_0" + }, + { + "children": [ + 46 + ], + "name": "Cube_1_2" + }, + { + "mesh": 15, + "name": "Cube_1_2_Body_0" + }, + { + "children": [ + 48 + ], + "name": "Cube_2_3" + }, + { + "mesh": 16, + "name": "Cube_2_3_Body_0" + }, + { + "children": [ + 50, + 55 + ], + "name": "Body", + "translation": [ + -2.6645352591003757e-15, + 22.783651351928711, + 0 + ] + }, + { + "children": [ + 51, + 52, + 53, + 54 + ], + "name": "Cube_1_3" + }, + { + "mesh": 17, + "name": "Cube_1_3_Body_0" + }, + { + "mesh": 18, + "name": "Cube_1_3_Red_0" + }, + { + "mesh": 19, + "name": "Cube_1_3_Glass_0" + }, + { + "mesh": 20, + "name": "Cube_1_3__0" + }, + { + "children": [ + 56, + 57, + 58, + 59 + ], + "name": "Cube_3" + }, + { + "mesh": 21, + "name": "Cube_3_Body_0" + }, + { + "mesh": 22, + "name": "Cube_3_Red_0" + }, + { + "mesh": 23, + "name": "Cube_3_Glass_0" + }, + { + "mesh": 24, + "name": "Cube_3__0" + } + ], + "scene": 0, + "scenes": [ + { + "name": "OSG_Scene", + "nodes": [ + 0 + ] + } + ] +} + diff --git a/cartoon_plane/texture_07.png b/cartoon_plane/texture_07.png new file mode 100644 index 0000000000000000000000000000000000000000..4e26acd557e0499cfff79e77d473c0ea6e8cb362 --- /dev/null +++ b/cartoon_plane/texture_07.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:affe82474a9ae58431f3e7f576b91cd9dec0479d1d89ab161d719a72c2c644aa +size 637 diff --git a/concrete_wall_004_ao_1k.jpg b/concrete_wall_004_ao_1k.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d537afc7aa8c7dc0d4b42237279cc0f4b77d9f0b --- /dev/null +++ b/concrete_wall_004_ao_1k.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:02a8595ac86a34fe8abc98f86d43752732af18573a7cb1880c094528a482969d +size 903053 diff --git a/concrete_wall_004_arm_1k.jpg b/concrete_wall_004_arm_1k.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0b282dba267bb060a1c9f1b89b45d44cac59fb0a --- /dev/null +++ b/concrete_wall_004_arm_1k.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8eaebd7ac073ede9cc449d37081ffb4df4fc385dd7eeba1563bef7867298b146 +size 855862 diff --git a/concrete_wall_004_diff_1k.jpg b/concrete_wall_004_diff_1k.jpg new file mode 100644 index 0000000000000000000000000000000000000000..31b6db1796829a96b16bb60ef4e0254f5c99e4c9 --- /dev/null +++ b/concrete_wall_004_diff_1k.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:446261c8d9ae49e5ca9858fe590a71a53cbd3c3b5fcf54f6adcc5c14a649c14f +size 531968 diff --git a/concrete_wall_004_disp_1k.jpg b/concrete_wall_004_disp_1k.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d0021973c5862c711be6af92349229412fa0b50b --- /dev/null +++ b/concrete_wall_004_disp_1k.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0cef48610f92645fb3b635d02aaeb5cfa16642a8359aa8266405a87b334ec925 +size 470896 diff --git a/concrete_wall_004_nor_gl_1k.jpg b/concrete_wall_004_nor_gl_1k.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8a825b4818376d57f1aa2662e0753d8658e552f3 --- /dev/null +++ b/concrete_wall_004_nor_gl_1k.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91fb0da4686d6735e6091974c235c0eefd26fd27840547cbfe03b1e6fcde3544 +size 993350 diff --git a/concrete_wall_004_rough_1k.jpg b/concrete_wall_004_rough_1k.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4232f6e27d1f75859e23afeb5db164063fdc9c44 --- /dev/null +++ b/concrete_wall_004_rough_1k.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca10ef32dd1cc81c87fbb6a711ede7fde317a4caa0b4f574cc8203b642c05d03 +size 233170 diff --git a/default_env.tres b/default_env.tres new file mode 100644 index 0000000000000000000000000000000000000000..94da8aa79bea450eeff0bc3b97e472b15d853a4f --- /dev/null +++ b/default_env.tres @@ -0,0 +1,10 @@ +[gd_resource type="Environment" load_steps=2 format=2] + +[sub_resource type="Sky" id=1] +sky_top_color = Color( 0.878431, 0.878431, 0.878431, 1 ) +sky_horizon_color = Color( 0.862745, 0.929412, 0.984314, 1 ) + +[resource] +background_mode = 3 +background_sky = SubResource( 1 ) +background_color = Color( 0.223529, 0.223529, 0.223529, 1 ) diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..0b4d74e9099d0805760043b99f6a27b4a825fc91 --- /dev/null +++ b/icon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c160bfdb8d0423b958083202dc7b58d499cbef22f28d2a58626884378ce9b7f +size 3305 diff --git a/mono_crash.0.0.json b/mono_crash.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..b12fb77b52e731fd6884c521e3cd6d2e766465d1 --- /dev/null +++ b/mono_crash.0.0.json @@ -0,0 +1,332 @@ +{ + "protocol_version" : "0.0.6", + "configuration" : { + "version" : "(6.12.0) ((no/c621c35)", + "tlc" : "__thread", + "sigsgev" : "altstack", + "notifications" : "epoll", + "architecture" : "amd64", + "disabled_features" : "none", + "smallconfig" : "disabled", + "bigarrays" : "disabled", + "softdebug" : "enabled", + "interpreter" : "enabled", + "llvm_support" : "disabled", + "suspend" : "preemptive" + }, + "memory" : { + "minor_gc_time" : "44823", + "major_gc_time" : "4895", + "minor_gc_count" : "13", + "major_gc_count" : "4", + "major_gc_time_concurrent" : "0" + }, + "threads" : [ + { + "is_managed" : false, + "offset_free_hash" : "0x0", + "offset_rich_hash" : "0x0", + "crashed" : true, + "native_thread_id" : "0x7f96f718f800", + "thread_info_addr" : "0x99ee510", + "thread_name" : "Godot_v3.3.2-st", + "ctx" : { + "IP" : "0x2d25daa", + "SP" : "0x7fffb799ff90", + "BP" : "0x7fffb79a0150" + }, + "unmanaged_frames" : [ + { + "is_managed" : "false", + "native_address" : "0xee21ab", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x106e389", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x106f45a", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1078244", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0xef12d9", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0xef14e9", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0xee41af", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0xe5b959", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x2d25daa", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x2d57051", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x2d57e97", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1501354", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x23cb12d", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x23f1c5f", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x3b7974d", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x3b91f81", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0xe1995e", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7f96f791b0b3", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0xe19c3e", + "native_offset" : "0x00000" + } + + ] + }, + { + "is_managed" : false, + "offset_free_hash" : "0x0", + "offset_rich_hash" : "0x0", + "crashed" : false, + "native_thread_id" : "0x7f96d1ffe700", + "thread_info_addr" : "0x7f96c0000b60", + "thread_name" : "Thread Pool I/O", + "ctx" : { + "IP" : "0x7f96f7a09aff", + "SP" : "0x7f96d1ffdc40", + "BP" : "0x1065c40" + }, + "unmanaged_frames" : [ + { + "is_managed" : "false", + "native_address" : "0xee21ab", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x106e389", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x106f45a", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1078107", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0xef0675", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7f96f7c5b3c0", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7f96f7a09aff", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1065467", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x106673b", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1077a46", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7f96f7c4f609", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7f96f7a16293", + "native_offset" : "0x00000" + } + + ] + }, + { + "is_managed" : false, + "offset_free_hash" : "0x0", + "offset_rich_hash" : "0x0", + "crashed" : false, + "native_thread_id" : "0x7f96d3fff700", + "thread_info_addr" : "0x7f96cc000b60", + "thread_name" : "Finalizer", + "ctx" : { + "IP" : "0x7f96f7c593f4", + "SP" : "0x7f96d3ffeca0", + "BP" : "0x5ba8020" + }, + "unmanaged_frames" : [ + { + "is_managed" : "false", + "native_address" : "0xee21ab", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x106e389", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x106f45a", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1078107", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0xef0675", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7f96f7c5b3c0", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7f96f7c593f4", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7f96f7c594e8", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0xfa9b80", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x1077a46", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7f96f7c4f609", + "native_offset" : "0x00000" + } +, + { + "is_managed" : "false", + "native_address" : "0x7f96f7a16293", + "native_offset" : "0x00000" + } + + ] + } + ] +} \ No newline at end of file diff --git a/project.godot b/project.godot new file mode 100644 index 0000000000000000000000000000000000000000..0d50fb063bebabac624036635bfc11d9cba66c2d --- /dev/null +++ b/project.godot @@ -0,0 +1,69 @@ +; 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=5 + +[application] + +config/name="FlyBy" +run/main_scene="res://FlyBy.tscn" +config/features=PackedStringArray("4.1", "C#") +config/icon="res://icon.png" + +[dotnet] + +project/assembly_name="FlyBy" + +[editor_plugins] + +enabled=PackedStringArray("res://addons/godot_rl_agents/plugin.cfg") + +[input] + +throttle_up={ +"deadzone": 0.5, +"events": [] +} +throttle_down={ +"deadzone": 0.5, +"events": [] +} +pitch_up={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} +pitch_down={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} +roll_left={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} +roll_right={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} +r_key={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} + +[physics] + +common/enable_pause_aware_picking=true + +[rendering] + +quality/filters/use_fxaa=true +environment/default_environment="res://default_env.tres"