2021-10-03 19:56:35 +02:00
|
|
|
tool
|
2021-10-04 11:23:43 +02:00
|
|
|
class_name MMNode
|
2021-10-03 19:56:35 +02:00
|
|
|
extends Resource
|
|
|
|
|
2021-10-04 13:27:29 +02:00
|
|
|
enum SlotTypes {
|
|
|
|
SLOT_TYPE_NONE = -1,
|
|
|
|
SLOT_TYPE_IMAGE = 0,
|
|
|
|
SLOT_TYPE_INT = 1,
|
|
|
|
SLOT_TYPE_FLOAT = 2,
|
|
|
|
SLOT_TYPE_VECTOR2 = 3,
|
|
|
|
SLOT_TYPE_VECTOR3 = 4,
|
2021-10-04 15:10:38 +02:00
|
|
|
SLOT_TYPE_UNIVERSAL = 5,
|
2021-10-04 13:27:29 +02:00
|
|
|
}
|
|
|
|
|
2021-10-04 13:09:43 +02:00
|
|
|
export(Vector2) var graph_position : Vector2 = Vector2()
|
2021-10-03 19:56:35 +02:00
|
|
|
|
2021-10-04 13:09:43 +02:00
|
|
|
func recalculate_image(material, slot_idx : int) -> ImageTexture:
|
|
|
|
var image : Image = Image.new()
|
|
|
|
image.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
|
|
|
|
|
|
|
var tex : ImageTexture = ImageTexture.new()
|
2021-10-04 11:54:52 +02:00
|
|
|
|
2021-10-04 13:09:43 +02:00
|
|
|
image.lock()
|
|
|
|
|
|
|
|
var w : float = image.get_width()
|
|
|
|
var h : float = image.get_width()
|
|
|
|
|
|
|
|
var pseed : float = randf() + randi()
|
|
|
|
|
|
|
|
for x in range(image.get_width()):
|
|
|
|
for y in range(image.get_height()):
|
|
|
|
var v : Vector2 = Vector2(x / w, y / h)
|
|
|
|
|
2021-10-04 13:15:18 +02:00
|
|
|
var col : Color = get_value_for(v, slot_idx, pseed)
|
2021-10-04 13:09:43 +02:00
|
|
|
|
|
|
|
image.set_pixel(x, y, col)
|
|
|
|
|
|
|
|
image.unlock()
|
|
|
|
|
|
|
|
tex.create_from_image(image)
|
|
|
|
|
|
|
|
return tex
|
|
|
|
|
2021-10-04 13:15:18 +02:00
|
|
|
func get_value_for(uv : Vector2, slot_idx : int, pseed : int) -> Color:
|
2021-10-04 13:09:43 +02:00
|
|
|
return Color()
|
|
|
|
|
|
|
|
func register_methods(mm_graph_node) -> void:
|
|
|
|
pass
|
|
|
|
|
|
|
|
func get_graph_position() -> Vector2:
|
|
|
|
return graph_position
|
|
|
|
|
|
|
|
func set_graph_position(pos : Vector2) -> void:
|
|
|
|
graph_position = pos
|
|
|
|
|
|
|
|
emit_changed()
|