Cleaned up the patterns.

This commit is contained in:
Relintai 2022-06-18 00:19:06 +02:00
parent efb00f2fbb
commit 3fbf9713f7
21 changed files with 1329 additions and 2022 deletions

View File

@ -112,6 +112,16 @@ sources = [
"nodes/sdf2d/sd_op_circle_repeat.cpp", "nodes/sdf2d/sd_op_circle_repeat.cpp",
"nodes/sdf2d/sd_op_bool.cpp", "nodes/sdf2d/sd_op_bool.cpp",
"nodes/sdf2d/sd_op_annular_shape.cpp", "nodes/sdf2d/sd_op_annular_shape.cpp",
"nodes/pattern/weave.cpp",
"nodes/pattern/truchet.cpp",
"nodes/pattern/sine_wave.cpp",
"nodes/pattern/scratches.cpp",
"nodes/pattern/runes.cpp",
"nodes/pattern/pattern.cpp",
"nodes/pattern/iching.cpp",
"nodes/pattern/bricks.cpp",
"nodes/pattern/beehive.cpp",
] ]
if env["tools"]: if env["tools"]:

View File

@ -82,6 +82,16 @@ def get_doc_classes():
"MMSdOpCircleRepeat", "MMSdOpCircleRepeat",
"MMSdOpBool", "MMSdOpBool",
"MMSdOpAnnularShape", "MMSdOpAnnularShape",
"MMWeave",
"MMTruchet",
"MMSineWave",
"MMScratches",
"MMRunes",
"MMPattern",
"MMIching",
"MMBricks",
"MMBeehive",
] ]
def get_doc_path(): def get_doc_path():

View File

@ -1,201 +1,161 @@
#include "beehive.h" #include "beehive.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Beehive::get_out_main() { Ref<MMNodeUniversalProperty> MMBeehive::get_out_main() {
return out_main; return out_main;
} }
void Beehive::set_out_main(const Ref<Resource> &val) { void MMBeehive::set_out_main(const Ref<MMNodeUniversalProperty> &val) {
out_main = val; out_main = val;
} }
Ref<MMNodeUniversalProperty> MMBeehive::get_out_random_color() {
Ref<Resource> Beehive::get_out_random_color() { return out_random_color;
return out_random_color;
} }
void Beehive::set_out_random_color(const Ref<Resource> &val) { void MMBeehive::set_out_random_color(const Ref<MMNodeUniversalProperty> &val) {
out_random_color = val; out_random_color = val;
} }
Ref<MMNodeUniversalProperty> MMBeehive::get_out_uv_map() {
Ref<Resource> Beehive::get_out_uv_map() { return out_uv_map;
return out_uv_map;
} }
void Beehive::set_out_uv_map(const Ref<Resource> &val) { void MMBeehive::set_out_uv_map(const Ref<MMNodeUniversalProperty> &val) {
out_uv_map = val; out_uv_map = val;
} }
Vector2 MMBeehive::get_size() {
Vector2 Beehive::get_size() { return size;
return size;
} }
void Beehive::set_size(const Vector2 &val) { void MMBeehive::set_size(const Vector2 &val) {
size = val; size = val;
set_dirty(true);
} }
void MMBeehive::_init_properties() {
if (!out_main.is_valid()) {
out_main.instance();
out_main->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
out_main->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//tool; if (!out_random_color.is_valid()) {
//export(Resource) ; out_random_color.instance();
Ref<Resource> out_main; out_random_color->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
//export(Resource) ; }
Ref<Resource> out_random_color;
//export(Resource) ;
Ref<Resource> out_uv_map;
//export(Vector2) ;
Vector2 size = Vector2(4, 4);
void Beehive::_init_properties() { out_random_color->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
if (!out_main) { if (!out_uv_map.is_valid()) {
out_main = MMNodeUniversalProperty.new(); out_uv_map.instance();
out_main.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE; out_uv_map->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
out_uv_map->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
register_output_property(out_main);
register_output_property(out_random_color);
register_output_property(out_uv_map);
} }
out_main.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; void MMBeehive::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_texture_universal(out_main);
if (!out_random_color) { mm_graph_node->add_slot_texture_universal(out_random_color);
out_random_color = MMNodeUniversalProperty.new(); mm_graph_node->add_slot_texture_universal(out_uv_map);
out_random_color.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE; //, Vector2(1, 32))//, Vector2(0, 32));
mm_graph_node->add_slot_vector2("get_size", "set_size", "Size");
} }
out_random_color.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; void MMBeehive::_render(const Ref<MMMaterial> &material) {
Ref<Image> main_pattern;
Ref<Image> random_color;
Ref<Image> uv_map;
if (!out_uv_map) { main_pattern.instance();
out_uv_map = MMNodeUniversalProperty.new(); random_color.instance();
out_uv_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE; uv_map.instance();
main_pattern->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
random_color->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
uv_map->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
main_pattern->lock();
random_color->lock();
uv_map->lock();
float w = material->image_size.x;
float h = material->image_size.y;
float pseed = Math::randf() + Math::rand();
for (int x = 0; x < material->image_size.x; ++x) { //x in range(material.image_size.x)
for (int y = 0; y < material->image_size.y; ++y) { //y in range(material.image_size.y)
Vector2 uv = Vector2(x / w, y / h);
float ps = 1.0 / float(pseed);
//vec2 $(name_uv)_uv = $uv*vec2($sx, $sy*1.73205080757);
//vec4 $(name_uv)_center = beehive_center($(name_uv)_uv);
Vector2 beehive_uv = uv * size;
Color beehive_uv_center = MMAlgos::beehive_center(beehive_uv);
//Output (float) - Shows the greyscale pattern;
//1.0-2.0*beehive_dist($(name_uv)_center.xy);
float f = 1.0 - 2.0 * MMAlgos::beehive_dist(Vector2(beehive_uv_center.r, beehive_uv_center.g));
Color main_pattern_col = Color(f, f, f, 1);
//Random color (rgb) - Shows a random color for each hexagonal tile;
//rand3(fract($(name_uv)_center.zw/vec2($sx, $sy))+vec2(float($seed)));
Vector3 rcv3 = MMAlgos::rand3(MMAlgos::fractv2(Vector2(beehive_uv_center.b, beehive_uv_center.a) / size) + Vector2(ps, ps));
Color random_color_col = Color(rcv3.x, rcv3.y, rcv3.z, 1);
//UV map (rgb) - Shows an UV map to be connected to the UV map port of the Custom UV node;
//vec3(vec2(0.5)+$(name_uv)_center.xy, rand(fract($(name_uv)_center.zw/vec2($sx, $sy))+vec2(float($seed))));
Vector2 uvm1 = Vector2(0.5, 0.5) + Vector2(beehive_uv_center.r, beehive_uv_center.g);
Vector2 uvm2 = MMAlgos::rand2(MMAlgos::fractv2(Vector2(beehive_uv_center.b, beehive_uv_center.a) / size) + Vector2(ps, ps));
Color uv_map_col = Color(uvm1.x, uvm1.y, uvm2.x, 1);
main_pattern->set_pixel(x, y, main_pattern_col);
random_color->set_pixel(x, y, random_color_col);
uv_map->set_pixel(x, y, uv_map_col);
}
}
main_pattern->unlock();
random_color->unlock();
uv_map->unlock();
out_main->set_value(main_pattern);
out_random_color->set_value(random_color);
out_uv_map->set_value(uv_map);
} }
out_uv_map.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; Color MMBeehive::_get_value_for(const Vector2 &uv, const int pseed) {
register_output_property(out_main); return Color();
register_output_property(out_random_color);
register_output_property(out_uv_map);
} }
MMBeehive::MMBeehive() {
void Beehive::_register_methods(const Variant &mm_graph_node) { size = Vector2(4, 4);
mm_graph_node.add_slot_texture_universal(out_main);
mm_graph_node.add_slot_texture_universal(out_random_color);
mm_graph_node.add_slot_texture_universal(out_uv_map);
//, Vector2(1, 32))//, Vector2(0, 32));
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size");
} }
MMBeehive::~MMBeehive() {
void Beehive::_render(const Variant &material) {
Ref<Image> main_pattern = Image.new();
Ref<Image> random_color = Image.new();
Ref<Image> uv_map = Image.new();
main_pattern.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
random_color.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
uv_map.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
main_pattern.lock();
random_color.lock();
uv_map.lock();
float w = material.image_size.x;
float h = material.image_size.y;
float pseed = randf() + randi();
for (int x = 0; x < material.image_size.x; ++x) { //x in range(material.image_size.x)
for (int y = 0; y < material.image_size.y; ++y) { //y in range(material.image_size.y)
Vector2 uv = Vector2(x / w, y / h);
float ps = 1.0 / float(pseed);
//vec2 $(name_uv)_uv = $uv*vec2($sx, $sy*1.73205080757);
//vec4 $(name_uv)_center = beehive_center($(name_uv)_uv);
Vector2 beehive_uv = uv * size;
Color beehive_uv_center = MMAlgos.beehive_center(beehive_uv);
//Output (float) - Shows the greyscale pattern;
//1.0-2.0*beehive_dist($(name_uv)_center.xy);
float f = 1.0 - 2.0 * MMAlgos.beehive_dist(Vector2(beehive_uv_center.r, beehive_uv_center.g));
Color main_pattern_col = Color(f, f, f, 1);
//Random color (rgb) - Shows a random color for each hexagonal tile;
//rand3(fract($(name_uv)_center.zw/vec2($sx, $sy))+vec2(float($seed)));
Vector3 rcv3 = MMAlgos.rand3(MMAlgos.fractv2(Vector2(beehive_uv_center.b, beehive_uv_center.a) / size) + Vector2(ps, ps));
Color random_color_col = Color(rcv3.x, rcv3.y, rcv3.z, 1);
//UV map (rgb) - Shows an UV map to be connected to the UV map port of the Custom UV node;
//vec3(vec2(0.5)+$(name_uv)_center.xy, rand(fract($(name_uv)_center.zw/vec2($sx, $sy))+vec2(float($seed))));
Vector2 uvm1 = Vector2(0.5, 0.5) + Vector2(beehive_uv_center.r, beehive_uv_center.g);
Vector2 uvm2 = MMAlgos.rand2(MMAlgos.fractv2(Vector2(beehive_uv_center.b, beehive_uv_center.a) / size) + Vector2(ps, ps));
Color uv_map_col = Color(uvm1.x, uvm1.y, uvm2.x, 1);
main_pattern.set_pixel(x, y, main_pattern_col);
random_color.set_pixel(x, y, random_color_col);
uv_map.set_pixel(x, y, uv_map_col);
} }
void MMBeehive::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_out_main"), &MMBeehive::get_out_main);
ClassDB::bind_method(D_METHOD("set_out_main", "value"), &MMBeehive::set_out_main);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_main", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_main", "get_out_main");
ClassDB::bind_method(D_METHOD("get_out_random_color"), &MMBeehive::get_out_random_color);
ClassDB::bind_method(D_METHOD("set_out_random_color", "value"), &MMBeehive::set_out_random_color);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_random_color", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_random_color", "get_out_random_color");
ClassDB::bind_method(D_METHOD("get_out_uv_map"), &MMBeehive::get_out_uv_map);
ClassDB::bind_method(D_METHOD("set_out_uv_map", "value"), &MMBeehive::set_out_uv_map);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_uv_map", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_uv_map", "get_out_uv_map");
ClassDB::bind_method(D_METHOD("get_size"), &MMBeehive::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &MMBeehive::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
} }
main_pattern.unlock();
random_color.unlock();
uv_map.unlock();
out_main.set_value(main_pattern);
out_random_color.set_value(random_color);
out_uv_map.set_value(uv_map);
}
Color Beehive::_get_value_for(const Vector2 &uv, const int pseed) {
return Color();
}
//size;
Vector2 Beehive::get_size() {
return size;
}
void Beehive::set_size(const Vector2 &val) {
size = val;
set_dirty(true);
}
}
Beehive::Beehive() {
out_main;
out_random_color;
out_uv_map;
size = Vector2(4, 4);
}
Beehive::~Beehive() {
}
static void Beehive::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_out_main"), &Beehive::get_out_main);
ClassDB::bind_method(D_METHOD("set_out_main", "value"), &Beehive::set_out_main);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_main", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_main", "get_out_main");
ClassDB::bind_method(D_METHOD("get_out_random_color"), &Beehive::get_out_random_color);
ClassDB::bind_method(D_METHOD("set_out_random_color", "value"), &Beehive::set_out_random_color);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_random_color", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_random_color", "get_out_random_color");
ClassDB::bind_method(D_METHOD("get_out_uv_map"), &Beehive::get_out_uv_map);
ClassDB::bind_method(D_METHOD("set_out_uv_map", "value"), &Beehive::set_out_uv_map);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_uv_map", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_uv_map", "get_out_uv_map");
ClassDB::bind_method(D_METHOD("get_size"), &Beehive::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &Beehive::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("_init_properties"), &Beehive::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Beehive::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Beehive::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Beehive::_get_value_for);
ClassDB::bind_method(D_METHOD("get_size"), &Beehive::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &Beehive::set_size);
}

View File

