From 207a7a230d54e06ab8fdae6b1fd973ba1c20438e Mon Sep 17 00:00:00 2001 From: Edin O Date: Mon, 8 Jan 2024 23:13:04 -0500 Subject: [PATCH] Trileset Loading + Camera Changes Trilesets seem to be loading correctly in the Palette now! I also modified the camera, turning it from a perspective to an orthogonal one to make it easier to visualize how things will look in-game. I'll add back the perspective cam once I get level editing done. --- Objects/Box.tscn | 10 +++- Scenes/Cursor.tscn | 85 ++++++++++++++++++++++++++++++--- Scenes/MainScene.tscn | 1 - Scenes/UI.tscn | 15 ++++-- Scripts/Cursor.gd | 82 ++++++++++++++----------------- Scripts/Importer/FEZImporter.gd | 23 ++++++--- Scripts/Settings.gd | 2 +- Scripts/UI/Titlebar/menuFile.gd | 2 +- Scripts/UI/Titlebar/menuView.gd | 3 +- Scripts/UI/Toolbar/Palette.gd | 33 +++++++------ Scripts/UI/UI.gd | 33 +++++++++---- project.godot | 50 +++++++++++++------ 12 files changed, 235 insertions(+), 104 deletions(-) diff --git a/Objects/Box.tscn b/Objects/Box.tscn index d92b298..f7a74d9 100644 --- a/Objects/Box.tscn +++ b/Objects/Box.tscn @@ -1,14 +1,22 @@ -[gd_scene load_steps=3 format=3 uid="uid://da143myvimsgb"] +[gd_scene load_steps=4 format=3 uid="uid://da143myvimsgb"] [ext_resource type="PackedScene" uid="uid://c5o8xkjxrw28u" path="res://Objects/Box.glb" id="1_yvw6e"] [ext_resource type="Material" uid="uid://cwmx5mt2bhij2" path="res://Materials/UI.tres" id="2_3wn0q"] +[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_chimh"] +points = PackedVector3Array(0.55, 0.55, 0.549993, 0.55, -0.55, 0.549993, 0.55, 0.55, -0.55, -0.55, 0.55, 0.549993, 0.55, -0.55, -0.55, -0.55, -0.55, 0.549993, -0.55, 0.55, -0.55, -0.55, -0.55, -0.55) + [node name="Box" instance=ExtResource("1_yvw6e")] [node name="Box" parent="." index="0"] layers = 2 surface_material_override/0 = ExtResource("2_3wn0q") +[node name="Area3D" type="Area3D" parent="Box" index="0"] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Box/Area3D" index="0"] +shape = SubResource("ConvexPolygonShape3D_chimh") + [node name="AnimationPlayer" parent="." index="1"] autoplay = "Outer CubeAction" speed_scale = 4.0 diff --git a/Scenes/Cursor.tscn b/Scenes/Cursor.tscn index 90f7c4e..18135aa 100644 --- a/Scenes/Cursor.tscn +++ b/Scenes/Cursor.tscn @@ -1,15 +1,88 @@ -[gd_scene load_steps=3 format=3 uid="uid://djsig0kkd1ved"] +[gd_scene load_steps=9 format=3 uid="uid://djsig0kkd1ved"] [ext_resource type="Script" path="res://Scripts/Cursor.gd" id="1_gsw3j"] -[ext_resource type="PackedScene" uid="uid://da143myvimsgb" path="res://Objects/Box.tscn" id="2_raobt"] +[ext_resource type="Material" uid="uid://cwmx5mt2bhij2" path="res://Materials/UI.tres" id="2_0tkj2"] + +[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_4lrr7"] +points = PackedVector3Array(0.55, 0.55, 0.549993, 0.55, -0.55, 0.549993, 0.55, 0.55, -0.55, -0.55, 0.55, 0.549993, 0.55, -0.55, -0.55, -0.55, -0.55, 0.549993, -0.55, 0.55, -0.55, -0.55, -0.55, -0.55) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_i5nyl"] + +[sub_resource type="ArrayMesh" id="ArrayMesh_ip15m"] +_surfaces = [{ +"aabb": AABB(-0.55, -0.55, -0.55, 1.1, 1.1, 1.10001), +"format": 34896613377, +"index_count": 144, +"index_data": PackedByteArray(2, 0, 18, 0, 19, 0, 2, 0, 0, 0, 18, 0, 19, 0, 6, 0, 2, 0, 4, 0, 18, 0, 0, 0, 4, 0, 22, 0, 18, 0, 23, 0, 6, 0, 19, 0, 4, 0, 23, 0, 22, 0, 6, 0, 23, 0, 4, 0, 12, 0, 14, 0, 13, 0, 12, 0, 15, 0, 14, 0, 13, 0, 4, 0, 12, 0, 6, 0, 14, 0, 15, 0, 6, 0, 7, 0, 14, 0, 5, 0, 4, 0, 13, 0, 6, 0, 5, 0, 7, 0, 4, 0, 5, 0, 6, 0, 12, 0, 21, 0, 15, 0, 12, 0, 20, 0, 21, 0, 17, 0, 15, 0, 21, 0, 8, 0, 20, 0, 12, 0, 8, 0, 16, 0, 20, 0, 17, 0, 10, 0, 15, 0, 8, 0, 17, 0, 16, 0, 10, 0, 17, 0, 8, 0, 1, 0, 2, 0, 3, 0, 1, 0, 0, 0, 2, 0, 9, 0, 0, 0, 1, 0, 10, 0, 3, 0, 2, 0, 10, 0, 11, 0, 3, 0, 9, 0, 8, 0, 0, 0, 10, 0, 9, 0, 11, 0, 8, 0, 9, 0, 10, 0, 28, 0, 8, 0, 12, 0, 0, 0, 24, 0, 4, 0, 0, 0, 25, 0, 24, 0, 29, 0, 8, 0, 28, 0, 0, 0, 29, 0, 25, 0, 8, 0, 29, 0, 0, 0, 4, 0, 28, 0, 12, 0, 4, 0, 24, 0, 28, 0, 31, 0, 15, 0, 10, 0, 6, 0, 27, 0, 2, 0, 6, 0, 26, 0, 27, 0, 30, 0, 15, 0, 31, 0, 6, 0, 30, 0, 26, 0, 15, 0, 30, 0, 6, 0, 27, 0, 10, 0, 2, 0, 27, 0, 31, 0, 10, 0), +"primitive": 3, +"uv_scale": Vector4(0, 0, 0, 0), +"vertex_count": 32, +"vertex_data": PackedByteArray(0, 0, 0, 0, 254, 255, 0, 0, 69, 23, 69, 23, 254, 255, 0, 0, 0, 0, 255, 255, 254, 255, 0, 0, 69, 23, 185, 232, 254, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 69, 23, 69, 23, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 69, 23, 185, 232, 0, 0, 0, 0, 255, 255, 0, 0, 254, 255, 0, 0, 185, 232, 69, 23, 254, 255, 0, 0, 255, 255, 255, 255, 254, 255, 0, 0, 185, 232, 185, 232, 254, 255, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 185, 232, 69, 23, 0, 0, 0, 0, 185, 232, 185, 232, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 69, 23, 184, 232, 0, 0, 255, 255, 185, 232, 184, 232, 0, 0, 0, 0, 69, 23, 184, 232, 0, 0, 0, 0, 185, 232, 184, 232, 0, 0, 255, 255, 69, 23, 69, 23, 0, 0, 255, 255, 185, 232, 69, 23, 0, 0, 0, 0, 69, 23, 69, 23, 0, 0, 0, 0, 185, 232, 69, 23, 0, 0, 69, 23, 0, 0, 69, 23, 0, 0, 69, 23, 0, 0, 184, 232, 0, 0, 69, 23, 255, 255, 69, 23, 0, 0, 69, 23, 255, 255, 184, 232, 0, 0, 185, 232, 0, 0, 69, 23, 0, 0, 185, 232, 0, 0, 184, 232, 0, 0, 185, 232, 255, 255, 69, 23, 0, 0, 185, 232, 255, 255, 184, 232, 0, 0) +}] +blend_shape_mode = 0 + +[sub_resource type="ArrayMesh" id="ArrayMesh_351w7"] +resource_name = "Box_Cube_001" +_surfaces = [{ +"aabb": AABB(-0.55, -0.55, -0.55, 1.1, 1.1, 1.10001), +"attribute_data": PackedByteArray(255, 95, 255, 255, 255, 31, 255, 63, 255, 95, 0, 0, 209, 101, 209, 5, 255, 159, 255, 255, 255, 159, 0, 0, 255, 223, 255, 63, 45, 154, 209, 5, 255, 95, 255, 191, 255, 31, 255, 127, 255, 95, 255, 191, 209, 101, 45, 186, 255, 159, 255, 191, 255, 159, 255, 191, 255, 223, 255, 127, 45, 154, 45, 186, 255, 95, 255, 63, 255, 95, 255, 63, 255, 95, 255, 63, 209, 101, 46, 58, 255, 159, 255, 63, 255, 159, 255, 63, 255, 159, 255, 63, 45, 154, 46, 58, 255, 95, 255, 127, 255, 95, 255, 127, 255, 95, 255, 127, 209, 101, 208, 133, 45, 154, 208, 133, 255, 159, 255, 127, 255, 159, 255, 127, 255, 159, 255, 127, 209, 101, 209, 69, 45, 154, 209, 69, 209, 101, 45, 250, 45, 154, 45, 250, 209, 101, 46, 122, 45, 154, 46, 122, 209, 101, 208, 197, 45, 154, 208, 197, 209, 37, 46, 122, 209, 37, 209, 69, 45, 218, 46, 122, 45, 218, 209, 69, 46, 90, 46, 122, 46, 90, 209, 69, 208, 165, 46, 122, 208, 165, 209, 69), +"format": 34896613399, +"index_count": 144, +"index_data": PackedByteArray(4, 0, 34, 0, 35, 0, 4, 0, 0, 0, 34, 0, 35, 0, 12, 0, 4, 0, 8, 0, 34, 0, 0, 0, 8, 0, 38, 0, 34, 0, 39, 0, 12, 0, 35, 0, 8, 0, 39, 0, 38, 0, 12, 0, 39, 0, 8, 0, 25, 0, 28, 0, 27, 0, 25, 0, 29, 0, 28, 0, 27, 0, 10, 0, 25, 0, 13, 0, 28, 0, 29, 0, 13, 0, 15, 0, 28, 0, 11, 0, 10, 0, 27, 0, 13, 0, 11, 0, 15, 0, 10, 0, 11, 0, 13, 0, 26, 0, 37, 0, 31, 0, 26, 0, 36, 0, 37, 0, 33, 0, 31, 0, 37, 0, 18, 0, 36, 0, 26, 0, 18, 0, 32, 0, 36, 0, 33, 0, 22, 0, 31, 0, 18, 0, 33, 0, 32, 0, 22, 0, 33, 0, 18, 0, 3, 0, 5, 0, 7, 0, 3, 0, 2, 0, 5, 0, 19, 0, 2, 0, 3, 0, 20, 0, 7, 0, 5, 0, 20, 0, 23, 0, 7, 0, 19, 0, 17, 0, 2, 0, 20, 0, 19, 0, 23, 0, 17, 0, 19, 0, 20, 0, 44, 0, 16, 0, 24, 0, 1, 0, 40, 0, 9, 0, 1, 0, 41, 0, 40, 0, 45, 0, 16, 0, 44, 0, 1, 0, 45, 0, 41, 0, 16, 0, 45, 0, 1, 0, 9, 0, 44, 0, 24, 0, 9, 0, 40, 0, 44, 0, 47, 0, 30, 0, 21, 0, 14, 0, 43, 0, 6, 0, 14, 0, 42, 0, 43, 0, 46, 0, 30, 0, 47, 0, 14, 0, 46, 0, 42, 0, 30, 0, 46, 0, 14, 0, 43, 0, 21, 0, 6, 0, 43, 0, 47, 0, 21, 0), +"material": SubResource("StandardMaterial3D_i5nyl"), +"primitive": 3, +"uv_scale": Vector4(0, 0, 0, 0), +"vertex_count": 48, +"vertex_data": PackedByteArray(0, 0, 0, 0, 254, 255, 84, 213, 0, 0, 0, 0, 254, 255, 255, 191, 0, 0, 0, 0, 254, 255, 255, 191, 69, 23, 69, 23, 254, 255, 255, 191, 0, 0, 255, 255, 254, 255, 84, 213, 0, 0, 255, 255, 254, 255, 255, 191, 0, 0, 255, 255, 254, 255, 255, 255, 69, 23, 185, 232, 254, 255, 255, 191, 0, 0, 0, 0, 0, 0, 84, 213, 0, 0, 0, 0, 0, 0, 255, 191, 0, 0, 0, 0, 0, 0, 255, 255, 69, 23, 69, 23, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 84, 213, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 69, 23, 185, 232, 0, 0, 255, 255, 255, 255, 0, 0, 254, 255, 255, 191, 255, 255, 0, 0, 254, 255, 255, 191, 255, 255, 0, 0, 254, 255, 84, 213, 185, 232, 69, 23, 254, 255, 255, 191, 255, 255, 255, 255, 254, 255, 255, 191, 255, 255, 255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 254, 255, 84, 213, 185, 232, 185, 232, 254, 255, 255, 191, 255, 255, 0, 0, 0, 0, 255, 191, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 84, 213, 185, 232, 69, 23, 0, 0, 255, 255, 185, 232, 185, 232, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 84, 213, 255, 255, 69, 23, 184, 232, 84, 213, 255, 255, 185, 232, 184, 232, 84, 213, 0, 0, 69, 23, 184, 232, 84, 213, 0, 0, 185, 232, 184, 232, 84, 213, 255, 255, 69, 23, 69, 23, 84, 213, 255, 255, 185, 232, 69, 23, 84, 213, 0, 0, 69, 23, 69, 23, 84, 213, 0, 0, 185, 232, 69, 23, 84, 213, 69, 23, 0, 0, 69, 23, 255, 191, 69, 23, 0, 0, 184, 232, 255, 191, 69, 23, 255, 255, 69, 23, 255, 255, 69, 23, 255, 255, 184, 232, 255, 255, 185, 232, 0, 0, 69, 23, 255, 191, 185, 232, 0, 0, 184, 232, 255, 191, 185, 232, 255, 255, 69, 23, 255, 255, 185, 232, 255, 255, 184, 232, 255, 255, 84, 213, 84, 213, 0, 0, 255, 127, 255, 255, 255, 255, 255, 255, 255, 255, 84, 213, 84, 213, 255, 255, 255, 255, 255, 127, 255, 191, 255, 255, 255, 255, 84, 213, 84, 213, 0, 0, 255, 127, 255, 191, 255, 191, 255, 191, 255, 191, 84, 213, 84, 213, 255, 191, 255, 191, 255, 127, 255, 191, 255, 191, 255, 191, 0, 0, 255, 127, 255, 255, 255, 255, 170, 42, 170, 42, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 255, 191, 170, 42, 170, 42, 255, 255, 255, 255, 0, 0, 255, 127, 255, 191, 255, 191, 170, 42, 170, 42, 255, 191, 255, 191, 255, 191, 255, 191, 255, 191, 255, 191, 255, 127, 255, 191, 170, 42, 170, 42, 170, 42, 170, 42, 170, 42, 170, 42, 84, 213, 84, 213, 84, 213, 84, 213, 170, 42, 170, 42, 170, 42, 170, 42, 84, 213, 84, 213, 84, 213, 84, 213, 0, 0, 255, 127, 0, 0, 255, 127, 255, 127, 255, 191, 255, 127, 255, 191, 0, 0, 255, 127, 0, 0, 255, 127, 255, 127, 255, 191, 255, 127, 255, 191) +}] +blend_shape_mode = 0 +shadow_mesh = SubResource("ArrayMesh_ip15m") + +[sub_resource type="Animation" id="Animation_e1hvu"] +resource_name = "CursorBreath" +loop_mode = 2 +tracks/0/type = "scale_3d" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = PackedFloat32Array(0, 1, 1.2, 1.2, 1.2, 1, 1, 1, 1, 1) + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_slj4o"] +_data = { +"CursorBreath": SubResource("Animation_e1hvu") +} [node name="Cursor" type="Node3D"] script = ExtResource("1_gsw3j") -[node name="Box" parent="." instance=ExtResource("2_raobt")] +[node name="Area3D" type="Area3D" parent="."] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"] +transform = Transform3D(0.9, 0, 0, 0, 0.9, 0, 0, 0, 0.9, 0, 0, 0) +shape = SubResource("ConvexPolygonShape3D_4lrr7") + +[node name="Box" type="MeshInstance3D" parent="."] +transform = Transform3D(1.2, 0, 0, 0, 1.2, 0, 0, 0, 1.2, 0, 0, 0) +layers = 2 +cast_shadow = 0 +mesh = SubResource("ArrayMesh_351w7") +skeleton = NodePath("") +surface_material_override/0 = ExtResource("2_0tkj2") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="Box"] +libraries = { +"": SubResource("AnimationLibrary_slj4o") +} +autoplay = "CursorBreath" +speed_scale = 1.25 + +[node name="Pivot" type="Node3D" parent="."] -[node name="Camera" type="Camera3D" parent="Box"] -transform = Transform3D(-0.612372, 0.5, -0.612373, -0.0473672, 0.75, 0.65974, 0.789149, 0.433013, -0.435595, -10, 10, -10) +[node name="Camera" type="Camera3D" parent="Pivot"] +transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -200, 0, 0) cull_mask = 1048574 +projection = 1 current = true -size = 10.0 +size = 20.0 diff --git a/Scenes/MainScene.tscn b/Scenes/MainScene.tscn index af187a6..8af094d 100644 --- a/Scenes/MainScene.tscn +++ b/Scenes/MainScene.tscn @@ -9,7 +9,6 @@ [node name="UI" parent="." instance=ExtResource("2_7lqbu")] [node name="Cursor" parent="." instance=ExtResource("1_qhvts")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 0.5) [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = ExtResource("3_tf75n") diff --git a/Scenes/UI.tscn b/Scenes/UI.tscn index 7211e51..7f07ca8 100644 --- a/Scenes/UI.tscn +++ b/Scenes/UI.tscn @@ -180,8 +180,14 @@ size_flags_vertical = 3 [node name="Position" type="Label" parent="Sidebar/SidebarVertical"] layout_mode = 2 mouse_filter = 1 -text = "(0, 0, 0) (x, y, z)" -horizontal_alignment = 2 +text = "[0, 0, 0]" +horizontal_alignment = 1 + +[node name="Object" type="Label" parent="Sidebar/SidebarVertical"] +layout_mode = 2 +mouse_filter = 1 +text = "None" +horizontal_alignment = 1 [node name="EditorLog" type="RichTextLabel" parent="Sidebar/SidebarVertical"] layout_mode = 2 @@ -194,6 +200,7 @@ threaded = true script = ExtResource("7_jfdyk") [node name="CompassView" type="SubViewportContainer" parent="Sidebar/SidebarVertical"] +visible = false layout_mode = 2 size_flags_vertical = 3 size_flags_stretch_ratio = 0.5 @@ -202,8 +209,8 @@ stretch = true [node name="Compass" type="SubViewport" parent="Sidebar/SidebarVertical/CompassView"] transparent_bg = true handle_input_locally = false -size = Vector2i(203, 205) -render_target_update_mode = 4 +size = Vector2i(2, 2) +render_target_update_mode = 0 [node name="Compass" parent="Sidebar/SidebarVertical/CompassView/Compass" instance=ExtResource("6_exilt")] transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 0, 0) diff --git a/Scripts/Cursor.gd b/Scripts/Cursor.gd index 713d0b7..26a3a44 100644 --- a/Scripts/Cursor.gd +++ b/Scripts/Cursor.gd @@ -1,17 +1,16 @@ extends Node3D -@onready var localCam = $"Box/Camera" -@onready var cursorBox = $"Box" +@onready var localCam: Camera3D = $"Pivot/Camera" +@onready var pivot: Node3D = $"Pivot" +@onready var cursorBox: MeshInstance3D = $"Box" signal hasMoved(keyPress) -var oldCamPos -var newCamPos - var allowMove = true -var mode2D = false +var mode3D = false var cursorSpeed = Settings.animationSpeed * 0.5 +var gomezPos := Vector3.ZERO func tweenToPos(obj: Object, property: NodePath, direction: Variant, action, speed): # Function dedicated to smooth movement. allowMove = false @@ -45,58 +44,51 @@ func _input(_event): var _moveTo = Vector3.ZERO # Prevent cursor from going below (0, 0, 0) ### Camera Movement - if Input.is_action_pressed("ui_lt", true): - tweenToPos(self, "rotation_degrees:y", rotation_degrees.y - 90, "ui_lt", Settings.animationSpeed) - - if Input.is_action_pressed("ui_rt", true): - tweenToPos(self, "rotation_degrees:y", rotation_degrees.y + 90, "ui_rt", Settings.animationSpeed) + if Input.is_action_pressed("move_lt", true): + tweenToPos(self, "rotation_degrees:y", rotation_degrees.y - 90, "move_lt", Settings.animationSpeed) - if Input.is_action_pressed("ui_2d", true): - if !mode2D: - emit_signal("hasMoved", "ui_2d_enter") - mode2D = true - oldCamPos = localCam.position - newCamPos = Vector3(oldCamPos.x, 0, 0) + if Input.is_action_pressed("move_rt", true): + tweenToPos(self, "rotation_degrees:y", rotation_degrees.y + 90, "move_rt", Settings.animationSpeed) - else: - emit_signal("hasMoved", "ui_2d_exit") - newCamPos = oldCamPos - mode2D = false + if Input.is_action_just_pressed("cam_zoom_in", true): # Don't want the camera zooming into the cursor or even behind it + tweenToPos(localCam, "size", localCam.size - Settings.zoomSpeed, "cam_zoom_in", cursorSpeed) - tweenToPos(localCam, "position", newCamPos, "N/A", Settings.animationSpeed) + if Input.is_action_just_pressed("cam_zoom_out", true): # zoom out is fine from zoom bug + tweenToPos(localCam, "size", localCam.size + Settings.zoomSpeed, "cam_zoom_out", cursorSpeed) - if Input.is_action_just_released("ui_zoom_in", true): # Don't want the camera zooming into the cursor or even behind it - var movePosition = localCam.position + Settings.zoomSpeed - movePosition = round(movePosition) # rounding due to weird decimal stuff - if movePosition == position or movePosition > position: - failMove() + if Input.is_action_pressed("cam_2d", true): # zoom out is fine from zoom bug + if mode3D: + mode3D = false + tweenToPos(pivot, "rotation_degrees", Vector3(0, 0, 0), "cam_zoom_in", Settings.animationSpeed) else: - tweenToPos(localCam, "position", localCam.position + Settings.zoomSpeed, "ui_zoom_in", cursorSpeed) - - if Input.is_action_just_released("ui_zoom_out", true): # zoom out is fine from zoom bug - tweenToPos(localCam, "position", localCam.position - Settings.zoomSpeed, "ui_zoom_out", cursorSpeed) - + mode3D = true + tweenToPos(pivot, "rotation_degrees", Vector3(0, -45, -45), "cam_zoom_out", Settings.animationSpeed) ### Cursor Movement. There must be a better way. - if Input.is_action_pressed("ui_up_layer", true): - tweenToPos(self, "position:y", position.y + Settings.movementSpeed, "ui_up_layer", cursorSpeed) + if Input.is_action_pressed("move_forward", true): + tweenToPos(self, "position:y", position.y + Settings.movementSpeed, "move_up", cursorSpeed) + + if Input.is_action_pressed("move_backward", true): + tweenToPos(self, "position:y", position.y - Settings.movementSpeed, "move_down", cursorSpeed) - if Input.is_action_pressed("ui_down_layer", true): - tweenToPos(self, "position:y", position.y - Settings.movementSpeed, "ui_down_layer", cursorSpeed) + if Input.is_action_pressed("move_up_layer", true): + tweenToPos(self, "position", position + (Settings.movementSpeed * right), "move_up_layer", cursorSpeed) - if Input.is_action_pressed("ui_up", true): - tweenToPos(self, "position", position + (Settings.movementSpeed * forward), "ui_up", cursorSpeed) + if Input.is_action_pressed("move_down_layer", true): + tweenToPos(self, "position", position - (Settings.movementSpeed * right), "move_down_layer", cursorSpeed) - if Input.is_action_pressed("ui_down", true): - tweenToPos(self, "position", position - (Settings.movementSpeed * forward), "ui_down", cursorSpeed) + if Input.is_action_pressed("move_right", true): + tweenToPos(self, "position", position + (forward * Settings.movementSpeed), "move_right", cursorSpeed) - if Input.is_action_pressed("ui_right", true): - tweenToPos(self, "position", position + (right * Settings.movementSpeed), "ui_right", cursorSpeed) + if Input.is_action_pressed("move_left", true): + tweenToPos(self, "position", position - (forward * Settings.movementSpeed), "move_left", cursorSpeed) - if Input.is_action_pressed("ui_left", true): - tweenToPos(self, "position", position - (right * Settings.movementSpeed), "ui_left", cursorSpeed) + if Input.is_action_pressed("move_gomez", true): + tweenToPos(self, "global_position", gomezPos, "loaded", cursorSpeed) # New cursor position func _on_ui_cursor_pos(newPos): - tweenToPos(self, "position", newPos, "loaded", cursorSpeed) + gomezPos = newPos + emit_signal("hasMoved", "loaded") + global_position = newPos pass # Replace with function body. diff --git a/Scripts/Importer/FEZImporter.gd b/Scripts/Importer/FEZImporter.gd index e84e63e..be45196 100644 --- a/Scripts/Importer/FEZImporter.gd +++ b/Scripts/Importer/FEZImporter.gd @@ -64,7 +64,7 @@ func _loadFEZLVL(path, dir): func _loadObj(filepath: String, type: int = 4): var cleanPath = filepath.get_basename() match type: - 2: # Load trileset as ArrayMesh. + 2: # Load trileset as ArrayMesh, and trile names as Dictionary. var mA = ObjParse.load_obj(cleanPath + ".obj") var mat = StandardMaterial3D.new() # Make a new material for the object, set settings. @@ -73,7 +73,13 @@ func _loadObj(filepath: String, type: int = 4): mat.albedo_texture = tex mat.texture_filter = BaseMaterial3D.TEXTURE_FILTER_NEAREST - return [mA, mat] + # Load in trile names. + var readTS = JSON.new() + var err = readTS.parse(FileAccess.get_file_as_string(filepath)) + if err == OK: + var tsData = readTS.data + var trileIDs = tsData["Triles"] + return [mA, mat, trileIDs] _: # Load everything else as MeshInstance3D. var m = MeshInstance3D.new() # Make a new mesh instance. @@ -94,6 +100,7 @@ func _loadObj(filepath: String, type: int = 4): m.set_surface_override_material(numMat, mat) m.layers = type # 8 for npcs, 4 for art objects, 2 for trilesets, 1 for UI. # find a way to put AOs, triles, NPCs into the palette + m.create_convex_collision(false, false) # Make a dirty collision so we can approx. what object the cursor is on. # NPCs will be a billboard texture. May be expensive to render because they're transparent. return m @@ -101,6 +108,7 @@ func _loadObj(filepath: String, type: int = 4): func _placeTrile(ts: Array, info: Dictionary): # id: String, emp, rot, mat: StandardMaterial3D): var mA = ts[0] var mat = ts[1] + var names = ts[2] var id = str(info["Id"]) var posTrile = info["Position"] @@ -116,12 +124,9 @@ func _placeTrile(ts: Array, info: Dictionary): # id: String, emp, rot, mat: Stan surfNum = 0; albColor = Color(0, 0, 0, 1) pass else: - # Extract the surface we need and make it its own mesh. var prim = mA.surface_get_primitive_type(surfNum) var arrays = mA.surface_get_arrays(surfNum) - var _blendshapes = mA.surface_get_blend_shape_arrays(surfNum) # we probably don't need all this info - var _format = mA.surface_get_format(surfNum) var pos = Vector3(posTrile[0], posTrile[1], posTrile[2]) var trMesh = ArrayMesh.new() @@ -134,11 +139,12 @@ func _placeTrile(ts: Array, info: Dictionary): # id: String, emp, rot, mat: Stan trile.set_surface_override_material(0, mat) trile.position = pos trile.rotation_degrees = Vector3(0, rot, 0) + trile.create_convex_collision(false, false) # Same reason as with the AOs! trile.layers = 2 + trile.set_meta("Name", names[id]["Name"]) add_child(trile) - if pos == Vector3(27, 24, 20): print(trile.name) pass func _placeAO(dir, ao): @@ -153,7 +159,10 @@ func _placeAO(dir, ao): obj.scale = Vector3(scale[0], scale[1], scale[2]) # Godot places objects by the center. Trixel places objects by their corners. obj.position = Vector3(pos[0] - 0.5, pos[1] - 0.5, pos[2] - 0.5) + obj.mesh + # Add in ActorSetting data later. + obj.set_meta("Name", objName) add_child(obj) pass @@ -176,7 +185,7 @@ func _placeStart(dir, posArray): var face = posArray["Face"] var adjust: Vector3 - match face: + match face: # Test with levels to find out where we should place Gomez! "Front": adjust = Vector3.FORWARD "Back": adjust = Vector3.DOWN "Left": adjust = Vector3.LEFT diff --git a/Scripts/Settings.gd b/Scripts/Settings.gd index 4029e86..b5b61bf 100644 --- a/Scripts/Settings.gd +++ b/Scripts/Settings.gd @@ -2,4 +2,4 @@ extends Node @export var movementSpeed: int = 1 @export var animationSpeed = 0.25 -@export var zoomSpeed = Vector3(2, -2, 2) +@export var zoomSpeed = 2 diff --git a/Scripts/UI/Titlebar/menuFile.gd b/Scripts/UI/Titlebar/menuFile.gd index c2896df..8ce4f3b 100644 --- a/Scripts/UI/Titlebar/menuFile.gd +++ b/Scripts/UI/Titlebar/menuFile.gd @@ -6,7 +6,7 @@ func _ready(): self.get_popup().id_pressed.connect(_on_file_menu_pressed) func _on_file_menu_pressed(id: int): - print("Item ID: ", id) + #print("Item ID: ", id) match id: 0: fdLoad.visible = true diff --git a/Scripts/UI/Titlebar/menuView.gd b/Scripts/UI/Titlebar/menuView.gd index 9d783b6..5c75530 100644 --- a/Scripts/UI/Titlebar/menuView.gd +++ b/Scripts/UI/Titlebar/menuView.gd @@ -9,7 +9,8 @@ func _ready(): func _on_view_menu_pressed(id: int): match id: 0: - palette.visible = true + #palette.visible = true + pass 1: print("Make this a submenu that allows changing of culls for the Cursor camera.") 2: diff --git a/Scripts/UI/Toolbar/Palette.gd b/Scripts/UI/Toolbar/Palette.gd index 4ac55e3..228d6da 100644 --- a/Scripts/UI/Toolbar/Palette.gd +++ b/Scripts/UI/Toolbar/Palette.gd @@ -3,20 +3,25 @@ extends ItemList const TRILE_SIZE = 18 # Width and height of trile textures, in pixels. func _on_loader_loaded_ts(trileset): - var tex: Texture2D = trileset[1].albedo_texture - var offset = TRILE_SIZE * 6 + var tex: Texture2D = trileset[1].albedo_texture # Get texture + var info: Dictionary = trileset[2] # Extract atlas offset and trile name from here! - var trileX = floor(tex.get_width() / offset) # Number of horizontal triles - var trileY = floor(tex.get_height() / TRILE_SIZE) # Number of vertical triles + var w = tex.get_width() + var h = tex.get_height() - for y in trileY: - for x in trileX: - var atl = AtlasTexture.new() - - atl.atlas = tex - atl.region = Rect2(x * offset, y * TRILE_SIZE, TRILE_SIZE, TRILE_SIZE) - atl.filter_clip = true - - add_icon_item(atl, true) - pass + # Trixel Engine defines the positions of textures as an "Atlas Offset" multiplied by image + # width and height. We'll implement the same thing here to find both the trile texture and its + # representative name. + + for trile in info: + var offsetX = floor(info[trile]["AtlasOffset"][0] * w) + var offsetY = floor(info[trile]["AtlasOffset"][1] * h) + var atl = AtlasTexture.new() + + atl.atlas = tex + atl.region = Rect2(offsetX, offsetY, TRILE_SIZE, TRILE_SIZE) + atl.filter_clip = true + + add_item(info[trile]["Name"], atl, true) pass + pass diff --git a/Scripts/UI/UI.gd b/Scripts/UI/UI.gd index 7782d3c..6623f52 100644 --- a/Scripts/UI/UI.gd +++ b/Scripts/UI/UI.gd @@ -7,14 +7,22 @@ var soundCancel = preload("res://Sounds/cancel.wav") var soundLeft = preload("res://Sounds/rotateleft.wav") var soundRight = preload("res://Sounds/rotateright.wav") -var posFormat = "(%d, %d, %d) (x, y, z)" # Position formatting. +var posFormat = "[%d, %d, %d]" # Position formatting. +var movement = false @onready var _infoLabel: Label = $"Sidebar/SidebarVertical/Position" +@onready var _objLabel: Label = $"Sidebar/SidebarVertical/Object" + @onready var _cursor: Node3D = $"../Cursor" @onready var _sfx: AudioStreamPlayer = $"SFX" signal cursorPos(newPos: Vector3) # A relay from Loader. +func _ready(): + var curArea = $"../Cursor/Area3D" + curArea.body_entered.connect(_on_body_entered) + pass + func _notification(what): if what == NOTIFICATION_WM_CLOSE_REQUEST: # Handle closing the window. _sfx.stream = soundCancel; _sfx.play() @@ -23,19 +31,19 @@ func _notification(what): get_tree().quit() func _process(_delta): - var pos = _cursor.global_position + var pos = _cursor.get_child(1).global_position var posStr = posFormat % [pos.x, pos.y, pos.z] _infoLabel.set_text(posStr) -func _on_cursor_has_moved(keyPress): # Sounds for movement, and rotation for Axis. - match keyPress: # Sounds for movement. - "ui_up", "ui_right", "ui_up_layer": +func _on_cursor_has_moved(keyPress): # Sounds for movement. + match keyPress: + "move_up", "move_right", "move_up_layer": _sfx.stream = soundUp; _sfx.play() - "ui_down", "ui_left", "ui_down_layer": + "move_down", "move_left", "move_down_layer": _sfx.stream = soundDown; _sfx.play() - "ui_lt", "ui_zoom_out", "ui_2d_exit": + "move_lt", "cam_zoom_out", "cam_2d_exit": _sfx.stream = soundLeft; _sfx.play() - "ui_rt", "ui_zoom_in", "ui_2d_enter": + "move_rt", "cam_zoom_in", "cam_2d_enter": _sfx.stream = soundRight; _sfx.play() "fail": _sfx.stream = soundCancel; _sfx.play() @@ -45,3 +53,12 @@ func _on_cursor_has_moved(keyPress): # Sounds for movement, and rotation for Axi func _on_loader_new_cur_por(newPos): emit_signal("cursorPos", newPos) pass # Replace with function body. + +# Check collisions (with triles, AOs) +func _on_body_entered(body): + var objName = body.get_parent().get_meta("Name") + if body != null: + _objLabel.set_text(str(objName)) + else: + _objLabel.set_text("None") + pass diff --git a/project.godot b/project.godot index 1c2be20..18aca8c 100644 --- a/project.godot +++ b/project.godot @@ -40,75 +40,95 @@ import/blender/enabled=false ui_left={ "deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"key_label":0,"unicode":97,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null) ] } ui_right={ "deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"key_label":0,"unicode":100,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null) ] } ui_up={ "deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":87,"physical_keycode":87,"key_label":87,"unicode":119,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null) ] } ui_down={ "deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"key_label":0,"unicode":115,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194322,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null) ] } -ui_lt={ +move_lt={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":113,"echo":false,"script":null) ] } -ui_rt={ +move_rt={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"echo":false,"script":null) ] } -ui_2d={ +cam_2d={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":50,"physical_keycode":0,"key_label":0,"unicode":64,"echo":false,"script":null) ] } -ui_up_layer={ +move_up_layer={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"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":114,"echo":false,"script":null) ] } -ui_down_layer={ +move_down_layer={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":70,"physical_keycode":0,"key_label":0,"unicode":102,"echo":false,"script":null) ] } -ui_zoom_in={ +cam_zoom_in={ "deadzone": 0.5, "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":8,"position":Vector2(181, 18),"global_position":Vector2(185, 59),"factor":1.0,"button_index":4,"canceled":false,"pressed":true,"double_click":false,"script":null) ] } -ui_zoom_out={ +cam_zoom_out={ "deadzone": 0.5, "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":16,"position":Vector2(209, 19),"global_position":Vector2(213, 60),"factor":1.0,"button_index":5,"canceled":false,"pressed":true,"double_click":false,"script":null) ] } -ui_modifier={ +cam_freecam={ "deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"echo":false,"script":null) +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":4,"position":Vector2(151, 20),"global_position":Vector2(155, 61),"factor":1.0,"button_index":3,"canceled":false,"pressed":true,"double_click":false,"script":null) ] } -ui_freecam={ +move_right={ "deadzone": 0.5, -"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":4,"position":Vector2(151, 20),"global_position":Vector2(155, 61),"factor":1.0,"button_index":3,"canceled":false,"pressed":true,"double_click":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"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":100,"echo":false,"script":null) +] +} +move_left={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"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":97,"echo":false,"script":null) +] +} +move_forward={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"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":119,"echo":false,"script":null) +] +} +move_backward={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"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":115,"echo":false,"script":null) +] +} +move_gomez={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":71,"key_label":0,"unicode":0,"echo":false,"script":null) ] }