diff --git a/addons/material_maker/icons/icons.svg b/addons/material_maker/icons/icons.svg index c493618..ad9aa94 100644 --- a/addons/material_maker/icons/icons.svg +++ b/addons/material_maker/icons/icons.svg @@ -11,14 +11,21 @@ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="128" - height="64" - viewBox="0 0 128 64" + height="128" + viewBox="0 0 128 128" version="1.1" id="svg8" - inkscape:version="0.92.4 (5da689c313, 2019-01-14)" + inkscape:version="0.92.3 (2405546, 2018-03-11)" sodipodi:docname="icons.svg"> + @@ -49,8 +56,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="28.608854" - inkscape:cx="86.841515" - inkscape:cy="21.061007" + inkscape:cx="54.703743" + inkscape:cy="64.734209" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" @@ -79,7 +86,7 @@ image/svg+xml - + @@ -87,10 +94,10 @@ inkscape:label="Calque 1" inkscape:groupmode="layer" id="layer1" - transform="translate(0,-280.06665)"> + transform="translate(0,-216.06665)"> @@ -110,7 +117,7 @@ inkscape:export-xdpi="16.531826" inkscape:export-filename="remove.png" id="g4564" - transform="matrix(0.43370177,0.42718925,-0.43370177,0.42718925,43.791013,273.09803)" + transform="matrix(0.43370177,0.42718925,-0.43370177,0.42718925,43.791013,209.09803)" style="fill:#ff0909;fill-opacity:1"> + transform="matrix(0.52573689,0,0,0.513409,30.847756,228.09585)"> @@ -187,7 +194,7 @@ inkscape:export-filename="save.png" inkscape:export-xdpi="14" inkscape:export-ydpi="14" - transform="matrix(0.52616852,0,0,0.52616852,14.395212,275.18126)"> + transform="matrix(0.52616852,0,0,0.52616852,14.395212,211.18126)"> + transform="matrix(0.51223521,0,0,0.51223521,5.2214853,211.80647)"> @@ -276,28 +283,28 @@ style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke" id="path5162" cx="7.8297439" - cy="319.77344" + cy="255.77344" rx="1.0486264" ry="0.87385535" /> @@ -317,7 +324,7 @@ inkscape:export-filename="config.png" inkscape:export-xdpi="16.559999" inkscape:export-ydpi="16.559999" - transform="matrix(0.52573689,0,0,0.513409,-1.7560956,259.17843)"> + transform="matrix(0.52573689,0,0,0.513409,-1.7560956,195.17843)"> @@ -356,45 +362,46 @@ sodipodi:nodetypes="cccccccc" inkscape:connector-curvature="0" id="path4561" - d="m 33.500409,335.78733 4.34961,-0.0488 0.123047,-6.82227 h 4.27539 l 0.125,6.82227 4.34961,0.0488 -6.611328,6.8457 z" - style="fill:#ffffff;fill-opacity:0.84322037;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + d="m 33.500409,271.78733 4.34961,-0.0488 0.123047,-6.82227 h 4.27539 l 0.125,6.82227 4.34961,0.0488 -6.611328,6.8457 z" + style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + id="g892" + transform="translate(0,-64)"> + transform="translate(16.00903,-64.034954)"> + + + + + + + + + + + diff --git a/addons/material_maker/library.gd b/addons/material_maker/library.gd index 353f022..4efb67c 100644 --- a/addons/material_maker/library.gd +++ b/addons/material_maker/library.gd @@ -1,4 +1,3 @@ -tool extends VBoxContainer var libraries = [] diff --git a/addons/material_maker/main_window.gd b/addons/material_maker/main_window.gd index d85ee66..951d59a 100644 --- a/addons/material_maker/main_window.gd +++ b/addons/material_maker/main_window.gd @@ -1,4 +1,3 @@ -tool extends Panel var recent_files = [] @@ -468,7 +467,7 @@ func update_preview() -> void: status = update_preview_2d() while status is GDScriptFunctionState: status = yield(status, "completed") - status = update_preview_3d() + status = update_preview_3d([ $VBoxContainer/HBoxContainer/VBoxContainer/Preview/Preview3D, $VBoxContainer/HBoxContainer/ProjectsPane/Preview3D]) while status is GDScriptFunctionState: status = yield(status, "completed") updating = false @@ -490,14 +489,15 @@ func update_preview_2d(node = null) -> void: result.release() preview_2d.set_preview_texture(tex) -func update_preview_3d() -> void: +func update_preview_3d(previews : Array) -> void: var graph_edit : MMGraphEdit = get_current_graph_edit() if graph_edit != null and graph_edit.top_generator != null and graph_edit.top_generator.has_node("Material"): var gen_material = graph_edit.top_generator.get_node("Material") var status = gen_material.render_textures() while status is GDScriptFunctionState: status = yield(status, "completed") - gen_material.update_materials(preview_3d.get_materials()) + for p in previews: + gen_material.update_materials(p.get_materials()) func _on_Projects_tab_changed(tab) -> void: var new_tab = projects.get_current_tab_control() @@ -511,12 +511,6 @@ func _on_Projects_tab_changed(tab) -> void: current_tab = new_tab update_preview() -func _on_Preview_show_background_preview(v) -> void: - var pv = preview_3d.get_node("MaterialPreview") - var bgpv = $VBoxContainer/HBoxContainer/ProjectsPane/BackgroundPreview/Viewport - bgpv.world = pv.find_world() - $VBoxContainer/HBoxContainer/ProjectsPane/BackgroundPreview.visible = v - func _exit_tree() -> void: # Save the window position and size to remember it when restarting the application if !Engine.editor_hint: @@ -525,3 +519,7 @@ func _exit_tree() -> void: config_cache.set_value("window", "position", OS.window_position) config_cache.set_value("window", "size", OS.window_size) config_cache.save("user://cache.ini") + +func show_background_preview(button_pressed): + $VBoxContainer/HBoxContainer/ProjectsPane/Preview3D.visible = button_pressed + $VBoxContainer/HBoxContainer/ProjectsPane/HBoxContainer/HBoxContainer.visible = button_pressed diff --git a/addons/material_maker/main_window.tscn b/addons/material_maker/main_window.tscn index b531dd8..d3ad15d 100644 --- a/addons/material_maker/main_window.tscn +++ b/addons/material_maker/main_window.tscn @@ -1,12 +1,13 @@ -[gd_scene load_steps=12 format=2] +[gd_scene load_steps=13 format=2] [ext_resource path="res://addons/material_maker/main_window.gd" type="Script" id=1] [ext_resource path="res://addons/material_maker/library.tscn" type="PackedScene" id=2] [ext_resource path="res://addons/material_maker/preview/preview_2d.tscn" type="PackedScene" id=3] [ext_resource path="res://addons/material_maker/preview/preview_3d.tscn" type="PackedScene" id=4] -[ext_resource path="res://addons/material_maker/preview/panoramas/epping_forest_01.hdr" type="Texture" id=5] +[ext_resource path="res://addons/material_maker/preview/preview_3d_ui.tscn" type="PackedScene" id=5] [ext_resource path="res://addons/material_maker/widgets/tabs.gd" type="Script" id=6] -[ext_resource path="res://addons/material_maker/node_factory.gd" type="Script" id=7] +[ext_resource path="res://addons/material_maker/icons/icons.svg" type="Texture" id=7] +[ext_resource path="res://addons/material_maker/node_factory.gd" type="Script" id=8] [sub_resource type="Shader" id=1] code = "shader_type canvas_item; @@ -20,18 +21,15 @@ void fragment() { [sub_resource type="ShaderMaterial" id=2] shader = SubResource( 1 ) -[sub_resource type="PanoramaSky" id=3] -resource_local_to_scene = true -panorama = ExtResource( 5 ) +[sub_resource type="AtlasTexture" id=3] +flags = 4 +atlas = ExtResource( 7 ) +region = Rect2( 96, 32, 32, 32 ) -[sub_resource type="Environment" id=4] -background_mode = 2 -background_sky = SubResource( 3 ) -background_energy = 1.5 -ambient_light_color = Color( 1, 1, 1, 1 ) -ambient_light_energy = 0.32 -tonemap_mode = 2 -tonemap_white = 16.0 +[sub_resource type="AtlasTexture" id=4] +flags = 4 +atlas = ExtResource( 7 ) +region = Rect2( 96, 64, 32, 32 ) [node name="MainWindow" type="Panel"] anchor_right = 1.0 @@ -119,6 +117,8 @@ rect_min_size = Vector2( 250, 250 ) [node name="Preview3D" parent="VBoxContainer/HBoxContainer/VBoxContainer/Preview" instance=ExtResource( 4 )] rect_min_size = Vector2( 250, 250 ) +[node name="Preview3DUI" parent="VBoxContainer/HBoxContainer/VBoxContainer/Preview/Preview3D" instance=ExtResource( 5 )] + [node name="ProjectsPane" type="Control" parent="VBoxContainer/HBoxContainer"] margin_left = 323.0 margin_right = 1268.0 @@ -127,22 +127,12 @@ size_flags_horizontal = 3 size_flags_vertical = 3 size_flags_stretch_ratio = 3.0 -[node name="BackgroundPreview" type="ViewportContainer" parent="VBoxContainer/HBoxContainer/ProjectsPane"] -visible = false -anchor_right = 1.0 -anchor_bottom = 1.0 -stretch = true - -[node name="Viewport" type="Viewport" parent="VBoxContainer/HBoxContainer/ProjectsPane/BackgroundPreview"] -size = Vector2( 945, 684 ) -handle_input_locally = false -msaa = 2 -render_target_update_mode = 0 - -[node name="Camera" type="Camera" parent="VBoxContainer/HBoxContainer/ProjectsPane/BackgroundPreview/Viewport"] -transform = Transform( 1, 0, 0, 0, 0.766044, 0.642788, 0, -0.642788, 0.766044, 0, 2.24976, 2.68115 ) -environment = SubResource( 4 ) -current = true +[node name="Preview3D" parent="VBoxContainer/HBoxContainer/ProjectsPane" instance=ExtResource( 4 )] +margin_left = 0.0 +margin_top = 0.0 +margin_right = 0.0 +margin_bottom = 0.0 +ui_path = "../HBoxContainer/HBoxContainer/Preview3DUI" [node name="Projects" type="Panel" parent="VBoxContainer/HBoxContainer/ProjectsPane"] self_modulate = Color( 1, 1, 1, 0 ) @@ -160,51 +150,59 @@ margin_bottom = 24.0 tab_align = 0 tab_close_display_policy = 1 +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/HBoxContainer/ProjectsPane"] +anchor_top = 1.0 +anchor_bottom = 1.0 +margin_left = 1.0 +margin_top = -45.0 +margin_right = 331.0 +margin_bottom = -13.0 +custom_constants/separation = 7 + +[node name="Button" type="Button" parent="VBoxContainer/HBoxContainer/ProjectsPane/HBoxContainer"] +margin_right = 44.0 +margin_bottom = 38.0 +hint_tooltip = "Show 3D preview" +toggle_mode = true +icon = SubResource( 3 ) + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/HBoxContainer/ProjectsPane/HBoxContainer"] +visible = false +margin_left = 51.0 +margin_right = 354.0 +margin_bottom = 38.0 +custom_constants/separation = 8 + +[node name="ControlView" type="TextureRect" parent="VBoxContainer/HBoxContainer/ProjectsPane/HBoxContainer/HBoxContainer"] +margin_top = 3.0 +margin_right = 32.0 +margin_bottom = 35.0 +size_flags_vertical = 4 +texture = SubResource( 4 ) + +[node name="Preview3DUI" parent="VBoxContainer/HBoxContainer/ProjectsPane/HBoxContainer/HBoxContainer" instance=ExtResource( 5 )] +anchor_right = 0.0 +margin_left = 40.0 +margin_top = 8.0 +margin_right = 303.0 +margin_bottom = 30.0 +size_flags_vertical = 4 + [node name="NodeFactory" type="Node" parent="."] -script = ExtResource( 7 ) +script = ExtResource( 8 ) [connection signal="need_update" from="VBoxContainer/HBoxContainer/VBoxContainer/Preview/Preview3D" to="." method="update_preview_3d"] -[connection signal="show_background_preview" from="VBoxContainer/HBoxContainer/VBoxContainer/Preview/Preview3D" to="." method="_on_Preview_show_background_preview"] +[connection signal="environment_selected" from="VBoxContainer/HBoxContainer/VBoxContainer/Preview/Preview3D/Preview3DUI" to="VBoxContainer/HBoxContainer/VBoxContainer/Preview/Preview3D" method="_on_Environment_item_selected"] +[connection signal="model_selected" from="VBoxContainer/HBoxContainer/VBoxContainer/Preview/Preview3D/Preview3DUI" to="VBoxContainer/HBoxContainer/VBoxContainer/Preview/Preview3D" method="_on_Model_item_selected"] +[connection signal="rotate_toggled" from="VBoxContainer/HBoxContainer/VBoxContainer/Preview/Preview3D/Preview3DUI" to="VBoxContainer/HBoxContainer/VBoxContainer/Preview/Preview3D" method="_on_Rotate_toggled"] +[connection signal="need_update" from="VBoxContainer/HBoxContainer/ProjectsPane/Preview3D" to="." method="update_preview_3d"] [connection signal="no_more_tabs" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects" to="." method="new_material"] [connection signal="resized" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects" method="_on_Projects_resized"] [connection signal="tab_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects" to="." method="_on_Projects_tab_changed"] -[connection signal="connection_request" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" method="connect_node"] -[connection signal="disconnection_request" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" method="disconnect_node"] -[connection signal="duplicate_nodes_request" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" method="duplicate_selected"] -[connection signal="focus_exited" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" method="_on_LineEdit_focus_exited"] -[connection signal="gui_input" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" method="_on_LineEdit_gui_input"] -[connection signal="resized" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" method="do_update"] -[connection signal="text_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" method="_on_LineEdit_text_changed"] -[connection signal="text_entered" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" method="_on_LineEdit_text_entered"] -[connection signal="focus_exited" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer3/roughness" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer3/roughness" method="_on_LineEdit_focus_exited"] -[connection signal="gui_input" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer3/roughness" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer3/roughness" method="_on_LineEdit_gui_input"] -[connection signal="resized" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer3/roughness" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer3/roughness" method="do_update"] -[connection signal="text_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer3/roughness" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer3/roughness" method="_on_LineEdit_text_changed"] -[connection signal="text_entered" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer3/roughness" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer3/roughness" method="_on_LineEdit_text_entered"] -[connection signal="focus_exited" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer4/emission_energy" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer4/emission_energy" method="_on_LineEdit_focus_exited"] -[connection signal="gui_input" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer4/emission_energy" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer4/emission_energy" method="_on_LineEdit_gui_input"] -[connection signal="resized" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer4/emission_energy" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer4/emission_energy" method="do_update"] -[connection signal="text_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer4/emission_energy" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer4/emission_energy" method="_on_LineEdit_text_changed"] -[connection signal="text_entered" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer4/emission_energy" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer4/emission_energy" method="_on_LineEdit_text_entered"] -[connection signal="focus_exited" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer5/normal_scale" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer5/normal_scale" method="_on_LineEdit_focus_exited"] -[connection signal="gui_input" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer5/normal_scale" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer5/normal_scale" method="_on_LineEdit_gui_input"] -[connection signal="resized" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer5/normal_scale" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer5/normal_scale" method="do_update"] -[connection signal="text_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer5/normal_scale" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer5/normal_scale" method="_on_LineEdit_text_changed"] -[connection signal="text_entered" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer5/normal_scale" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer5/normal_scale" method="_on_LineEdit_text_entered"] -[connection signal="focus_exited" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer6/ao_light_affect" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer6/ao_light_affect" method="_on_LineEdit_focus_exited"] -[connection signal="gui_input" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer6/ao_light_affect" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer6/ao_light_affect" method="_on_LineEdit_gui_input"] -[connection signal="resized" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer6/ao_light_affect" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer6/ao_light_affect" method="do_update"] -[connection signal="text_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer6/ao_light_affect" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer6/ao_light_affect" method="_on_LineEdit_text_changed"] -[connection signal="text_entered" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer6/ao_light_affect" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer6/ao_light_affect" method="_on_LineEdit_text_entered"] -[connection signal="focus_exited" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer7/depth_scale" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer7/depth_scale" method="_on_LineEdit_focus_exited"] -[connection signal="gui_input" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer7/depth_scale" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer7/depth_scale" method="_on_LineEdit_gui_input"] -[connection signal="resized" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer7/depth_scale" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer7/depth_scale" method="do_update"] -[connection signal="text_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer7/depth_scale" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer7/depth_scale" method="_on_LineEdit_text_changed"] -[connection signal="text_entered" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer7/depth_scale" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer7/depth_scale" method="_on_LineEdit_text_entered"] -[connection signal="focus_exited" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer8/subsurf_scatter_strength" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer8/subsurf_scatter_strength" method="_on_LineEdit_focus_exited"] -[connection signal="gui_input" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer8/subsurf_scatter_strength" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer8/subsurf_scatter_strength" method="_on_LineEdit_gui_input"] -[connection signal="resized" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer8/subsurf_scatter_strength" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer8/subsurf_scatter_strength" method="do_update"] -[connection signal="text_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer8/subsurf_scatter_strength" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer8/subsurf_scatter_strength" method="_on_LineEdit_text_changed"] -[connection signal="text_entered" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer8/subsurf_scatter_strength" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer8/subsurf_scatter_strength" method="_on_LineEdit_text_entered"] [connection signal="reposition_active_tab_request" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/Tabs" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects" method="move_active_tab_to"] [connection signal="tab_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/Tabs" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects" method="set_current_tab"] [connection signal="tab_close" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/Tabs" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects" method="close_tab"] +[connection signal="toggled" from="VBoxContainer/HBoxContainer/ProjectsPane/HBoxContainer/Button" to="." method="show_background_preview"] +[connection signal="gui_input" from="VBoxContainer/HBoxContainer/ProjectsPane/HBoxContainer/HBoxContainer/ControlView" to="VBoxContainer/HBoxContainer/ProjectsPane/Preview3D" method="on_gui_input"] +[connection signal="environment_selected" from="VBoxContainer/HBoxContainer/ProjectsPane/HBoxContainer/HBoxContainer/Preview3DUI" to="VBoxContainer/HBoxContainer/ProjectsPane/Preview3D" method="_on_Environment_item_selected"] +[connection signal="model_selected" from="VBoxContainer/HBoxContainer/ProjectsPane/HBoxContainer/HBoxContainer/Preview3DUI" to="VBoxContainer/HBoxContainer/ProjectsPane/Preview3D" method="_on_Model_item_selected"] +[connection signal="rotate_toggled" from="VBoxContainer/HBoxContainer/ProjectsPane/HBoxContainer/HBoxContainer/Preview3DUI" to="VBoxContainer/HBoxContainer/ProjectsPane/Preview3D" method="_on_Rotate_toggled"] diff --git a/addons/material_maker/preview/preview_3d.gd b/addons/material_maker/preview/preview_3d.gd index 1e51c61..2fefb78 100644 --- a/addons/material_maker/preview/preview_3d.gd +++ b/addons/material_maker/preview/preview_3d.gd @@ -1,4 +1,3 @@ -tool extends ViewportContainer const ENVIRONMENTS = [ @@ -8,6 +7,8 @@ const ENVIRONMENTS = [ const CAMERA_DISTANCE_MIN = 1.0 const CAMERA_DISTANCE_MAX = 10.0 +export var ui_path : String = "Preview3DUI" + onready var objects = $MaterialPreview/Preview3d/Objects onready var current_object = objects.get_child(0) @@ -17,8 +18,9 @@ onready var current_environment = environments.get_child(0) onready var camera_stand = $MaterialPreview/Preview3d/CameraPivot onready var camera = $MaterialPreview/Preview3d/CameraPivot/Camera -signal need_update -signal show_background_preview +onready var ui = get_node(ui_path) + +signal need_update(me) func _ready() -> void: var model_list : Array = [] @@ -26,25 +28,23 @@ func _ready() -> void: var m = o.get_surface_material(0) o.set_surface_material(0, m.duplicate()) model_list.push_back(o.name) - $Preview3DUI.set_models(model_list) + ui.set_models(model_list) var environment_list : Array = [] for e in environments.get_children(): environment_list.push_back(e.name) - $Preview3DUI.set_environments(environment_list) + ui.set_environments(environment_list) $MaterialPreview/Preview3d/ObjectRotate.play("rotate") - $MaterialPreview/Preview3d/CameraPivot/Camera/RemoteTransform.set_remote_node("../../../../../../../../ProjectsPane/BackgroundPreview/Viewport/Camera") func _on_Model_item_selected(id) -> void: current_object.visible = false current_object = objects.get_child(id) current_object.visible = true - emit_signal("need_update") + emit_signal("need_update", [ self ]) func _on_Environment_item_selected(id) -> void: current_environment.visible = false current_environment = environments.get_child(id) $MaterialPreview/Preview3d/CameraPivot/Camera.set_environment(current_environment.environment) - get_node("../../../ProjectsPane/BackgroundPreview/Viewport/Camera").set_environment(current_environment.environment) current_environment.visible = true func _on_Rotate_toggled(button_pressed) -> void: @@ -53,16 +53,13 @@ func _on_Rotate_toggled(button_pressed) -> void: else: $MaterialPreview/Preview3d/ObjectRotate.stop(false) -func _on_Background_toggled(button_pressed) -> void: - emit_signal("show_background_preview", button_pressed) - func get_materials() -> Array: return [ current_object.get_surface_material(0) ] func on_gui_input(event) -> void: if event is InputEventMouseButton: $MaterialPreview/Preview3d/ObjectRotate.stop(false) - $Preview3DUI.rotation_cancelled() + ui.rotation_cancelled() match event.button_index: BUTTON_WHEEL_UP: camera.translation.z = clamp( diff --git a/addons/material_maker/preview/preview_3d.tscn b/addons/material_maker/preview/preview_3d.tscn index 3dab17f..c7651d5 100644 --- a/addons/material_maker/preview/preview_3d.tscn +++ b/addons/material_maker/preview/preview_3d.tscn @@ -1,8 +1,7 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://addons/material_maker/preview/preview_3d.gd" type="Script" id=1] [ext_resource path="res://addons/material_maker/preview/preview_3d_scene.tscn" type="PackedScene" id=2] -[ext_resource path="res://addons/material_maker/preview/preview_3d_ui.tscn" type="PackedScene" id=3] [sub_resource type="World" id=1] @@ -32,11 +31,5 @@ render_target_update_mode = 0 physics_object_picking = true [node name="Preview3d" parent="MaterialPreview" instance=ExtResource( 2 )] - -[node name="Preview3DUI" parent="." instance=ExtResource( 3 )] [connection signal="gui_input" from="." to="." method="on_gui_input"] [connection signal="resized" from="." to="." method="_on_Preview_resized"] -[connection signal="background_toggled" from="Preview3DUI" to="." method="_on_Background_toggled"] -[connection signal="environment_selected" from="Preview3DUI" to="." method="_on_Environment_item_selected"] -[connection signal="model_selected" from="Preview3DUI" to="." method="_on_Model_item_selected"] -[connection signal="rotate_toggled" from="Preview3DUI" to="." method="_on_Rotate_toggled"] diff --git a/addons/material_maker/preview/preview_3d_scene.tscn b/addons/material_maker/preview/preview_3d_scene.tscn index 05b5692..348f57e 100644 --- a/addons/material_maker/preview/preview_3d_scene.tscn +++ b/addons/material_maker/preview/preview_3d_scene.tscn @@ -68,9 +68,6 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 3.5 ) environment = SubResource( 2 ) current = true -[node name="RemoteTransform" type="RemoteTransform" parent="CameraPivot/Camera"] -remote_path = NodePath("../../../../../../ProjectsPane/BackgroundPreview/Viewport/Camera") - [node name="ObjectRotate" type="AnimationPlayer" parent="."] autoplay = "rotate" playback_speed = 0.1 diff --git a/addons/material_maker/preview/preview_3d_ui.gd b/addons/material_maker/preview/preview_3d_ui.gd index 78718e5..2764864 100644 --- a/addons/material_maker/preview/preview_3d_ui.gd +++ b/addons/material_maker/preview/preview_3d_ui.gd @@ -1,10 +1,8 @@ -tool extends HBoxContainer signal model_selected(id) signal environment_selected(id) signal rotate_toggled(b) -signal background_toggled(b) func set_models(model_list : Array) -> void: $Model.clear() @@ -29,6 +27,3 @@ func _on_Environment_item_selected(ID) -> void: func _on_Rotate_toggled(button_pressed) -> void: emit_signal("rotate_toggled", button_pressed) - -func _on_Background_toggled(button_pressed) -> void: - emit_signal("background_toggled", button_pressed) diff --git a/addons/material_maker/preview/preview_3d_ui.tscn b/addons/material_maker/preview/preview_3d_ui.tscn index 1e7ab55..2c74404 100644 --- a/addons/material_maker/preview/preview_3d_ui.tscn +++ b/addons/material_maker/preview/preview_3d_ui.tscn @@ -1,6 +1,12 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://addons/material_maker/preview/preview_3d_ui.gd" type="Script" id=1] +[ext_resource path="res://addons/material_maker/icons/icons.svg" type="Texture" id=2] + +[sub_resource type="AtlasTexture" id=1] +flags = 4 +atlas = ExtResource( 2 ) +region = Rect2( 48, 48, 16, 16 ) [node name="Preview3DUI" type="HBoxContainer"] anchor_right = 1.0 @@ -10,7 +16,7 @@ script = ExtResource( 1 ) [node name="Model" type="OptionButton" parent="."] margin_right = 100.0 -margin_bottom = 20.0 +margin_bottom = 22.0 rect_min_size = Vector2( 100, 0 ) text = "Cube" items = [ "Cube", null, false, 0, null, "Cylinder", null, false, 1, null, "Sphere", null, false, 2, null, "Sphere2", null, false, 3, null, "Prism", null, false, 4, null, "Quad", null, false, 5, null, "Plane", null, false, 6, null, "SphereTess", null, false, 7, null ] @@ -19,7 +25,7 @@ selected = 0 [node name="Environment" type="OptionButton" parent="."] margin_left = 104.0 margin_right = 231.0 -margin_bottom = 20.0 +margin_bottom = 22.0 rect_min_size = Vector2( 100, 0 ) text = "Epping Forest" items = [ "Epping Forest", null, false, 0, null, "Moonless Golf", null, false, 1, null, "Studio", null, false, 2, null ] @@ -27,27 +33,14 @@ selected = 0 [node name="Rotate" type="Button" parent="."] margin_left = 235.0 -margin_right = 255.0 -margin_bottom = 20.0 +margin_right = 263.0 +margin_bottom = 22.0 rect_pivot_offset = Vector2( -4, 7 ) hint_tooltip = "Rotate object" size_flags_horizontal = 2 toggle_mode = true pressed = true -text = "R" - -[node name="Background" type="Button" parent="."] -margin_left = 1257.0 -margin_right = 1280.0 -margin_bottom = 20.0 -grow_horizontal = 2 -grow_vertical = 2 -rect_pivot_offset = Vector2( -4, 7 ) -hint_tooltip = "Show in main view" -size_flags_horizontal = 8 -toggle_mode = true -text = "O" +icon = SubResource( 1 ) [connection signal="item_selected" from="Model" to="." method="_on_Model_item_selected"] [connection signal="item_selected" from="Environment" to="." method="_on_Environment_item_selected"] [connection signal="toggled" from="Rotate" to="." method="_on_Rotate_toggled"] -[connection signal="toggled" from="Background" to="." method="_on_Background_toggled"] diff --git a/addons/material_maker/widgets/tabs.gd b/addons/material_maker/widgets/tabs.gd index 818d5ea..9e665b3 100644 --- a/addons/material_maker/widgets/tabs.gd +++ b/addons/material_maker/widgets/tabs.gd @@ -1,4 +1,3 @@ -tool extends Panel var current_tab = -1 setget set_current_tab