@ -1,48 +1,40 @@
#ifndef BEEHIVE_H #ifndef MM_BEEHIVE_H
#define BEEHIVE_H #define MM_BEEHIVE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Beehive : public MMNode { class MMBeehive : public MMNode {
GDCLASS(Beehive, MMNode); GDCLASS(MMBeehive, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_out_main();
void set_out_main(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_main(); Ref<MMNodeUniversalProperty> get_out_random_color();
void set_out_main(const Ref<Resource> &val); void set_out_random_color(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_random_color(); Ref<MMNodeUniversalProperty> get_out_uv_map();
void set_out_random_color(const Ref<Resource> &val); void set_out_uv_map(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_uv_map(); Vector2 get_size();
void set_out_uv_map(const Ref<Resource> &val); void set_size(const Vector2 &val);
Vector2 get_size(); void _init_properties();
void set_size(const Vector2 &val); void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties(); MMBeehive();
void _register_methods(const Variant &mm_graph_node); ~MMBeehive();
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
Vector2 get_size();
void set_size(const Vector2 &val);
Beehive(); protected:
~Beehive(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> out_main;
static void _bind_methods(); Ref<MMNodeUniversalProperty> out_random_color;
Ref<MMNodeUniversalProperty> out_uv_map;
//tool Vector2 size;
//export(Resource)
Ref<Resource> out_main;
//export(Resource)
Ref<Resource> out_random_color;
//export(Resource)
Ref<Resource> out_uv_map;
//export(Vector2)
Vector2 size = Vector2(4, 4);
//size
}; };
#endif #endif

View File

@ -1,584 +1,441 @@
#include "bricks.h" #include "bricks.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Bricks::get_out_bricks_pattern() { Ref<MMNodeUniversalProperty> MMBricks::get_out_bricks_pattern() {
return out_bricks_pattern; return out_bricks_pattern;
} }
void Bricks::set_out_bricks_pattern(const Ref<Resource> &val) { void MMBricks::set_out_bricks_pattern(const Ref<MMNodeUniversalProperty> &val) {
out_bricks_pattern = val; out_bricks_pattern = val;
} }
Ref<MMNodeUniversalProperty> MMBricks::get_out_random_color() {
Ref<Resource> Bricks::get_out_random_color() { return out_random_color;
return out_random_color;
} }
void Bricks::set_out_random_color(const Ref<Resource> &val) { void MMBricks::set_out_random_color(const Ref<MMNodeUniversalProperty> &val) {
out_random_color = val; out_random_color = val;
} }
Ref<MMNodeUniversalProperty> MMBricks::get_out_position_x() {
Ref<Resource> Bricks::get_out_position_x() { return out_position_x;
return out_position_x;
} }
void Bricks::set_out_position_x(const Ref<Resource> &val) { void MMBricks::set_out_position_x(const Ref<MMNodeUniversalProperty> &val) {
out_position_x = val; out_position_x = val;
} }
Ref<MMNodeUniversalProperty> MMBricks::get_out_position_y() {
Ref<Resource> Bricks::get_out_position_y() { return out_position_y;
return out_position_y;
} }
void Bricks::set_out_position_y(const Ref<Resource> &val) { void MMBricks::set_out_position_y(const Ref<MMNodeUniversalProperty> &val) {
out_position_y = val; out_position_y = val;
} }
Ref<MMNodeUniversalProperty> MMBricks::get_out_brick_uv() {
Ref<Resource> Bricks::get_out_brick_uv() { return out_brick_uv;
return out_brick_uv;
} }
void Bricks::set_out_brick_uv(const Ref<Resource> &val) { void MMBricks::set_out_brick_uv(const Ref<MMNodeUniversalProperty> &val) {
out_brick_uv = val; out_brick_uv = val;
} }
Ref<MMNodeUniversalProperty> MMBricks::get_out_corner_uv() {
Ref<Resource> Bricks::get_out_corner_uv() { return out_corner_uv;
return out_corner_uv;
} }
void Bricks::set_out_corner_uv(const Ref<Resource> &val) { void MMBricks::set_out_corner_uv(const Ref<MMNodeUniversalProperty> &val) {
out_corner_uv = val; out_corner_uv = val;
} }
Ref<MMNodeUniversalProperty> MMBricks::get_out_direction() {
Ref<Resource> Bricks::get_out_direction() { return out_direction;
return out_direction;
} }
void Bricks::set_out_direction(const Ref<Resource> &val) { void MMBricks::set_out_direction(const Ref<MMNodeUniversalProperty> &val) {
out_direction = val; out_direction = val;
} }
int MMBricks::get_type() const {
int Bricks::get_type() const { return type;
return type;
} }
void Bricks::set_type(const int val) { void MMBricks::set_type(const int val) {
type = val; type = val;
set_dirty(true);
} }
int MMBricks::get_repeat() const {
int Bricks::get_repeat() const { return repeat;
return repeat;
} }
void Bricks::set_repeat(const int val) { void MMBricks::set_repeat(const int val) {
repeat = val; repeat = val;
set_dirty(true);
} }
Vector2 MMBricks::get_col_row() {
Vector2 Bricks::get_col_row() { return col_row;
return col_row;
} }
void Bricks::set_col_row(const Vector2 &val) { void MMBricks::set_col_row(const Vector2 &val) {
col_row = val; col_row = val;
set_dirty(true);
} }
float MMBricks::get_offset() const {
float Bricks::get_offset() const { return offset;
return offset;
} }
void Bricks::set_offset(const float val) { void MMBricks::set_offset(const float val) {
offset = val; offset = val;
set_dirty(true);
} }
Ref<MMNodeUniversalProperty> MMBricks::get_mortar() {
Ref<Resource> Bricks::get_mortar() { return mortar;
return mortar;
} }
void Bricks::set_mortar(const Ref<Resource> &val) { void MMBricks::set_mortar(const Ref<MMNodeUniversalProperty> &val) {
mortar = val; mortar = val;
} }
Ref<MMNodeUniversalProperty> MMBricks::get_bevel() {
Ref<Resource> Bricks::get_bevel() { return bevel;
return bevel;
} }
void Bricks::set_bevel(const Ref<Resource> &val) { void MMBricks::set_bevel(const Ref<MMNodeUniversalProperty> &val) {
bevel = val; bevel = val;
} }
Ref<MMNodeUniversalProperty> MMBricks::get_roundness() {
Ref<Resource> Bricks::get_roundness() { return roundness;
return roundness;
} }
void Bricks::set_roundness(const Ref<Resource> &val) { void MMBricks::set_roundness(const Ref<MMNodeUniversalProperty> &val) {
roundness = val; roundness = val;
} }
float MMBricks::get_corner() const {
float Bricks::get_corner() const { return corner;
return corner;
} }
void Bricks::set_corner(const float val) { void MMBricks::set_corner(const float val) {
corner = val; corner = val;
set_dirty(true);
} }
void MMBricks::_init_properties() {
if (!out_bricks_pattern.is_valid()) {
out_bricks_pattern.instance();
out_bricks_pattern->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
out_bricks_pattern->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//tool; if (!out_random_color.is_valid()) {
//export(Resource) ; out_random_color.instance();
Ref<Resource> out_bricks_pattern; out_random_color->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
//export(Resource) ; }
Ref<Resource> out_random_color;
//export(Resource) ;
Ref<Resource> out_position_x;
//export(Resource) ;
Ref<Resource> out_position_y;
//export(Resource) ;
Ref<Resource> out_brick_uv;
//export(Resource) ;
Ref<Resource> out_corner_uv;
//export(Resource) ;
Ref<Resource> out_direction;
//export(int, "Running Bond,Running Bond (2),HerringBone,Basket Weave,Spanish Bond") ;
int type = 0;
//export(int) ;
int repeat = 1;
//export(Vector2) ;
Vector2 col_row = Vector2(4, 4);
//export(float) ;
float offset = 0.5;
//export(Resource) ;
Ref<Resource> mortar;
//export(Resource) ;
Ref<Resource> bevel;
//export(Resource) ;
Ref<Resource> roundness;
//export(float) ;
float corner = 0.3;
void Bricks::_init_properties() { out_random_color->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
if (!out_bricks_pattern) { if (!out_position_x.is_valid()) {
out_bricks_pattern = MMNodeUniversalProperty.new(); out_position_x.instance();
out_bricks_pattern.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE; out_position_x->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
out_position_x->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
if (!out_position_y.is_valid()) {
out_position_y.instance();
out_position_y->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
out_position_y->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
if (!out_brick_uv.is_valid()) {
out_brick_uv.instance();
out_brick_uv->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
out_brick_uv->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
if (!out_corner_uv.is_valid()) {
out_corner_uv.instance();
out_corner_uv->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
out_corner_uv->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
if (!out_direction.is_valid()) {
out_direction.instance();
out_direction->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
out_direction->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
if (!mortar.is_valid()) {
mortar.instance();
mortar->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
mortar->set_default_value(0.1);
}
mortar->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
mortar->set_slot_name("Mortar");
mortar->set_value_step(0.01);
mortar->set_value_range(Vector2(0, 0.5));
if (!bevel.is_valid()) {
bevel.instance();
bevel->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
bevel->set_default_value(0.1);
}
bevel->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
bevel->set_slot_name("Bevel");
bevel->set_value_step(0.01);
bevel->set_value_range(Vector2(0, 0.5));
if (!roundness.is_valid()) {
roundness.instance();
roundness->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
roundness->set_default_value(0.1);
}
roundness->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
roundness->set_slot_name("Roundness");
roundness->set_value_step(0.01);
roundness->set_value_range(Vector2(0, 0.5));
register_output_property(out_bricks_pattern);
register_output_property(out_random_color);
register_output_property(out_position_x);
register_output_property(out_position_y);
register_output_property(out_brick_uv);
register_output_property(out_corner_uv);
register_output_property(out_direction);
register_input_property(mortar);
register_input_property(bevel);
register_input_property(roundness);
} }
out_bricks_pattern.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; void MMBricks::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_texture_universal(out_bricks_pattern);
mm_graph_node->add_slot_texture_universal(out_random_color);
mm_graph_node->add_slot_texture_universal(out_position_x);
mm_graph_node->add_slot_texture_universal(out_position_y);
mm_graph_node->add_slot_texture_universal(out_brick_uv);
mm_graph_node->add_slot_texture_universal(out_corner_uv);
mm_graph_node->add_slot_texture_universal(out_direction);
if (!out_random_color) { Array arr;
out_random_color = MMNodeUniversalProperty.new(); arr.push_back("Running Bond");
out_random_color.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE; arr.push_back("Running Bond (2)");
arr.push_back("HerringBone");
arr.push_back("Basket Weave");
arr.push_back("Spanish Bond");
mm_graph_node->add_slot_enum("get_type", "set_type", "Type", arr);
mm_graph_node->add_slot_int("get_repeat", "set_repeat", "Repeat");
//, Vector2(1, 32))//, Vector2(0, 32));
mm_graph_node->add_slot_vector2("get_col_row", "set_col_row", "Col, Row");
mm_graph_node->add_slot_float("get_offset", "set_offset", "Offset");
mm_graph_node->add_slot_float_universal(mortar);
mm_graph_node->add_slot_float_universal(bevel);
mm_graph_node->add_slot_float_universal(roundness);
mm_graph_node->add_slot_float("get_corner", "set_corner", "Corner");
} }
out_random_color.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; void MMBricks::_render(const Ref<MMMaterial> &material) {
Ref<Image> bricks_pattern;
Ref<Image> random_color;
Ref<Image> position_x;
Ref<Image> position_y;
Ref<Image> brick_uv;
Ref<Image> corner_uv;
Ref<Image> direction;
if (!out_position_x) { bricks_pattern.instance();
out_position_x = MMNodeUniversalProperty.new(); random_color.instance();
out_position_x.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE; position_x.instance();
position_y.instance();
brick_uv.instance();
corner_uv.instance();
direction.instance();
bricks_pattern->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
random_color->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
position_x->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
position_y->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
brick_uv->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
corner_uv->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
direction->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
bricks_pattern->lock();
random_color->lock();
position_x->lock();
position_y->lock();
brick_uv->lock();
corner_uv->lock();
direction->lock();
float w = material->image_size.x;
float h = material->image_size.y;
float pseed = Math::randf() + Math::rand();
for (int x = 0; x < material->image_size.x; ++x) { //x in range(material.image_size.x)
for (int y = 0; y < material->image_size.y; ++y) { //y in range(material.image_size.y)
Vector2 uv = Vector2(x / w, y / h);
//vec4 $(name_uv)_rect = bricks_$pattern($uv, vec2($columns, $rows), $repeat, $row_offset);
Color brick_rect = Color();
//"Running Bond,Running Bond (2),HerringBone,Basket Weave,Spanish Bond";
if (type == 0) {
brick_rect = MMAlgos::bricks_rb(uv, col_row, repeat, offset);
} else if (type == 1) {
brick_rect = MMAlgos::bricks_rb2(uv, col_row, repeat, offset);
} else if (type == 2) {
brick_rect = MMAlgos::bricks_hb(uv, col_row, repeat, offset);
} else if (type == 3) {
brick_rect = MMAlgos::bricks_bw(uv, col_row, repeat, offset);
} else if (type == 4) {
brick_rect = MMAlgos::bricks_sb(uv, col_row, repeat, offset);
}
//vec4 $(name_uv) = brick($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $round*$round_map($uv), max(0.001, $bevel*$bevel_map($uv)));
Color brick = MMAlgos::brick(uv, Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), mortar->get_value(uv), roundness->get_value(uv), MAX(0.001, float(bevel->get_value(uv))));
//MMBricks pattern (float) - A greyscale image that shows the bricks pattern;
//$(name_uv).x;
Color bricks_pattern_col = Color(brick.r, brick.r, brick.r, 1);
//Random color (rgb) - A random color for each brick;
//brick_random_color($(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed));
Vector3 brc = MMAlgos::brick_random_color(Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), 1 / float(pseed));
Color random_color_col = Color(brc.x, brc.y, brc.z, 1);
//Position.x (float) - The position of each brick along the X axis",;
//$(name_uv).y;
Color position_x_col = Color(brick.g, brick.g, brick.g, 1);
//Position.y (float) - The position of each brick along the Y axis;
//$(name_uv).z;
Color position_y_col = Color(brick.b, brick.b, brick.b, 1);
//Brick UV (rgb) - An UV map output for each brick, to be connected to the Map input of a CustomUV node;
//brick_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed));
Vector3 buv = MMAlgos::brick_uv(uv, Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), pseed);
Color brick_uv_col = Color(buv.x, buv.y, buv.z, 1);
//Corner UV (rgb) - An UV map output for each brick corner, to be connected to the Map input of a CustomUV node;
//brick_corner_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $corner, float($seed));
Vector3 bcuv = MMAlgos::brick_corner_uv(uv, Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), mortar->get_value(uv), corner, pseed);
Color corner_uv_col = Color(bcuv.x, bcuv.y, bcuv.z, 1);
//Direction (float) - The direction of each brick (white: horizontal, black: vertical);
//0.5*(sign($(name_uv)_rect.z-$(name_uv)_rect.x-$(name_uv)_rect.w+$(name_uv)_rect.y)+1.0);
float d = 0.5 * (SGN(brick_rect.b - brick_rect.r - brick_rect.a + brick_rect.g) + 1.0);
Color direction_col = Color(d, d, d, 1);
bricks_pattern->set_pixel(x, y, bricks_pattern_col);
random_color->set_pixel(x, y, random_color_col);
position_x->set_pixel(x, y, position_x_col);
position_y->set_pixel(x, y, position_y_col);
brick_uv->set_pixel(x, y, brick_uv_col);
corner_uv->set_pixel(x, y, corner_uv_col);
direction->set_pixel(x, y, direction_col);
}
}
bricks_pattern->unlock();
random_color->unlock();
position_x->unlock();
position_y->unlock();
brick_uv->unlock();
corner_uv->unlock();
direction->unlock();
out_bricks_pattern->set_value(bricks_pattern);
out_random_color->set_value(random_color);
out_position_x->set_value(position_x);
out_position_y->set_value(position_y);
out_brick_uv->set_value(brick_uv);
out_corner_uv->set_value(corner_uv);
out_direction->set_value(direction);
} }
out_position_x.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; Color MMBricks::_get_value_for(const Vector2 &uv, const int pseed) {
return Color();
if (!out_position_y) {
out_position_y = MMNodeUniversalProperty.new();
out_position_y.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
} }
out_position_y.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; MMBricks::MMBricks() {
type = 0;
if (!out_brick_uv) { repeat = 1;
out_brick_uv = MMNodeUniversalProperty.new(); col_row = Vector2(4, 4);
out_brick_uv.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE; offset = 0.5;
corner = 0.3;
} }
out_brick_uv.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; MMBricks::~MMBricks() {
if (!out_corner_uv) {
out_corner_uv = MMNodeUniversalProperty.new();
out_corner_uv.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
} }
out_corner_uv.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; void MMBricks::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_out_bricks_pattern"), &MMBricks::get_out_bricks_pattern);
ClassDB::bind_method(D_METHOD("set_out_bricks_pattern", "value"), &MMBricks::set_out_bricks_pattern);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_bricks_pattern", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_bricks_pattern", "get_out_bricks_pattern");
if (!out_direction) { ClassDB::bind_method(D_METHOD("get_out_random_color"), &MMBricks::get_out_random_color);
out_direction = MMNodeUniversalProperty.new(); ClassDB::bind_method(D_METHOD("set_out_random_color", "value"), &MMBricks::set_out_random_color);
out_direction.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE; ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_random_color", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_random_color", "get_out_random_color");
ClassDB::bind_method(D_METHOD("get_out_position_x"), &MMBricks::get_out_position_x);
ClassDB::bind_method(D_METHOD("set_out_position_x", "value"), &MMBricks::set_out_position_x);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_position_x", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_position_x", "get_out_position_x");
ClassDB::bind_method(D_METHOD("get_out_position_y"), &MMBricks::get_out_position_y);
ClassDB::bind_method(D_METHOD("set_out_position_y", "value"), &MMBricks::set_out_position_y);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_position_y", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_position_y", "get_out_position_y");
ClassDB::bind_method(D_METHOD("get_out_brick_uv"), &MMBricks::get_out_brick_uv);
ClassDB::bind_method(D_METHOD("set_out_brick_uv", "value"), &MMBricks::set_out_brick_uv);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_brick_uv", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_brick_uv", "get_out_brick_uv");
ClassDB::bind_method(D_METHOD("get_out_corner_uv"), &MMBricks::get_out_corner_uv);
ClassDB::bind_method(D_METHOD("set_out_corner_uv", "value"), &MMBricks::set_out_corner_uv);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_corner_uv", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_corner_uv", "get_out_corner_uv");
ClassDB::bind_method(D_METHOD("get_out_direction"), &MMBricks::get_out_direction);
ClassDB::bind_method(D_METHOD("set_out_direction", "value"), &MMBricks::set_out_direction);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_direction", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_direction", "get_out_direction");
ClassDB::bind_method(D_METHOD("get_type"), &MMBricks::get_type);
ClassDB::bind_method(D_METHOD("set_type", "value"), &MMBricks::set_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "type"), "set_type", "get_type");
ClassDB::bind_method(D_METHOD("get_repeat"), &MMBricks::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "value"), &MMBricks::set_repeat);
ADD_PROPERTY(PropertyInfo(Variant::INT, "repeat"), "set_repeat", "get_repeat");
ClassDB::bind_method(D_METHOD("get_col_row"), &MMBricks::get_col_row);
ClassDB::bind_method(D_METHOD("set_col_row", "value"), &MMBricks::set_col_row);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "col_row"), "set_col_row", "get_col_row");
ClassDB::bind_method(D_METHOD("get_offset"), &MMBricks::get_offset);
ClassDB::bind_method(D_METHOD("set_offset", "value"), &MMBricks::set_offset);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset"), "set_offset", "get_offset");
ClassDB::bind_method(D_METHOD("get_mortar"), &MMBricks::get_mortar);
ClassDB::bind_method(D_METHOD("set_mortar", "value"), &MMBricks::set_mortar);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mortar", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_mortar", "get_mortar");
ClassDB::bind_method(D_METHOD("get_bevel"), &MMBricks::get_bevel);
ClassDB::bind_method(D_METHOD("set_bevel", "value"), &MMBricks::set_bevel);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "bevel", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_bevel", "get_bevel");
ClassDB::bind_method(D_METHOD("get_roundness"), &MMBricks::get_roundness);
ClassDB::bind_method(D_METHOD("set_roundness", "value"), &MMBricks::set_roundness);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "roundness", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_roundness", "get_roundness");
ClassDB::bind_method(D_METHOD("get_corner"), &MMBricks::get_corner);
ClassDB::bind_method(D_METHOD("set_corner", "value"), &MMBricks::set_corner);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "corner"), "set_corner", "get_corner");
} }
out_direction.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!mortar) {
mortar = MMNodeUniversalProperty.new();
mortar.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
mortar.set_default_value(0.1);
}
mortar.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
mortar.slot_name = "Mortar";
mortar.value_step = 0.01;
mortar.value_range = Vector2(0, 0.5);
if (!bevel) {
bevel = MMNodeUniversalProperty.new();
bevel.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
bevel.set_default_value(0.1);
}
bevel.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
bevel.slot_name = "Bevel";
bevel.value_step = 0.01;
bevel.value_range = Vector2(0, 0.5);
if (!roundness) {
roundness = MMNodeUniversalProperty.new();
roundness.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
roundness.set_default_value(0.1);
}
roundness.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
roundness.slot_name = "Roundness";
roundness.value_step = 0.01;
roundness.value_range = Vector2(0, 0.5);
register_output_property(out_bricks_pattern);
register_output_property(out_random_color);
register_output_property(out_position_x);
register_output_property(out_position_y);
register_output_property(out_brick_uv);
register_output_property(out_corner_uv);
register_output_property(out_direction);
register_input_property(mortar);
register_input_property(bevel);
register_input_property(roundness);
}
void Bricks::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(out_bricks_pattern);
mm_graph_node.add_slot_texture_universal(out_random_color);
mm_graph_node.add_slot_texture_universal(out_position_x);
mm_graph_node.add_slot_texture_universal(out_position_y);
mm_graph_node.add_slot_texture_universal(out_brick_uv);
mm_graph_node.add_slot_texture_universal(out_corner_uv);
mm_graph_node.add_slot_texture_universal(out_direction);
mm_graph_node.add_slot_enum("get_type", "set_type", "Type", [ "Running Bond", "Running Bond (2)", "HerringBone", "Basket Weave", "Spanish Bond" ]);
mm_graph_node.add_slot_int("get_repeat", "set_repeat", "Repeat");
//, Vector2(1, 32))//, Vector2(0, 32));
mm_graph_node.add_slot_vector2("get_col_row", "set_col_row", "Col, Row");
mm_graph_node.add_slot_float("get_offset", "set_offset", "Offset");
mm_graph_node.add_slot_float_universal(mortar);
mm_graph_node.add_slot_float_universal(bevel);
mm_graph_node.add_slot_float_universal(roundness);
mm_graph_node.add_slot_float("get_corner", "set_corner", "Corner");
}
void Bricks::_render(const Variant &material) {
Ref<Image> bricks_pattern = Image.new();
Ref<Image> random_color = Image.new();
Ref<Image> position_x = Image.new();
Ref<Image> position_y = Image.new();
Ref<Image> brick_uv = Image.new();
Ref<Image> corner_uv = Image.new();
Ref<Image> direction = Image.new();
bricks_pattern.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
random_color.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
position_x.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
position_y.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
brick_uv.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
corner_uv.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
direction.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
bricks_pattern.lock();
random_color.lock();
position_x.lock();
position_y.lock();
brick_uv.lock();
corner_uv.lock();
direction.lock();
float w = material.image_size.x;
float h = material.image_size.y;
float pseed = randf() + randi();
for (int x = 0; x < material.image_size.x; ++x) { //x in range(material.image_size.x)
for (int y = 0; y < material.image_size.y; ++y) { //y in range(material.image_size.y)
Vector2 uv = Vector2(x / w, y / h);
//vec4 $(name_uv)_rect = bricks_$pattern($uv, vec2($columns, $rows), $repeat, $row_offset);
Color brick_rect = Color();
//"Running Bond,Running Bond (2),HerringBone,Basket Weave,Spanish Bond";
if (type == 0) {
brick_rect = MMAlgos.bricks_rb(uv, col_row, repeat, offset);
}
else if (type == 1) {
brick_rect = MMAlgos.bricks_rb2(uv, col_row, repeat, offset);
}
else if (type == 2) {
brick_rect = MMAlgos.bricks_hb(uv, col_row, repeat, offset);
}
else if (type == 3) {
brick_rect = MMAlgos.bricks_bw(uv, col_row, repeat, offset);
}
else if (type == 4) {
brick_rect = MMAlgos.bricks_sb(uv, col_row, repeat, offset);
}
//vec4 $(name_uv) = brick($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $round*$round_map($uv), max(0.001, $bevel*$bevel_map($uv)));
Color brick = MMAlgos.brick(uv, Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), mortar.get_value(uv), roundness.get_value(uv), max(0.001, bevel.get_value(uv)));
//Bricks pattern (float) - A greyscale image that shows the bricks pattern;
//$(name_uv).x;
Color bricks_pattern_col = Color(brick.r, brick.r, brick.r, 1);
//Random color (rgb) - A random color for each brick;
//brick_random_color($(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed));
Vector3 brc = MMAlgos.brick_random_color(Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), 1 / float(pseed));
Color random_color_col = Color(brc.x, brc.y, brc.z, 1);
//Position.x (float) - The position of each brick along the X axis",;
//$(name_uv).y;
Color position_x_col = Color(brick.g, brick.g, brick.g, 1);
//Position.y (float) - The position of each brick along the Y axis;
//$(name_uv).z;
Color position_y_col = Color(brick.b, brick.b, brick.b, 1);
//Brick UV (rgb) - An UV map output for each brick, to be connected to the Map input of a CustomUV node;
//brick_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed));
Vector3 buv = MMAlgos.brick_uv(uv, Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), pseed);
Color brick_uv_col = Color(buv.x, buv.y, buv.z, 1);
//Corner UV (rgb) - An UV map output for each brick corner, to be connected to the Map input of a CustomUV node;
//brick_corner_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $corner, float($seed));
Vector3 bcuv = MMAlgos.brick_corner_uv(uv, Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), mortar.get_value(uv), corner, pseed);
Color corner_uv_col = Color(bcuv.x, bcuv.y, bcuv.z, 1);
//Direction (float) - The direction of each brick (white: horizontal, black: vertical);
//0.5*(sign($(name_uv)_rect.z-$(name_uv)_rect.x-$(name_uv)_rect.w+$(name_uv)_rect.y)+1.0);
float d = 0.5 * (sign(brick_rect.b - brick_rect.r - brick_rect.a + brick_rect.g) + 1.0);
Color direction_col = Color(d, d, d, 1);
bricks_pattern.set_pixel(x, y, bricks_pattern_col);
random_color.set_pixel(x, y, random_color_col);
position_x.set_pixel(x, y, position_x_col);
position_y.set_pixel(x, y, position_y_col);
brick_uv.set_pixel(x, y, brick_uv_col);
corner_uv.set_pixel(x, y, corner_uv_col);
direction.set_pixel(x, y, direction_col);
}
}
bricks_pattern.unlock();
random_color.unlock();
position_x.unlock();
position_y.unlock();
brick_uv.unlock();
corner_uv.unlock();
direction.unlock();
out_bricks_pattern.set_value(bricks_pattern);
out_random_color.set_value(random_color);
out_position_x.set_value(position_x);
out_position_y.set_value(position_y);
out_brick_uv.set_value(brick_uv);
out_corner_uv.set_value(corner_uv);
out_direction.set_value(direction);
}
Color Bricks::_get_value_for(const Vector2 &uv, const int pseed) {
return Color();
}
//type;
int Bricks::get_type() {
return type;
}
void Bricks::set_type(const int val) {
type = val;
set_dirty(true);
}
//repeat;
int Bricks::get_repeat() {
return repeat;
}
void Bricks::set_repeat(const int val) {
repeat = val;
set_dirty(true);
}
//col_row;
Vector2 Bricks::get_col_row() {
return col_row;
}
void Bricks::set_col_row(const Vector2 &val) {
col_row = val;
set_dirty(true);
}
//offset;
float Bricks::get_offset() {
return offset;
}
void Bricks::set_offset(const float val) {
offset = val;
set_dirty(true);
}
//corner;
float Bricks::get_corner() {
return corner;
}
void Bricks::set_corner(const float val) {
corner = val;
set_dirty(true);
}
}
Bricks::Bricks() {
out_bricks_pattern;
out_random_color;
out_position_x;
out_position_y;
out_brick_uv;
out_corner_uv;
out_direction;
type = 0;
repeat = 1;
col_row = Vector2(4, 4);
offset = 0.5;
mortar;
bevel;
roundness;
corner = 0.3;
}
Bricks::~Bricks() {
}
static void Bricks::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_out_bricks_pattern"), &Bricks::get_out_bricks_pattern);
ClassDB::bind_method(D_METHOD("set_out_bricks_pattern", "value"), &Bricks::set_out_bricks_pattern);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_bricks_pattern", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_bricks_pattern", "get_out_bricks_pattern");
ClassDB::bind_method(D_METHOD("get_out_random_color"), &Bricks::get_out_random_color);
ClassDB::bind_method(D_METHOD("set_out_random_color", "value"), &Bricks::set_out_random_color);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_random_color", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_random_color", "get_out_random_color");
ClassDB::bind_method(D_METHOD("get_out_position_x"), &Bricks::get_out_position_x);
ClassDB::bind_method(D_METHOD("set_out_position_x", "value"), &Bricks::set_out_position_x);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_position_x", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_position_x", "get_out_position_x");
ClassDB::bind_method(D_METHOD("get_out_position_y"), &Bricks::get_out_position_y);
ClassDB::bind_method(D_METHOD("set_out_position_y", "value"), &Bricks::set_out_position_y);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_position_y", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_position_y", "get_out_position_y");
ClassDB::bind_method(D_METHOD("get_out_brick_uv"), &Bricks::get_out_brick_uv);
ClassDB::bind_method(D_METHOD("set_out_brick_uv", "value"), &Bricks::set_out_brick_uv);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_brick_uv", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_brick_uv", "get_out_brick_uv");
ClassDB::bind_method(D_METHOD("get_out_corner_uv"), &Bricks::get_out_corner_uv);
ClassDB::bind_method(D_METHOD("set_out_corner_uv", "value"), &Bricks::set_out_corner_uv);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_corner_uv", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_corner_uv", "get_out_corner_uv");
ClassDB::bind_method(D_METHOD("get_out_direction"), &Bricks::get_out_direction);
ClassDB::bind_method(D_METHOD("set_out_direction", "value"), &Bricks::set_out_direction);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_direction", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_direction", "get_out_direction");
ClassDB::bind_method(D_METHOD("get_type"), &Bricks::get_type);
ClassDB::bind_method(D_METHOD("set_type", "value"), &Bricks::set_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "type"), "set_type", "get_type");
ClassDB::bind_method(D_METHOD("get_repeat"), &Bricks::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "value"), &Bricks::set_repeat);
ADD_PROPERTY(PropertyInfo(Variant::INT, "repeat"), "set_repeat", "get_repeat");
ClassDB::bind_method(D_METHOD("get_col_row"), &Bricks::get_col_row);
ClassDB::bind_method(D_METHOD("set_col_row", "value"), &Bricks::set_col_row);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "col_row"), "set_col_row", "get_col_row");
ClassDB::bind_method(D_METHOD("get_offset"), &Bricks::get_offset);
ClassDB::bind_method(D_METHOD("set_offset", "value"), &Bricks::set_offset);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset"), "set_offset", "get_offset");
ClassDB::bind_method(D_METHOD("get_mortar"), &Bricks::get_mortar);
ClassDB::bind_method(D_METHOD("set_mortar", "value"), &Bricks::set_mortar);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mortar", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_mortar", "get_mortar");
ClassDB::bind_method(D_METHOD("get_bevel"), &Bricks::get_bevel);
ClassDB::bind_method(D_METHOD("set_bevel", "value"), &Bricks::set_bevel);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "bevel", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_bevel", "get_bevel");
ClassDB::bind_method(D_METHOD("get_roundness"), &Bricks::get_roundness);
ClassDB::bind_method(D_METHOD("set_roundness", "value"), &Bricks::set_roundness);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "roundness", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_roundness", "get_roundness");
ClassDB::bind_method(D_METHOD("get_corner"), &Bricks::get_corner);
ClassDB::bind_method(D_METHOD("set_corner", "value"), &Bricks::set_corner);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "corner"), "set_corner", "get_corner");
ClassDB::bind_method(D_METHOD("_init_properties"), &Bricks::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Bricks::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Bricks::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Bricks::_get_value_for);
ClassDB::bind_method(D_METHOD("get_type"), &Bricks::get_type);
ClassDB::bind_method(D_METHOD("set_type", "val"), &Bricks::set_type);
ClassDB::bind_method(D_METHOD("get_repeat"), &Bricks::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "val"), &Bricks::set_repeat);
ClassDB::bind_method(D_METHOD("get_col_row"), &Bricks::get_col_row);
ClassDB::bind_method(D_METHOD("set_col_row", "val"), &Bricks::set_col_row);
ClassDB::bind_method(D_METHOD("get_offset"), &Bricks::get_offset);
ClassDB::bind_method(D_METHOD("set_offset", "val"), &Bricks::set_offset);
ClassDB::bind_method(D_METHOD("get_corner"), &Bricks::get_corner);
ClassDB::bind_method(D_METHOD("set_corner", "val"), &Bricks::set_corner);
}

