Browse Source

:beetle: Add arrows to debug plane forces

DricomDragon 2 months ago
parent
commit
756048b47a

BIN
godot/component/entity/primitives/arrow/arrow.glb


+ 36 - 0
godot/component/entity/primitives/arrow/arrow.glb.import

@@ -0,0 +1,36 @@
+[remap]
+
+importer="scene"
+importer_version=1
+type="PackedScene"
+uid="uid://bts7m2kaelmep"
+path="res://.godot/imported/arrow.glb-f0e13e5af17c4b2050749cea402227bc.scn"
+
+[deps]
+
+source_file="res://component/entity/primitives/arrow/arrow.glb"
+dest_files=["res://.godot/imported/arrow.glb-f0e13e5af17c4b2050749cea402227bc.scn"]
+
+[params]
+
+nodes/root_type=""
+nodes/root_name=""
+nodes/apply_root_scale=true
+nodes/root_scale=1.0
+nodes/import_as_skeleton_bones=false
+meshes/ensure_tangents=true
+meshes/generate_lods=true
+meshes/create_shadow_meshes=true
+meshes/light_baking=1
+meshes/lightmap_texel_size=0.2
+meshes/force_disable_compression=false
+skins/use_named_skins=true
+animation/import=true
+animation/fps=30
+animation/trimming=false
+animation/remove_immutable_tracks=true
+animation/import_rest_as_RESET=false
+import_script/path=""
+_subresources={}
+gltf/naming_version=1
+gltf/embedded_image_handling=1

+ 8 - 0
godot/component/entity/primitives/arrow/arrow.tscn

@@ -0,0 +1,8 @@
+[gd_scene load_steps=2 format=3 uid="uid://dhw0ntwvoxk7c"]
+
+[ext_resource type="PackedScene" uid="uid://bts7m2kaelmep" path="res://component/entity/primitives/arrow/arrow.glb" id="1_qnk22"]
+
+[node name="Arrow" type="Node3D"]
+
+[node name="ArrowModel" parent="." instance=ExtResource("1_qnk22")]
+transform = Transform3D(-4.37114e-08, -4.37114e-08, 1, -1, 0, -4.37114e-08, 0, -1, -4.37114e-08, 0, 0, 0)

+ 27 - 0
godot/component/entity/vehicles/biplan/biplan.gd

@@ -81,6 +81,7 @@ func _apply_plane_rotation() -> void:
 func _apply_plane_thrust() -> void:
 	var force: Vector3 = transform.basis * target_thrust
 	apply_central_force(force)
+	debug_central_force(force, $ArrowForceThrust)
 
 
 func _apply_wing_resistance() -> void:
@@ -88,6 +89,7 @@ func _apply_wing_resistance() -> void:
 	local_wing_force = Vector3.UP * -wing_resistance * vertical_speed
 	var wing_force = transform.basis * local_wing_force
 	apply_central_force(wing_force)
+	#debug_central_force(wing_force, $ArrowForceWing)
 
 
 func _apply_foil_resistance() -> void:
@@ -95,6 +97,7 @@ func _apply_foil_resistance() -> void:
 	horizontal_speed = linear_velocity.dot(transform.basis * Vector3.RIGHT)
 	local_foil_force = Vector3.RIGHT * -foil_resistance * horizontal_speed
 	apply_force(local_foil_force, foil_position)
+	debug_force(local_foil_force, foil_position, $ArrowForceFoil)
 
 
 func _apply_lift() -> void:
@@ -104,6 +107,7 @@ func _apply_lift() -> void:
 	local_lift_force = Vector3.UP * lift * forward_speed
 	var lift_force = transform.basis * local_lift_force
 	apply_central_force(lift_force)
+	debug_central_force(lift_force, $ArrowForceLift)
 
 
 func _on_dir_changed(dir: Vector2) -> void:
@@ -112,3 +116,26 @@ func _on_dir_changed(dir: Vector2) -> void:
 
 func _on_main_action(pressed: bool) -> void:
 	trigger_thrust(pressed)
+
+
+func debug_central_force(force: Vector3, arrow: Node3D) -> void:
+	if force.is_zero_approx():
+		arrow.hide()
+		return
+	else:
+		arrow.show()
+
+	arrow.look_at(force)
+	arrow.set_scale(Vector3.ONE * force.length() / 1000.0)
+
+
+func debug_force(force: Vector3, pos: Vector3, arrow: Node3D) -> void:
+	if force.is_zero_approx():
+		arrow.hide()
+		return
+	else:
+		arrow.show()
+
+	arrow.set_position(pos)
+	arrow.look_at(force)
+	arrow.set_scale(Vector3.ONE * force.length() / 1000.0)

+ 15 - 1
godot/component/entity/vehicles/biplan/biplan.tscn

@@ -1,7 +1,8 @@
-[gd_scene load_steps=10 format=3 uid="uid://ceqqr0vn633o4"]
+[gd_scene load_steps=11 format=3 uid="uid://ceqqr0vn633o4"]
 
 [ext_resource type="Script" path="res://component/entity/vehicles/biplan/biplan.gd" id="1_vi3fj"]
 [ext_resource type="PackedScene" uid="uid://bcysn7mbjre1r" path="res://component/entity/vehicles/biplan/TheWindWaker_noWheel.glb" id="2_mr41j"]
+[ext_resource type="PackedScene" uid="uid://dhw0ntwvoxk7c" path="res://component/entity/primitives/arrow/arrow.tscn" id="2_xec4p"]
 [ext_resource type="PackedScene" uid="uid://bhutb1ntqf2vt" path="res://component/entity/vehicles/biplan/wheels/TheWindWaker_sideWheel.glb" id="3_8s6eu"]
 [ext_resource type="PackedScene" uid="uid://lcp33gkhc60y" path="res://component/entity/vehicles/biplan/wheels/TheWindWaker_rearWheel.glb" id="4_5u4vt"]
 
@@ -31,6 +32,19 @@ max_contacts_reported = 1
 angular_damp = 30.0
 script = ExtResource("1_vi3fj")
 
+[node name="ArrowForceThrust" parent="." instance=ExtResource("2_xec4p")]
+editor_description = "Debug the thrust force"
+
+[node name="ArrowForceWing" parent="." instance=ExtResource("2_xec4p")]
+editor_description = "Debug the thrust force"
+visible = false
+
+[node name="ArrowForceLift" parent="." instance=ExtResource("2_xec4p")]
+editor_description = "Debug the thrust force"
+
+[node name="ArrowForceFoil" parent="." instance=ExtResource("2_xec4p")]
+editor_description = "Debug the thrust force"
+
 [node name="TheWindWaker_noWheel" parent="." instance=ExtResource("2_mr41j")]
 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0)