diff --git a/assets/draggables/test_draggable.tres b/assets/draggables/test_draggable.tres index 5b65641..4614ca8 100644 --- a/assets/draggables/test_draggable.tres +++ b/assets/draggables/test_draggable.tres @@ -2,7 +2,7 @@ [ext_resource type="Script" uid="uid://b3i73cilpra74" path="res://src/resources/draggable.gd" id="1_62sy8"] [ext_resource type="Texture2D" uid="uid://bdyc1cwthn845" path="res://icon.svg" id="1_kgkdo"] -[ext_resource type="PackedScene" uid="uid://bjxjcx2qu16q5" path="res://scenes/draggable_object.tscn" id="2_jkgu4"] +[ext_resource type="PackedScene" uid="uid://bjxjcx2qu16q5" path="res://scenes/flask.tscn" id="2_jkgu4"] [resource] script = ExtResource("1_62sy8") diff --git a/assets/meshes/jar.res b/assets/meshes/jar.res new file mode 100644 index 0000000..c6ca6a6 Binary files /dev/null and b/assets/meshes/jar.res differ diff --git a/assets/meshes/jar_fill.res b/assets/meshes/jar_fill.res new file mode 100644 index 0000000..66a9553 Binary files /dev/null and b/assets/meshes/jar_fill.res differ diff --git a/assets/models/Chemistry.glb.import b/assets/models/Chemistry.glb.import index 8d99fd5..650df12 100644 --- a/assets/models/Chemistry.glb.import +++ b/assets/models/Chemistry.glb.import @@ -48,6 +48,26 @@ _subresources={ "use_external/fallback_path": "res://assets/materials/mat_glass.tres", "use_external/path": "uid://64m17act0kwu" } +}, +"meshes": { +"Chemistry_Circle_001": { +"generate/lightmap_uv": 0, +"generate/lods": 0, +"generate/shadow_meshes": 0, +"lods/normal_merge_angle": 20.0, +"save_to_file/enabled": true, +"save_to_file/fallback_path": "res://assets/meshes/jar_fill.res", +"save_to_file/path": "uid://dxeseuqcwne1m" +}, +"Chemistry_Circle_003": { +"generate/lightmap_uv": 0, +"generate/lods": 0, +"generate/shadow_meshes": 0, +"lods/normal_merge_angle": 20.0, +"save_to_file/enabled": true, +"save_to_file/fallback_path": "res://assets/meshes/jar.res", +"save_to_file/path": "uid://dddqboph2ygmw" +} } } gltf/naming_version=2 diff --git a/project.godot b/project.godot index 76fd157..1af40d1 100644 --- a/project.godot +++ b/project.godot @@ -32,6 +32,7 @@ drag_camera={ 3d_physics/layer_1="Drag" 3d_physics/layer_2="Interaction" +3d_physics/layer_3="FlaskInteraction" [rendering] diff --git a/scenes/draggable_object.tscn b/scenes/flask.tscn similarity index 69% rename from scenes/draggable_object.tscn rename to scenes/flask.tscn index fcc875f..ede41ea 100644 --- a/scenes/draggable_object.tscn +++ b/scenes/flask.tscn @@ -1,15 +1,20 @@ -[gd_scene load_steps=9 format=3 uid="uid://bjxjcx2qu16q5"] +[gd_scene load_steps=11 format=3 uid="uid://bjxjcx2qu16q5"] -[ext_resource type="Script" uid="uid://bjnv2g1ni0525" path="res://src/drag/draggable_object.gd" id="1_vcwhe"] -[ext_resource type="Script" uid="uid://ctu7escah5lo1" path="res://src/interactible/interaction_source.gd" id="2_627mb"] -[ext_resource type="PackedScene" uid="uid://b6ydpkle2ol20" path="res://assets/models/FlaskNew.glb" id="2_qf1og"] -[ext_resource type="Script" uid="uid://e8xu57ewvb5a" path="res://src/interactible/proximity_rotator.gd" id="3_00eeh"] -[ext_resource type="Script" uid="uid://dteb2xxl8gixp" path="res://src/ui/slider_display.gd" id="5_qb0nw"] +[ext_resource type="Script" uid="uid://bjnv2g1ni0525" path="res://src/drag/draggable_object.gd" id="1_0xufn"] +[ext_resource type="PackedScene" uid="uid://b6ydpkle2ol20" path="res://assets/models/FlaskNew.glb" id="2_h7awq"] +[ext_resource type="Script" uid="uid://mjx50qh1bwv3" path="res://src/interactible/interaction_reciever.gd" id="3_ailwx"] +[ext_resource type="Script" uid="uid://ctu7escah5lo1" path="res://src/interactible/interaction_source.gd" id="4_kkw7a"] +[ext_resource type="Script" uid="uid://e8xu57ewvb5a" path="res://src/interactible/proximity_rotator.gd" id="5_rqua0"] +[ext_resource type="Script" uid="uid://dteb2xxl8gixp" path="res://src/ui/slider_display.gd" id="6_wadb5"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_vcwhe"] radius = 0.1 height = 0.9921875 +[sub_resource type="CylinderShape3D" id="CylinderShape3D_0xufn"] +height = 0.16210938 +radius = 0.625 + [sub_resource type="SphereShape3D" id="SphereShape3D_vcwhe"] radius = 0.49649125 @@ -18,26 +23,36 @@ _data = [Vector2(0, 0), 0.0, 0.067761436, 0, 0, Vector2(0.75, 1), 0.0, 0.0, 0, 0 point_count = 2 [node name="Flask" type="Area3D"] -script = ExtResource("1_vcwhe") +script = ExtResource("1_0xufn") [node name="DragArea" type="CollisionShape3D" parent="."] shape = SubResource("CapsuleShape3D_vcwhe") -[node name="FlaskNew" parent="." instance=ExtResource("2_qf1og")] +[node name="FlaskNew" parent="." instance=ExtResource("2_h7awq")] transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, -0.38859487, 0) +[node name="InteractibleArea" type="Area3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6011598, 0) +collision_layer = 6 +collision_mask = 0 +script = ExtResource("3_ailwx") +metadata/_custom_type_script = "uid://mjx50qh1bwv3" + +[node name="CollisionShape3D" type="CollisionShape3D" parent="InteractibleArea"] +shape = SubResource("CylinderShape3D_0xufn") + [node name="InteractionArea" type="Area3D" parent="." node_paths=PackedStringArray("interaction_dialog")] collision_layer = 2 collision_mask = 2 input_ray_pickable = false -script = ExtResource("2_627mb") +script = ExtResource("4_kkw7a") interaction_dialog = NodePath("../InteractionDialog") [node name="InteractionArea" type="CollisionShape3D" parent="InteractionArea"] shape = SubResource("SphereShape3D_vcwhe") [node name="ProximityRotator" type="Node" parent="." node_paths=PackedStringArray("rotated")] -script = ExtResource("3_00eeh") +script = ExtResource("5_rqua0") rotated = NodePath("..") proximity_radius = 0.1 modification_curve = SubResource("Curve_qb0nw") @@ -56,14 +71,14 @@ offset_bottom = 82.0 [node name="Label" type="Label" parent="InteractionDialog/VBoxContainer"] layout_mode = 2 -text = "Введите объём" +text = "Введите количество" [node name="HBoxContainer" type="HBoxContainer" parent="InteractionDialog/VBoxContainer"] layout_mode = 2 [node name="AmountLabel" type="Label" parent="InteractionDialog/VBoxContainer/HBoxContainer" node_paths=PackedStringArray("slider")] layout_mode = 2 -script = ExtResource("5_qb0nw") +script = ExtResource("6_wadb5") slider = NodePath("../HSlider") suffix = "%" diff --git a/scenes/lab.tscn b/scenes/lab.tscn index 6bdc4be..e42d252 100644 --- a/scenes/lab.tscn +++ b/scenes/lab.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=10 format=3 uid="uid://c7r4rhgj3ucao"] +[gd_scene load_steps=9 format=3 uid="uid://c7r4rhgj3ucao"] -[ext_resource type="PackedScene" uid="uid://bjxjcx2qu16q5" path="res://scenes/draggable_object.tscn" id="1_bb6uc"] +[ext_resource type="PackedScene" uid="uid://bjxjcx2qu16q5" path="res://scenes/flask.tscn" id="1_bb6uc"] [ext_resource type="Script" uid="uid://crjao0jjv5yqs" path="res://src/drag/draggable_camera.gd" id="1_hem3r"] [ext_resource type="PackedScene" uid="uid://dfxlr4svnsdyx" path="res://scenes/ui.tscn" id="3_hflkp"] -[ext_resource type="PackedScene" uid="uid://q1y0r2rn0qb4" path="res://scenes/interactible_object.tscn" id="4_f680m"] [ext_resource type="PackedScene" uid="uid://bx5wihgk668w1" path="res://assets/models/Chemistry.glb" id="5_q4uld"] [ext_resource type="PackedScene" uid="uid://bg8y4u2a4hx3p" path="res://assets/models/Drip.glb" id="6_gipex"] [ext_resource type="PackedScene" uid="uid://dwtaqdacgcysa" path="res://assets/models/FlaskHolder.glb" id="7_064jp"] @@ -32,9 +31,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.542716, 1.0920403, 0.20219 transform = Transform3D(1, 0, 0, 0, 0.8403207, 0.5420896, 0, -0.5420896, 0.8403207, 0, 1.9293891, 0) shadow_enabled = true -[node name="InteractibleObject" parent="." instance=ExtResource("4_f680m")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.11957906, 0.87858754, -0.0035084486) - [node name="UI" type="CanvasLayer" parent="."] layer = 100 diff --git a/scenes/substance_jar.tscn b/scenes/substance_jar.tscn new file mode 100644 index 0000000..fa47b90 --- /dev/null +++ b/scenes/substance_jar.tscn @@ -0,0 +1,85 @@ +[gd_scene load_steps=10 format=3 uid="uid://cw6v8kbi76qak"] + +[ext_resource type="Script" uid="uid://bjnv2g1ni0525" path="res://src/drag/draggable_object.gd" id="1_o7vug"] +[ext_resource type="ArrayMesh" uid="uid://dddqboph2ygmw" path="res://assets/meshes/jar.res" id="2_o7vug"] +[ext_resource type="Script" uid="uid://ctu7escah5lo1" path="res://src/interactible/interaction_source.gd" id="3_00jpx"] +[ext_resource type="Script" uid="uid://e8xu57ewvb5a" path="res://src/interactible/proximity_rotator.gd" id="4_ymvgp"] +[ext_resource type="ArrayMesh" uid="uid://dxeseuqcwne1m" path="res://assets/meshes/jar_fill.res" id="6_kfk5m"] +[ext_resource type="Script" uid="uid://co33kqhl3n06u" path="res://src/interactible/destructor.gd" id="7_00jpx"] + +[sub_resource type="CylinderShape3D" id="CylinderShape3D_kfk5m"] +height = 0.5024414 +radius = 0.22460938 + +[sub_resource type="SphereShape3D" id="SphereShape3D_vcwhe"] +radius = 0.49649125 + +[sub_resource type="Curve" id="Curve_qb0nw"] +_data = [Vector2(0, 0), 0.0, 0.067761436, 0, 0, Vector2(0.75, 1), 0.0, 0.0, 0, 0] +point_count = 2 + +[node name="Flask" type="Area3D"] +script = ExtResource("1_o7vug") + +[node name="Jar" type="MeshInstance3D" parent="."] +transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, -0.20877336, 0) +mesh = ExtResource("2_o7vug") + +[node name="DragArea" type="CollisionShape3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.04284668, 0) +shape = SubResource("CylinderShape3D_kfk5m") + +[node name="InteractionArea" type="Area3D" parent="." node_paths=PackedStringArray("interaction_dialog")] +collision_layer = 4 +collision_mask = 4 +input_ray_pickable = false +script = ExtResource("3_00jpx") +interaction_dialog = NodePath("../InteractionDialog") + +[node name="InteractionArea" type="CollisionShape3D" parent="InteractionArea"] +shape = SubResource("SphereShape3D_vcwhe") + +[node name="ProximityRotator" type="Node" parent="." node_paths=PackedStringArray("rotated")] +script = ExtResource("4_ymvgp") +rotated = NodePath("..") +proximity_radius = 0.1 +modification_curve = SubResource("Curve_qb0nw") + +[node name="InteractionDialog" type="ConfirmationDialog" parent="."] +oversampling_override = 1.0 +position = Vector2i(0, 36) +size = Vector2i(200, 131) +borderless = true + +[node name="VBoxContainer" type="VBoxContainer" parent="InteractionDialog"] +offset_left = 8.0 +offset_top = 8.0 +offset_right = 192.0 +offset_bottom = 82.0 + +[node name="Label" type="Label" parent="InteractionDialog/VBoxContainer"] +layout_mode = 2 +text = "Введите объём" + +[node name="HBoxContainer" type="HBoxContainer" parent="InteractionDialog/VBoxContainer"] +layout_mode = 2 + +[node name="SpinBox" type="SpinBox" parent="InteractionDialog/VBoxContainer/HBoxContainer"] +layout_mode = 2 +max_value = 10.0 +step = 0.01 +allow_greater = true +suffix = "мг" + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, -0.20759426, 0) +mesh = ExtResource("6_kfk5m") + +[node name="DestructorOnStop" type="Node" parent="." node_paths=PackedStringArray("node")] +script = ExtResource("7_00jpx") +node = NodePath("..") + +[connection signal="drag_ended" from="." to="InteractionArea" method="request_interaction"] +[connection signal="interaction_closed" from="InteractionArea" to="DestructorOnStop" method="destruct"] +[connection signal="interaction_reciever_entered" from="InteractionArea" to="ProximityRotator" method="_on_interaction_area_interaction_reciever_entered"] +[connection signal="interaction_reciever_exited" from="InteractionArea" to="ProximityRotator" method="_on_interaction_area_interaction_reciever_exited"] diff --git a/src/interactible/destructor.gd b/src/interactible/destructor.gd new file mode 100644 index 0000000..332e2e6 --- /dev/null +++ b/src/interactible/destructor.gd @@ -0,0 +1,6 @@ +extends Node + +@export var node: Node3D + +func destruct() -> void: + node.queue_free() diff --git a/src/interactible/destructor.gd.uid b/src/interactible/destructor.gd.uid new file mode 100644 index 0000000..763f7f6 --- /dev/null +++ b/src/interactible/destructor.gd.uid @@ -0,0 +1 @@ +uid://co33kqhl3n06u diff --git a/src/interactible/proximity_rotator.gd b/src/interactible/proximity_rotator.gd index b6ac49c..3000d9f 100644 --- a/src/interactible/proximity_rotator.gd +++ b/src/interactible/proximity_rotator.gd @@ -7,8 +7,6 @@ var start_rotation var reciever: InteractionReciever func _ready() -> void: - print(self.get_path(), rotated) - print_stack() start_rotation = rotated.quaternion func _on_interaction_area_interaction_reciever_entered(rec: InteractionReciever) -> void: diff --git a/src/resources/reagent.gd b/src/resources/reagent.gd index a01e96b..5d67384 100644 --- a/src/resources/reagent.gd +++ b/src/resources/reagent.gd @@ -3,4 +3,4 @@ extends Resource class_name Reagent @export var substance: Substance -@export var storage: PackedScene +@export var storage: PackedScene = preload("res://scenes/substance_jar.tscn") diff --git a/src/ui/reagent_drag_and_drop.gd b/src/ui/reagent_drag_and_drop.gd index 198bcfc..f8628c7 100644 --- a/src/ui/reagent_drag_and_drop.gd +++ b/src/ui/reagent_drag_and_drop.gd @@ -7,8 +7,7 @@ func _ready() -> void: text = reagent.substance.get_formula() func _on_button_down() -> void: - return - var scene = reagent.scene.instantiate() + var scene = reagent.storage.instantiate() if scene is DraggableObject: scene.dragged = true scene.mouse_in = true