View File

@ -1,115 +1,85 @@
#ifndef BRICKS_H #ifndef MM_BRICKS_H
#define BRICKS_H #define MM_BRICKS_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Bricks : public MMNode { class MMBricks : public MMNode {
GDCLASS(Bricks, MMNode); GDCLASS(MMBricks, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_out_bricks_pattern();
void set_out_bricks_pattern(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_bricks_pattern(); Ref<MMNodeUniversalProperty> get_out_random_color();
void set_out_bricks_pattern(const Ref<Resource> &val); void set_out_random_color(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_random_color(); Ref<MMNodeUniversalProperty> get_out_position_x();
void set_out_random_color(const Ref<Resource> &val); void set_out_position_x(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_position_x(); Ref<MMNodeUniversalProperty> get_out_position_y();
void set_out_position_x(const Ref<Resource> &val); void set_out_position_y(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_position_y(); Ref<MMNodeUniversalProperty> get_out_brick_uv();
void set_out_position_y(const Ref<Resource> &val); void set_out_brick_uv(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_brick_uv(); Ref<MMNodeUniversalProperty> get_out_corner_uv();
void set_out_brick_uv(const Ref<Resource> &val); void set_out_corner_uv(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_corner_uv(); Ref<MMNodeUniversalProperty> get_out_direction();
void set_out_corner_uv(const Ref<Resource> &val); void set_out_direction(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_direction(); int get_type() const;
void set_out_direction(const Ref<Resource> &val); void set_type(const int val);
int get_type() const; int get_repeat() const;
void set_type(const int val); void set_repeat(const int val);
int get_repeat() const; Vector2 get_col_row();
void set_repeat(const int val); void set_col_row(const Vector2 &val);
Vector2 get_col_row(); float get_offset() const;
void set_col_row(const Vector2 &val); void set_offset(const float val);
float get_offset() const; Ref<MMNodeUniversalProperty> get_mortar();
void set_offset(const float val); void set_mortar(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_mortar(); Ref<MMNodeUniversalProperty> get_bevel();
void set_mortar(const Ref<Resource> &val); void set_bevel(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_bevel(); Ref<MMNodeUniversalProperty> get_roundness();
void set_bevel(const Ref<Resource> &val); void set_roundness(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_roundness(); float get_corner() const;
void set_roundness(const Ref<Resource> &val); void set_corner(const float val);
float get_corner() const; void _init_properties();
void set_corner(const float val); void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties(); MMBricks();
void _register_methods(const Variant &mm_graph_node); ~MMBricks();
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
int get_type();
void set_type(const int val);
int get_repeat();
void set_repeat(const int val);
Vector2 get_col_row();
void set_col_row(const Vector2 &val);
float get_offset();
void set_offset(const float val);
float get_corner();
void set_corner(const float val);
Bricks(); protected:
~Bricks(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> out_bricks_pattern;
static void _bind_methods(); Ref<MMNodeUniversalProperty> out_random_color;
Ref<MMNodeUniversalProperty> out_position_x;
//tool Ref<MMNodeUniversalProperty> out_position_y;
//export(Resource) Ref<MMNodeUniversalProperty> out_brick_uv;
Ref<Resource> out_bricks_pattern; Ref<MMNodeUniversalProperty> out_corner_uv;
//export(Resource) Ref<MMNodeUniversalProperty> out_direction;
Ref<Resource> out_random_color; //export(int, "Running Bond,Running Bond (2),HerringBone,Basket Weave,Spanish Bond")
//export(Resource) int type;
Ref<Resource> out_position_x; int repeat;
//export(Resource) Vector2 col_row;
Ref<Resource> out_position_y; float offset;
//export(Resource) Ref<MMNodeUniversalProperty> mortar;
Ref<Resource> out_brick_uv; Ref<MMNodeUniversalProperty> bevel;
//export(Resource) Ref<MMNodeUniversalProperty> roundness;
Ref<Resource> out_corner_uv; float corner;
//export(Resource)
Ref<Resource> out_direction;
//export(int, "Running Bond,Running Bond (2),HerringBone,Basket Weave,Spanish Bond")
int type = 0;
//export(int)
int repeat = 1;
//export(Vector2)
Vector2 col_row = Vector2(4, 4);
//export(float)
float offset = 0.5;
//export(Resource)
Ref<Resource> mortar;
//export(Resource)
Ref<Resource> bevel;
//export(Resource)
Ref<Resource> roundness;
//export(float)
float corner = 0.3;
//type
//repeat
//col_row
//offset
//corner
}; };
#endif #endif

View File

@ -1,104 +1,66 @@
#include "iching.h" #include "iching.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Iching::get_image() { Ref<MMNodeUniversalProperty> MMIching::get_image() {
return image; return image;
} }
void Iching::set_image(const Ref<Resource> &val) { void MMIching::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val; image = val;
} }
Vector2 MMIching::get_size() {
Vector2 Iching::get_size() { return size;
return size;
} }
void Iching::set_size(const Vector2 &val) { void MMIching::set_size(const Vector2 &val) {
size = val; size = val;
set_dirty(true);
} }
void MMIching::_init_properties() {
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//tool; register_output_property(image);
//export(Resource) ;
Ref<Resource> image;
//export(Vector2) ;
Vector2 size = Vector2(4, 4);
void Iching::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
} }
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; void MMIching::_register_methods(MMGraphNode *mm_graph_node) {
register_output_property(image); mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_vector2("get_size", "set_size", "Size", 1);
} }
void MMIching::_render(const Ref<MMMaterial> &material) {
void Iching::_register_methods(const Variant &mm_graph_node) { Ref<Image> img = render_image(material);
mm_graph_node.add_slot_texture_universal(image); image->set_value(img);
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 1);
} }
Color MMIching::_get_value_for(const Vector2 &uv, const int pseed) {
void Iching::_render(const Variant &material) { float ps = 1.0 / float(pseed);
Ref<Image> img = render_image(material); //IChing(vec2($columns, $rows)*$uv, float($seed));
image.set_value(img); return MMAlgos::IChingc(uv, size, ps);
} }
MMIching::MMIching() {
Color Iching::_get_value_for(const Vector2 &uv, const int pseed) { size = Vector2(4, 4);
float ps = 1.0 / float(pseed);
//IChing(vec2($columns, $rows)*$uv, float($seed));
return MMAlgos.IChingc(uv, size, ps);
} }
//size; MMIching::~MMIching() {
Vector2 Iching::get_size() {
return size;
} }
void MMIching::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMIching::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMIching::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
void Iching::set_size(const Vector2 &val) { ClassDB::bind_method(D_METHOD("get_size"), &MMIching::get_size);
size = val; ClassDB::bind_method(D_METHOD("set_size", "value"), &MMIching::set_size);
set_dirty(true); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
} }
}
Iching::Iching() {
image;
size = Vector2(4, 4);
}
Iching::~Iching() {
}
static void Iching::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Iching::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Iching::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_size"), &Iching::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &Iching::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("_init_properties"), &Iching::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Iching::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Iching::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Iching::_get_value_for);
ClassDB::bind_method(D_METHOD("get_size"), &Iching::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &Iching::set_size);
}

