mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-01-15 02:01:09 +01:00
sd_op_bool node.
This commit is contained in:
parent
dc56ca252b
commit
89b6600dd9
@ -1,4 +1,4 @@
|
||||
[gd_resource type="Resource" load_steps=76 format=2]
|
||||
[gd_resource type="Resource" load_steps=81 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/mm_material.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/noise/noise.gd" type="Script" id=2]
|
||||
@ -20,6 +20,7 @@
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf2d/sd_tf_translate.gd" type="Script" id=18]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf2d/sd_tf_rotate.gd" type="Script" id=19]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf2d/sd_tf_scale.gd" type="Script" id=20]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf2d/sd_op_bool.gd" type="Script" id=21]
|
||||
|
||||
[sub_resource type="Resource" id=3]
|
||||
script = ExtResource( 5 )
|
||||
@ -57,7 +58,7 @@ sides = 11
|
||||
radius = SubResource( 4 )
|
||||
edge = SubResource( 3 )
|
||||
|
||||
[sub_resource type="Resource" id=67]
|
||||
[sub_resource type="Resource" id=74]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
@ -69,7 +70,7 @@ default_color = Color( 0, 0, 0, 1 )
|
||||
[sub_resource type="Resource" id=6]
|
||||
script = ExtResource( 6 )
|
||||
graph_position = Vector2( 300, -400 )
|
||||
image = SubResource( 67 )
|
||||
image = SubResource( 74 )
|
||||
postfix = "-test"
|
||||
|
||||
[sub_resource type="Resource" id=9]
|
||||
@ -342,7 +343,7 @@ default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=53]
|
||||
[sub_resource type="Resource" id=75]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
@ -351,16 +352,6 @@ default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=72]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 53 )
|
||||
|
||||
[sub_resource type="Resource" id=48]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
@ -369,22 +360,31 @@ default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 72 )
|
||||
input_property = SubResource( 75 )
|
||||
|
||||
[sub_resource type="Resource" id=49]
|
||||
script = ExtResource( 13 )
|
||||
graph_position = Vector2( 1580, -720 )
|
||||
graph_position = Vector2( 1680, -900 )
|
||||
image = SubResource( 47 )
|
||||
input = SubResource( 48 )
|
||||
bevel = 0.0
|
||||
bevel = 0.01
|
||||
base = 0.17
|
||||
|
||||
[sub_resource type="Resource" id=53]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=54]
|
||||
script = ExtResource( 14 )
|
||||
graph_position = Vector2( 1020, -680 )
|
||||
output = SubResource( 53 )
|
||||
center = Vector2( 0, 0 )
|
||||
radius = 0.1
|
||||
radius = 0.15
|
||||
|
||||
[sub_resource type="Resource" id=56]
|
||||
script = ExtResource( 5 )
|
||||
@ -423,10 +423,10 @@ default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=60]
|
||||
script = ExtResource( 15 )
|
||||
graph_position = Vector2( 740, -820 )
|
||||
graph_position = Vector2( 860, -980 )
|
||||
output = SubResource( 59 )
|
||||
center = Vector2( 0.04, 0 )
|
||||
size = Vector2( 0.3, 0.2 )
|
||||
center = Vector2( 0.03, 0 )
|
||||
size = Vector2( 0.38, 0.2 )
|
||||
|
||||
[sub_resource type="Resource" id=62]
|
||||
script = ExtResource( 5 )
|
||||
@ -474,7 +474,7 @@ default_color = Color( 0, 0, 0, 1 )
|
||||
script = ExtResource( 18 )
|
||||
graph_position = Vector2( 1180, -880 )
|
||||
output = SubResource( 68 )
|
||||
translation = Vector2( 0.15, 0.03 )
|
||||
translation = Vector2( 0.16, 0.03 )
|
||||
|
||||
[sub_resource type="Resource" id=70]
|
||||
script = ExtResource( 5 )
|
||||
@ -492,13 +492,51 @@ graph_position = Vector2( 1480, -240 )
|
||||
output = SubResource( 70 )
|
||||
angle = 52.0
|
||||
|
||||
[sub_resource type="Resource" id=72]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 53 )
|
||||
|
||||
[sub_resource type="Resource" id=73]
|
||||
script = ExtResource( 20 )
|
||||
graph_position = Vector2( 1340, -740 )
|
||||
output = SubResource( 72 )
|
||||
scale = 3.0
|
||||
scale = 1.83
|
||||
|
||||
[sub_resource type="Resource" id=76]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 59 )
|
||||
|
||||
[sub_resource type="Resource" id=77]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 72 )
|
||||
|
||||
[sub_resource type="Resource" id=78]
|
||||
script = ExtResource( 21 )
|
||||
graph_position = Vector2( 1440, -1020 )
|
||||
input1 = SubResource( 76 )
|
||||
input2 = SubResource( 77 )
|
||||
output = SubResource( 75 )
|
||||
operation = 2
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
image_size = Vector2( 128, 128 )
|
||||
nodes = [ SubResource( 5 ), SubResource( 6 ), SubResource( 12 ), SubResource( 15 ), SubResource( 18 ), SubResource( 21 ), SubResource( 24 ), SubResource( 27 ), SubResource( 39 ), SubResource( 42 ), SubResource( 45 ), SubResource( 49 ), SubResource( 54 ), SubResource( 58 ), SubResource( 60 ), SubResource( 63 ), SubResource( 66 ), SubResource( 69 ), SubResource( 71 ), SubResource( 73 ) ]
|
||||
nodes = [ SubResource( 5 ), SubResource( 6 ), SubResource( 12 ), SubResource( 15 ), SubResource( 18 ), SubResource( 21 ), SubResource( 24 ), SubResource( 27 ), SubResource( 39 ), SubResource( 42 ), SubResource( 45 ), SubResource( 49 ), SubResource( 54 ), SubResource( 58 ), SubResource( 60 ), SubResource( 63 ), SubResource( 66 ), SubResource( 69 ), SubResource( 71 ), SubResource( 73 ), SubResource( 78 ) ]
|
||||
|
76
game/addons/mat_maker_gd/nodes/sdf2d/sd_op_bool.gd
Normal file
76
game/addons/mat_maker_gd/nodes/sdf2d/sd_op_bool.gd
Normal file
@ -0,0 +1,76 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var SDF2D = preload("res://addons/mat_maker_gd/nodes/common/sdf2d.gd")
|
||||
|
||||
export(Resource) var input1 : Resource
|
||||
export(Resource) var input2 : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(int, "Union,Substraction,Intersection") var operation : int = 0
|
||||
|
||||
func _init_properties():
|
||||
if !input1:
|
||||
input1 = MMNodeUniversalProperty.new()
|
||||
input1.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
|
||||
input1.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
# input1.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
input1.slot_name = ">>> Input 1 "
|
||||
if !input2.is_connected("changed", self, "on_input_changed"):
|
||||
input1.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !input2:
|
||||
input2 = MMNodeUniversalProperty.new()
|
||||
input2.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
|
||||
input2.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
# input2.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
input2.slot_name = ">>> Input 2 "
|
||||
|
||||
if !input2.is_connected("changed", self, "on_input_changed"):
|
||||
input2.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
# output.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
output.slot_name = " Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input1)
|
||||
register_input_property(input2)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input1)
|
||||
mm_graph_node.add_slot_label_universal(input2)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_enum("get_operation", "set_operation", "Operation", [ "Union", "Substraction", "Intersection" ])
|
||||
|
||||
func get_property_value(uv : Vector2) -> float:
|
||||
if operation == 0:
|
||||
return SDF2D.sdf_boolean_union(input1.get_value(uv), input2.get_value(uv))
|
||||
elif operation == 1:
|
||||
return SDF2D.sdf_boolean_substraction(input1.get_value(uv), input2.get_value(uv))
|
||||
elif operation == 2:
|
||||
return SDF2D.sdf_boolean_intersection(input1.get_value(uv), input2.get_value(uv))
|
||||
|
||||
return 0.0
|
||||
|
||||
#operation
|
||||
func get_operation() -> int:
|
||||
return operation
|
||||
|
||||
func set_operation(val : int) -> void:
|
||||
operation = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
Loading…
Reference in New Issue
Block a user