Cleaned up SDF show, rhombus, and transforms.

This commit is contained in:
Relintai 2022-06-17 18:59:08 +02:00
parent 8282061088
commit d339fb1fdb
13 changed files with 385 additions and 602 deletions

View File

@ -92,6 +92,14 @@ sources = [
"nodes/sdf3d/sdf3d_op_circle_repeat.cpp",
"nodes/sdf3d/sdf3d_op_bool.cpp",
"nodes/sdf2d/sd_shape_rhombus.cpp",
"nodes/sdf2d/sd_tf_translate.cpp",
"nodes/sdf2d/sd_tf_scale.cpp",
"nodes/sdf2d/sd_tf_rotate.cpp",
"nodes/sdf2d/sd_show.cpp",
]
if env["tools"]:

View File

@ -61,6 +61,14 @@ def get_doc_classes():
"MMSdf3dOpElongation",
"MMSdf3dOpCircleRepeat",
"MMSdf3dOpBool",
"SSSdShow",
"MMSdTfTranslate",
"MMSdTfScale",
"MMSdTfRotate",
"MMSdShapeRhombus",
]
def get_doc_path():

View File

@ -1,131 +1,79 @@
#include "sd_shape_rhombus.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> SdShapeRhombus::get_output() {
return output;
Ref<MMNodeUniversalProperty> MMSdShapeRhombus::get_output() {
return output;
}
void SdShapeRhombus::set_output(const Ref<Resource> &val) {
output = val;
void MMSdShapeRhombus::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
Vector2 SdShapeRhombus::get_center() {
return center;
Vector2 MMSdShapeRhombus::get_center() {
return center;
}
void SdShapeRhombus::set_center(const Vector2 &val) {
center = val;
void MMSdShapeRhombus::set_center(const Vector2 &val) {
center = val;
emit_changed();
output->do_emit_changed();
}
Vector2 SdShapeRhombus::get_size() {
return size;
Vector2 MMSdShapeRhombus::get_size() {
return size;
}
void SdShapeRhombus::set_size(const Vector2 &val) {
size = val;
void MMSdShapeRhombus::set_size(const Vector2 &val) {
size = val;
emit_changed();
output->do_emit_changed();
}
void MMSdShapeRhombus::_init_properties() {
if (!output.is_valid()) {
output.instance();
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
output->set_slot_name(">>> Output >>>");
output->set_get_value_from_owner(true);
//tool;
//export(Resource) ;
Ref<Resource> output;
//export(Vector2) ;
Vector2 center = Vector2(0, 0);
//export(Vector2) ;
Vector2 size = Vector2(0.3, 0.2);
void SdShapeRhombus::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
register_output_property(output);
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Output >>>";
output.get_value_from_owner = true;
register_output_property(output);
void MMSdShapeRhombus::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(output);
mm_graph_node->add_slot_vector2("get_center", "set_center", "Center", 0.01);
mm_graph_node->add_slot_vector2("get_size", "set_size", "Size", 0.01);
}
void SdShapeRhombus::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_vector2("get_center", "set_center", "Center", 0.01);
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 0.01);
Variant MMSdShapeRhombus::_get_property_value(const Vector2 &uv) {
return MMAlgos::sdf_rhombus(uv, center, size);
}
float SdShapeRhombus::_get_property_value(const Vector2 &uv) {
return MMAlgos.sdf_rhombus(uv, center, size);
MMSdShapeRhombus::MMSdShapeRhombus() {
center = Vector2(0, 0);
size = Vector2(0.3, 0.2);
}
//center;
Vector2 SdShapeRhombus::get_center() {
return center;
MMSdShapeRhombus::~MMSdShapeRhombus() {
}
void MMSdShapeRhombus::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &MMSdShapeRhombus::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdShapeRhombus::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
void SdShapeRhombus::set_center(const Vector2 &val) {
center = val;
emit_changed();
output.emit_changed();
ClassDB::bind_method(D_METHOD("get_center"), &MMSdShapeRhombus::get_center);
ClassDB::bind_method(D_METHOD("set_center", "value"), &MMSdShapeRhombus::set_center);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center"), "set_center", "get_center");
ClassDB::bind_method(D_METHOD("get_size"), &MMSdShapeRhombus::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &MMSdShapeRhombus::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
}
//size;
Vector2 SdShapeRhombus::get_size() {
return size;
}
void SdShapeRhombus::set_size(const Vector2 &val) {
size = val;
emit_changed();
output.emit_changed();
}
}
SdShapeRhombus::SdShapeRhombus() {
output;
center = Vector2(0, 0);
size = Vector2(0.3, 0.2);
}
SdShapeRhombus::~SdShapeRhombus() {
}
static void SdShapeRhombus::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdShapeRhombus::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdShapeRhombus::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_center"), &SdShapeRhombus::get_center);
ClassDB::bind_method(D_METHOD("set_center", "value"), &SdShapeRhombus::set_center);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center"), "set_center", "get_center");
ClassDB::bind_method(D_METHOD("get_size"), &SdShapeRhombus::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &SdShapeRhombus::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdShapeRhombus::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdShapeRhombus::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdShapeRhombus::_get_property_value);
ClassDB::bind_method(D_METHOD("get_center"), &SdShapeRhombus::get_center);
ClassDB::bind_method(D_METHOD("set_center", "val"), &SdShapeRhombus::set_center);
ClassDB::bind_method(D_METHOD("get_size"), &SdShapeRhombus::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &SdShapeRhombus::set_size);
}

View File

@ -1,45 +1,35 @@
#ifndef SD_SHAPE_RHOMBUS_H
#define SD_SHAPE_RHOMBUS_H
#ifndef MM_SD_SHAPE_RHOMBUS_H
#define MM_SD_SHAPE_RHOMBUS_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdShapeRhombus : public MMNode {
GDCLASS(SdShapeRhombus, MMNode);
class MMSdShapeRhombus : public MMNode {
GDCLASS(MMSdShapeRhombus, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
Vector2 get_center();
void set_center(const Vector2 &val);
Vector2 get_center();
void set_center(const Vector2 &val);
Vector2 get_size();
void set_size(const Vector2 &val);
Vector2 get_size();
void set_size(const Vector2 &val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
float _get_property_value(const Vector2 &uv);
Vector2 get_center();
void set_center(const Vector2 &val);
Vector2 get_size();
void set_size(const Vector2 &val);
MMSdShapeRhombus();
~MMSdShapeRhombus();
SdShapeRhombus();
~SdShapeRhombus();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(Vector2)
Vector2 center = Vector2(0, 0);
//export(Vector2)
Vector2 size = Vector2(0.3, 0.2);
//center
//size
Ref<MMNodeUniversalProperty> output;
Vector2 center;
Vector2 size;
};
#endif

View File

@ -1,166 +1,107 @@
#include "sd_show.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> SdShow::get_image() {
return image;
Ref<MMNodeUniversalProperty> SSSdShow::get_image() {
return image;
}
void SdShow::set_image(const Ref<Resource> &val) {
image = val;
void SSSdShow::set_image(const Ref<MMNodeUniversalProperty> &val) {
image = val;
}
Ref<Resource> SdShow::get_input() {
return input;
Ref<MMNodeUniversalProperty> SSSdShow::get_input() {
return input;
}
void SdShow::set_input(const Ref<Resource> &val) {
input = val;
void SSSdShow::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
float SdShow::get_bevel() const {
return bevel;
float SSSdShow::get_bevel() const {
return bevel;
}
void SdShow::set_bevel(const float val) {
bevel = val;
void SSSdShow::set_bevel(const float val) {
bevel = val;
set_dirty(true);
}
float SdShow::get_base() const {
return base;
float SSSdShow::get_base() const {
return base;
}
void SdShow::set_base(const float val) {
base = val;
void SSSdShow::set_base(const float val) {
base = val;
set_dirty(true);
}
void SSSdShow::_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;
//export(Resource) ;
Ref<Resource> image;
//export(Resource) ;
Ref<Resource> input;
//export(float) ;
float bevel = 0;
//export(float) ;
float base = 0;
if (!input.is_valid()) {
input.instance();
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
void SdShow::_init_properties() {
//for some reason this doesn't work, todo check;
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input->set_slot_name("Input");
if (!image) {
image = MMNodeUniversalProperty.new();
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
register_output_property(image);
register_input_property(input);
}
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
if (!input) {
input = MMNodeUniversalProperty.new();
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
void SSSdShow::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_texture_universal(image);
mm_graph_node->add_slot_label_universal(input);
mm_graph_node->add_slot_float("get_bevel", "set_bevel", "Bevel", 0.01);
mm_graph_node->add_slot_float("get_base", "set_base", "Base", 0.01);
}
//for some reason this doesn't work, todo check;
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
input.slot_name = "Input";
register_output_property(image);
register_input_property(input);
void SSSdShow::_render(const Ref<MMMaterial> &material) {
Ref<Image> img = render_image(material);
image->set_value(img);
}
void SdShow::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_texture_universal(image);
mm_graph_node.add_slot_label_universal(input);
mm_graph_node.add_slot_float("get_bevel", "set_bevel", "Bevel", 0.01);
mm_graph_node.add_slot_float("get_base", "set_base", "Base", 0.01);
Color SSSdShow::_get_value_for(const Vector2 &uv, const int pseed) {
float f = input->get_value(uv);
//clamp($base-$in($uv)/max($bevel, 0.00001), 0.0, 1.0);
float cf = CLAMP(base - f / MAX(bevel, 0.00001), 0.0, 1.0);
return Color(cf, cf, cf, 1);
}
void SdShow::_render(const Variant &material) {
Ref<Image> img = render_image(material);
image.set_value(img);
SSSdShow::SSSdShow() {
bevel = 0;
base = 0;
}
Color SdShow::_get_value_for(const Vector2 &uv, const int pseed) {
float f = input.get_value(uv);
//clamp($base-$in($uv)/max($bevel, 0.00001), 0.0, 1.0);
float cf = clamp(base - f / max(bevel, 0.00001), 0.0, 1.0);
return Color(cf, cf, cf, 1);
SSSdShow::~SSSdShow() {
}
//bevel;
void SSSdShow::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &SSSdShow::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &SSSdShow::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
float SdShow::get_bevel() {
return bevel;
ClassDB::bind_method(D_METHOD("get_input"), &SSSdShow::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &SSSdShow::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_bevel"), &SSSdShow::get_bevel);
ClassDB::bind_method(D_METHOD("set_bevel", "value"), &SSSdShow::set_bevel);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bevel"), "set_bevel", "get_bevel");
ClassDB::bind_method(D_METHOD("get_base"), &SSSdShow::get_base);
ClassDB::bind_method(D_METHOD("set_base", "value"), &SSSdShow::set_base);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "base"), "set_base", "get_base");
}
void SdShow::set_bevel(const float val) {
bevel = val;
set_dirty(true);
}
//base;
float SdShow::get_base() {
return base;
}
void SdShow::set_base(const float val) {
base = val;
set_dirty(true);
}
}
SdShow::SdShow() {
image;
input;
bevel = 0;
base = 0;
}
SdShow::~SdShow() {
}
static void SdShow::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_image"), &SdShow::get_image);
ClassDB::bind_method(D_METHOD("set_image", "value"), &SdShow::set_image);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
ClassDB::bind_method(D_METHOD("get_input"), &SdShow::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &SdShow::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
ClassDB::bind_method(D_METHOD("get_bevel"), &SdShow::get_bevel);
ClassDB::bind_method(D_METHOD("set_bevel", "value"), &SdShow::set_bevel);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bevel"), "set_bevel", "get_bevel");
ClassDB::bind_method(D_METHOD("get_base"), &SdShow::get_base);
ClassDB::bind_method(D_METHOD("set_base", "value"), &SdShow::set_base);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "base"), "set_base", "get_base");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdShow::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdShow::_register_methods);
ClassDB::bind_method(D_METHOD("_render", "material"), &SdShow::_render);
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &SdShow::_get_value_for);
ClassDB::bind_method(D_METHOD("get_bevel"), &SdShow::get_bevel);
ClassDB::bind_method(D_METHOD("set_bevel", "val"), &SdShow::set_bevel);
ClassDB::bind_method(D_METHOD("get_base"), &SdShow::get_base);
ClassDB::bind_method(D_METHOD("set_base", "val"), &SdShow::set_base);
}

View File

@ -1,51 +1,41 @@
#ifndef SD_SHOW_H
#define SD_SHOW_H
#ifndef MM_SD_SHOW_H
#define MM_SD_SHOW_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdShow : public MMNode {
GDCLASS(SdShow, MMNode);
class SSSdShow : public MMNode {
GDCLASS(SSSdShow, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_image();
void set_image(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_image();
void set_image(const Ref<Resource> &val);
Ref<MMNodeUniversalProperty> get_input();
void set_input(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input();
void set_input(const Ref<Resource> &val);
float get_bevel() const;
void set_bevel(const float val);
float get_bevel() const;
void set_bevel(const float val);
float get_base() const;
void set_base(const float val);
float get_base() const;
void set_base(const float val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
void _render(const Ref<MMMaterial> &material);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _render(const Variant &material);
Color _get_value_for(const Vector2 &uv, const int pseed);
float get_bevel();
void set_bevel(const float val);
float get_base();
void set_base(const float val);
Color _get_value_for(const Vector2 &uv, const int pseed);
SdShow();
~SdShow();
SSSdShow();
~SSSdShow();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> image;
//export(Resource)
Ref<Resource> input;
//export(float)
float bevel = 0;
//export(float)
float base = 0;
//bevel
//base
Ref<MMNodeUniversalProperty> image;
Ref<MMNodeUniversalProperty> input;
float bevel;
float base;
};
#endif

View File

@ -1,102 +1,67 @@
#include "sd_tf_rotate.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> SdTfRotate::get_output() {
return output;
Ref<MMNodeUniversalProperty> MMSdTfRotate::get_output() {
return output;
}
void SdTfRotate::set_output(const Ref<Resource> &val) {
output = val;
void MMSdTfRotate::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
float SdTfRotate::get_angle() const {
return angle;
float MMSdTfRotate::get_angle() const {
return angle;
}
void SdTfRotate::set_angle(const float val) {
angle = val;
void MMSdTfRotate::set_angle(const float val) {
angle = val;
emit_changed();
output->do_emit_changed();
}
void MMSdTfRotate::_init_properties() {
if (!output.is_valid()) {
output.instance();
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
output->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output->set_slot_name(">>> Apply >>>");
output->set_get_value_from_owner(true);
//tool;
//export(Resource) ;
Ref<Resource> output;
//export(float) ;
float angle = 0;
void SdTfRotate::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
register_input_property(output);
register_output_property(output);
}
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Apply >>>";
output.get_value_from_owner = true;
register_input_property(output);
register_output_property(output);
void MMSdTfRotate::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(output);
mm_graph_node->add_slot_float("get_angle", "set_angle", "Angle", 1);
}
void SdTfRotate::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_float("get_angle", "set_angle", "Angle", 1);
Variant MMSdTfRotate::_get_property_value(const Vector2 &uv) {
//$in(sdf2d_rotate($uv, $a*0.01745329251))",;
return output->get_value(MMAlgos::sdf2d_rotate(uv, angle * 0.01745329251), true);
}
void SdTfRotate::_get_property_value(const Vector2 &uv) {
//$in(sdf2d_rotate($uv, $a*0.01745329251))",;
return output.get_value(MMAlgos.sdf2d_rotate(uv, angle * 0.01745329251), true);
MMSdTfRotate::MMSdTfRotate() {
angle = 0;
}
//angle;
float SdTfRotate::get_angle() {
return angle;
MMSdTfRotate::~MMSdTfRotate() {
}
void MMSdTfRotate::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &MMSdTfRotate::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdTfRotate::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
void SdTfRotate::set_angle(const float val) {
angle = val;
emit_changed();
output.emit_changed();
ClassDB::bind_method(D_METHOD("get_angle"), &MMSdTfRotate::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "value"), &MMSdTfRotate::set_angle);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angle"), "set_angle", "get_angle");
}
}
SdTfRotate::SdTfRotate() {
output;
angle = 0;
}
SdTfRotate::~SdTfRotate() {
}
static void SdTfRotate::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdTfRotate::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdTfRotate::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_angle"), &SdTfRotate::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "value"), &SdTfRotate::set_angle);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angle"), "set_angle", "get_angle");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdTfRotate::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdTfRotate::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdTfRotate::_get_property_value);
ClassDB::bind_method(D_METHOD("get_angle"), &SdTfRotate::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "val"), &SdTfRotate::set_angle);
}

View File

@ -1,37 +1,31 @@
#ifndef SD_TF_ROTATE_H
#define SD_TF_ROTATE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdTfRotate : public MMNode {
GDCLASS(SdTfRotate, MMNode);
class MMSdTfRotate : public MMNode {
GDCLASS(MMSdTfRotate, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
float get_angle() const;
void set_angle(const float val);
float get_angle() const;
void set_angle(const float val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _get_property_value(const Vector2 &uv);
float get_angle();
void set_angle(const float val);
MMSdTfRotate();
~MMSdTfRotate();
SdTfRotate();
~SdTfRotate();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(float)
float angle = 0;
//angle
Ref<MMNodeUniversalProperty> output;
float angle;
};
#endif

View File

@ -1,102 +1,67 @@
#include "sd_tf_scale.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> SdTfScale::get_output() {
return output;
Ref<MMNodeUniversalProperty> MMSdTfScale::get_output() {
return output;
}
void SdTfScale::set_output(const Ref<Resource> &val) {
output = val;
void MMSdTfScale::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
float SdTfScale::get_scale() const {
return scale;
float MMSdTfScale::get_scale() const {
return scale;
}
void SdTfScale::set_scale(const float val) {
scale = val;
void MMSdTfScale::set_scale(const float val) {
scale = val;
emit_changed();
output->do_emit_changed();
}
void MMSdTfScale::_init_properties() {
if (!output.is_valid()) {
output.instance();
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
output->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output->set_slot_name(">>> Apply >>>");
output->set_get_value_from_owner(true);
//tool;
//export(Resource) ;
Ref<Resource> output;
//export(float) ;
float scale = 1;
void SdTfScale::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
register_input_property(output);
register_output_property(output);
}
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Apply >>>";
output.get_value_from_owner = true;
register_input_property(output);
register_output_property(output);
void MMSdTfScale::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(output);
mm_graph_node->add_slot_float("get_scale", "set_scale", "Scale", 0.01);
}
void SdTfScale::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_float("get_scale", "set_scale", "Scale", 0.01);
Variant MMSdTfScale::_get_property_value(const Vector2 &uv) {
//$in(($uv-vec2(0.5))/$s+vec2(0.5))*$s;
return output->get_value(((uv - Vector2(0.5, 0.5)) / scale + Vector2(0.5, 0.5)), true);
}
void SdTfScale::_get_property_value(const Vector2 &uv) {
//$in(($uv-vec2(0.5))/$s+vec2(0.5))*$s;
return output.get_value(((uv - Vector2(0.5, 0.5)) / scale + Vector2(0.5, 0.5)), true);
MMSdTfScale::MMSdTfScale() {
scale = 1;
}
//scale;
float SdTfScale::get_scale() {
return scale;
MMSdTfScale::~MMSdTfScale() {
}
void MMSdTfScale::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &MMSdTfScale::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdTfScale::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
void SdTfScale::set_scale(const float val) {
scale = val;
emit_changed();
output.emit_changed();
ClassDB::bind_method(D_METHOD("get_scale"), &MMSdTfScale::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "value"), &MMSdTfScale::set_scale);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale"), "set_scale", "get_scale");
}
}
SdTfScale::SdTfScale() {
output;
scale = 1;
}
SdTfScale::~SdTfScale() {
}
static void SdTfScale::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdTfScale::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdTfScale::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_scale"), &SdTfScale::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "value"), &SdTfScale::set_scale);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale"), "set_scale", "get_scale");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdTfScale::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdTfScale::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdTfScale::_get_property_value);
ClassDB::bind_method(D_METHOD("get_scale"), &SdTfScale::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "val"), &SdTfScale::set_scale);
}

View File

@ -1,37 +1,31 @@
#ifndef SD_TF_SCALE_H
#define SD_TF_SCALE_H
#ifndef MM_SD_TF_SCALE_H
#define MM_SD_TF_SCALE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdTfScale : public MMNode {
GDCLASS(SdTfScale, MMNode);
class MMSdTfScale : public MMNode {
GDCLASS(MMSdTfScale, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
float get_scale() const;
void set_scale(const float val);
float get_scale() const;
void set_scale(const float val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _get_property_value(const Vector2 &uv);
float get_scale();
void set_scale(const float val);
MMSdTfScale();
~MMSdTfScale();
SdTfScale();
~SdTfScale();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(float)
float scale = 1;
//scale
Ref<MMNodeUniversalProperty> output;
float scale;
};
#endif

View File

@ -1,101 +1,66 @@
#include "sd_tf_translate.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> SdTfTranslate::get_output() {
return output;
Ref<MMNodeUniversalProperty> MMSdTfTranslate::get_output() {
return output;
}
void SdTfTranslate::set_output(const Ref<Resource> &val) {
output = val;
void MMSdTfTranslate::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
Vector2 SdTfTranslate::get_translation() {
return translation;
Vector2 MMSdTfTranslate::get_translation() {
return translation;
}
void SdTfTranslate::set_translation(const Vector2 &val) {
translation = val;
void MMSdTfTranslate::set_translation(const Vector2 &val) {
translation = val;
emit_changed();
output->do_emit_changed();
}
void MMSdTfTranslate::_init_properties() {
if (!output.is_valid()) {
output.instance();
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
output->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output->set_slot_name(">>> Apply >>>");
output->set_get_value_from_owner(true);
//tool;
//export(Resource) ;
Ref<Resource> output;
//export(Vector2) ;
Vector2 translation = Vector2(0, 0);
void SdTfTranslate::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
register_input_property(output);
register_output_property(output);
}
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Apply >>>";
output.get_value_from_owner = true;
register_input_property(output);
register_output_property(output);
void MMSdTfTranslate::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(output);
mm_graph_node->add_slot_vector2("get_translation", "set_translation", "Translation", 0.01);
}
void SdTfTranslate::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_vector2("get_translation", "set_translation", "Translation", 0.01);
Variant MMSdTfTranslate::_get_property_value(const Vector2 &uv) {
return output->get_value(uv - translation, true);
}
void SdTfTranslate::_get_property_value(const Vector2 &uv) {
return output.get_value(uv - translation, true);
MMSdTfTranslate::MMSdTfTranslate() {
translation = Vector2(0, 0);
}
//a;
Vector2 SdTfTranslate::get_translation() {
return translation;
MMSdTfTranslate::~MMSdTfTranslate() {
}
void MMSdTfTranslate::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &MMSdTfTranslate::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdTfTranslate::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
void SdTfTranslate::set_translation(const Vector2 &val) {
translation = val;
emit_changed();
output.emit_changed();
ClassDB::bind_method(D_METHOD("get_translation"), &MMSdTfTranslate::get_translation);
ClassDB::bind_method(D_METHOD("set_translation", "value"), &MMSdTfTranslate::set_translation);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "translation"), "set_translation", "get_translation");
}
}
SdTfTranslate::SdTfTranslate() {
output;
translation = Vector2(0, 0);
}
SdTfTranslate::~SdTfTranslate() {
}
static void SdTfTranslate::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdTfTranslate::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdTfTranslate::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_translation"), &SdTfTranslate::get_translation);
ClassDB::bind_method(D_METHOD("set_translation", "value"), &SdTfTranslate::set_translation);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "translation"), "set_translation", "get_translation");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdTfTranslate::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdTfTranslate::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdTfTranslate::_get_property_value);
ClassDB::bind_method(D_METHOD("get_translation"), &SdTfTranslate::get_translation);
ClassDB::bind_method(D_METHOD("set_translation", "val"), &SdTfTranslate::set_translation);
}

View File

@ -1,37 +1,31 @@
#ifndef SD_TF_TRANSLATE_H
#define SD_TF_TRANSLATE_H
#ifndef MM_SD_TF_TRANSLATE_H
#define MM_SD_TF_TRANSLATE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdTfTranslate : public MMNode {
GDCLASS(SdTfTranslate, MMNode);
class MMSdTfTranslate : public MMNode {
GDCLASS(MMSdTfTranslate, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
Vector2 get_translation();
void set_translation(const Vector2 &val);
Vector2 get_translation();
void set_translation(const Vector2 &val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _get_property_value(const Vector2 &uv);
Vector2 get_translation();
void set_translation(const Vector2 &val);
MMSdTfTranslate();
~MMSdTfTranslate();
SdTfTranslate();
~SdTfTranslate();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(Vector2)
Vector2 translation = Vector2(0, 0);
//a
Ref<MMNodeUniversalProperty> output;
Vector2 translation;
};
#endif

View File

@ -84,6 +84,14 @@ SOFTWARE.
#include "nodes/sdf3d/sdf3d_op_rounded.h"
#include "nodes/sdf3d/sdf3d_op_smooth_bool.h"
#include "nodes/sdf2d/sd_shape_rhombus.h"
#include "nodes/sdf2d/sd_tf_rotate.h"
#include "nodes/sdf2d/sd_tf_scale.h"
#include "nodes/sdf2d/sd_tf_translate.h"
#include "nodes/sdf2d/sd_show.h"
static _MMAlgos *_mm_algos_singleton = nullptr;
void register_material_maker_types() {
@ -177,6 +185,19 @@ void register_material_maker_types() {
ClassDB::register_class<MMSdf3dOpBool>();
MMAlgos::register_node_class("SDF3D - OP", "MMSdf3dOpBool");
ClassDB::register_class<SSSdShow>();
MMAlgos::register_node_class("SDF2D", "SSSdShow");
ClassDB::register_class<MMSdShapeRhombus>();
MMAlgos::register_node_class("SDF2D - Shape", "MMSdShapeRhombus");
ClassDB::register_class<MMSdTfTranslate>();
MMAlgos::register_node_class("SDF2D - TF", "MMSdTfTranslate");
ClassDB::register_class<MMSdTfScale>();
MMAlgos::register_node_class("SDF2D - TF", "MMSdTfScale");
ClassDB::register_class<MMSdTfRotate>();
MMAlgos::register_node_class("SDF2D - TF", "MMSdTfRotate");
_mm_algos_singleton = memnew(_MMAlgos);
Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton()));