View File

@ -1,38 +1,32 @@
#ifndef ICHING_H #ifndef MM_ICHING_H
#define ICHING_H #define MM_ICHING_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Iching : public MMNode { class MMIching : public MMNode {
GDCLASS(Iching, MMNode); GDCLASS(MMIching, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image(); Vector2 get_size();
void set_image(const Ref<Resource> &val); void set_size(const Vector2 &val);
Vector2 get_size(); void _init_properties();
void set_size(const Vector2 &val); void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties(); MMIching();
void _register_methods(const Variant &mm_graph_node); ~MMIching();
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
Vector2 get_size();
void set_size(const Vector2 &val);
Iching(); protected:
~Iching(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> image;
static void _bind_methods(); Vector2 size;
//tool
//export(Resource)
Ref<Resource> image;
//export(Vector2)
Vector2 size = Vector2(4, 4);
//size
}; };
#endif #endif

View File

@ -1,200 +1,129 @@
#include "pattern.h" #include "pattern.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Pattern::get_image() { Ref<MMNodeUniversalProperty> MMPattern::get_image() {
return image; return image;
} }
void Pattern::set_image(const Ref<Resource> &val) { void MMPattern::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val; image = val;
} }
int MMPattern::get_combiner_type() const {
int Pattern::get_combiner_type() const { return combiner_type;
return combiner_type;
} }
void Pattern::set_combiner_type(const int val) { void MMPattern::set_combiner_type(const int val) {
combiner_type = val; combiner_type = val;
set_dirty(true);
} }
int MMPattern::get_combiner_axis_type_x() const {
int Pattern::get_combiner_axis_type_x() const { return combiner_axis_type_x;
return combiner_axis_type_x;
} }
void Pattern::set_combiner_axis_type_x(const int val) { void MMPattern::set_combiner_axis_type_x(const int val) {
combiner_axis_type_x = val; combiner_axis_type_x = val;
set_dirty(true);
} }
int MMPattern::get_combiner_axis_type_y() const {
int Pattern::get_combiner_axis_type_y() const { return combiner_axis_type_y;
return combiner_axis_type_y;
} }
void Pattern::set_combiner_axis_type_y(const int val) { void MMPattern::set_combiner_axis_type_y(const int val) {
combiner_axis_type_y = val; combiner_axis_type_y = val;
set_dirty(true);
} }
Vector2 MMPattern::get_repeat() {
Vector2 Pattern::get_repeat() { return repeat;
return repeat;
} }
void Pattern::set_repeat(const Vector2 &val) { void MMPattern::set_repeat(const Vector2 &val) {
repeat = val; repeat = val;
set_dirty(true);
} }
void MMPattern::_init_properties() {
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//tool; register_output_property(image);
//export(Resource) ;
Ref<Resource> image;
//export(int, "Multiply,Add,Max,Min,Xor,Pow") ;
int combiner_type = 0;
//export(int, "Sine,Triangle,Square,Sawtooth,Constant,Bounce") ;
int combiner_axis_type_x = 0;
//export(int, "Sine,Triangle,Square,Sawtooth,Constant,Bounce") ;
int combiner_axis_type_y = 0;
//export(Vector2) ;
Vector2 repeat = Vector2(4, 4);
void Pattern::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
} }
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; void MMPattern::_register_methods(MMGraphNode *mm_graph_node) {
register_output_property(image); mm_graph_node->add_slot_texture_universal(image);
Array arr1;
arr1.push_back("Multiply");
arr1.push_back("Add");
arr1.push_back("Max");
arr1.push_back("Min");
arr1.push_back("Xor");
arr1.push_back("Pow");
mm_graph_node->add_slot_enum("get_combiner_type", "set_combiner_type", "Combiner Type", arr1);
Array arr2;
arr2.push_back("Sine");
arr2.push_back("Triangle");
arr2.push_back("Square");
arr2.push_back("Sawtooth");
arr2.push_back("Constant");
arr2.push_back("Bounce");
mm_graph_node->add_slot_enum("get_combiner_axis_type_x", "set_combiner_axis_type_x", "Combiner Axis type", arr2);
mm_graph_node->add_slot_enum("get_combiner_axis_type_y", "set_combiner_axis_type_y", "", arr2);
//, Vector2(0, 32));
mm_graph_node->add_slot_vector2("get_repeat", "set_repeat", "Repeat", 1);
} }
void MMPattern::_render(const Ref<MMMaterial> &material) {
void Pattern::_register_methods(const Variant &mm_graph_node) { Ref<Image> img = render_image(material);
mm_graph_node.add_slot_texture_universal(image); image->set_value(img);
mm_graph_node.add_slot_enum("get_combiner_type", "set_combiner_type", "Combiner Type", [ "Multiply", "Add" , "Max", "Min", "Xor", "Pow" ]);
mm_graph_node.add_slot_enum("get_combiner_axis_type_x", "set_combiner_axis_type_x", "Combiner Axis type", [ "Sine", "Triangle", "Square", "Sawtooth", "Constant", "Bounce" ]);
mm_graph_node.add_slot_enum("get_combiner_axis_type_y", "set_combiner_axis_type_y", "", [ "Sine", "Triangle", "Square", "Sawtooth", "Constant", "Bounce" ]);
//, Vector2(0, 32));
mm_graph_node.add_slot_vector2("get_repeat", "set_repeat", "Repeat", 1);
} }
Color MMPattern::_get_value_for(const Vector2 &uv, const int pseed) {
void Pattern::_render(const Variant &material) { float f = MMAlgos::pattern(uv, repeat.x, repeat.y, combiner_type, combiner_axis_type_x, combiner_axis_type_y);
Ref<Image> img = render_image(material); return Color(f, f, f, 1);
image.set_value(img);
} }
MMPattern::MMPattern() {
Color Pattern::_get_value_for(const Vector2 &uv, const int pseed) { combiner_type = 0;
float f = MMAlgos.pattern(uv, repeat.x, repeat.y, combiner_type, combiner_axis_type_x, combiner_axis_type_y); combiner_axis_type_x = 0;
return Color(f, f, f, 1); combiner_axis_type_y = 0;
repeat = Vector2(4, 4);
} }
//combiner_type; MMPattern::~MMPattern() {
int Pattern::get_combiner_type() {
return combiner_type;
} }
void MMPattern::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMPattern::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMPattern::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
void Pattern::set_combiner_type(const int val) { ClassDB::bind_method(D_METHOD("get_combiner_type"), &MMPattern::get_combiner_type);
combiner_type = val; ClassDB::bind_method(D_METHOD("set_combiner_type", "value"), &MMPattern::set_combiner_type);
set_dirty(true); ADD_PROPERTY(PropertyInfo(Variant::INT, "combiner_type"), "set_combiner_type", "get_combiner_type");
ClassDB::bind_method(D_METHOD("get_combiner_axis_type_x"), &MMPattern::get_combiner_axis_type_x);
ClassDB::bind_method(D_METHOD("set_combiner_axis_type_x", "value"), &MMPattern::set_combiner_axis_type_x);
ADD_PROPERTY(PropertyInfo(Variant::INT, "combiner_axis_type_x"), "set_combiner_axis_type_x", "get_combiner_axis_type_x");
ClassDB::bind_method(D_METHOD("get_combiner_axis_type_y"), &MMPattern::get_combiner_axis_type_y);
ClassDB::bind_method(D_METHOD("set_combiner_axis_type_y", "value"), &MMPattern::set_combiner_axis_type_y);
ADD_PROPERTY(PropertyInfo(Variant::INT, "combiner_axis_type_y"), "set_combiner_axis_type_y", "get_combiner_axis_type_y");
ClassDB::bind_method(D_METHOD("get_repeat"), &MMPattern::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "value"), &MMPattern::set_repeat);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "repeat"), "set_repeat", "get_repeat");
} }
//combiner_axis_type_x;
int Pattern::get_combiner_axis_type_x() {
return combiner_axis_type_x;
}
void Pattern::set_combiner_axis_type_x(const int val) {
combiner_axis_type_x = val;
set_dirty(true);
}
//combiner_axis_type_y;
int Pattern::get_combiner_axis_type_y() {
return combiner_axis_type_y;
}
void Pattern::set_combiner_axis_type_y(const int val) {
combiner_axis_type_y = val;
set_dirty(true);
}
//repeat;
Vector2 Pattern::get_repeat() {
return repeat;
}
void Pattern::set_repeat(const Vector2 &val) {
repeat = val;
set_dirty(true);
}
}
Pattern::Pattern() {
image;
combiner_type = 0;
combiner_axis_type_x = 0;
combiner_axis_type_y = 0;
repeat = Vector2(4, 4);
}
Pattern::~Pattern() {
}
static void Pattern::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Pattern::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Pattern::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_combiner_type"), &Pattern::get_combiner_type);
ClassDB::bind_method(D_METHOD("set_combiner_type", "value"), &Pattern::set_combiner_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "combiner_type"), "set_combiner_type", "get_combiner_type");
ClassDB::bind_method(D_METHOD("get_combiner_axis_type_x"), &Pattern::get_combiner_axis_type_x);
ClassDB::bind_method(D_METHOD("set_combiner_axis_type_x", "value"), &Pattern::set_combiner_axis_type_x);
ADD_PROPERTY(PropertyInfo(Variant::INT, "combiner_axis_type_x"), "set_combiner_axis_type_x", "get_combiner_axis_type_x");
ClassDB::bind_method(D_METHOD("get_combiner_axis_type_y"), &Pattern::get_combiner_axis_type_y);
ClassDB::bind_method(D_METHOD("set_combiner_axis_type_y", "value"), &Pattern::set_combiner_axis_type_y);
ADD_PROPERTY(PropertyInfo(Variant::INT, "combiner_axis_type_y"), "set_combiner_axis_type_y", "get_combiner_axis_type_y");
ClassDB::bind_method(D_METHOD("get_repeat"), &Pattern::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "value"), &Pattern::set_repeat);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "repeat"), "set_repeat", "get_repeat");
ClassDB::bind_method(D_METHOD("_init_properties"), &Pattern::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Pattern::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Pattern::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Pattern::_get_value_for);
ClassDB::bind_method(D_METHOD("get_combiner_type"), &Pattern::get_combiner_type);
ClassDB::bind_method(D_METHOD("set_combiner_type", "val"), &Pattern::set_combiner_type);
ClassDB::bind_method(D_METHOD("get_combiner_axis_type_x"), &Pattern::get_combiner_axis_type_x);
ClassDB::bind_method(D_METHOD("set_combiner_axis_type_x", "val"), &Pattern::set_combiner_axis_type_x);
ClassDB::bind_method(D_METHOD("get_combiner_axis_type_y"), &Pattern::get_combiner_axis_type_y);
ClassDB::bind_method(D_METHOD("set_combiner_axis_type_y", "val"), &Pattern::set_combiner_axis_type_y);
ClassDB::bind_method(D_METHOD("get_repeat"), &Pattern::get_repeat);
ClassDB::bind_method(D_METHOD("set_repeat", "val"), &Pattern::set_repeat);
}

