mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
commit
9c9d6a5952
@ -116,6 +116,9 @@ func get_parameter_def(param_name : String) -> Dictionary:
|
||||
return p
|
||||
return {}
|
||||
|
||||
func get_parameter(n : String):
|
||||
return parameters[n]
|
||||
|
||||
func set_parameter(n : String, v) -> void:
|
||||
parameters[n] = v
|
||||
source_changed(0)
|
||||
|
@ -1,4 +1,3 @@
|
||||
tool
|
||||
extends GraphEdit
|
||||
class_name MMGraphEdit
|
||||
|
||||
@ -11,6 +10,8 @@ var need_save = false
|
||||
var top_generator = null
|
||||
var generator = null
|
||||
|
||||
var last_selected = null
|
||||
|
||||
onready var timer : Timer = $Timer
|
||||
|
||||
onready var subgraph_ui : HBoxContainer = $GraphUI/SubGraphUI
|
||||
@ -45,6 +46,7 @@ func offset_from_global_position(global_position) -> Vector2:
|
||||
|
||||
func add_node(node) -> void:
|
||||
add_child(node)
|
||||
move_child(node, 0)
|
||||
node.connect("close_request", self, "remove_node", [ node ])
|
||||
|
||||
func connect_node(from, from_slot, to, to_slot):
|
||||
@ -166,10 +168,11 @@ func new_material() -> void:
|
||||
top_generator = loader.create_gen({nodes=[{name="Material", type="material","parameters":{"size":11}}], connections=[]})
|
||||
if top_generator != null:
|
||||
add_child(top_generator)
|
||||
move_child(top_generator, 0)
|
||||
update_view(top_generator)
|
||||
center_view()
|
||||
set_save_path(null)
|
||||
set_need_save(false)
|
||||
center_view()
|
||||
|
||||
func get_free_name(type) -> String:
|
||||
var i = 0
|
||||
@ -200,10 +203,11 @@ func load_file(filename) -> void:
|
||||
top_generator = MMGenLoader.load_gen(filename)
|
||||
if top_generator != null:
|
||||
add_child(top_generator)
|
||||
move_child(top_generator, 0)
|
||||
update_view(top_generator)
|
||||
center_view()
|
||||
set_save_path(filename)
|
||||
set_need_save(false)
|
||||
center_view()
|
||||
|
||||
func save_file(filename) -> void:
|
||||
var data = top_generator.serialize()
|
||||
@ -352,3 +356,16 @@ func edit_subgraph(g : MMGenGraph) -> void:
|
||||
func _on_ButtonTransmitsSeed_toggled(button_pressed) -> void:
|
||||
if button_pressed != generator.transmits_seed:
|
||||
generator.transmits_seed = button_pressed
|
||||
|
||||
func _on_GraphEdit_node_selected(node) -> void:
|
||||
last_selected = node
|
||||
|
||||
func _on_GraphEdit_gui_input(event) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
call_deferred("check_last_selected")
|
||||
|
||||
func check_last_selected() -> void:
|
||||
if last_selected != null and !(is_instance_valid(last_selected) && last_selected.selected):
|
||||
print("Unselected")
|
||||
last_selected = null
|
||||
emit_signal("node_selected", null)
|
@ -79,6 +79,8 @@ icon = SubResource( 4 )
|
||||
[connection signal="connection_request" from="." to="." method="connect_node"]
|
||||
[connection signal="disconnection_request" from="." to="." method="disconnect_node"]
|
||||
[connection signal="duplicate_nodes_request" from="." to="." method="duplicate_selected"]
|
||||
[connection signal="gui_input" from="." to="." method="_on_GraphEdit_gui_input"]
|
||||
[connection signal="node_selected" from="." to="." method="_on_GraphEdit_node_selected"]
|
||||
[connection signal="timeout" from="Timer" to="." method="do_send_changed_signal"]
|
||||
[connection signal="text_changed" from="GraphUI/SubGraphUI/Label" to="." method="_on_Label_text_changed"]
|
||||
[connection signal="toggled" from="GraphUI/SubGraphUI/ButtonTransmitsSeed" to="." method="_on_ButtonTransmitsSeed_toggled"]
|
||||
|
@ -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)"
|
||||
sodipodi:docname="icons.svg">
|
||||
<defs
|
||||
id="defs2">
|
||||
<inkscape:perspective
|
||||
sodipodi:type="inkscape:persp3d"
|
||||
inkscape:vp_x="-18.04226 : 31.214068 : 1"
|
||||
inkscape:vp_y="0 : 1122.4747 : 0"
|
||||
inkscape:vp_z="139.87989 : 43.976074 : 1"
|
||||
inkscape:persp3d-origin="55.733336 : 19.241004 : 1"
|
||||
id="perspective4586" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient836">
|
||||
@ -48,9 +55,9 @@
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="28.608854"
|
||||
inkscape:cx="86.841515"
|
||||
inkscape:cy="21.061007"
|
||||
inkscape:zoom="20.229515"
|
||||
inkscape:cx="12.288977"
|
||||
inkscape:cy="55.740147"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
@ -87,10 +94,10 @@
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-280.06665)">
|
||||
transform="translate(0,-216.06665)">
|
||||
<g
|
||||
id="g4582"
|
||||
transform="matrix(0.61648821,0.13623838,-0.13553815,0.6196732,31.995696,300.23749)"
|
||||
transform="matrix(0.61648821,0.13623838,-0.13553815,0.6196732,31.995696,236.23749)"
|
||||
inkscape:export-filename="link.png"
|
||||
inkscape:export-xdpi="15.926786"
|
||||
inkscape:export-ydpi="15.926786">
|
||||
@ -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">
|
||||
<rect
|
||||
style="opacity:1;fill:#ff0909;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke"
|
||||
@ -134,7 +141,7 @@
|
||||
inkscape:export-filename="config.png"
|
||||
inkscape:export-xdpi="16.559999"
|
||||
inkscape:export-ydpi="16.559999"
|
||||
transform="matrix(0.52573689,0,0,0.513409,30.847756,292.09585)">
|
||||
transform="matrix(0.52573689,0,0,0.513409,30.847756,228.09585)">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4598"
|
||||
@ -143,7 +150,7 @@
|
||||
</g>
|
||||
<g
|
||||
id="g855"
|
||||
transform="matrix(0.25769655,-0.25630492,0.25630492,0.25769655,4.0104312,296.39647)"
|
||||
transform="matrix(0.25769655,-0.25630492,0.25630492,0.25769655,4.0104312,232.39647)"
|
||||
inkscape:export-filename="edit.png"
|
||||
inkscape:export-xdpi="14.942099"
|
||||
inkscape:export-ydpi="14.942099">
|
||||
@ -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)">
|
||||
<path
|
||||
id="rect859"
|
||||
transform="scale(0.26458333)"
|
||||
@ -211,7 +218,7 @@
|
||||
</g>
|
||||
<g
|
||||
style="fill:#18ff09;fill-opacity:1"
|
||||
transform="matrix(0.00372977,0.49303806,-0.49303806,-0.00372977,83.199877,280.80247)"
|
||||
transform="matrix(0.00372977,0.49303806,-0.49303806,-0.00372977,83.199877,216.80247)"
|
||||
id="g849"
|
||||
inkscape:export-filename="plus.png"
|
||||
inkscape:export-xdpi="16.531826"
|
||||
@ -227,7 +234,7 @@
|
||||
inkscape:export-xdpi="16.531826"
|
||||
inkscape:export-filename="minus.png"
|
||||
id="g856"
|
||||
transform="matrix(0.00372977,0.49303806,-0.49303806,-0.00372977,18.535206,297.77843)"
|
||||
transform="matrix(0.00372977,0.49303806,-0.49303806,-0.00372977,18.535206,233.77843)"
|
||||
style="fill:#ff0909;fill-opacity:1">
|
||||
<rect
|
||||
style="opacity:1;fill:#ff0909;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke"
|
||||
@ -243,7 +250,7 @@
|
||||
inkscape:export-filename="load.png"
|
||||
inkscape:export-xdpi="13.499794"
|
||||
inkscape:export-ydpi="13.499794"
|
||||
transform="matrix(0.51223521,0,0,0.51223521,5.2214853,275.80647)">
|
||||
transform="matrix(0.51223521,0,0,0.51223521,5.2214853,211.80647)">
|
||||
<path
|
||||
id="rect849"
|
||||
transform="scale(0.26458333)"
|
||||
@ -268,7 +275,7 @@
|
||||
</g>
|
||||
<path
|
||||
style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1.96038949;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke"
|
||||
d="m 14.281124,319.9133 c -3.380125,5.56722 -9.3711249,5.74887 -12.9027613,0 2.6589695,-5.76337 10.0526323,-5.46131 12.9027613,0 z"
|
||||
d="m 14.281124,255.9133 c -3.380125,5.56722 -9.3711249,5.74887 -12.9027613,0 2.6589695,-5.76337 10.0526323,-5.46131 12.9027613,0 z"
|
||||
id="path5159"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccc" />
|
||||
@ -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" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5166"
|
||||
d="m 30.429971,319.84339 c -3.380125,5.56722 -9.371125,5.74887 -12.902762,0"
|
||||
d="m 30.429971,255.84339 c -3.380125,5.56722 -9.371125,5.74887 -12.902762,0"
|
||||
style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1.96038949;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke" />
|
||||
<path
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke"
|
||||
d="m 33.869141,312.36502 v 1.50195 h -1.501953 v 1.5957 h 1.501953 v 1.50196 h 1.595703 v -1.50196 h 1.501953 v -1.5957 h -1.501953 v -1.50195 z"
|
||||
d="m 33.869141,248.36502 v 1.50195 h -1.501953 v 1.5957 h 1.501953 v 1.50196 h 1.595703 v -1.50196 h 1.501953 v -1.5957 h -1.501953 v -1.50195 z"
|
||||
id="rect860"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path865"
|
||||
d="m 49.948079,312.36502 v 1.50195 h -1.501953 v 1.5957 h 1.501953 v 1.50196 h 1.595703 v -1.50196 h 1.501953 v -1.5957 h -1.501953 v -1.50195 z"
|
||||
d="m 49.948079,248.36502 v 1.50195 h -1.501953 v 1.5957 h 1.501953 v 1.50196 h 1.595703 v -1.50196 h 1.501953 v -1.5957 h -1.501953 v -1.50195 z"
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke" />
|
||||
<g
|
||||
id="g4582-9"
|
||||
transform="matrix(0.61648821,0.13623838,-0.13553815,0.6196732,0.09092866,268.4386)"
|
||||
transform="matrix(0.61648821,0.13623838,-0.13553815,0.6196732,0.09092866,204.4386)"
|
||||
inkscape:export-filename="link.png"
|
||||
inkscape:export-xdpi="15.926786"
|
||||
inkscape:export-ydpi="15.926786">
|
||||
@ -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)">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4598-6"
|
||||
@ -326,29 +333,28 @@
|
||||
</g>
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 2.9383367,329.45579 0.1398168,13.14278"
|
||||
d="m 2.9383367,265.45579 0.1398168,13.14278"
|
||||
id="path1469"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 3.5097233,333.01844 4.9679886,-0.0742"
|
||||
d="m 3.5097233,269.01844 4.9679886,-0.0742"
|
||||
id="path1471"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 7.4643412,333.1173 0.024716,3.95462 7.1924608,-0.0247 v 0"
|
||||
d="m 7.4643412,269.1173 0.024716,3.95462 7.1924608,-0.0247 v 0"
|
||||
id="path1473"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 7.4890575,337.83813 -0.024716,3.68273 h 5.8083445"
|
||||
d="m 7.4890575,273.83813 -0.024716,3.68273 h 5.8083445"
|
||||
id="path1475"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
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 17.351562,55.695312 4.34961,0.04883 0.123047,6.822265 h 4.27539 l 0.125,-6.822265 4.34961,-0.04883 -6.611328,-6.845703 z"
|
||||
transform="translate(0,280.06665)"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 17.351562,271.76196 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"
|
||||
id="path1477"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccccccc" />
|
||||
@ -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" />
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:3.77952766;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 67.601449,292.54414 5.38295,-1e-5"
|
||||
d="m 67.601449,228.54414 5.38295,-1e-5"
|
||||
id="path4570"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:3.77952766;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 73.823299,283.52594 9.857089,-0.0699"
|
||||
d="m 73.823299,219.52594 9.857089,-0.0699"
|
||||
id="path4572"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:3.77952766;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 85.288282,289.32835 7.55011,-0.0699"
|
||||
d="m 85.288282,225.32835 7.55011,-0.0699"
|
||||
id="path4574"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#f6f6f6;stroke-width:3.77952766;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 98.850517,292.96359 8.668643,-9.57745 9.36773,9.92699 8.24919,-6.78111"
|
||||
d="m 98.850517,228.96359 8.668643,-9.57745 9.36773,9.92699 8.24919,-6.78111"
|
||||
id="path4576"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccc" />
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#f6f6f6;stroke-width:3.77952766;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 67.110738,309.04251 c 3.472118,0.55927 4.555698,-9.96194 8.319101,-9.85708 3.763403,0.10486 4.678964,9.98562 9.36773,9.92699 4.552323,-0.0569 5.040651,-6.78111 8.24919,-6.78111"
|
||||
d="m 67.110738,245.04251 c 3.472118,0.55927 4.555698,-9.96194 8.319101,-9.85708 3.763403,0.10486 4.678964,9.98562 9.36773,9.92699 4.552323,-0.0569 5.040651,-6.78111 8.24919,-6.78111"
|
||||
id="path4576-7"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="czsc" />
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#f6f6f6;stroke-width:3.77952766;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 99.268615,309.04251 c 0,0 4.241035,-9.53142 8.668645,-9.57745 4.42761,-0.046 4.9669,9.84949 9.36773,9.92699 3.55898,0.0627 8.24919,-6.78111 8.24919,-6.78111"
|
||||
d="m 99.268615,245.04251 c 0,0 4.241035,-9.53142 8.668645,-9.57745 4.42761,-0.046 4.9669,9.84949 9.36773,9.92699 3.55898,0.0627 8.24919,-6.78111 8.24919,-6.78111"
|
||||
id="path4576-0"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="czsc" />
|
||||
<g
|
||||
id="g892">
|
||||
id="g892"
|
||||
transform="translate(0,-64)">
|
||||
<rect
|
||||
y="313.76132"
|
||||
x="65.504196"
|
||||
@ -416,7 +423,7 @@
|
||||
</g>
|
||||
<g
|
||||
id="g900"
|
||||
transform="translate(16.00903,-0.03495421)">
|
||||
transform="translate(16.00903,-64.034954)">
|
||||
<rect
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:18.89763832;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect894"
|
||||
@ -440,15 +447,98 @@
|
||||
style="opacity:1;fill:none;fill-opacity:1;stroke:#ff0606;stroke-width:2.00201297;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path902"
|
||||
cx="88.014717"
|
||||
cy="320.29779"
|
||||
cy="256.29779"
|
||||
r="6.1100225" />
|
||||
<rect
|
||||
style="opacity:1;fill:none;fill-opacity:1;stroke:#ff0606;stroke-width:2.26771665;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect904"
|
||||
width="10.905715"
|
||||
height="0.2446795"
|
||||
x="-73.237968"
|
||||
y="324.99719"
|
||||
x="-44.044609"
|
||||
y="268.04309"
|
||||
transform="rotate(-27.138711)" />
|
||||
<g
|
||||
sodipodi:type="inkscape:box3d"
|
||||
id="g4588"
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:20;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke"
|
||||
inkscape:perspectiveID="#perspective4586"
|
||||
inkscape:corner0="-0.3641017 : 0.0069993558 : 0 : 1"
|
||||
inkscape:corner7="-0.46453547 : -0.0037016866 : 0.25 : 1">
|
||||
<path
|
||||
sodipodi:type="inkscape:box3dside"
|
||||
id="path4590"
|
||||
style="fill:#353564;fill-rule:evenodd;stroke:none;stroke-width:1.13750851px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
|
||||
inkscape:box3dsidetype="6"
|
||||
d="m 97.975657,255.32605 v 18.88926 l 11.825353,-10.75878 v -13.55872 z"
|
||||
points="97.975657,274.21531 109.80101,263.45653 109.80101,249.89781 97.975657,255.32605 " />
|
||||
<path
|
||||
sodipodi:type="inkscape:box3dside"
|
||||
id="path4599"
|
||||
style="fill:#afafde;fill-rule:evenodd;stroke:none;stroke-width:1.13750851px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
|
||||
inkscape:box3dsidetype="13"
|
||||
d="m 97.975657,274.21531 21.760763,4.75713 6.41132,-13.64857 -16.34673,-1.86734 z"
|
||||
points="119.73642,278.97244 126.14774,265.32387 109.80101,263.45653 97.975657,274.21531 " />
|
||||
<path
|
||||
sodipodi:type="inkscape:box3dside"
|
||||
id="path4601"
|
||||
style="fill:#e9e9ff;fill-rule:evenodd;stroke:none;stroke-width:1.13750851px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
|
||||
inkscape:box3dsidetype="11"
|
||||
d="m 109.80101,249.89781 16.34673,0.13364 v 15.29242 l -16.34673,-1.86734 z"
|
||||
points="126.14774,250.03145 126.14774,265.32387 109.80101,263.45653 109.80101,249.89781 " />
|
||||
<path
|
||||
sodipodi:type="inkscape:box3dside"
|
||||
id="path4592"
|
||||
style="fill:#4d4d9f;fill-rule:evenodd;stroke:none;stroke-width:1.13750851px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
|
||||
inkscape:box3dsidetype="5"
|
||||
d="m 97.975657,255.32605 21.760763,1.21418 6.41132,-6.50878 -16.34673,-0.13364 z"
|
||||
points="119.73642,256.54023 126.14774,250.03145 109.80101,249.89781 97.975657,255.32605 " />
|
||||
<path
|
||||
sodipodi:type="inkscape:box3dside"
|
||||
id="path4596"
|
||||
style="fill:#d7d7ff;fill-rule:evenodd;stroke:none;stroke-width:1.13750851px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
|
||||
inkscape:box3dsidetype="14"
|
||||
d="m 119.73642,256.54023 v 22.43221 l 6.41132,-13.64857 v -15.29242 z"
|
||||
points="119.73642,278.97244 126.14774,265.32387 126.14774,250.03145 119.73642,256.54023 " />
|
||||
<path
|
||||
sodipodi:type="inkscape:box3dside"
|
||||
id="path4594"
|
||||
style="fill:#8686bf;fill-rule:evenodd;stroke:none;stroke-width:1.13750851px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
|
||||
inkscape:box3dsidetype="3"
|
||||
d="m 97.975657,255.32605 21.760763,1.21418 v 22.43221 l -21.760763,-4.75713 z"
|
||||
points="119.73642,256.54023 119.73642,278.97244 97.975657,274.21531 97.975657,255.32605 " />
|
||||
</g>
|
||||
<path
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.34946194px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 49.776199,270.54617 c -1.580776,6.41312 2.996943,7.37745 6.473631,7.43221 3.476688,0.0548 5.434538,-1.49738 6.066576,-4.21642 l 1.324219,0.42188 -1.042969,-4.5293 -3.396484,3.26953 1.492187,0.37891 c -0.223999,2.03551 -1.852974,3.08872 -4.455415,3.12251 -2.602441,0.0338 -6.433022,-0.77881 -4.803745,-5.21976 z"
|
||||
id="path4603"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="czccccczcc" />
|
||||
<path
|
||||
sodipodi:nodetypes="ccczccccczccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4608"
|
||||
d="m 99.260188,289.64829 -2.078332,5.56675 1.847291,-0.42019 c 1.235833,3.28529 6.174393,5.754 13.089483,5.82132 6.91507,0.0674 11.74325,-2.38113 13.00037,-5.72299 l 1.99478,0.32186 -2.07446,-5.56675 -5.57366,4.22699 1.98123,0.41653 c -0.44553,2.50175 -3.88073,3.63683 -9.05695,3.67834 -5.17621,0.0416 -9.80918,-1.20479 -10.25332,-3.69868 l 2.27622,-0.53524 z"
|
||||
style="fill:#ff1616;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.54638809px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
<path
|
||||
style="fill:#2804ff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.6067068px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 105.85575,308.26514 6.68987,2.89435 -0.45291,-2.69961 c 4.11987,-0.74392 7.02059,-4.85195 7.58556,-11.72804 0.56503,-6.87606 -1.84976,-11.08563 -5.8652,-12.83258 l 0.82033,-2.54598 -6.97955,1.241 4.41346,6.88009 0.82796,-2.44403 c 3.04058,0.81429 3.91231,4.28165 3.60225,9.44228 -0.31004,5.16064 -1.77929,8.61625 -4.87226,8.68902 l -0.41393,-2.77867 z"
|
||||
id="path4610"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccczccccczccc" />
|
||||
<path
|
||||
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.8088189;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="M 80.011719 49.464844 C 72.001268 49.464844 65.474609 56.033506 65.474609 64.072266 C 65.474609 72.111026 72.001268 78.681641 80.011719 78.681641 C 88.022167 78.681641 94.544922 72.111026 94.544922 64.072266 C 94.544922 56.033506 88.022167 49.464844 80.011719 49.464844 z M 77.914062 53.720703 L 77.914062 57.927734 L 82.109375 57.927734 L 82.109375 53.720703 C 86.235662 54.556313 89.469292 57.812373 90.292969 61.976562 L 86.152344 61.976562 L 86.152344 66.169922 L 90.289062 66.169922 C 89.463951 70.331962 86.234181 73.590471 82.109375 74.425781 L 82.109375 70.21875 L 77.914062 70.21875 L 77.914062 74.425781 C 73.789254 73.590471 70.559484 70.331962 69.734375 66.169922 L 73.867188 66.169922 L 73.867188 61.976562 L 69.730469 61.976562 C 70.554144 57.812372 73.787776 54.556313 77.914062 53.720703 z M 77.876953 61.941406 L 77.876953 66.205078 L 82.142578 66.205078 L 82.142578 61.941406 L 77.876953 61.941406 z "
|
||||
transform="translate(0,216.06665)"
|
||||
id="path973" />
|
||||
<path
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.80881888;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 6.5259032,281.28721 v 5.18946 H 1.3344969 v 2.96679 h 5.1914063 v 5.19141 h 2.9648437 v -5.19141 h 5.1914061 v -2.96679 H 9.4907469 v -5.18946 z"
|
||||
id="rect1173"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.80881888;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 23.974609 64.923828 A 6.9700141 6.9700141 0 0 0 17.003906 71.894531 A 6.9700141 6.9700141 0 0 0 23.974609 78.863281 A 6.9700141 6.9700141 0 0 0 30.945312 71.894531 A 6.9700141 6.9700141 0 0 0 23.974609 64.923828 z M 23.974609 67.494141 A 4.4003119 4.4003119 0 0 1 28.375 71.894531 A 4.4003119 4.4003119 0 0 1 23.974609 76.294922 A 4.4003119 4.4003119 0 0 1 19.574219 71.894531 A 4.4003119 4.4003119 0 0 1 23.974609 67.494141 z "
|
||||
transform="translate(0,216.06665)"
|
||||
id="path897" />
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 36 KiB |
@ -1,4 +1,3 @@
|
||||
tool
|
||||
extends VBoxContainer
|
||||
|
||||
var libraries = []
|
||||
|
@ -739,7 +739,6 @@
|
||||
"cx": 0,
|
||||
"cy": 0,
|
||||
"h": 0.2,
|
||||
"r": 0.3,
|
||||
"w": 0.3
|
||||
},
|
||||
"tree_item": "Simple/SDF/Shapes/sdBox",
|
||||
@ -750,15 +749,10 @@
|
||||
"icon": "simple_sdf_shapes_sdline",
|
||||
"name": "sdline",
|
||||
"parameters": {
|
||||
"ax": 0.2,
|
||||
"ay": 0.2,
|
||||
"bx": 0.8,
|
||||
"by": 0.8,
|
||||
"cx": 0,
|
||||
"cy": 0,
|
||||
"h": 0.2,
|
||||
"r": 0.3,
|
||||
"w": 0.3
|
||||
"ax": -0.3,
|
||||
"ay": -0.3,
|
||||
"bx": 0.3,
|
||||
"by": 0.3
|
||||
},
|
||||
"tree_item": "Simple/SDF/Shapes/sdLine",
|
||||
"type": "sdline"
|
||||
@ -771,7 +765,6 @@
|
||||
"cx": 0,
|
||||
"cy": 0,
|
||||
"h": 0.2,
|
||||
"r": 0.3,
|
||||
"w": 0.3
|
||||
},
|
||||
"tree_item": "Simple/SDF/Shapes/sdRhombus",
|
||||
|
@ -1,4 +1,3 @@
|
||||
tool
|
||||
extends Panel
|
||||
|
||||
var recent_files = []
|
||||
@ -14,6 +13,9 @@ var need_update : bool = false
|
||||
onready var projects = $VBoxContainer/HBoxContainer/ProjectsPane/Projects
|
||||
onready var library = $VBoxContainer/HBoxContainer/VBoxContainer/Library
|
||||
|
||||
onready var preview_2d = $VBoxContainer/HBoxContainer/VBoxContainer/Preview/Preview2D
|
||||
onready var preview_3d = $VBoxContainer/HBoxContainer/VBoxContainer/Preview/Preview3D
|
||||
|
||||
const RECENT_FILES_COUNT = 15
|
||||
|
||||
const MENU = [
|
||||
@ -465,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
|
||||
@ -473,7 +475,6 @@ func update_preview() -> void:
|
||||
func update_preview_2d(node = null) -> void:
|
||||
var graph_edit : MMGraphEdit = get_current_graph_edit()
|
||||
if graph_edit != null:
|
||||
var preview = $VBoxContainer/HBoxContainer/VBoxContainer/Preview
|
||||
if node == null:
|
||||
for n in graph_edit.get_children():
|
||||
if n is GraphNode and n.selected:
|
||||
@ -486,16 +487,23 @@ func update_preview_2d(node = null) -> void:
|
||||
var tex = ImageTexture.new()
|
||||
result.copy_to_texture(tex)
|
||||
result.release()
|
||||
preview.set_2d(tex)
|
||||
preview_2d.set_preview_texture(tex)
|
||||
else:
|
||||
preview_2d.set_preview_texture(null)
|
||||
|
||||
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($VBoxContainer/HBoxContainer/VBoxContainer/Preview.get_materials())
|
||||
for p in previews:
|
||||
gen_material.update_materials(p.get_materials())
|
||||
|
||||
func on_selected_node_change(node) -> void:
|
||||
preview_2d.setup_controls(node.generator if node != null else null)
|
||||
update_preview_2d(node)
|
||||
|
||||
func _on_Projects_tab_changed(tab) -> void:
|
||||
var new_tab = projects.get_current_tab_control()
|
||||
@ -505,16 +513,10 @@ func _on_Projects_tab_changed(tab) -> void:
|
||||
if c.method_name == "update_preview" or c.method_name == "update_preview_2d":
|
||||
c.source.disconnect(c.signal_name, self, c.method_name)
|
||||
new_tab.connect("graph_changed", self, "update_preview")
|
||||
new_tab.connect("node_selected", self, "update_preview_2d")
|
||||
new_tab.connect("node_selected", self, "on_selected_node_change")
|
||||
current_tab = new_tab
|
||||
update_preview()
|
||||
|
||||
func _on_Preview_show_background_preview(v) -> void:
|
||||
var pv = $VBoxContainer/HBoxContainer/VBoxContainer/Preview/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:
|
||||
@ -523,3 +525,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
|
||||
|
@ -1,24 +1,23 @@
|
||||
[gd_scene load_steps=9 format=2]
|
||||
[gd_scene load_steps=11 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.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://addons/material_maker/preview/panoramas/epping_forest_01.hdr" type="Texture" id=4]
|
||||
[ext_resource path="res://addons/material_maker/widgets/tabs.gd" type="Script" id=5]
|
||||
[ext_resource path="res://addons/material_maker/node_factory.gd" type="Script" id=6]
|
||||
[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/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/icons/icons.svg" type="Texture" id=7]
|
||||
[ext_resource path="res://addons/material_maker/node_factory.gd" type="Script" id=8]
|
||||
|
||||
[sub_resource type="PanoramaSky" id=1]
|
||||
resource_local_to_scene = true
|
||||
panorama = ExtResource( 4 )
|
||||
[sub_resource type="AtlasTexture" id=1]
|
||||
flags = 4
|
||||
atlas = ExtResource( 7 )
|
||||
region = Rect2( 96, 32, 32, 32 )
|
||||
|
||||
[sub_resource type="Environment" id=2]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
||||
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=2]
|
||||
flags = 4
|
||||
atlas = ExtResource( 7 )
|
||||
region = Rect2( 96, 64, 32, 32 )
|
||||
|
||||
[node name="MainWindow" type="Panel"]
|
||||
anchor_right = 1.0
|
||||
@ -89,18 +88,27 @@ size_flags_vertical = 3
|
||||
|
||||
[node name="Library" parent="VBoxContainer/HBoxContainer/VBoxContainer" instance=ExtResource( 2 )]
|
||||
margin_right = 311.0
|
||||
margin_bottom = 404.0
|
||||
margin_bottom = 386.0
|
||||
size_flags_vertical = 3
|
||||
size_flags_stretch_ratio = 1.5
|
||||
|
||||
[node name="Preview" parent="VBoxContainer/HBoxContainer/VBoxContainer" instance=ExtResource( 3 )]
|
||||
anchor_left = 0.0
|
||||
anchor_right = 0.0
|
||||
margin_left = 0.0
|
||||
margin_top = 416.0
|
||||
[node name="Preview" type="TabContainer" parent="VBoxContainer/HBoxContainer/VBoxContainer"]
|
||||
margin_top = 398.0
|
||||
margin_right = 311.0
|
||||
margin_bottom = 684.0
|
||||
rect_min_size = Vector2( 300, 200 )
|
||||
tab_align = 0
|
||||
|
||||
[node name="Preview2D" parent="VBoxContainer/HBoxContainer/VBoxContainer/Preview" instance=ExtResource( 3 )]
|
||||
margin_left = 4.0
|
||||
margin_top = 32.0
|
||||
margin_right = -4.0
|
||||
margin_bottom = -4.0
|
||||
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
|
||||
@ -110,22 +118,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( 2 )
|
||||
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 )
|
||||
@ -135,7 +133,7 @@ margin_right = 5.0
|
||||
margin_bottom = 5.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 5 )
|
||||
script = ExtResource( 6 )
|
||||
|
||||
[node name="Tabs" type="Tabs" parent="VBoxContainer/HBoxContainer/ProjectsPane/Projects"]
|
||||
margin_right = 950.0
|
||||
@ -143,51 +141,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( 1 )
|
||||
|
||||
[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( 2 )
|
||||
|
||||
[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( 6 )
|
||||
[connection signal="need_update" from="VBoxContainer/HBoxContainer/VBoxContainer/Preview" to="." method="update_preview_3d"]
|
||||
[connection signal="show_background_preview" from="VBoxContainer/HBoxContainer/VBoxContainer/Preview" to="." method="_on_Preview_show_background_preview"]
|
||||
script = ExtResource( 8 )
|
||||
[connection signal="need_update" from="VBoxContainer/HBoxContainer/VBoxContainer/Preview/Preview3D" to="." method="update_preview_3d"]
|
||||
[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"]
|
||||
|
@ -7,6 +7,9 @@ var generator : MMGenBase = null setget set_generator
|
||||
func _ready() -> void:
|
||||
connect("offset_changed", self, "_on_offset_changed")
|
||||
|
||||
func _exit_tree() -> void:
|
||||
get_parent().call_deferred("check_last_selected")
|
||||
|
||||
func _draw() -> void:
|
||||
if generator != null and generator.has_randomness():
|
||||
var icon = preload("res://addons/material_maker/icons/randomness_locked.tres") if generator.is_seed_locked() else preload("res://addons/material_maker/icons/randomness_unlocked.tres")
|
||||
|
@ -1,4 +1,3 @@
|
||||
tool
|
||||
extends MMGraphNodeBase
|
||||
class_name MMGraphNodeGeneric
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "Radius1.x",
|
||||
"default": 0,
|
||||
"label": "",
|
||||
"max": 1,
|
||||
|
@ -5,8 +5,8 @@
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"a1": 0,
|
||||
"a2": 0,
|
||||
"a1": 135,
|
||||
"a2": 45,
|
||||
"cx": 0,
|
||||
"cy": 0,
|
||||
"r": 0.4,
|
||||
@ -15,7 +15,7 @@
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
"global": "float sdArc(vec2 p, vec2 sca, vec2 scb, float ra, float rb) {\n p *= mat2(vec2(sca.x,sca.y),vec2(-sca.y,sca.x));\n p.x = abs(p.x);\n float k = (scb.y*p.x>scb.x*p.y) ? dot(p.xy,scb) : length(p.xy);\n return sqrt( dot(p,p) + ra*ra - 2.0*ra*k ) - rb;\n}",
|
||||
"global": "float sdArc(vec2 p, float a1, float a2, float ra, float rb) {\n\tfloat amid = 0.5*(a1+a2)+1.6+3.14*step(a1, a2);\n\tfloat alength = 0.5*(a1-a2)-1.6+3.14*step(a1, a2);\n\tvec2 sca = vec2(cos(amid), sin(amid));\n\tvec2 scb = vec2(cos(alength), sin(alength));\n p *= mat2(vec2(sca.x,sca.y),vec2(-sca.y,sca.x));\n p.x = abs(p.x);\n float k = (scb.y*p.x>scb.x*p.y) ? dot(p.xy,scb) : length(p.xy);\n return sqrt( dot(p,p) + ra*ra - 2.0*ra*k ) - rb;\n}\n",
|
||||
"inputs": [
|
||||
|
||||
],
|
||||
@ -23,12 +23,13 @@
|
||||
"name": "sdArc",
|
||||
"outputs": [
|
||||
{
|
||||
"sdf2d": "sdArc($uv-vec2(0.5), vec2(cos($a1*0.01745329251), sin($a1*0.01745329251)), vec2(cos($a2*0.01745329251), sin($a2*0.01745329251)), $r1, $r2)",
|
||||
"sdf2d": "sdArc($uv-vec2(0.5), mod($a1, 360.0)*0.01745329251, mod($a2, 360.0)*0.01745329251, $r1, $r2)",
|
||||
"type": "sdf2d"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "Angle1.a",
|
||||
"default": 0,
|
||||
"label": "Angle 1",
|
||||
"max": 180,
|
||||
@ -38,6 +39,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "Angle2.a",
|
||||
"default": 0,
|
||||
"label": "Angle 2",
|
||||
"max": 180,
|
||||
@ -47,6 +49,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "Radius1.r",
|
||||
"default": 0.5,
|
||||
"label": "Radius 1",
|
||||
"max": 1,
|
||||
@ -56,6 +59,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "Radius11.r",
|
||||
"default": 0.1,
|
||||
"label": "Radius 2",
|
||||
"max": 1,
|
||||
|
@ -12,7 +12,7 @@
|
||||
"w": 0.3
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "vec2 $(name_uv)_d = abs($uv-0.5*vec2($cx+1.0, $cy+1.0))-vec2($w, $h);\n",
|
||||
"code": "vec2 $(name_uv)_d = abs($uv-vec2($cx+0.5, $cy+0.5))-vec2($w, $h);\n",
|
||||
"global": "",
|
||||
"inputs": [
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "Rect1.x",
|
||||
"default": 0.5,
|
||||
"label": "Width",
|
||||
"max": 1,
|
||||
@ -36,6 +37,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "Rect1.y",
|
||||
"default": 1,
|
||||
"label": "Height",
|
||||
"max": 1,
|
||||
@ -45,6 +47,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "P1.x",
|
||||
"default": 0,
|
||||
"label": "Center X",
|
||||
"max": 1,
|
||||
@ -54,6 +57,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "P1.y",
|
||||
"default": 0,
|
||||
"label": "Center Y",
|
||||
"max": 1,
|
||||
|
@ -7,7 +7,7 @@
|
||||
"parameters": {
|
||||
"cx": 0,
|
||||
"cy": 0,
|
||||
"r": 0.25
|
||||
"r": 0.4
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
@ -19,12 +19,13 @@
|
||||
"name": "sdCircle",
|
||||
"outputs": [
|
||||
{
|
||||
"sdf2d": "length($uv-0.5*vec2($cx+1.0, $cy+1.0))-$r",
|
||||
"sdf2d": "length($uv-vec2($cx+0.5, $cy+0.5))-$r",
|
||||
"type": "sdf2d"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "Radius1.x",
|
||||
"default": 0.5,
|
||||
"label": "Radius",
|
||||
"max": 1,
|
||||
@ -34,6 +35,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "P1.x",
|
||||
"default": 0,
|
||||
"label": "Center X",
|
||||
"max": 1,
|
||||
@ -43,6 +45,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "P1.y",
|
||||
"default": 0,
|
||||
"label": "Center Y",
|
||||
"max": 1,
|
||||
|
@ -5,10 +5,10 @@
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"r": 0.01,
|
||||
"sx": 0.25,
|
||||
"r": 0.05,
|
||||
"sx": 0.3,
|
||||
"sy": 0.25,
|
||||
"sz": 0.5
|
||||
"sz": 0.25
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "vec3 $(name_uv)_q = abs($uv) - vec3($sx, $sy, $sz);\n",
|
||||
@ -26,6 +26,7 @@
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "Rect1.x",
|
||||
"default": 0.5,
|
||||
"label": "Size X",
|
||||
"max": 1,
|
||||
@ -35,6 +36,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "Rect1.y",
|
||||
"default": 0.5,
|
||||
"label": "Size Y",
|
||||
"max": 1,
|
||||
@ -44,6 +46,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0.5,
|
||||
"label": "Size Z",
|
||||
"max": 1,
|
||||
@ -53,6 +56,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0.5,
|
||||
"label": "Radius",
|
||||
"max": 1,
|
||||
|
@ -5,14 +5,14 @@
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"l": 0.25,
|
||||
"r": 0.1,
|
||||
"l": 0.3,
|
||||
"r": 0.15,
|
||||
"sx": 0.25,
|
||||
"sy": 0.25,
|
||||
"sz": 0.5
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "vec3 $(name_uv)_p = $uv;\n$(name_uv)_p.y -= clamp($(name_uv)_p.y, -0.5*$l, 0.5*$l);\n",
|
||||
"code": "vec3 $(name_uv)_p = $uv;\n$(name_uv)_p.y -= clamp($(name_uv)_p.y, -$l, $l);\n",
|
||||
"global": "",
|
||||
"inputs": [
|
||||
|
||||
@ -27,7 +27,8 @@
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"default": 0.5,
|
||||
"control": "Rect1.y",
|
||||
"default": 0.25,
|
||||
"label": "Length",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
@ -36,6 +37,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "Rect1.x",
|
||||
"default": 0.2,
|
||||
"label": "Radius",
|
||||
"max": 1,
|
||||
|
@ -5,8 +5,8 @@
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"l": 0.25,
|
||||
"r": 0.1,
|
||||
"l": 0.4,
|
||||
"r": 0.2,
|
||||
"sx": 0.25,
|
||||
"sy": 0.25,
|
||||
"sz": 0.5
|
||||
@ -27,6 +27,7 @@
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "Rect1.y",
|
||||
"default": 0.5,
|
||||
"label": "Length",
|
||||
"max": 1,
|
||||
@ -36,6 +37,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "Rect1.x",
|
||||
"default": 0.2,
|
||||
"label": "Radius",
|
||||
"max": 1,
|
||||
|
@ -32,6 +32,7 @@
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "Scale1.x",
|
||||
"default": 1,
|
||||
"label": "",
|
||||
"max": 5,
|
||||
|
@ -5,7 +5,7 @@
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"r": 0.5
|
||||
"r": 0.4
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
@ -23,6 +23,7 @@
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "Radius1.r",
|
||||
"default": 0.5,
|
||||
"label": "",
|
||||
"max": 1,
|
||||
|
@ -5,7 +5,7 @@
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"R": 0.25,
|
||||
"R": 0.3,
|
||||
"r": 0.1,
|
||||
"sx": 0.1,
|
||||
"sy": 0.1,
|
||||
@ -27,6 +27,7 @@
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "Radius1.r",
|
||||
"default": 0.5,
|
||||
"label": "R",
|
||||
"max": 1,
|
||||
@ -36,6 +37,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "Radius11.r",
|
||||
"default": 0.1,
|
||||
"label": "r",
|
||||
"max": 0.5,
|
||||
|
@ -30,6 +30,7 @@
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "P1.x",
|
||||
"default": 0,
|
||||
"label": "X",
|
||||
"max": 1,
|
||||
@ -39,6 +40,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "P1.y",
|
||||
"default": 0,
|
||||
"label": "Y",
|
||||
"max": 1,
|
||||
@ -48,6 +50,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "None",
|
||||
"default": 0,
|
||||
"label": "Z",
|
||||
"max": 1,
|
||||
|
@ -5,10 +5,10 @@
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"ax": 0.2,
|
||||
"ay": 0.2,
|
||||
"bx": 0.8,
|
||||
"by": 0.8,
|
||||
"ax": 0.224,
|
||||
"ay": 0.2672,
|
||||
"bx": -0.272,
|
||||
"by": -0.2344,
|
||||
"cx": 0,
|
||||
"cy": 0,
|
||||
"h": 0.2,
|
||||
@ -25,43 +25,47 @@
|
||||
"name": "sdLine",
|
||||
"outputs": [
|
||||
{
|
||||
"sdf2d": "sdLine($uv, vec2($ax, $ay), vec2($bx, $by))",
|
||||
"sdf2d": "sdLine($uv, vec2($ax+0.5, $ay+0.5), vec2($bx+0.5, $by+0.5))",
|
||||
"type": "sdf2d"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "P1.x",
|
||||
"default": 0,
|
||||
"label": "A X",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"min": -1,
|
||||
"name": "ax",
|
||||
"step": 0.01,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "P1.y",
|
||||
"default": 0,
|
||||
"label": "A Y",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"min": -1,
|
||||
"name": "ay",
|
||||
"step": 0.01,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "P2.x",
|
||||
"default": 1,
|
||||
"label": "B X",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"min": -1,
|
||||
"name": "bx",
|
||||
"step": 0.01,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "P2.y",
|
||||
"default": 1,
|
||||
"label": "B Y",
|
||||
"max": 1,
|
||||
"min": 0,
|
||||
"min": -1,
|
||||
"name": "by",
|
||||
"step": 0.01,
|
||||
"type": "float"
|
||||
|
@ -5,11 +5,11 @@
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"cx": 0,
|
||||
"cy": 0,
|
||||
"h": 0.2,
|
||||
"cx": -0.19353,
|
||||
"cy": -0.224011,
|
||||
"h": 0.187815,
|
||||
"r": 0.3,
|
||||
"w": 0.5
|
||||
"w": 0.393785
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
@ -21,12 +21,13 @@
|
||||
"name": "sdRhombus",
|
||||
"outputs": [
|
||||
{
|
||||
"sdf2d": "sdRhombus($uv-0.5*vec2($cx+1.0, $cy+1.0), vec2($w, $h))",
|
||||
"sdf2d": "sdRhombus($uv-vec2($cx+0.5, $cy+0.5), vec2($w, $h))",
|
||||
"type": "sdf2d"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "Rect1.x",
|
||||
"default": 0.5,
|
||||
"label": "Width",
|
||||
"max": 1,
|
||||
@ -36,6 +37,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "Rect1.y",
|
||||
"default": 1,
|
||||
"label": "Height",
|
||||
"max": 1,
|
||||
@ -45,6 +47,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "P1.x",
|
||||
"default": 0,
|
||||
"label": "Center X",
|
||||
"max": 1,
|
||||
@ -54,6 +57,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "P1.y",
|
||||
"default": 0,
|
||||
"label": "Center Y",
|
||||
"max": 1,
|
||||
|
@ -31,6 +31,7 @@
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "Radius1.a",
|
||||
"default": 0,
|
||||
"label": "",
|
||||
"max": 180,
|
||||
|
@ -11,7 +11,7 @@
|
||||
"h": 0.08,
|
||||
"k": 0.15,
|
||||
"op": 0,
|
||||
"r": 0.1,
|
||||
"r": 0.15,
|
||||
"w": 0.28
|
||||
},
|
||||
"shader_model": {
|
||||
@ -35,6 +35,7 @@
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "Radius1.x",
|
||||
"default": 0,
|
||||
"label": "",
|
||||
"max": 1,
|
||||
|
@ -6,7 +6,7 @@
|
||||
},
|
||||
"parameters": {
|
||||
"a": 0,
|
||||
"s": 2.21,
|
||||
"s": 1,
|
||||
"x": 0.35,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
@ -32,6 +32,7 @@
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "Scale1.x",
|
||||
"default": 1,
|
||||
"label": "",
|
||||
"max": 5,
|
||||
|
@ -5,8 +5,8 @@
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"x": 0.024,
|
||||
"y": 0.024,
|
||||
"z": 0
|
||||
},
|
||||
"shader_model": {
|
||||
@ -30,6 +30,7 @@
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "P1.x",
|
||||
"default": 0,
|
||||
"label": "X",
|
||||
"max": 1,
|
||||
@ -39,6 +40,7 @@
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "P1.y",
|
||||
"default": 0,
|
||||
"label": "Y",
|
||||
"max": 1,
|
||||
|
@ -63,54 +63,54 @@
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"control": "P1.x",
|
||||
"default": 0,
|
||||
"label": "2:Translate X:",
|
||||
"max": 1,
|
||||
"min": -1,
|
||||
"name": "translate_x",
|
||||
"step": 0.005,
|
||||
"type": "float",
|
||||
"widget": "spinbox"
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "P1.y",
|
||||
"default": 0,
|
||||
"label": "Translate Y:",
|
||||
"max": 1,
|
||||
"min": -1,
|
||||
"name": "translate_y",
|
||||
"step": 0.005,
|
||||
"type": "float",
|
||||
"widget": "spinbox"
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "Radius1.a",
|
||||
"default": 0,
|
||||
"label": "Rotate:",
|
||||
"max": 720,
|
||||
"min": -720,
|
||||
"name": "rotate",
|
||||
"step": 0.005,
|
||||
"type": "float",
|
||||
"widget": "spinbox"
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "Scale1.x",
|
||||
"default": 1,
|
||||
"label": "Scale X:",
|
||||
"max": 50,
|
||||
"min": 0,
|
||||
"name": "scale_x",
|
||||
"step": 0.005,
|
||||
"type": "float",
|
||||
"widget": "spinbox"
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"control": "Scale1.y",
|
||||
"default": 1,
|
||||
"label": "Scale Y:",
|
||||
"max": 50,
|
||||
"min": 0,
|
||||
"name": "scale_y",
|
||||
"step": 0.005,
|
||||
"type": "float",
|
||||
"widget": "spinbox"
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"default": false,
|
||||
|
@ -1,47 +1,17 @@
|
||||
tool
|
||||
extends EditorPlugin
|
||||
|
||||
var mm_button = null
|
||||
var material_maker = null
|
||||
var importer = null
|
||||
|
||||
func _enter_tree() -> void:
|
||||
add_tool_menu_item("Material Maker", self, "open_material_maker")
|
||||
importer = preload("res://addons/material_maker/import_plugin/ptex_import.gd").new(self)
|
||||
add_import_plugin(importer)
|
||||
|
||||
func _exit_tree() -> void:
|
||||
remove_tool_menu_item("Material Maker")
|
||||
if material_maker != null:
|
||||
material_maker.hide()
|
||||
material_maker.queue_free()
|
||||
material_maker = null
|
||||
if importer != null:
|
||||
remove_import_plugin(importer)
|
||||
importer = null
|
||||
|
||||
func _get_state() -> Dictionary:
|
||||
return { mm_button=mm_button, material_maker=material_maker }
|
||||
|
||||
func _set_state(s) -> void:
|
||||
mm_button = s.mm_button
|
||||
material_maker = s.material_maker
|
||||
|
||||
func open_material_maker(__) -> void:
|
||||
if material_maker == null:
|
||||
material_maker = preload("res://addons/material_maker/window_dialog.tscn").instance()
|
||||
var panel = material_maker.get_node("MainWindow")
|
||||
panel.editor_interface = get_editor_interface()
|
||||
panel.connect("quit", self, "close_material_maker")
|
||||
add_child(material_maker)
|
||||
material_maker.popup_centered()
|
||||
|
||||
func close_material_maker() -> void:
|
||||
if material_maker != null:
|
||||
material_maker.hide()
|
||||
material_maker.queue_free()
|
||||
material_maker = null
|
||||
|
||||
func generate_material(ptex_filename: String) -> Material:
|
||||
var generator = MMGenLoader.load_gen(ptex_filename)
|
||||
add_child(generator)
|
||||
|
156
addons/material_maker/preview/control_point.gd
Normal file
156
addons/material_maker/preview/control_point.gd
Normal file
@ -0,0 +1,156 @@
|
||||
extends TextureRect
|
||||
|
||||
export var parent_control : String = ""
|
||||
export(int, "Simple", "Rect", "Radius", "Scale" ) var control_type : int = 0
|
||||
|
||||
var generator : MMGenBase = null
|
||||
var parameter_x : String = ""
|
||||
var parameter_y : String = ""
|
||||
var parameter_r : String = ""
|
||||
var parameter_a : String = ""
|
||||
var is_xy : bool = false
|
||||
|
||||
var dragging : bool = false
|
||||
|
||||
var parent_control_node = null
|
||||
var children_control_nodes = []
|
||||
|
||||
func _ready() -> void:
|
||||
if parent_control != "":
|
||||
parent_control_node = get_parent().get_node(parent_control)
|
||||
if parent_control_node != null:
|
||||
parent_control_node.children_control_nodes.push_back(self)
|
||||
|
||||
func _draw() -> void:
|
||||
match control_type:
|
||||
1: # Rect
|
||||
var ppos = parent_control_node.rect_position+0.5*parent_control_node.rect_size
|
||||
draw_rect(Rect2(0.5*rect_size, 2.0*(ppos-(rect_position+0.5*rect_size))), modulate, false)
|
||||
2: # Radius
|
||||
var ppos
|
||||
if parent_control_node == null:
|
||||
ppos = get_parent().value_to_pos(Vector2(0, 0))
|
||||
else:
|
||||
ppos = parent_control_node.rect_position+0.5*parent_control_node.rect_size
|
||||
draw_line(0.5*rect_size, ppos-rect_position, modulate)
|
||||
3: # Scale
|
||||
var ppos
|
||||
if parent_control_node == null:
|
||||
ppos = get_parent().value_to_pos(Vector2(0, 0))
|
||||
else:
|
||||
ppos = parent_control_node.rect_position+0.5*parent_control_node.rect_size
|
||||
draw_rect(Rect2(0.5*rect_size, ppos-(rect_position+0.5*rect_size)), modulate, false)
|
||||
|
||||
func setup_control(g : MMGenBase, param_defs : Array) -> void:
|
||||
hide()
|
||||
if is_instance_valid(generator):
|
||||
generator.disconnect("parameter_changed", self, "on_parameter_changed")
|
||||
generator = g
|
||||
parameter_x = ""
|
||||
parameter_y = ""
|
||||
parameter_r = ""
|
||||
parameter_a = ""
|
||||
for p in param_defs:
|
||||
if p.has("control"):
|
||||
if p.control == name+".x":
|
||||
show()
|
||||
parameter_x = p.name
|
||||
elif p.control == name+".y":
|
||||
show()
|
||||
parameter_y = p.name
|
||||
elif p.control == name+".r":
|
||||
show()
|
||||
parameter_r = p.name
|
||||
elif p.control == name+".a":
|
||||
show()
|
||||
parameter_a = p.name
|
||||
is_xy = parameter_x != "" or parameter_y != ""
|
||||
if visible:
|
||||
generator.connect("parameter_changed", self, "on_parameter_changed")
|
||||
update_position(get_value())
|
||||
else:
|
||||
generator = null
|
||||
update_position(Vector2(0, 0))
|
||||
|
||||
func get_value() -> Vector2:
|
||||
var pos : Vector2 = Vector2(0, 0)
|
||||
if is_instance_valid(generator):
|
||||
if is_xy:
|
||||
if parameter_x != "":
|
||||
pos.x = generator.get_parameter(parameter_x)
|
||||
if parameter_y != "":
|
||||
pos.y = generator.get_parameter(parameter_y)
|
||||
else:
|
||||
var r = 0.25
|
||||
var a = 0
|
||||
if parameter_r != "":
|
||||
r = generator.get_parameter(parameter_r)
|
||||
if parameter_a != "":
|
||||
a = generator.get_parameter(parameter_a)*0.01745329251
|
||||
pos.x = r*cos(a)
|
||||
pos.y = r*sin(a)
|
||||
return pos
|
||||
|
||||
func get_parent_value() -> Vector2:
|
||||
var parent_value = Vector2(0, 0)
|
||||
var p = parent_control_node
|
||||
while p != null:
|
||||
parent_value += p.get_value()
|
||||
p = p.parent_control_node
|
||||
return parent_value
|
||||
|
||||
func on_parameter_changed(p, v) -> void:
|
||||
if !dragging and (p == parameter_x or p == parameter_y or p == parameter_r or p == parameter_a):
|
||||
update_position(get_value())
|
||||
update()
|
||||
|
||||
func update_parameters(value : Vector2) -> void:
|
||||
if !is_instance_valid(generator):
|
||||
return
|
||||
match control_type:
|
||||
1: # Rect
|
||||
value.x = abs(value.x)
|
||||
value.y = abs(value.y)
|
||||
3: # Scale
|
||||
value = 4.0*value
|
||||
if parameter_x != "":
|
||||
generator.set_parameter(parameter_x, value.x)
|
||||
if parameter_y != "":
|
||||
generator.set_parameter(parameter_y, value.y)
|
||||
if parameter_r != "":
|
||||
generator.set_parameter(parameter_r, value.length())
|
||||
if parameter_a != "":
|
||||
generator.set_parameter(parameter_a, atan2(value.y, value.x)*57.2957795131)
|
||||
|
||||
func update_position(pos : Vector2) -> void:
|
||||
match control_type:
|
||||
3: # Scale
|
||||
pos *= 0.25
|
||||
if parent_control_node != null:
|
||||
pos += parent_control_node.get_value()
|
||||
rect_position = get_parent().value_to_pos(pos)-0.5*rect_size
|
||||
for c in children_control_nodes:
|
||||
c.update_position(c.get_value())
|
||||
update()
|
||||
|
||||
func _on_Point_gui_input(event : InputEvent):
|
||||
if event is InputEventMouseMotion and event.button_mask == BUTTON_MASK_LEFT:
|
||||
var parent_value = get_parent_value()
|
||||
var value = get_parent().pos_to_value(rect_position+0.5*rect_size+event.relative)-parent_value
|
||||
if is_xy:
|
||||
if parameter_x == "":
|
||||
value.x = 0
|
||||
if parameter_y == "":
|
||||
value.y = 0
|
||||
else:
|
||||
if parameter_r == "":
|
||||
value = 0.25*value/value.length()
|
||||
if parameter_a == "":
|
||||
value = Vector2(value.length(), 0.0)
|
||||
rect_position = get_parent().value_to_pos(value+parent_value)-0.5*rect_size
|
||||
dragging = true
|
||||
update_parameters(value)
|
||||
update()
|
||||
dragging = false
|
||||
for c in children_control_nodes:
|
||||
c.update_position(c.get_value())
|
9
addons/material_maker/preview/control_point.tscn
Normal file
9
addons/material_maker/preview/control_point.tscn
Normal file
@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/material_maker/preview/control_point.gd" type="Script" id=1]
|
||||
|
||||
[node name="Point" type="TextureRect"]
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 13
|
||||
script = ExtResource( 1 )
|
||||
[connection signal="gui_input" from="." to="." method="_on_Point_gui_input"]
|
@ -1,108 +0,0 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://addons/material_maker/preview/preview.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/material_maker/preview/preview_3d.tscn" type="PackedScene" id=2]
|
||||
|
||||
|
||||
[sub_resource type="World" id=1]
|
||||
|
||||
[sub_resource type="Shader" id=2]
|
||||
code = "shader_type canvas_item;
|
||||
|
||||
uniform sampler2D tex;
|
||||
|
||||
void fragment() {
|
||||
COLOR = texture(tex, UV);
|
||||
}"
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=3]
|
||||
shader = SubResource( 2 )
|
||||
|
||||
[node name="Preview" type="ViewportContainer"]
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
margin_left = -398.0
|
||||
margin_top = 3.0
|
||||
margin_right = -3.0
|
||||
margin_bottom = 373.0
|
||||
rect_min_size = Vector2( 200, 200 )
|
||||
mouse_filter = 1
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
stretch = true
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="MaterialPreview" type="Viewport" parent="."]
|
||||
size = Vector2( 395, 370 )
|
||||
own_world = true
|
||||
world = SubResource( 1 )
|
||||
handle_input_locally = false
|
||||
msaa = 2
|
||||
render_target_clear_mode = 1
|
||||
render_target_update_mode = 3
|
||||
physics_object_picking = true
|
||||
|
||||
[node name="Preview3d" parent="MaterialPreview" instance=ExtResource( 2 )]
|
||||
|
||||
[node name="Config" type="HBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
margin_bottom = 20.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Model" type="OptionButton" parent="Config"]
|
||||
margin_right = 100.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 100, 0 )
|
||||
text = "Cube"
|
||||
items = [ "Cube", null, false, -1, null, "Cylinder", null, false, -1, null, "Sphere", null, false, -1, null, "Sphere2", null, false, -1, null, "Quad", null, false, -1, null, "Plane", null, false, -1, null ]
|
||||
selected = 0
|
||||
|
||||
[node name="Environment" type="OptionButton" parent="Config"]
|
||||
margin_left = 104.0
|
||||
margin_right = 231.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 100, 0 )
|
||||
text = "Epping Forest"
|
||||
items = [ "Epping Forest", null, false, -1, null, "Moonless Golf", null, false, -1, null ]
|
||||
selected = 0
|
||||
|
||||
[node name="Rotate" type="Button" parent="Config"]
|
||||
margin_left = 235.0
|
||||
margin_right = 255.0
|
||||
margin_bottom = 20.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="Config"]
|
||||
margin_left = 372.0
|
||||
margin_right = 395.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"
|
||||
|
||||
[node name="Preview2D" type="ColorRect" parent="."]
|
||||
material = SubResource( 3 )
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_top = -64.0
|
||||
margin_right = 64.0
|
||||
rect_min_size = Vector2( 64, 64 )
|
||||
mouse_filter = 1
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 8
|
||||
[connection signal="gui_input" from="." to="." method="on_gui_input"]
|
||||
[connection signal="resized" from="." to="." method="_on_Preview_resized"]
|
||||
[connection signal="item_selected" from="Config/Model" to="." method="_on_Model_item_selected"]
|
||||
[connection signal="item_selected" from="Config/Environment" to="." method="_on_Environment_item_selected"]
|
||||
[connection signal="toggled" from="Config/Rotate" to="." method="_on_Rotate_toggled"]
|
||||
[connection signal="toggled" from="Config/Background" to="." method="_on_Background_toggled"]
|
||||
[connection signal="gui_input" from="Preview2D" to="." method="_on_Preview2D_gui_input"]
|
31
addons/material_maker/preview/preview_2d.gd
Normal file
31
addons/material_maker/preview/preview_2d.gd
Normal file
@ -0,0 +1,31 @@
|
||||
tool
|
||||
extends ColorRect
|
||||
|
||||
var generator = null
|
||||
|
||||
func set_preview_texture(tex: Texture) -> void:
|
||||
material.set_shader_param("tex", tex)
|
||||
|
||||
func on_resized() -> void:
|
||||
material.set_shader_param("size", rect_size)
|
||||
setup_controls(generator)
|
||||
|
||||
func setup_controls(g : MMGenBase) -> void:
|
||||
if is_instance_valid(g):
|
||||
generator = g
|
||||
var param_defs : Array = generator.get_parameter_defs()
|
||||
for c in get_children():
|
||||
c.setup_control(generator, param_defs)
|
||||
else:
|
||||
g = null
|
||||
for c in get_children():
|
||||
c.setup_control(generator, [])
|
||||
|
||||
func value_to_pos(value : Vector2) -> Vector2:
|
||||
return rect_size*0.5+value*min(rect_size.x, rect_size.y)/1.2
|
||||
|
||||
func value_to_offset(value : Vector2) -> Vector2:
|
||||
return value*min(rect_size.x, rect_size.y)/1.2
|
||||
|
||||
func pos_to_value(pos : Vector2) -> Vector2:
|
||||
return (pos - rect_size*0.5)*1.2/min(rect_size.x, rect_size.y)
|
115
addons/material_maker/preview/preview_2d.tscn
Normal file
115
addons/material_maker/preview/preview_2d.tscn
Normal file
@ -0,0 +1,115 @@
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://addons/material_maker/preview/preview_2d.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/material_maker/preview/control_point.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://addons/material_maker/icons/icons.svg" type="Texture" id=3]
|
||||
|
||||
[sub_resource type="Shader" id=1]
|
||||
code = "shader_type canvas_item;
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 size;
|
||||
|
||||
void fragment() {
|
||||
float ms = max(size.x, size.y);
|
||||
vec2 uv = fract(0.5+1.2*(UV-vec2(0.5))*ms/size.yx);
|
||||
vec2 m2 = min(fract(uv), 1.0-fract(uv));
|
||||
COLOR = mix(texture(tex, uv), vec4(0.0, 1.0, 0.0, 1.0), step(min(m2.x, m2.y), 1.0/min(size.x, size.y)));
|
||||
}"
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=2]
|
||||
shader = SubResource( 1 )
|
||||
shader_param/size = Vector2( 721, 546 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=3]
|
||||
flags = 4
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 64, 48, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=4]
|
||||
flags = 4
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 16, 64, 16, 16 )
|
||||
|
||||
[node name="Preview2D" type="ColorRect"]
|
||||
material = SubResource( 2 )
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_right = -559.0
|
||||
margin_bottom = -174.0
|
||||
rect_min_size = Vector2( 64, 64 )
|
||||
rect_clip_content = true
|
||||
mouse_filter = 1
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 8
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="P1" parent="." instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
self_modulate = Color( 1, 0.466667, 0, 1 )
|
||||
texture = SubResource( 3 )
|
||||
|
||||
[node name="P2" parent="." instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
self_modulate = Color( 0, 0.505882, 1, 1 )
|
||||
texture = SubResource( 3 )
|
||||
|
||||
[node name="Rect1" parent="." instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
self_modulate = Color( 1, 0.631373, 0, 1 )
|
||||
margin_right = 16.0
|
||||
margin_bottom = 16.0
|
||||
texture = SubResource( 4 )
|
||||
parent_control = "P1"
|
||||
control_type = 1
|
||||
|
||||
[node name="Radius1" parent="." instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
self_modulate = Color( 1, 0.631373, 0, 1 )
|
||||
margin_right = 16.0
|
||||
margin_bottom = 16.0
|
||||
mouse_default_cursor_shape = 10
|
||||
texture = SubResource( 4 )
|
||||
parent_control = "P1"
|
||||
control_type = 2
|
||||
|
||||
[node name="Radius11" parent="." instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
self_modulate = Color( 1, 0.631373, 0, 1 )
|
||||
margin_right = 16.0
|
||||
margin_bottom = 16.0
|
||||
mouse_default_cursor_shape = 10
|
||||
texture = SubResource( 4 )
|
||||
parent_control = "Radius1"
|
||||
control_type = 2
|
||||
|
||||
[node name="Scale1" parent="." instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
self_modulate = Color( 1, 0.631373, 0, 1 )
|
||||
margin_right = 16.0
|
||||
margin_bottom = 16.0
|
||||
mouse_default_cursor_shape = 10
|
||||
texture = SubResource( 4 )
|
||||
parent_control = "P1"
|
||||
control_type = 3
|
||||
|
||||
[node name="Angle1" parent="." instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
self_modulate = Color( 1, 0.631373, 0, 1 )
|
||||
margin_right = 16.0
|
||||
margin_bottom = 16.0
|
||||
mouse_default_cursor_shape = 10
|
||||
texture = SubResource( 4 )
|
||||
parent_control = "P1"
|
||||
control_type = 2
|
||||
|
||||
[node name="Angle2" parent="." instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
self_modulate = Color( 1, 0.631373, 0, 1 )
|
||||
margin_right = 16.0
|
||||
margin_bottom = 16.0
|
||||
mouse_default_cursor_shape = 10
|
||||
texture = SubResource( 4 )
|
||||
parent_control = "P1"
|
||||
control_type = 2
|
||||
[connection signal="resized" from="." to="." method="on_resized"]
|
@ -1,8 +1,5 @@
|
||||
tool
|
||||
extends ViewportContainer
|
||||
|
||||
var preview_maximized = false
|
||||
|
||||
const ENVIRONMENTS = [
|
||||
"experiment", "lobby", "night", "park", "schelde"
|
||||
]
|
||||
@ -10,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)
|
||||
|
||||
@ -19,65 +18,48 @@ 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:
|
||||
$Config/Model.clear()
|
||||
var model_list : Array = []
|
||||
for o in objects.get_children():
|
||||
var m = o.get_surface_material(0)
|
||||
o.set_surface_material(0, m.duplicate())
|
||||
$Config/Model.add_item(o.name)
|
||||
call_deferred("_on_Model_item_selected", 0)
|
||||
$Config/Environment.clear()
|
||||
model_list.push_back(o.name)
|
||||
ui.set_models(model_list)
|
||||
var environment_list : Array = []
|
||||
for e in environments.get_children():
|
||||
$Config/Environment.add_item(e.name)
|
||||
call_deferred("_on_Environment_item_selected", 0)
|
||||
environment_list.push_back(e.name)
|
||||
ui.set_environments(environment_list)
|
||||
$MaterialPreview/Preview3d/ObjectRotate.play("rotate")
|
||||
$Preview2D.material = $Preview2D.material.duplicate(true)
|
||||
_on_Preview_resized()
|
||||
$MaterialPreview/Preview3d/CameraPivot/Camera/RemoteTransform.set_remote_node("../../../../../../../ProjectsPane/BackgroundPreview/Viewport/Camera")
|
||||
|
||||
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_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)
|
||||
current_environment.visible = true
|
||||
|
||||
func _on_Rotate_toggled(button_pressed) -> void:
|
||||
if button_pressed:
|
||||
$MaterialPreview/Preview3d/ObjectRotate.play("rotate")
|
||||
else:
|
||||
$MaterialPreview/Preview3d/ObjectRotate.stop(false)
|
||||
|
||||
func get_materials() -> Array:
|
||||
return [ current_object.get_surface_material(0) ]
|
||||
|
||||
func set_2d(tex: Texture) -> void:
|
||||
$Preview2D.material.set_shader_param("tex", tex)
|
||||
|
||||
func _on_Preview_resized() -> void:
|
||||
if preview_maximized:
|
||||
var size = min(rect_size.x, rect_size.y)
|
||||
$Preview2D.rect_position = 0.5*Vector2(rect_size.x-size, rect_size.y-size)
|
||||
$Preview2D.rect_size = Vector2(size, size)
|
||||
else:
|
||||
$Preview2D.rect_position = Vector2(0, rect_size.y-64)
|
||||
$Preview2D.rect_size = Vector2(64, 64)
|
||||
|
||||
func _on_Preview2D_gui_input(ev : InputEvent) -> void:
|
||||
if ev is InputEventMouseButton and ev.button_index == 1 and ev.pressed:
|
||||
preview_maximized = !preview_maximized
|
||||
_on_Preview_resized()
|
||||
|
||||
func _on_Background_toggled(button_pressed) -> void:
|
||||
emit_signal("show_background_preview", button_pressed)
|
||||
|
||||
func on_gui_input(event) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
$MaterialPreview/Preview3d/ObjectRotate.stop(false)
|
||||
$Config/Rotate.pressed = false
|
||||
ui.rotation_cancelled()
|
||||
match event.button_index:
|
||||
BUTTON_WHEEL_UP:
|
||||
camera.translation.z = clamp(
|
||||
@ -106,9 +88,3 @@ func on_gui_input(event) -> void:
|
||||
camera_stand.rotate(camera_basis.y.normalized(), -motion.x)
|
||||
elif event.button_mask & BUTTON_MASK_RIGHT:
|
||||
camera_stand.rotate(camera_basis.z.normalized(), -motion.x)
|
||||
|
||||
func _on_Rotate_toggled(button_pressed) -> void:
|
||||
if button_pressed:
|
||||
$MaterialPreview/Preview3d/ObjectRotate.play("rotate")
|
||||
else:
|
||||
$MaterialPreview/Preview3d/ObjectRotate.stop(false)
|
@ -1,121 +1,34 @@
|
||||
[gd_scene load_steps=14 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://addons/material_maker/preview/preview_objects.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://addons/material_maker/preview/panoramas/moonless_golf.hdr" type="Texture" id=2]
|
||||
[ext_resource path="res://addons/material_maker/environment.gd" type="Script" id=3]
|
||||
[ext_resource path="res://addons/material_maker/preview/panoramas/epping_forest_01.hdr" type="Texture" id=4]
|
||||
[ext_resource path="res://addons/material_maker/preview/panoramas/studio_sky.tres" type="Environment" id=5]
|
||||
[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]
|
||||
|
||||
[sub_resource type="PanoramaSky" id=3]
|
||||
resource_local_to_scene = true
|
||||
panorama = ExtResource( 2 )
|
||||
[sub_resource type="World" id=1]
|
||||
|
||||
[sub_resource type="Environment" id=4]
|
||||
resource_local_to_scene = true
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 3 )
|
||||
|
||||
[sub_resource type="Animation" id=5]
|
||||
loop = true
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Objects:rotation_degrees")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 1 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 360, 0 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="PanoramaSky" id=1]
|
||||
resource_local_to_scene = true
|
||||
panorama = ExtResource( 4 )
|
||||
|
||||
[sub_resource type="Environment" id=2]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
||||
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="CylinderMesh" id=6]
|
||||
top_radius = 5.0
|
||||
bottom_radius = 5.0
|
||||
height = 0.5
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=7]
|
||||
|
||||
[sub_resource type="PlaneMesh" id=8]
|
||||
size = Vector2( 1000, 1000 )
|
||||
subdivide_width = 10
|
||||
subdivide_depth = 10
|
||||
|
||||
[node name="Preview3d" type="Spatial"]
|
||||
|
||||
[node name="Objects" parent="." instance=ExtResource( 1 )]
|
||||
transform = Transform( -0.799512, 0, 0.60065, 0, 1, 0, -0.60065, 0, -0.799512, 0, 0, 0 )
|
||||
|
||||
[node name="CameraPivot" type="Spatial" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, 0.766044, 0.642788, 0, -0.642788, 0.766044, 0, 0, 0 )
|
||||
|
||||
[node name="Camera" type="Camera" parent="CameraPivot"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 3.5 )
|
||||
environment = SubResource( 4 )
|
||||
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
|
||||
anims/rotate = SubResource( 5 )
|
||||
|
||||
[node name="Environments" type="Spatial" parent="."]
|
||||
|
||||
[node name="Epping Forest" type="Spatial" parent="Environments"]
|
||||
editor/display_folded = true
|
||||
[node name="Preview3D" type="ViewportContainer"]
|
||||
visible = false
|
||||
script = ExtResource( 3 )
|
||||
environment = SubResource( 2 )
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 4.0
|
||||
margin_top = 32.0
|
||||
margin_right = -4.0
|
||||
margin_bottom = -4.0
|
||||
rect_min_size = Vector2( 200, 200 )
|
||||
mouse_filter = 1
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
stretch = true
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="DirectionalLight" type="DirectionalLight" parent="Environments/Epping Forest"]
|
||||
transform = Transform( 0.976272, -0.0494319, -0.21083, 0.216548, 0.222856, 0.950496, -8.69534e-009, -0.973597, 0.228272, -5.08826, 21.6274, 5.3744 )
|
||||
light_energy = 0.5
|
||||
shadow_enabled = true
|
||||
[node name="MaterialPreview" type="Viewport" parent="."]
|
||||
size = Vector2( 1272, 684 )
|
||||
own_world = true
|
||||
world = SubResource( 1 )
|
||||
handle_input_locally = false
|
||||
msaa = 2
|
||||
render_target_clear_mode = 1
|
||||
render_target_update_mode = 0
|
||||
physics_object_picking = true
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="Environments/Epping Forest"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.3343, 0 )
|
||||
visible = false
|
||||
mesh = SubResource( 6 )
|
||||
material/0 = SubResource( 7 )
|
||||
|
||||
[node name="Moonless Golf" type="Spatial" parent="Environments"]
|
||||
editor/display_folded = true
|
||||
visible = false
|
||||
script = ExtResource( 3 )
|
||||
environment = SubResource( 4 )
|
||||
|
||||
[node name="DirectionalLight" type="DirectionalLight" parent="Environments/Moonless Golf"]
|
||||
transform = Transform( 0.569388, 0.170928, 0.804103, 0.171359, -0.981336, 0.087263, 0.804011, 0.088104, -0.588051, 91.9658, 9.62053, -85.1176 )
|
||||
light_energy = 0.2
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="Studio" type="Spatial" parent="Environments"]
|
||||
visible = false
|
||||
script = ExtResource( 3 )
|
||||
environment = ExtResource( 5 )
|
||||
|
||||
[node name="DirectionalLight" type="DirectionalLight" parent="Environments/Studio"]
|
||||
transform = Transform( 0.707107, -0.40558, 0.579228, 0, 0.819152, 0.573577, -0.707107, -0.40558, 0.579228, 10, 10, 0 )
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="GroundPlane" type="MeshInstance" parent="Environments/Studio"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.05186, 0 )
|
||||
mesh = SubResource( 8 )
|
||||
material/0 = null
|
||||
[node name="Preview3d" parent="MaterialPreview" instance=ExtResource( 2 )]
|
||||
[connection signal="gui_input" from="." to="." method="on_gui_input"]
|
||||
|
118
addons/material_maker/preview/preview_3d_scene.tscn
Normal file
118
addons/material_maker/preview/preview_3d_scene.tscn
Normal file
@ -0,0 +1,118 @@
|
||||
[gd_scene load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://addons/material_maker/preview/preview_objects.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://addons/material_maker/preview/panoramas/moonless_golf.hdr" type="Texture" id=2]
|
||||
[ext_resource path="res://addons/material_maker/environment.gd" type="Script" id=3]
|
||||
[ext_resource path="res://addons/material_maker/preview/panoramas/epping_forest_01.hdr" type="Texture" id=4]
|
||||
[ext_resource path="res://addons/material_maker/preview/panoramas/studio_sky.tres" type="Environment" id=5]
|
||||
|
||||
[sub_resource type="PanoramaSky" id=1]
|
||||
resource_local_to_scene = true
|
||||
panorama = ExtResource( 2 )
|
||||
|
||||
[sub_resource type="Environment" id=2]
|
||||
resource_local_to_scene = true
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
loop = true
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Objects:rotation_degrees")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 1 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 360, 0 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="PanoramaSky" id=4]
|
||||
resource_local_to_scene = true
|
||||
panorama = ExtResource( 4 )
|
||||
|
||||
[sub_resource type="Environment" id=5]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 4 )
|
||||
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="CylinderMesh" id=6]
|
||||
top_radius = 5.0
|
||||
bottom_radius = 5.0
|
||||
height = 0.5
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=7]
|
||||
|
||||
[sub_resource type="PlaneMesh" id=8]
|
||||
size = Vector2( 1000, 1000 )
|
||||
subdivide_width = 10
|
||||
subdivide_depth = 10
|
||||
|
||||
[node name="Preview3dScene" type="Spatial"]
|
||||
|
||||
[node name="Objects" parent="." instance=ExtResource( 1 )]
|
||||
transform = Transform( -0.799512, 0, 0.60065, 0, 1, 0, -0.60065, 0, -0.799512, 0, 0, 0 )
|
||||
|
||||
[node name="CameraPivot" type="Spatial" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, 0.766044, 0.642788, 0, -0.642788, 0.766044, 0, 0, 0 )
|
||||
|
||||
[node name="Camera" type="Camera" parent="CameraPivot"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 3.5 )
|
||||
environment = SubResource( 2 )
|
||||
current = true
|
||||
|
||||
[node name="ObjectRotate" type="AnimationPlayer" parent="."]
|
||||
autoplay = "rotate"
|
||||
playback_speed = 0.1
|
||||
anims/rotate = SubResource( 3 )
|
||||
|
||||
[node name="Environments" type="Spatial" parent="."]
|
||||
|
||||
[node name="Epping Forest" type="Spatial" parent="Environments"]
|
||||
editor/display_folded = true
|
||||
visible = false
|
||||
script = ExtResource( 3 )
|
||||
environment = SubResource( 5 )
|
||||
|
||||
[node name="DirectionalLight" type="DirectionalLight" parent="Environments/Epping Forest"]
|
||||
transform = Transform( 0.976272, -0.0494319, -0.21083, 0.216548, 0.222856, 0.950496, -8.69534e-009, -0.973597, 0.228272, -5.08826, 21.6274, 5.3744 )
|
||||
light_energy = 0.5
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="Environments/Epping Forest"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.3343, 0 )
|
||||
visible = false
|
||||
mesh = SubResource( 6 )
|
||||
material/0 = SubResource( 7 )
|
||||
|
||||
[node name="Moonless Golf" type="Spatial" parent="Environments"]
|
||||
editor/display_folded = true
|
||||
visible = false
|
||||
script = ExtResource( 3 )
|
||||
environment = SubResource( 2 )
|
||||
|
||||
[node name="DirectionalLight" type="DirectionalLight" parent="Environments/Moonless Golf"]
|
||||
transform = Transform( 0.569388, 0.170928, 0.804103, 0.171359, -0.981336, 0.087263, 0.804011, 0.088104, -0.588051, 91.9658, 9.62053, -85.1176 )
|
||||
light_energy = 0.2
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="Studio" type="Spatial" parent="Environments"]
|
||||
visible = false
|
||||
script = ExtResource( 3 )
|
||||
environment = ExtResource( 5 )
|
||||
|
||||
[node name="DirectionalLight" type="DirectionalLight" parent="Environments/Studio"]
|
||||
transform = Transform( 0.707107, -0.40558, 0.579228, 0, 0.819152, 0.573577, -0.707107, -0.40558, 0.579228, 10, 10, 0 )
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="GroundPlane" type="MeshInstance" parent="Environments/Studio"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.05186, 0 )
|
||||
mesh = SubResource( 8 )
|
||||
material/0 = null
|
29
addons/material_maker/preview/preview_3d_ui.gd
Normal file
29
addons/material_maker/preview/preview_3d_ui.gd
Normal file
@ -0,0 +1,29 @@
|
||||
extends HBoxContainer
|
||||
|
||||
signal model_selected(id)
|
||||
signal environment_selected(id)
|
||||
signal rotate_toggled(b)
|
||||
|
||||
func set_models(model_list : Array) -> void:
|
||||
$Model.clear()
|
||||
for m in model_list:
|
||||
$Model.add_item(m)
|
||||
call_deferred("_on_Model_item_selected", 0)
|
||||
|
||||
func set_environments(environment_list : Array) -> void:
|
||||
$Environment.clear()
|
||||
for e in environment_list:
|
||||
$Environment.add_item(e)
|
||||
call_deferred("_on_Environment_item_selected", 0)
|
||||
|
||||
func rotation_cancelled() -> void:
|
||||
$Rotate.pressed = false
|
||||
|
||||
func _on_Model_item_selected(ID) -> void:
|
||||
emit_signal("model_selected", ID)
|
||||
|
||||
func _on_Environment_item_selected(ID) -> void:
|
||||
emit_signal("environment_selected", ID)
|
||||
|
||||
func _on_Rotate_toggled(button_pressed) -> void:
|
||||
emit_signal("rotate_toggled", button_pressed)
|
46
addons/material_maker/preview/preview_3d_ui.tscn
Normal file
46
addons/material_maker/preview/preview_3d_ui.tscn
Normal file
@ -0,0 +1,46 @@
|
||||
[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
|
||||
margin_bottom = 20.0
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Model" type="OptionButton" parent="."]
|
||||
margin_right = 100.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 ]
|
||||
selected = 0
|
||||
|
||||
[node name="Environment" type="OptionButton" parent="."]
|
||||
margin_left = 104.0
|
||||
margin_right = 231.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 ]
|
||||
selected = 0
|
||||
|
||||
[node name="Rotate" type="Button" parent="."]
|
||||
margin_left = 235.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
|
||||
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"]
|
@ -1,14 +1,21 @@
|
||||
tool
|
||||
extends HBoxContainer
|
||||
|
||||
const CONTROLS = [ "None", "P1.x", "P1.y", "P1.a", "P1.r", "P2.x", "P2.y", "P2.a", "P2.r", "Rect1.x", "Rect1.y", "Radius1.r", "Radius1.a", "Radius11.r", "Radius11.a", "Scale1.x", "Scale1.y", "Angle1.a", "Angle2.a" ]
|
||||
|
||||
func _ready() -> void:
|
||||
$Control.clear()
|
||||
for c in CONTROLS:
|
||||
$Control.add_item(c)
|
||||
|
||||
func get_model_data() -> Dictionary:
|
||||
var data = {
|
||||
min = $Min.value,
|
||||
max = $Max.value,
|
||||
step = $Step.value,
|
||||
default = $Default.value,
|
||||
control = $Control.get_item_text($Control.selected)
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
func set_model_data(data) -> void:
|
||||
@ -23,6 +30,12 @@ func set_model_data(data) -> void:
|
||||
$Default.step = data.step
|
||||
if data.has("default"):
|
||||
$Default.value = data.default
|
||||
if data.has("control"):
|
||||
$Control.selected = 0
|
||||
for i in range($Control.get_item_count()):
|
||||
if data.control == $Control.get_item_text(i):
|
||||
$Control.selected = i
|
||||
break
|
||||
|
||||
|
||||
func _on_Min_value_changed(v : float) -> void:
|
||||
|
@ -81,6 +81,20 @@ margin_left = 342.0
|
||||
margin_right = 400.0
|
||||
margin_bottom = 24.0
|
||||
step = 0.1
|
||||
|
||||
[node name="LabelControl" type="Label" parent="."]
|
||||
margin_left = 404.0
|
||||
margin_top = 5.0
|
||||
margin_right = 454.0
|
||||
margin_bottom = 19.0
|
||||
text = "Control:"
|
||||
|
||||
[node name="Control" type="OptionButton" parent="."]
|
||||
margin_left = 458.0
|
||||
margin_right = 533.0
|
||||
margin_bottom = 24.0
|
||||
text = "None"
|
||||
selected = 0
|
||||
[connection signal="value_changed" from="Min" to="." method="_on_Min_value_changed"]
|
||||
[connection signal="value_changed" from="Max" to="." method="_on_Max_value_changed"]
|
||||
[connection signal="value_changed" from="Step" to="." method="_on_Step_value_changed"]
|
||||
|
@ -1,4 +1,3 @@
|
||||
tool
|
||||
extends Panel
|
||||
|
||||
var current_tab = -1 setget set_current_tab
|
||||
|
Loading…
Reference in New Issue
Block a user