diff --git a/Interface/Interface.gd b/Interface/Interface.gd index 456f705..2dae587 100644 --- a/Interface/Interface.gd +++ b/Interface/Interface.gd @@ -4,6 +4,7 @@ var lower_function: Expression = null var upper_function: Expression = null signal num_rect_changed() +signal shape_rotation_changed() signal disk_rotation_changed() signal disk_trans_changed() signal disk_pos_changed() @@ -26,6 +27,9 @@ func _on_num_rect_value_changed(_value: int) -> void: func _on_disk_rotation_value_changed(_value: float) -> void: disk_rotation_changed.emit() +func _on_shape_rotation_value_changed(_value: float) -> void: + shape_rotation_changed.emit() + func _on_disk_trans_value_changed(_value: float) -> void: disk_trans_changed.emit() @@ -50,6 +54,9 @@ func get_num_rect() -> int: func get_disk_rotation() -> float: return $ParamContainer/DiskRotation.value +func get_shape_rotation() -> float: + return $ParamContainer/ShapeRotation.value + func get_lower_function() -> Expression: var new_function = get_function_from_string($ParamContainer/LowerFunction.text) if new_function != null: diff --git a/Interface/Interface.tscn b/Interface/Interface.tscn index 95df93a..9cf7288 100644 --- a/Interface/Interface.tscn +++ b/Interface/Interface.tscn @@ -102,6 +102,26 @@ min_value = 1.0 max_value = 200.0 value = 5.0 +[node name="Label10" type="Label" parent="ParamContainer"] +layout_mode = 2 +theme_override_colors/font_color = Color(0.709804, 0.741176, 0.992157, 1) +theme_override_fonts/font = ExtResource("1_0s4fo") +theme_override_font_sizes/font_size = 40 +text = "Shape Rotation:" +horizontal_alignment = 2 + +[node name="ShapeRotation" type="HSlider" parent="ParamContainer"] +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 +size_flags_vertical = 4 +focus_mode = 0 +theme_override_constants/center_grabber = 0 +theme_override_styles/slider = SubResource("StyleBoxFlat_4eipt") +theme_override_styles/grabber_area = SubResource("StyleBoxFlat_j6y4i") +theme_override_styles/grabber_area_highlight = SubResource("StyleBoxFlat_81xuu") +max_value = 6.283 +step = 0.1 + [node name="Label2" type="Label" parent="ParamContainer"] layout_mode = 2 theme_override_colors/font_color = Color(0.709804, 0.741176, 0.992157, 1) @@ -269,6 +289,7 @@ alignment = 1 update_on_text_changed = true [connection signal="value_changed" from="ParamContainer/NumRect" to="." method="_on_num_rect_value_changed"] +[connection signal="value_changed" from="ParamContainer/ShapeRotation" to="." method="_on_shape_rotation_value_changed"] [connection signal="value_changed" from="ParamContainer/DiskRotation" to="." method="_on_disk_rotation_value_changed"] [connection signal="value_changed" from="ParamContainer/DiskTrans" to="." method="_on_disk_trans_value_changed"] [connection signal="value_changed" from="ParamContainer/DiskPos" to="." method="_on_disk_pos_value_changed"] diff --git a/Main.gd b/Main.gd index 36a8313..e106a4e 100644 --- a/Main.gd +++ b/Main.gd @@ -7,7 +7,7 @@ extends Node3D @export var ordinary_color: Color = Color.BLUE func _ready() -> void: - self.update_rects() + update_rects() func _on_interface_num_rect_changed() -> void: update_rects() @@ -17,6 +17,12 @@ func _on_interface_disk_rotation_changed() -> void: var rot = $CanvasLayer/Interface.get_disk_rotation() disk.set_rot(rot) +func _on_interface_shape_rotation_changed() -> void: + var disk = get_disk() + for rect in $Rectangles.get_children(): + if rect != disk: + rect.set_rot($CanvasLayer/Interface.get_shape_rotation()) + func _on_interface_disk_trans_changed() -> void: var disk = get_disk() var trans = $CanvasLayer/Interface.get_disk_trans() @@ -42,6 +48,9 @@ func update_rects() -> void: var domain_max = $CanvasLayer/Interface.get_domain_max() var lower_function = $CanvasLayer/Interface.get_lower_function() var higher_function = $CanvasLayer/Interface.get_upper_function() + var shape_rotation = $CanvasLayer/Interface.get_shape_rotation() + var disk_rotation = $CanvasLayer/Interface.get_disk_rotation() + var disk_trans = $CanvasLayer/Interface.get_disk_trans() var delta_x = (domain_max - domain_min) / (num_rects as float) for i in num_rects: @@ -55,6 +64,8 @@ func update_rects() -> void: rect.reset() rect.set_size(Vector3(delta_x, higher_y - lower_y, 0.01)) rect.set_pos(Vector3(x + delta_x / 2, (higher_y + lower_y) / 2, 0)) + if shape_rotation > 0.1: + rect.set_rot(shape_rotation) if $CanvasLayer/Interface.get_coloring() == 0: rect.set_color(gradient.sample(i as float / num_rects)) else: @@ -70,9 +81,8 @@ func update_rects() -> void: # Set disk properties var disk = get_disk() - var disk_rotation = $CanvasLayer/Interface.get_disk_rotation() disk.set_rot(disk_rotation) - disk.set_alpha(1. - $CanvasLayer/Interface.get_disk_trans()) + disk.set_alpha(1. - disk_trans) if $CanvasLayer/Interface.get_coloring() == 1: disk.set_color(distinction_color) diff --git a/Main.tscn b/Main.tscn index 9d81834..34673a7 100644 --- a/Main.tscn +++ b/Main.tscn @@ -50,3 +50,4 @@ light_energy = 0.205 [connection signal="domain_changed" from="CanvasLayer/Interface" to="." method="_on_interface_domain_changed"] [connection signal="function_changed" from="CanvasLayer/Interface" to="." method="_on_interface_function_changed"] [connection signal="num_rect_changed" from="CanvasLayer/Interface" to="." method="_on_interface_num_rect_changed"] +[connection signal="shape_rotation_changed" from="CanvasLayer/Interface" to="." method="_on_interface_shape_rotation_changed"] diff --git a/Rectangle/Rectangle.gd b/Rectangle/Rectangle.gd index ae3a63f..8aebced 100644 --- a/Rectangle/Rectangle.gd +++ b/Rectangle/Rectangle.gd @@ -4,10 +4,7 @@ const RESOLUTION: int = 30 var size: Vector3 var color: Color -var material: Material - -func _ready() -> void: - material = $MeshInstance3D.mesh.material +var material: Material = null func set_size(new_size: Vector3) -> void: size = new_size