View File

@ -1,62 +1,49 @@
#ifndef PATTERN_H #ifndef MM_PATTERN_H
#define PATTERN_H #define MM_PATTERN_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Pattern : public MMNode { class MMPattern : public MMNode {
GDCLASS(Pattern, MMNode); GDCLASS(MMPattern, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image(); int get_combiner_type() const;
void set_image(const Ref<Resource> &val); void set_combiner_type(const int val);
int get_combiner_type() const; int get_combiner_axis_type_x() const;
void set_combiner_type(const int val); void set_combiner_axis_type_x(const int val);
int get_combiner_axis_type_x() const; int get_combiner_axis_type_y() const;
void set_combiner_axis_type_x(const int val); void set_combiner_axis_type_y(const int val);
int get_combiner_axis_type_y() const; Vector2 get_repeat();
void set_combiner_axis_type_y(const int val); void set_repeat(const Vector2 &val);
Vector2 get_repeat(); void _init_properties();
void set_repeat(const Vector2 &val); void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
void _init_properties(); Color _get_value_for(const Vector2 &uv, const int pseed);
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
int get_combiner_type();
void set_combiner_type(const int val);
int get_combiner_axis_type_x();
void set_combiner_axis_type_x(const int val);
int get_combiner_axis_type_y();
void set_combiner_axis_type_y(const int val);
Vector2 get_repeat();
void set_repeat(const Vector2 &val);
Pattern(); MMPattern();
~Pattern(); ~MMPattern();
protected: protected:
static void _bind_methods(); static void _bind_methods();
//tool Ref<MMNodeUniversalProperty> image;
//export(Resource) //export(int, "Multiply,Add,Max,Min,Xor,Pow")
Ref<Resource> image; int combiner_type = 0;
//export(int, "Multiply,Add,Max,Min,Xor,Pow") //export(int, "Sine,Triangle,Square,Sawtooth,Constant,Bounce")
int combiner_type = 0; int combiner_axis_type_x = 0;
//export(int, "Sine,Triangle,Square,Sawtooth,Constant,Bounce") //export(int, "Sine,Triangle,Square,Sawtooth,Constant,Bounce")
int combiner_axis_type_x = 0; int combiner_axis_type_y = 0;
//export(int, "Sine,Triangle,Square,Sawtooth,Constant,Bounce") //export(Vector2)
int combiner_axis_type_y = 0; Vector2 repeat = Vector2(4, 4);
//export(Vector2)
Vector2 repeat = Vector2(4, 4);
//combiner_type
//combiner_axis_type_x
//combiner_axis_type_y
//repeat
}; };
#endif #endif

View File

@ -1,104 +1,66 @@
#include "runes.h" #include "runes.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Runes::get_image() { Ref<MMNodeUniversalProperty> MMRunes::get_image() {
return image; return image;
} }
void Runes::set_image(const Ref<Resource> &val) { void MMRunes::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val; image = val;
} }
Vector2 MMRunes::get_size() {
Vector2 Runes::get_size() { return size;
return size;
} }
void Runes::set_size(const Vector2 &val) { void MMRunes::set_size(const Vector2 &val) {
size = val; size = val;
set_dirty(true);
} }
void MMRunes::_init_properties() {
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//tool; register_output_property(image);
//export(Resource) ;
Ref<Resource> image;
//export(Vector2) ;
Vector2 size = Vector2(4, 4);
void Runes::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
} }
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; void MMRunes::_register_methods(MMGraphNode *mm_graph_node) {
register_output_property(image); mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_vector2("get_size", "set_size", "Size", 1);
} }
void MMRunes::_render(const Ref<MMMaterial> &material) {
void Runes::_register_methods(const Variant &mm_graph_node) { Ref<Image> img = render_image(material);
mm_graph_node.add_slot_texture_universal(image); image->set_value(img);
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 1);
} }
Color MMRunes::_get_value_for(const Vector2 &uv, const int pseed) {
void Runes::_render(const Variant &material) { float ps = 1.0 / float(pseed);
Ref<Image> img = render_image(material); //Rune(vec2($columns, $rows)*$uv, float($seed));
image.set_value(img); return MMAlgos::runesc(uv, size, ps);
} }
MMRunes::MMRunes() {
Color Runes::_get_value_for(const Vector2 &uv, const int pseed) { size = Vector2(4, 4);
float ps = 1.0 / float(pseed);
//Rune(vec2($columns, $rows)*$uv, float($seed));
return MMAlgos.runesc(uv, size, ps);
} }
//size; MMRunes::~MMRunes() {
Vector2 Runes::get_size() {
return size;
} }
void MMRunes::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMRunes::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMRunes::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
void Runes::set_size(const Vector2 &val) { ClassDB::bind_method(D_METHOD("get_size"), &MMRunes::get_size);
size = val; ClassDB::bind_method(D_METHOD("set_size", "value"), &MMRunes::set_size);
set_dirty(true); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
} }
}
Runes::Runes() {
image;
size = Vector2(4, 4);
}
Runes::~Runes() {
}
static void Runes::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Runes::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Runes::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_size"), &Runes::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &Runes::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("_init_properties"), &Runes::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Runes::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Runes::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Runes::_get_value_for);
ClassDB::bind_method(D_METHOD("get_size"), &Runes::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &Runes::set_size);
}

