mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-18 01:06:47 +01:00
sd_op_circle_repeat node.
This commit is contained in:
parent
8a896d0e3d
commit
27ba62e20a
@ -1,4 +1,4 @@
|
||||
[gd_resource type="Resource" load_steps=95 format=2]
|
||||
[gd_resource type="Resource" load_steps=98 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]
|
||||
@ -25,6 +25,7 @@
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf2d/sd_op_rounded_shape.gd" type="Script" id=23]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf2d/sd_op_annular_shape.gd" type="Script" id=24]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf2d/sd_op_repeat.gd" type="Script" id=25]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf2d/sd_op_circle_repeat.gd" type="Script" id=26]
|
||||
|
||||
[sub_resource type="Resource" id=3]
|
||||
script = ExtResource( 5 )
|
||||
@ -356,7 +357,7 @@ default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=89]
|
||||
[sub_resource type="Resource" id=91]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
@ -374,7 +375,7 @@ 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( 89 )
|
||||
input_property = SubResource( 91 )
|
||||
|
||||
[sub_resource type="Resource" id=49]
|
||||
script = ExtResource( 13 )
|
||||
@ -431,7 +432,7 @@ script = ExtResource( 15 )
|
||||
graph_position = Vector2( 1060, -1320 )
|
||||
output = SubResource( 59 )
|
||||
center = Vector2( 0.03, 0 )
|
||||
size = Vector2( 0.1, 0.1 )
|
||||
size = Vector2( 0.2, 0.2 )
|
||||
|
||||
[sub_resource type="Resource" id=62]
|
||||
script = ExtResource( 5 )
|
||||
@ -617,6 +618,15 @@ output = SubResource( 87 )
|
||||
width = 0.02
|
||||
ripples = 3
|
||||
|
||||
[sub_resource type="Resource" id=89]
|
||||
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=90]
|
||||
script = ExtResource( 25 )
|
||||
graph_position = Vector2( 840, -1140 )
|
||||
@ -625,7 +635,13 @@ x = 5
|
||||
y = 5
|
||||
random_rotation = 0.5
|
||||
|
||||
[sub_resource type="Resource" id=92]
|
||||
script = ExtResource( 26 )
|
||||
graph_position = Vector2( 860, -880 )
|
||||
output = SubResource( 91 )
|
||||
count = 5
|
||||
|
||||
[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 ), SubResource( 78 ), SubResource( 82 ), SubResource( 85 ), SubResource( 88 ), SubResource( 90 ) ]
|
||||
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 ), SubResource( 82 ), SubResource( 85 ), SubResource( 88 ), SubResource( 90 ), SubResource( 92 ) ]
|
||||
|
@ -240,39 +240,13 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
#sdcirclerepeat.mmg
|
||||
#Repeats its input shape around a circle
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "label": "",
|
||||
# "longdesc": "The input shape, defined as a signed distance function",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "sdf2d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The shape generated by the repeat operation",
|
||||
# "sdf2d": "$in(circle_repeat_transform_2d($uv-vec2(0.5), $c)+vec2(0.5))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "sdf2d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "",
|
||||
# "longdesc": "The number of repetitions of the input shape around the circle",
|
||||
# "max": 32,
|
||||
# "min": 1,
|
||||
# "name": "c",
|
||||
# "shortdesc": "Count",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#Output:
|
||||
#Out, sdf2d (float) (property)
|
||||
#$in(circle_repeat_transform_2d($uv-vec2(0.5), $c)+vec2(0.5))
|
||||
|
||||
#Input:
|
||||
#in, float (sdf2d), default : 0
|
||||
#count, int, min: 1, max: 32, default: 6
|
||||
|
||||
#----------------------
|
||||
#sdelongation.mmg
|
||||
@ -2345,8 +2319,20 @@ static func sdBezier(pos : Vector2, A : Vector2, B : Vector2, C : Vector2) -> Ve
|
||||
# return rv;
|
||||
#}
|
||||
|
||||
static func circle_repeat_transform_2d(pos : Vector2, count : float) -> Vector2:
|
||||
return Vector2()
|
||||
static func circle_repeat_transform_2d(p : Vector2, count : float) -> Vector2:
|
||||
var r : float = 6.28 / count
|
||||
var pa : float = atan2(p.x, p.y)
|
||||
var a : float = Commons.modf(pa + 0.5 * r, r)-0.5*r
|
||||
|
||||
var rv : Vector2 = Vector2()
|
||||
|
||||
var c : float = cos(a - pa);
|
||||
var s : float = sin(a - pa);
|
||||
|
||||
rv.x = p.x * c + p.y * s
|
||||
rv.y = -p.x * s + p.y * c
|
||||
|
||||
return rv;
|
||||
|
||||
#float sdNgon(vec2 p, float r, float n) {
|
||||
# float PI = 3.1415926535;
|
||||
|
43
game/addons/mat_maker_gd/nodes/sdf2d/sd_op_circle_repeat.gd
Normal file
43
game/addons/mat_maker_gd/nodes/sdf2d/sd_op_circle_repeat.gd
Normal file
@ -0,0 +1,43 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var SDF2D = preload("res://addons/mat_maker_gd/nodes/common/sdf2d.gd")
|
||||
|
||||
export(Resource) var output : Resource
|
||||
export(int) var count : int = 6
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
output.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
#output.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Apply >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(output)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_int("get_count", "set_count", "Count")
|
||||
|
||||
func get_property_value(uv : Vector2):
|
||||
#$in(circle_repeat_transform_2d($uv-vec2(0.5), $c)+vec2(0.5))
|
||||
var new_uv : Vector2 = SDF2D.circle_repeat_transform_2d(uv - Vector2(0.5, 0.5), count) + Vector2(0.5, 0.5)
|
||||
|
||||
return output.get_value(new_uv, true)
|
||||
|
||||
#count
|
||||
func get_count() -> int:
|
||||
return count
|
||||
|
||||
func set_count(val : int) -> void:
|
||||
count = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
Loading…
Reference in New Issue
Block a user