mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Started implementing remote node
This commit is contained in:
parent
ac4a5c39b6
commit
afb84a85cf
@ -38,7 +38,6 @@ func get_output_defs():
|
||||
return rv
|
||||
|
||||
func _get_shader_code(uv : String, output_index : int, context : MMGenContext):
|
||||
print("Getting shader code from ios")
|
||||
if mask != 2:
|
||||
var source = get_source(output_index)
|
||||
if source != null:
|
||||
|
23
addons/material_maker/engine/gen_remote.gd
Normal file
23
addons/material_maker/engine/gen_remote.gd
Normal file
@ -0,0 +1,23 @@
|
||||
tool
|
||||
extends MMGenBase
|
||||
class_name MMGenRemote
|
||||
|
||||
"""
|
||||
Remote can be used to control parameters from several generators in the same graph
|
||||
"""
|
||||
|
||||
var widgets = null
|
||||
|
||||
func set_widgets(w):
|
||||
widgets = w
|
||||
|
||||
func get_type():
|
||||
return "remote"
|
||||
|
||||
func get_type_name():
|
||||
return "Remote"
|
||||
|
||||
func _serialize(data):
|
||||
data.type = "remote"
|
||||
data.widgets = widgets
|
||||
return data
|
@ -49,6 +49,9 @@ static func create_gen(data) -> MMGenBase:
|
||||
elif data.has("model_data"):
|
||||
generator = MMGenShader.new()
|
||||
generator.set_shader_model(data.model_data)
|
||||
elif data.has("widgets"):
|
||||
generator = MMGenRemote.new()
|
||||
generator.set_widgets(data.widgets)
|
||||
elif data.has("type"):
|
||||
if data.type == "material":
|
||||
generator = MMGenMaterial.new()
|
||||
|
@ -102,10 +102,6 @@ script = ExtResource( 6 )
|
||||
[connection signal="no_more_tabs" from="VBoxContainer/HBoxContainer/Projects" to="." method="new_material"]
|
||||
[connection signal="resized" from="VBoxContainer/HBoxContainer/Projects" to="VBoxContainer/HBoxContainer/Projects" method="_on_Projects_resized"]
|
||||
[connection signal="tab_changed" from="VBoxContainer/HBoxContainer/Projects" to="." method="_on_Projects_tab_changed"]
|
||||
[connection signal="connection_request" from="VBoxContainer/HBoxContainer/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/Projects/GraphEdit" method="connect_node"]
|
||||
[connection signal="disconnection_request" from="VBoxContainer/HBoxContainer/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/Projects/GraphEdit" method="disconnect_node"]
|
||||
[connection signal="close_request" from="VBoxContainer/HBoxContainer/Projects/GraphEdit/node_Material" to="VBoxContainer/HBoxContainer/Projects/GraphEdit/node_Material" method="on_close_request"]
|
||||
[connection signal="offset_changed" from="VBoxContainer/HBoxContainer/Projects/GraphEdit/node_Material" to="VBoxContainer/HBoxContainer/Projects/GraphEdit/node_Material" method="on_offset_changed"]
|
||||
[connection signal="reposition_active_tab_request" from="VBoxContainer/HBoxContainer/Projects/Tabs" to="VBoxContainer/HBoxContainer/Projects" method="move_active_tab_to"]
|
||||
[connection signal="tab_changed" from="VBoxContainer/HBoxContainer/Projects/Tabs" to="VBoxContainer/HBoxContainer/Projects" method="set_current_tab"]
|
||||
[connection signal="tab_close" from="VBoxContainer/HBoxContainer/Projects/Tabs" to="VBoxContainer/HBoxContainer/Projects" method="close_tab"]
|
||||
|
@ -5,10 +5,6 @@ var generator = null setget set_generator
|
||||
|
||||
var controls = []
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
func set_generator(g):
|
||||
generator = g
|
||||
update_node()
|
||||
|
@ -4,13 +4,24 @@ extends "res://addons/material_maker/node_base.gd"
|
||||
const LinkedControl = preload("res://addons/material_maker/widgets/linked_widgets/linked_control.tscn")
|
||||
const ConfigControl = preload("res://addons/material_maker/widgets/linked_widgets/config_control.tscn")
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
var generator = null setget set_generator
|
||||
|
||||
func _get_shader_code(uv, slot = 0):
|
||||
var rv = { defs="", code="" }
|
||||
rv.rgb = "vec3(1.0)"
|
||||
return rv
|
||||
func set_generator(g):
|
||||
generator = g
|
||||
call_deferred("update_node")
|
||||
|
||||
|
||||
func update_node():
|
||||
for w in generator.widgets:
|
||||
var widget
|
||||
if w.type == "linked_control":
|
||||
widget = LinkedControl.instance()
|
||||
elif w.type == "config_control":
|
||||
widget = ConfigControl.instance()
|
||||
else:
|
||||
continue
|
||||
add_control(widget)
|
||||
widget.deserialize(w)
|
||||
|
||||
func add_control(widget):
|
||||
var controls = widget.get_associated_controls()
|
||||
@ -18,7 +29,6 @@ func add_control(widget):
|
||||
$Controls.add_child(widget)
|
||||
$Controls.add_child(controls.buttons)
|
||||
|
||||
|
||||
func _on_AddLink_pressed():
|
||||
var widget = LinkedControl.instance()
|
||||
add_control(widget)
|
||||
@ -42,22 +52,3 @@ func serialize():
|
||||
widgets.append($Controls.get_child(i).serialize())
|
||||
var data = { type="remote", node_position={x=offset.x,y=offset.y}, editable=true, widgets=widgets }
|
||||
return data
|
||||
|
||||
func deserialize(data):
|
||||
if data.has("node_position"):
|
||||
offset.x = data.node_position.x
|
||||
offset.y = data.node_position.y
|
||||
call_deferred("do_deserialize", data)
|
||||
|
||||
func do_deserialize(data):
|
||||
if data.has("widgets"):
|
||||
for w in data.widgets:
|
||||
var widget
|
||||
if w.type == "linked_control":
|
||||
widget = LinkedControl.instance()
|
||||
elif w.type == "config_control":
|
||||
widget = ConfigControl.instance()
|
||||
else:
|
||||
continue
|
||||
add_control(widget)
|
||||
widget.deserialize(w)
|
57
addons/material_maker/nodes/remote.tscn
Normal file
57
addons/material_maker/nodes/remote.tscn
Normal file
@ -0,0 +1,57 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://addons/material_maker/nodes/remote.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/material_maker/icons/link.png" type="Texture" id=2]
|
||||
[ext_resource path="res://addons/material_maker/icons/config.png" type="Texture" id=3]
|
||||
|
||||
[sub_resource type="Theme" id=1]
|
||||
|
||||
[node name="Remote" type="GraphNode"]
|
||||
margin_right = 95.0
|
||||
margin_bottom = 55.0
|
||||
mouse_filter = 1
|
||||
theme = SubResource( 1 )
|
||||
title = "Remote"
|
||||
show_close = true
|
||||
slot/0/left_enabled = false
|
||||
slot/0/left_type = 0
|
||||
slot/0/left_color = Color( 0.5, 0.5, 1, 1 )
|
||||
slot/0/right_enabled = false
|
||||
slot/0/right_type = 0
|
||||
slot/0/right_color = Color( 0.5, 0.5, 1, 1 )
|
||||
slot/1/left_enabled = false
|
||||
slot/1/left_type = 0
|
||||
slot/1/left_color = Color( 1, 1, 1, 1 )
|
||||
slot/1/right_enabled = false
|
||||
slot/1/right_type = 0
|
||||
slot/1/right_color = Color( 1, 1, 1, 1 )
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Controls" type="GridContainer" parent="."]
|
||||
margin_left = 16.0
|
||||
margin_top = 24.0
|
||||
margin_right = 79.0
|
||||
margin_bottom = 24.0
|
||||
columns = 3
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
margin_left = 16.0
|
||||
margin_top = 24.0
|
||||
margin_right = 79.0
|
||||
margin_bottom = 46.0
|
||||
|
||||
[node name="AddLink" type="Button" parent="HBoxContainer"]
|
||||
margin_right = 28.0
|
||||
margin_bottom = 22.0
|
||||
hint_tooltip = "Add linked control"
|
||||
size_flags_horizontal = 0
|
||||
icon = ExtResource( 2 )
|
||||
|
||||
[node name="AddConfig" type="Button" parent="HBoxContainer"]
|
||||
margin_left = 32.0
|
||||
margin_right = 60.0
|
||||
margin_bottom = 22.0
|
||||
hint_tooltip = "Add configurations"
|
||||
icon = ExtResource( 3 )
|
||||
[connection signal="pressed" from="HBoxContainer/AddLink" to="." method="_on_AddLink_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/AddConfig" to="." method="_on_AddConfig_pressed"]
|
@ -1,140 +0,0 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://addons/material_maker/nodes/remote/remote.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/material_maker/icons/link.png" type="Texture" id=2]
|
||||
[ext_resource path="res://addons/material_maker/icons/config.png" type="Texture" id=3]
|
||||
|
||||
|
||||
[sub_resource type="Theme" id=1]
|
||||
|
||||
|
||||
[node name="Remote" type="GraphNode"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 95.0
|
||||
margin_bottom = 55.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
theme = SubResource( 1 )
|
||||
title = "Remote"
|
||||
offset = Vector2( 0, 0 )
|
||||
show_close = true
|
||||
resizable = false
|
||||
selected = false
|
||||
comment = false
|
||||
overlay = 0
|
||||
slot/0/left_enabled = false
|
||||
slot/0/left_type = 0
|
||||
slot/0/left_color = Color( 0.5, 0.5, 1, 1 )
|
||||
slot/0/right_enabled = false
|
||||
slot/0/right_type = 0
|
||||
slot/0/right_color = Color( 0.5, 0.5, 1, 1 )
|
||||
slot/1/left_enabled = false
|
||||
slot/1/left_type = 0
|
||||
slot/1/left_color = Color( 1, 1, 1, 1 )
|
||||
slot/1/right_enabled = false
|
||||
slot/1/right_type = 0
|
||||
slot/1/right_color = Color( 1, 1, 1, 1 )
|
||||
script = ExtResource( 1 )
|
||||
_sections_unfolded = [ "Theme", "slot" ]
|
||||
|
||||
[node name="Controls" type="GridContainer" parent="." index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 16.0
|
||||
margin_top = 24.0
|
||||
margin_right = 79.0
|
||||
margin_bottom = 24.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
columns = 3
|
||||
_sections_unfolded = [ "Hint" ]
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="." index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 16.0
|
||||
margin_top = 24.0
|
||||
margin_right = 79.0
|
||||
margin_bottom = 46.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
alignment = 0
|
||||
|
||||
[node name="AddLink" type="Button" parent="HBoxContainer" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 28.0
|
||||
margin_bottom = 22.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
hint_tooltip = "Add linked control"
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 1
|
||||
toggle_mode = false
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
icon = ExtResource( 2 )
|
||||
flat = false
|
||||
align = 1
|
||||
_sections_unfolded = [ "Hint", "Rect", "Size Flags" ]
|
||||
|
||||
[node name="AddConfig" type="Button" parent="HBoxContainer" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 32.0
|
||||
margin_right = 60.0
|
||||
margin_bottom = 22.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
hint_tooltip = "Add configurations"
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
toggle_mode = false
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
icon = ExtResource( 3 )
|
||||
flat = false
|
||||
align = 1
|
||||
_sections_unfolded = [ "Hint" ]
|
||||
|
||||
[connection signal="pressed" from="HBoxContainer/AddLink" to="." method="_on_AddLink_pressed"]
|
||||
|
||||
[connection signal="pressed" from="HBoxContainer/AddConfig" to="." method="_on_AddConfig_pressed"]
|
||||
|
||||
|
@ -115,9 +115,10 @@ func deserialize(data):
|
||||
var c = data.configurations[k]
|
||||
var configuration = []
|
||||
for e in c:
|
||||
var node = graph_edit.get_node(e.node)
|
||||
var node = graph_edit.get_node("node_"+e.node)
|
||||
print(e.widget)
|
||||
var widget = null
|
||||
for w in node.property_widgets:
|
||||
for w in node.controls:
|
||||
if w.name == e.widget:
|
||||
widget = w
|
||||
break
|
||||
|
@ -68,7 +68,10 @@ func update_shaders():
|
||||
func _on_value_changed(v):
|
||||
for l in linked_widgets:
|
||||
l.widget.value = v
|
||||
l.node.parameters[l.widget.name] = v
|
||||
var parent = l.widget.get_parent()
|
||||
while !(parent is GraphNode):
|
||||
parent = parent.get_parent()
|
||||
parent.generator.set_parameter(l.widget.name, v)
|
||||
update_shaders()
|
||||
|
||||
func _on_color_changed(c):
|
||||
|
@ -88,8 +88,8 @@ func get_graph_edit():
|
||||
func find_control(gp):
|
||||
for c in graph_edit.get_children():
|
||||
if c is GraphNode:
|
||||
if c.get("property_widgets") != null:
|
||||
for w in c.property_widgets:
|
||||
if c.get("controls") != null:
|
||||
for w in c.controls:
|
||||
if Rect2(w.rect_global_position, w.rect_size*w.get_global_transform().get_scale()).has_point(gp):
|
||||
return { node=c, widget=w }
|
||||
return null
|
||||
|
@ -34,6 +34,11 @@ _global_script_classes=[ {
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/material_maker/engine/gen_graph.gd"
|
||||
}, {
|
||||
"base": "MMGenBase",
|
||||
"class": "MMGenIOs",
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/material_maker/engine/gen_ios.gd"
|
||||
}, {
|
||||
"base": "MMGenTexture",
|
||||
"class": "MMGenImage",
|
||||
"language": "GDScript",
|
||||
@ -49,6 +54,11 @@ _global_script_classes=[ {
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/material_maker/engine/gen_material.gd"
|
||||
}, {
|
||||
"base": "MMGenBase",
|
||||
"class": "MMGenRemote",
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/material_maker/engine/gen_remote.gd"
|
||||
}, {
|
||||
"base": "Viewport",
|
||||
"class": "MMGenRenderer",
|
||||
"language": "GDScript",
|
||||
@ -60,6 +70,11 @@ _global_script_classes=[ {
|
||||
"path": "res://addons/material_maker/engine/gen_shader.gd"
|
||||
}, {
|
||||
"base": "MMGenBase",
|
||||
"class": "MMGenSwitch",
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/material_maker/engine/gen_switch.gd"
|
||||
}, {
|
||||
"base": "MMGenBase",
|
||||
"class": "MMGenTexture",
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/material_maker/engine/gen_texture.gd"
|
||||
@ -80,11 +95,14 @@ _global_script_class_icons={
|
||||
"MMGenContext": "",
|
||||
"MMGenConvolution": "",
|
||||
"MMGenGraph": "",
|
||||
"MMGenIOs": "",
|
||||
"MMGenImage": "",
|
||||
"MMGenLoader": "",
|
||||
"MMGenMaterial": "",
|
||||
"MMGenRemote": "",
|
||||
"MMGenRenderer": "",
|
||||
"MMGenShader": "",
|
||||
"MMGenSwitch": "",
|
||||
"MMGenTexture": "",
|
||||
"MMGradient": "",
|
||||
"MMType": ""
|
||||
|
Loading…
Reference in New Issue
Block a user