View File

@ -1,38 +1,32 @@
#ifndef RUNES_H #ifndef MM_RUNES_H
#define RUNES_H #define MM_RUNES_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Runes : public MMNode { class MMRunes : public MMNode {
GDCLASS(Runes, MMNode); GDCLASS(MMRunes, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image(); Vector2 get_size();
void set_image(const Ref<Resource> &val); void set_size(const Vector2 &val);
Vector2 get_size(); void _init_properties();
void set_size(const Vector2 &val); void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties(); MMRunes();
void _register_methods(const Variant &mm_graph_node); ~MMRunes();
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
Vector2 get_size();
void set_size(const Vector2 &val);
Runes(); protected:
~Runes(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> image;
static void _bind_methods(); Vector2 size;
//tool
//export(Resource)
Ref<Resource> image;
//export(Vector2)
Vector2 size = Vector2(4, 4);
//size
}; };
#endif #endif

View File

@ -1,231 +1,125 @@
#include "scratches.h" #include "scratches.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Scratches::get_image() { Ref<MMNodeUniversalProperty> MMScratches::get_image() {
return image; return image;
} }
void Scratches::set_image(const Ref<Resource> &val) { void MMScratches::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val; image = val;
} }
Vector2 MMScratches::get_size() {
Vector2 Scratches::get_size() { return size;
return size;
} }
void Scratches::set_size(const Vector2 &val) { void MMScratches::set_size(const Vector2 &val) {
size = val; size = val;
set_dirty(true);
} }
int MMScratches::get_layers() const {
int Scratches::get_layers() const { return layers;
return layers;
} }
void Scratches::set_layers(const int val) { void MMScratches::set_layers(const int val) {
layers = val; layers = val;
set_dirty(true);
} }
float MMScratches::get_waviness() const {
float Scratches::get_waviness() const { return waviness;
return waviness;
} }
void Scratches::set_waviness(const float val) { void MMScratches::set_waviness(const float val) {
waviness = val; waviness = val;
set_dirty(true);
} }
int MMScratches::get_angle() const {
int Scratches::get_angle() const { return angle;
return angle;
} }
void Scratches::set_angle(const int val) { void MMScratches::set_angle(const int val) {
angle = val; angle = val;
set_dirty(true);
} }
float MMScratches::get_randomness() const {
float Scratches::get_randomness() const { return randomness;
return randomness;
} }
void Scratches::set_randomness(const float val) { void MMScratches::set_randomness(const float val) {
randomness = val; randomness = val;
set_dirty(true);
} }
void MMScratches::_init_properties() {
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//tool; register_output_property(image);
//export(Resource) ;
Ref<Resource> image;
//export(Vector2) ;
Vector2 size = Vector2(0.25, 0.4);
//export(int) ;
int layers = 4;
//export(float) ;
float waviness = 0.51;
//export(int) ;
int angle = 0;
//export(float) ;
float randomness = 0.44;
void Scratches::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
} }
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; void MMScratches::_register_methods(MMGraphNode *mm_graph_node) {
register_output_property(image); mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_vector2("get_size", "set_size", "Size", 0.01);
mm_graph_node->add_slot_int("get_layers", "set_layers", "Layers");
mm_graph_node->add_slot_float("get_waviness", "set_waviness", "Waviness", 0.01);
mm_graph_node->add_slot_int("get_angle", "set_angle", "Angle");
mm_graph_node->add_slot_float("get_randomness", "set_randomness", "Randomness", 0.01);
} }
void MMScratches::_render(const Ref<MMMaterial> &material) {
void Scratches::_register_methods(const Variant &mm_graph_node) { Ref<Image> img = render_image(material);
mm_graph_node.add_slot_texture_universal(image); image->set_value(img);
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 0.01);
mm_graph_node.add_slot_int("get_layers", "set_layers", "Layers");
mm_graph_node.add_slot_float("get_waviness", "set_waviness", "Waviness", 0.01);
mm_graph_node.add_slot_int("get_angle", "set_angle", "Angle");
mm_graph_node.add_slot_float("get_randomness", "set_randomness", "Randomness", 0.01);
} }
Color MMScratches::_get_value_for(const Vector2 &uv, const int pseed) {
void Scratches::_render(const Variant &material) { //scratches($uv, int($layers), vec2($length, $width), $waviness, $angle, $randomness, vec2(float($seed), 0.0));
Ref<Image> img = render_image(material); return MMAlgos::scratchesc(uv, layers, size, waviness, angle, randomness, Vector2(pseed, 0.0));
image.set_value(img);
} }
MMScratches::MMScratches() {
Color Scratches::_get_value_for(const Vector2 &uv, const int pseed) { size = Vector2(0.25, 0.4);
//scratches($uv, int($layers), vec2($length, $width), $waviness, $angle, $randomness, vec2(float($seed), 0.0)); layers = 4;
return MMAlgos.scratchesc(uv, layers, size, waviness, angle, randomness, Vector2(pseed, 0.0)); waviness = 0.51;
angle = 0;
randomness = 0.44;
} }
//size; MMScratches::~MMScratches() {
Vector2 Scratches::get_size() {
return size;
} }
void MMScratches::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMScratches::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMScratches::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
void Scratches::set_size(const Vector2 &val) { ClassDB::bind_method(D_METHOD("get_size"), &MMScratches::get_size);
size = val; ClassDB::bind_method(D_METHOD("set_size", "value"), &MMScratches::set_size);
set_dirty(true); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("get_layers"), &MMScratches::get_layers);
ClassDB::bind_method(D_METHOD("set_layers", "value"), &MMScratches::set_layers);
ADD_PROPERTY(PropertyInfo(Variant::INT, "layers"), "set_layers", "get_layers");
ClassDB::bind_method(D_METHOD("get_waviness"), &MMScratches::get_waviness);
ClassDB::bind_method(D_METHOD("set_waviness", "value"), &MMScratches::set_waviness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "waviness"), "set_waviness", "get_waviness");
ClassDB::bind_method(D_METHOD("get_angle"), &MMScratches::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "value"), &MMScratches::set_angle);
ADD_PROPERTY(PropertyInfo(Variant::INT, "angle"), "set_angle", "get_angle");
ClassDB::bind_method(D_METHOD("get_randomness"), &MMScratches::get_randomness);
ClassDB::bind_method(D_METHOD("set_randomness", "value"), &MMScratches::set_randomness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "randomness"), "set_randomness", "get_randomness");
} }
//layers;
int Scratches::get_layers() {
return layers;
}
void Scratches::set_layers(const int val) {
layers = val;
set_dirty(true);
}
//waviness;
float Scratches::get_waviness() {
return waviness;
}
void Scratches::set_waviness(const float val) {
waviness = val;
set_dirty(true);
}
//angle;
int Scratches::get_angle() {
return angle;
}
void Scratches::set_angle(const int val) {
angle = val;
set_dirty(true);
}
//randomness;
float Scratches::get_randomness() {
return randomness;
}
void Scratches::set_randomness(const float val) {
randomness = val;
set_dirty(true);
}
}
Scratches::Scratches() {
image;
size = Vector2(0.25, 0.4);
layers = 4;
waviness = 0.51;
angle = 0;
randomness = 0.44;
}
Scratches::~Scratches() {
}
static void Scratches::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Scratches::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Scratches::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_size"), &Scratches::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &Scratches::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("get_layers"), &Scratches::get_layers);
ClassDB::bind_method(D_METHOD("set_layers", "value"), &Scratches::set_layers);
ADD_PROPERTY(PropertyInfo(Variant::INT, "layers"), "set_layers", "get_layers");
ClassDB::bind_method(D_METHOD("get_waviness"), &Scratches::get_waviness);
ClassDB::bind_method(D_METHOD("set_waviness", "value"), &Scratches::set_waviness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "waviness"), "set_waviness", "get_waviness");
ClassDB::bind_method(D_METHOD("get_angle"), &Scratches::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "value"), &Scratches::set_angle);
ADD_PROPERTY(PropertyInfo(Variant::INT, "angle"), "set_angle", "get_angle");
ClassDB::bind_method(D_METHOD("get_randomness"), &Scratches::get_randomness);
ClassDB::bind_method(D_METHOD("set_randomness", "value"), &Scratches::set_randomness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "randomness"), "set_randomness", "get_randomness");
ClassDB::bind_method(D_METHOD("_init_properties"), &Scratches::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Scratches::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Scratches::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Scratches::_get_value_for);
ClassDB::bind_method(D_METHOD("get_size"), &Scratches::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &Scratches::set_size);
ClassDB::bind_method(D_METHOD("get_layers"), &Scratches::get_layers);
ClassDB::bind_method(D_METHOD("set_layers", "val"), &Scratches::set_layers);
ClassDB::bind_method(D_METHOD("get_waviness"), &Scratches::get_waviness);
ClassDB::bind_method(D_METHOD("set_waviness", "val"), &Scratches::set_waviness);
ClassDB::bind_method(D_METHOD("get_angle"), &Scratches::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "val"), &Scratches::set_angle);
ClassDB::bind_method(D_METHOD("get_randomness"), &Scratches::get_randomness);
ClassDB::bind_method(D_METHOD("set_randomness", "val"), &Scratches::set_randomness);
}

View File

@ -1,70 +1,48 @@
#ifndef SCRATCHES_H #ifndef MM_SCRATCHES_H
#define SCRATCHES_H #define MM_SCRATCHES_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Scratches : public MMNode { class MMScratches : public MMNode {
GDCLASS(Scratches, MMNode); GDCLASS(MMScratches, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image(); Vector2 get_size();
void set_image(const Ref<Resource> &val); void set_size(const Vector2 &val);
Vector2 get_size(); int get_layers() const;
void set_size(const Vector2 &val); void set_layers(const int val);
int get_layers() const; float get_waviness() const;
void set_layers(const int val); void set_waviness(const float val);
float get_waviness() const; int get_angle() const;
void set_waviness(const float val); void set_angle(const int val);
int get_angle() const; float get_randomness() const;
void set_angle(const int val); void set_randomness(const float val);
float get_randomness() const; void _init_properties();
void set_randomness(const float val); void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties(); MMScratches();
void _register_methods(const Variant &mm_graph_node); ~MMScratches();
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
Vector2 get_size();
void set_size(const Vector2 &val);
int get_layers();
void set_layers(const int val);
float get_waviness();
void set_waviness(const float val);
int get_angle();
void set_angle(const int val);
float get_randomness();
void set_randomness(const float val);
Scratches(); protected:
~Scratches(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> image;
static void _bind_methods(); Vector2 size;
int layers;
//tool float waviness;
//export(Resource) int angle;
Ref<Resource> image; float randomness;
//export(Vector2)
Vector2 size = Vector2(0.25, 0.4);
//export(int)
int layers = 4;
//export(float)
float waviness = 0.51;
//export(int)
int angle = 0;
//export(float)
float randomness = 0.44;
//size
//layers
//waviness
//angle
//randomness
}; };
#endif #endif

View File

@ -1,167 +1,95 @@
#include "sine_wave.h" #include "sine_wave.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> SineWave::get_image() { Ref<MMNodeUniversalProperty> MMSineWave::get_image() {
return image; return image;
} }
void SineWave::set_image(const Ref<Resource> &val) { void MMSineWave::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val; image = val;
} }
float MMSineWave::get_amplitude() const {
float SineWave::get_amplitude() const { return amplitude;
return amplitude;
} }
void SineWave::set_amplitude(const float val) { void MMSineWave::set_amplitude(const float val) {
amplitude = val; amplitude = val;
set_dirty(true);
} }
float MMSineWave::get_frequency() const {
float SineWave::get_frequency() const { return frequency;
return frequency;
} }
void SineWave::set_frequency(const float val) { void MMSineWave::set_frequency(const float val) {
frequency = val; frequency = val;
set_dirty(true);
} }
float MMSineWave::get_phase() const {
float SineWave::get_phase() const { return phase;
return phase;
} }
void SineWave::set_phase(const float val) { void MMSineWave::set_phase(const float val) {
phase = val; phase = val;
set_dirty(true);
} }
void MMSineWave::_init_properties() {
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//tool; register_output_property(image);
//export(Resource) ;
Ref<Resource> image;
//export(float) ;
float amplitude = 0.5;
//export(float) ;
float frequency = 2;
//export(float) ;
float phase = 0;
void SineWave::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
} }
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; void MMSineWave::_register_methods(MMGraphNode *mm_graph_node) {
register_output_property(image); mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_float("get_amplitude", "set_amplitude", "Amplitude", 0.01);
mm_graph_node->add_slot_float("get_frequency", "set_frequency", "Frequency", 0.1);
mm_graph_node->add_slot_float("get_phase", "set_phase", "Phase", 0.01);
} }
void MMSineWave::_render(const Ref<MMMaterial> &material) {
void SineWave::_register_methods(const Variant &mm_graph_node) { Ref<Image> img = render_image(material);
mm_graph_node.add_slot_texture_universal(image); image->set_value(img);
mm_graph_node.add_slot_float("get_amplitude", "set_amplitude", "Amplitude", 0.01);
mm_graph_node.add_slot_float("get_frequency", "set_frequency", "Frequency", 0.1);
mm_graph_node.add_slot_float("get_phase", "set_phase", "Phase", 0.01);
} }
Color MMSineWave::_get_value_for(const Vector2 &uv, const int pseed) {
void SineWave::_render(const Variant &material) { float f = 1.0 - abs(2.0 * (uv.y - 0.5) - amplitude * sin((frequency * uv.x + phase) * 6.28318530718));
Ref<Image> img = render_image(material); return Color(f, f, f, 1);
image.set_value(img);
} }
MMSineWave::MMSineWave() {
Color SineWave::_get_value_for(const Vector2 &uv, const int pseed) { amplitude = 0.5;
float f = 1.0 - abs(2.0 * (uv.y - 0.5) - amplitude *sin((frequency * uv.x + phase)*6.28318530718)); frequency = 2;
return Color(f, f, f, 1); phase = 0;
} }
//amplitude; MMSineWave::~MMSineWave() {
float SineWave::get_amplitude() {
return amplitude;
} }
void MMSineWave::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMSineWave::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMSineWave::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
void SineWave::set_amplitude(const float val) { ClassDB::bind_method(D_METHOD("get_amplitude"), &MMSineWave::get_amplitude);
amplitude = val; ClassDB::bind_method(D_METHOD("set_amplitude", "value"), &MMSineWave::set_amplitude);
set_dirty(true); ADD_PROPERTY(PropertyInfo(Variant::REAL, "amplitude"), "set_amplitude", "get_amplitude");
ClassDB::bind_method(D_METHOD("get_frequency"), &MMSineWave::get_frequency);
ClassDB::bind_method(D_METHOD("set_frequency", "value"), &MMSineWave::set_frequency);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "frequency"), "set_frequency", "get_frequency");
ClassDB::bind_method(D_METHOD("get_phase"), &MMSineWave::get_phase);
ClassDB::bind_method(D_METHOD("set_phase", "value"), &MMSineWave::set_phase);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "phase"), "set_phase", "get_phase");
} }
//frequency;
float SineWave::get_frequency() {
return frequency;
}
void SineWave::set_frequency(const float val) {
frequency = val;
set_dirty(true);
}
//phase;
float SineWave::get_phase() {
return phase;
}
void SineWave::set_phase(const float val) {
phase = val;
set_dirty(true);
}
}
SineWave::SineWave() {
image;
amplitude = 0.5;
frequency = 2;
phase = 0;
}
SineWave::~SineWave() {
}
static void SineWave::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &SineWave::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &SineWave::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_amplitude"), &SineWave::get_amplitude);
ClassDB::bind_method(D_METHOD("set_amplitude", "value"), &SineWave::set_amplitude);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "amplitude"), "set_amplitude", "get_amplitude");
ClassDB::bind_method(D_METHOD("get_frequency"), &SineWave::get_frequency);
ClassDB::bind_method(D_METHOD("set_frequency", "value"), &SineWave::set_frequency);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "frequency"), "set_frequency", "get_frequency");
ClassDB::bind_method(D_METHOD("get_phase"), &SineWave::get_phase);
ClassDB::bind_method(D_METHOD("set_phase", "value"), &SineWave::set_phase);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "phase"), "set_phase", "get_phase");
ClassDB::bind_method(D_METHOD("_init_properties"), &SineWave::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SineWave::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &SineWave::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &SineWave::_get_value_for);
ClassDB::bind_method(D_METHOD("get_amplitude"), &SineWave::get_amplitude);
ClassDB::bind_method(D_METHOD("set_amplitude", "val"), &SineWave::set_amplitude);
ClassDB::bind_method(D_METHOD("get_frequency"), &SineWave::get_frequency);
ClassDB::bind_method(D_METHOD("set_frequency", "val"), &SineWave::set_frequency);
ClassDB::bind_method(D_METHOD("get_phase"), &SineWave::get_phase);
ClassDB::bind_method(D_METHOD("set_phase", "val"), &SineWave::set_phase);
}

View File

@ -1,54 +1,40 @@
#ifndef SINE_WAVE_H #ifndef MM_SINE_WAVE_H
#define SINE_WAVE_H #define MM_SINE_WAVE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SineWave : public MMNode { class MMSineWave : public MMNode {
GDCLASS(SineWave, MMNode); GDCLASS(MMSineWave, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image(); float get_amplitude() const;
void set_image(const Ref<Resource> &val); void set_amplitude(const float val);
float get_amplitude() const; float get_frequency() const;
void set_amplitude(const float val); void set_frequency(const float val);
float get_frequency() const; float get_phase() const;
void set_frequency(const float val); void set_phase(const float val);
float get_phase() const; void _init_properties();
void set_phase(const float val); void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties(); MMSineWave();
void _register_methods(const Variant &mm_graph_node); ~MMSineWave();
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
float get_amplitude();
void set_amplitude(const float val);
float get_frequency();
void set_frequency(const float val);
float get_phase();
void set_phase(const float val);
SineWave(); protected:
~SineWave(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> image;
static void _bind_methods(); float amplitude;
float frequency;
//tool float phase;
//export(Resource)
Ref<Resource> image;
//export(float)
float amplitude = 0.5;
//export(float)
float frequency = 2;
//export(float)
float phase = 0;
//amplitude
//frequency
//phase
}; };
#endif #endif

View File

@ -1,144 +1,93 @@
#include "truchet.h" #include "truchet.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Truchet::get_image() { Ref<MMNodeUniversalProperty> MMTruchet::get_image() {
return image; return image;
} }
void Truchet::set_image(const Ref<Resource> &val) { void MMTruchet::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val; image = val;
} }
int MMTruchet::get_shape() const {
int Truchet::get_shape() const { return shape;
return shape;
} }
void Truchet::set_shape(const int val) { void MMTruchet::set_shape(const int val) {
shape = val; shape = val;
set_dirty(true);
} }
float MMTruchet::get_size() const {
float Truchet::get_size() const { return size;
return size;
} }
void Truchet::set_size(const float val) { void MMTruchet::set_size(const float val) {
size = val; size = val;
set_dirty(true);
} }
void MMTruchet::_init_properties() {
if (!image.is_valid()) {
image.instance();
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//tool; register_output_property(image);
//export(Resource) ;
Ref<Resource> image;
//export(int, "Line,Circle") ;
int shape = 0;
//export(float) ;
float size = 4;
void Truchet::_init_properties() {
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
} }
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; void MMTruchet::_register_methods(MMGraphNode *mm_graph_node) {
register_output_property(image); mm_graph_node->add_slot_texture_universal(image);
Array arr;
arr.push_back("Line");
arr.push_back("Circle");
mm_graph_node->add_slot_enum("get_shape", "set_shape", "Shape", arr);
mm_graph_node->add_slot_float("get_size", "set_size", "Size", 1);
} }
void MMTruchet::_render(const Ref<MMMaterial> &material) {
void Truchet::_register_methods(const Variant &mm_graph_node) { Ref<Image> img = render_image(material);
mm_graph_node.add_slot_texture_universal(image); image->set_value(img);
mm_graph_node.add_slot_enum("get_shape", "set_shape", "Shape", [ "Line", "Circle" ]);
mm_graph_node.add_slot_float("get_size", "set_size", "Size", 1);
} }
Color MMTruchet::_get_value_for(const Vector2 &uv, const int pseed) {
if (shape == 0) {
return MMAlgos::truchet1c(uv, size, pseed);
}
void Truchet::_render(const Variant &material) { else if (shape == 1) {
Ref<Image> img = render_image(material); return MMAlgos::truchet2c(uv, size, pseed);
image.set_value(img); }
return Color();
} }
MMTruchet::MMTruchet() {
Color Truchet::_get_value_for(const Vector2 &uv, const int pseed) { shape = 0;
size = 4;
if (shape == 0) {
return MMAlgos.truchet1c(uv, size, pseed);
} }
MMTruchet::~MMTruchet() {
else if (shape == 1) {
return MMAlgos.truchet2c(uv, size, pseed);
} }
return Color(); void MMTruchet::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &MMTruchet::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMTruchet::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_shape"), &MMTruchet::get_shape);
ClassDB::bind_method(D_METHOD("set_shape", "value"), &MMTruchet::set_shape);
ADD_PROPERTY(PropertyInfo(Variant::INT, "shape"), "set_shape", "get_shape");
ClassDB::bind_method(D_METHOD("get_size"), &MMTruchet::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &MMTruchet::set_size);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "size"), "set_size", "get_size");
} }
//shape;
int Truchet::get_shape() {
return shape;
}
void Truchet::set_shape(const int val) {
shape = val;
set_dirty(true);
}
//size;
float Truchet::get_size() {
return size;
}
void Truchet::set_size(const float val) {
size = val;
set_dirty(true);
}
}
Truchet::Truchet() {
image;
shape = 0;
size = 4;
}
Truchet::~Truchet() {
}
static void Truchet::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &Truchet::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &Truchet::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_shape"), &Truchet::get_shape);
ClassDB::bind_method(D_METHOD("set_shape", "value"), &Truchet::set_shape);
ADD_PROPERTY(PropertyInfo(Variant::INT, "shape"), "set_shape", "get_shape");
ClassDB::bind_method(D_METHOD("get_size"), &Truchet::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &Truchet::set_size);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("_init_properties"), &Truchet::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Truchet::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Truchet::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Truchet::_get_value_for);
ClassDB::bind_method(D_METHOD("get_shape"), &Truchet::get_shape);
ClassDB::bind_method(D_METHOD("set_shape", "val"), &Truchet::set_shape);
ClassDB::bind_method(D_METHOD("get_size"), &Truchet::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &Truchet::set_size);
}

View File

@ -1,46 +1,37 @@
#ifndef TRUCHET_H #ifndef MM_TRUCHET_H
#define TRUCHET_H #define MM_TRUCHET_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Truchet : public MMNode { class MMTruchet : public MMNode {
GDCLASS(Truchet, MMNode); GDCLASS(MMTruchet, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image(); int get_shape() const;
void set_image(const Ref<Resource> &val); void set_shape(const int val);
int get_shape() const; float get_size() const;
void set_shape(const int val); void set_size(const float val);
float get_size() const; void _init_properties();
void set_size(const float val); void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties(); MMTruchet();
void _register_methods(const Variant &mm_graph_node); ~MMTruchet();
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
int get_shape();
void set_shape(const int val);
float get_size();
void set_size(const float val);
Truchet(); protected:
~Truchet(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> image;
static void _bind_methods(); //export(int, "Line,Circle")
int shape;
//tool float size;
//export(Resource)
Ref<Resource> image;
//export(int, "Line,Circle")
int shape = 0;
//export(float)
float size = 4;
//shape
//size
}; };
#endif #endif

View File

@ -1,258 +1,196 @@
#include "weave.h" #include "weave.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Weave::get_out_main() { Ref<MMNodeUniversalProperty> MMWeave::get_out_main() {
return out_main; return out_main;
} }
void Weave::set_out_main(const Ref<Resource> &val) { void MMWeave::set_out_main(const Ref<MMNodeUniversalProperty> &val) {
out_main = val; out_main = val;
} }
Ref<MMNodeUniversalProperty> MMWeave::get_out_horizontal_map() {
Ref<Resource> Weave::get_out_horizontal_map() { return out_horizontal_map;
return out_horizontal_map;
} }
void Weave::set_out_horizontal_map(const Ref<Resource> &val) { void MMWeave::set_out_horizontal_map(const Ref<MMNodeUniversalProperty> &val) {
out_horizontal_map = val; out_horizontal_map = val;
} }
Ref<MMNodeUniversalProperty> MMWeave::get_out_vertical_map() {
Ref<Resource> Weave::get_out_vertical_map() { return out_vertical_map;
return out_vertical_map;
} }
void Weave::set_out_vertical_map(const Ref<Resource> &val) { void MMWeave::set_out_vertical_map(const Ref<MMNodeUniversalProperty> &val) {
out_vertical_map = val; out_vertical_map = val;
} }
Vector2 MMWeave::get_size() {
Vector2 Weave::get_size() { return size;
return size;
} }
void Weave::set_size(const Vector2 &val) { void MMWeave::set_size(const Vector2 &val) {
size = val; size = val;
set_dirty(true);
} }
Ref<MMNodeUniversalProperty> MMWeave::get_width() {
Ref<Resource> Weave::get_width() { return width;
return width;
} }
void Weave::set_width(const Ref<Resource> &val) { void MMWeave::set_width(const Ref<MMNodeUniversalProperty> &val) {
width = val; width = val;
} }
int MMWeave::get_stitch() const {
int Weave::get_stitch() const { return stitch;
return stitch;
} }
void Weave::set_stitch(const int val) { void MMWeave::set_stitch(const int val) {
stitch = val; stitch = val;
set_dirty(true);
} }
void MMWeave::_init_properties() {
if (!out_main.is_valid()) {
out_main.instance();
out_main->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
out_main->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
//tool; if (!out_horizontal_map.is_valid()) {
//export(Resource) ; out_horizontal_map.instance();
Ref<Resource> out_main; out_horizontal_map->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
//export(Resource) ; }
Ref<Resource> out_horizontal_map;
//export(Resource) ;
Ref<Resource> out_vertical_map;
//export(Vector2) ;
Vector2 size = Vector2(4, 4);
//export(Resource) ;
Ref<Resource> width;
//export(int) ;
int stitch = 1;
void Weave::_init_properties() { out_horizontal_map->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
if (!out_main) { if (!out_vertical_map.is_valid()) {
out_main = MMNodeUniversalProperty.new(); out_vertical_map.instance();
out_main.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE; out_vertical_map->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
}
out_vertical_map->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
if (!width.is_valid()) {
width.instance();
width->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
width->set_default_value(Vector2(0.9, 0.9));
}
width->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
width->set_slot_name("Width");
width->set_value_step(0.01);
width->set_value_range(Vector2(0, 1));
register_output_property(out_main);
register_output_property(out_horizontal_map);
register_output_property(out_vertical_map);
register_input_property(width);
} }
out_main.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; void MMWeave::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_texture_universal(out_main);
if (!out_horizontal_map) { mm_graph_node->add_slot_texture_universal(out_horizontal_map);
out_horizontal_map = MMNodeUniversalProperty.new(); mm_graph_node->add_slot_texture_universal(out_vertical_map);
out_horizontal_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE; //, Vector2(1, 32))//, Vector2(0, 32));
mm_graph_node->add_slot_vector2("get_size", "set_size", "Size");
mm_graph_node->add_slot_vector2_universal(width);
mm_graph_node->add_slot_int("get_stitch", "set_stitch", "Stitch");
} }
out_horizontal_map.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; void MMWeave::_render(const Ref<MMMaterial> &material) {
Ref<Image> main_pattern;
Ref<Image> horizontal_map;
Ref<Image> vertical_map;
if (!out_vertical_map) { main_pattern.instance();
out_vertical_map = MMNodeUniversalProperty.new(); horizontal_map.instance();
out_vertical_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE; vertical_map.instance();
main_pattern->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
horizontal_map->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
vertical_map->create(material->image_size.x, material->image_size.y, false, Image::FORMAT_RGBA8);
main_pattern->lock();
horizontal_map->lock();
vertical_map->lock();
float w = material->image_size.x;
float h = material->image_size.y;
//float pseed = Math::randf() + Math::rand();
for (int x = 0; x < material->image_size.x; ++x) { //x in range(material.image_size.x)
for (int y = 0; y < material->image_size.y; ++y) { //y in range(material.image_size.y)
Vector2 uv = Vector2(x / w, y / h);
Vector2 width_val = width->get_value(uv);
//vec3 $(name_uv) = weave2($uv, vec2($columns, $rows), $stitch, $width_x*$width_map($uv), $width_y*$width_map($uv));
Vector3 weave = MMAlgos::weave2(uv, size, stitch, width_val.x, width_val.y);
//Outputs:;
//Output (float) - Shows the generated greyscale weave pattern.;
//$(name_uv).x;
Color main_pattern_col = Color(weave.x, weave.x, weave.x, 1);
//Horizontal mask (float) - Horizontal mask;
//$(name_uv).y;
Color horizontal_map_col = Color(weave.y, weave.y, weave.y, 1);
//Vertical mask (float) - Mask for vertical stripes;
//$(name_uv).z;
Color vertical_map_col = Color(weave.z, weave.z, weave.z, 1);
main_pattern->set_pixel(x, y, main_pattern_col);
horizontal_map->set_pixel(x, y, horizontal_map_col);
vertical_map->set_pixel(x, y, vertical_map_col);
}
}
main_pattern->unlock();
horizontal_map->unlock();
vertical_map->unlock();
out_main->set_value(main_pattern);
out_horizontal_map->set_value(horizontal_map);
out_vertical_map->set_value(vertical_map);
} }
out_vertical_map.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE; Color MMWeave::_get_value_for(const Vector2 &uv, const int pseed) {
return Color();
if (!width) {
width = MMNodeUniversalProperty.new();
width.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
width.set_default_value(Vector2(0.9, 0.9));
} }
width.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; MMWeave::MMWeave() {
width.slot_name = "Width"; size = Vector2(4, 4);
width.value_step = 0.01; stitch = 1;
width.value_range = Vector2(0, 1);
register_output_property(out_main);
register_output_property(out_horizontal_map);
register_output_property(out_vertical_map);
register_input_property(width);
} }
MMWeave::~MMWeave() {
void Weave::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(out_main);
mm_graph_node.add_slot_texture_universal(out_horizontal_map);
mm_graph_node.add_slot_texture_universal(out_vertical_map);
//, Vector2(1, 32))//, Vector2(0, 32));
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size");
mm_graph_node.add_slot_vector2_universal(width);
mm_graph_node.add_slot_int("get_stitch", "set_stitch", "Stitch");
} }
void MMWeave::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_out_main"), &MMWeave::get_out_main);
ClassDB::bind_method(D_METHOD("set_out_main", "value"), &MMWeave::set_out_main);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_main", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_main", "get_out_main");
void Weave::_render(const Variant &material) { ClassDB::bind_method(D_METHOD("get_out_horizontal_map"), &MMWeave::get_out_horizontal_map);
Ref<Image> main_pattern = Image.new(); ClassDB::bind_method(D_METHOD("set_out_horizontal_map", "value"), &MMWeave::set_out_horizontal_map);
Ref<Image> horizontal_map = Image.new(); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_horizontal_map", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_horizontal_map", "get_out_horizontal_map");
Ref<Image> vertical_map = Image.new();
main_pattern.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
horizontal_map.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
vertical_map.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8);
main_pattern.lock();
horizontal_map.lock();
vertical_map.lock();
float w = material.image_size.x;
float h = material.image_size.y;
float pseed = randf() + randi();
for (int x = 0; x < material.image_size.x; ++x) { //x in range(material.image_size.x) ClassDB::bind_method(D_METHOD("get_out_vertical_map"), &MMWeave::get_out_vertical_map);
ClassDB::bind_method(D_METHOD("set_out_vertical_map", "value"), &MMWeave::set_out_vertical_map);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_vertical_map", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_out_vertical_map", "get_out_vertical_map");
for (int y = 0; y < material.image_size.y; ++y) { //y in range(material.image_size.y) ClassDB::bind_method(D_METHOD("get_size"), &MMWeave::get_size);
Vector2 uv = Vector2(x / w, y / h); ClassDB::bind_method(D_METHOD("set_size", "value"), &MMWeave::set_size);
Vector2 width_val = width.get_value(uv); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
//vec3 $(name_uv) = weave2($uv, vec2($columns, $rows), $stitch, $width_x*$width_map($uv), $width_y*$width_map($uv));
Vector3 weave = MMAlgos.weave2(uv, size, stitch, width_val.x, width_val.y); ClassDB::bind_method(D_METHOD("get_width"), &MMWeave::get_width);
//Outputs:; ClassDB::bind_method(D_METHOD("set_width", "value"), &MMWeave::set_width);
//Output (float) - Shows the generated greyscale weave pattern.; ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "width", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_width", "get_width");
//$(name_uv).x;
Color main_pattern_col = Color(weave.x, weave.x, weave.x, 1); ClassDB::bind_method(D_METHOD("get_stitch"), &MMWeave::get_stitch);
//Horizontal mask (float) - Horizontal mask; ClassDB::bind_method(D_METHOD("set_stitch", "value"), &MMWeave::set_stitch);
//$(name_uv).y; ADD_PROPERTY(PropertyInfo(Variant::INT, "stitch"), "set_stitch", "get_stitch");
Color horizontal_map_col = Color(weave.y, weave.y, weave.y, 1);
//Vertical mask (float) - Mask for vertical stripes;
//$(name_uv).z;
Color vertical_map_col = Color(weave.z, weave.z, weave.z, 1);
main_pattern.set_pixel(x, y, main_pattern_col);
horizontal_map.set_pixel(x, y, horizontal_map_col);
vertical_map.set_pixel(x, y, vertical_map_col);
} }
}
main_pattern.unlock();
horizontal_map.unlock();
vertical_map.unlock();
out_main.set_value(main_pattern);
out_horizontal_map.set_value(horizontal_map);
out_vertical_map.set_value(vertical_map);
}
Color Weave::_get_value_for(const Vector2 &uv, const int pseed) {
return Color();
}
//size;
Vector2 Weave::get_size() {
return size;
}
void Weave::set_size(const Vector2 &val) {
size = val;
set_dirty(true);
}
//stitch;
int Weave::get_stitch() {
return stitch;
}
void Weave::set_stitch(const int val) {
stitch = val;
set_dirty(true);
}
}
Weave::Weave() {
out_main;
out_horizontal_map;
out_vertical_map;
size = Vector2(4, 4);
width;
stitch = 1;
}
Weave::~Weave() {
}
static void Weave::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_out_main"), &Weave::get_out_main);
ClassDB::bind_method(D_METHOD("set_out_main", "value"), &Weave::set_out_main);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_main", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_main", "get_out_main");
ClassDB::bind_method(D_METHOD("get_out_horizontal_map"), &Weave::get_out_horizontal_map);
ClassDB::bind_method(D_METHOD("set_out_horizontal_map", "value"), &Weave::set_out_horizontal_map);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_horizontal_map", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_horizontal_map", "get_out_horizontal_map");
ClassDB::bind_method(D_METHOD("get_out_vertical_map"), &Weave::get_out_vertical_map);
ClassDB::bind_method(D_METHOD("set_out_vertical_map", "value"), &Weave::set_out_vertical_map);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "out_vertical_map", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_out_vertical_map", "get_out_vertical_map");
ClassDB::bind_method(D_METHOD("get_size"), &Weave::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &Weave::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("get_width"), &Weave::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &Weave::set_width);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "width", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_width", "get_width");
ClassDB::bind_method(D_METHOD("get_stitch"), &Weave::get_stitch);
ClassDB::bind_method(D_METHOD("set_stitch", "value"), &Weave::set_stitch);
ADD_PROPERTY(PropertyInfo(Variant::INT, "stitch"), "set_stitch", "get_stitch");
ClassDB::bind_method(D_METHOD("_init_properties"), &Weave::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Weave::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &Weave::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Weave::_get_value_for);
ClassDB::bind_method(D_METHOD("get_size"), &Weave::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &Weave::set_size);
ClassDB::bind_method(D_METHOD("get_stitch"), &Weave::get_stitch);
ClassDB::bind_method(D_METHOD("set_stitch", "val"), &Weave::set_stitch);
}

View File

@ -1,61 +1,48 @@
#ifndef WEAVE_H #ifndef MM_WEAVE_H
#define WEAVE_H #define MM_WEAVE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Weave : public MMNode { class MMWeave : public MMNode {
GDCLASS(Weave, MMNode); GDCLASS(MMWeave, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_out_main();
void set_out_main(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_main(); Ref<MMNodeUniversalProperty> get_out_horizontal_map();
void set_out_main(const Ref<Resource> &val); void set_out_horizontal_map(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_horizontal_map(); Ref<MMNodeUniversalProperty> get_out_vertical_map();
void set_out_horizontal_map(const Ref<Resource> &val); void set_out_vertical_map(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_out_vertical_map(); Vector2 get_size();
void set_out_vertical_map(const Ref<Resource> &val); void set_size(const Vector2 &val);
Vector2 get_size(); Ref<MMNodeUniversalProperty> get_width();
void set_size(const Vector2 &val); void set_width(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_width(); int get_stitch() const;
void set_width(const Ref<Resource> &val); void set_stitch(const int val);
int get_stitch() const; void _init_properties();
void set_stitch(const int val); void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
void _init_properties(); MMWeave();
void _register_methods(const Variant &mm_graph_node); ~MMWeave();
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
Vector2 get_size();
void set_size(const Vector2 &val);
int get_stitch();
void set_stitch(const int val);
Weave(); protected:
~Weave(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> out_main;
static void _bind_methods(); Ref<MMNodeUniversalProperty> out_horizontal_map;
Ref<MMNodeUniversalProperty> out_vertical_map;
//tool Vector2 size;
//export(Resource) Ref<MMNodeUniversalProperty> width;
Ref<Resource> out_main; int stitch;
//export(Resource)
Ref<Resource> out_horizontal_map;
//export(Resource)
Ref<Resource> out_vertical_map;
//export(Vector2)
Vector2 size = Vector2(4, 4);
//export(Resource)
Ref<Resource> width;
//export(int)
int stitch = 1;
//size
//stitch
}; };
#endif #endif

View File

@ -107,6 +107,16 @@ SOFTWARE.
#include "nodes/sdf2d/sd_op_rounded_shape.h" #include "nodes/sdf2d/sd_op_rounded_shape.h"
#include "nodes/sdf2d/sd_op_smooth_bool.h" #include "nodes/sdf2d/sd_op_smooth_bool.h"
#include "nodes/pattern/beehive.h"
#include "nodes/pattern/bricks.h"
#include "nodes/pattern/iching.h"
#include "nodes/pattern/pattern.h"
#include "nodes/pattern/runes.h"
#include "nodes/pattern/scratches.h"
#include "nodes/pattern/sine_wave.h"
#include "nodes/pattern/truchet.h"
#include "nodes/pattern/weave.h"
static _MMAlgos *_mm_algos_singleton = nullptr; static _MMAlgos *_mm_algos_singleton = nullptr;
void register_material_maker_types() { void register_material_maker_types() {
@ -238,6 +248,25 @@ void register_material_maker_types() {
ClassDB::register_class<MMSdOpAnnularShape>(); ClassDB::register_class<MMSdOpAnnularShape>();
MMAlgos::register_node_class("SDF2D - OP", "MMSdOpAnnularShape"); MMAlgos::register_node_class("SDF2D - OP", "MMSdOpAnnularShape");
ClassDB::register_class<MMWeave>();
MMAlgos::register_node_class("Patterns", "MMWeave");
ClassDB::register_class<MMTruchet>();
MMAlgos::register_node_class("Patterns", "MMTruchet");
ClassDB::register_class<MMSineWave>();
MMAlgos::register_node_class("Patterns", "MMSineWave");
ClassDB::register_class<MMScratches>();
MMAlgos::register_node_class("Patterns", "MMScratches");
ClassDB::register_class<MMRunes>();
MMAlgos::register_node_class("Patterns", "MMRunes");
ClassDB::register_class<MMPattern>();
MMAlgos::register_node_class("Patterns", "MMPattern");
ClassDB::register_class<MMIching>();
MMAlgos::register_node_class("Patterns", "MMIching");
ClassDB::register_class<MMBricks>();
MMAlgos::register_node_class("Patterns", "MMBricks");
ClassDB::register_class<MMBeehive>();
MMAlgos::register_node_class("Patterns", "MMBeehive");
_mm_algos_singleton = memnew(_MMAlgos); _mm_algos_singleton = memnew(_MMAlgos);
Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton()));