mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-24 18:17:21 +01:00
Cleaned up sdf3d op nodes, and sdf3d color.
This commit is contained in:
parent
88f2303cf8
commit
8282061088
@ -70,6 +70,7 @@ sources = [
|
||||
"nodes/simple/curve.cpp",
|
||||
|
||||
"nodes/sdf3d/sdf3d_render.cpp",
|
||||
"nodes/sdf3d/sdf3d_color.cpp",
|
||||
|
||||
"nodes/sdf3d/sdf3d_tf_translate.cpp",
|
||||
"nodes/sdf3d/sdf3d_tf_scale.cpp",
|
||||
@ -82,6 +83,15 @@ sources = [
|
||||
"nodes/sdf3d/sdf3d_shape_capsule.cpp",
|
||||
"nodes/sdf3d/sdf3d_shape_box.cpp",
|
||||
|
||||
"nodes/sdf3d/sdf3d_op_smooth_bool.cpp",
|
||||
"nodes/sdf3d/sdf3d_op_rounded.cpp",
|
||||
"nodes/sdf3d/sdf3d_op_revolution.cpp",
|
||||
"nodes/sdf3d/sdf3d_op_repeat.cpp",
|
||||
"nodes/sdf3d/sdf3d_op_morph.cpp",
|
||||
"nodes/sdf3d/sdf3d_op_elongation.cpp",
|
||||
"nodes/sdf3d/sdf3d_op_circle_repeat.cpp",
|
||||
"nodes/sdf3d/sdf3d_op_bool.cpp",
|
||||
|
||||
]
|
||||
|
||||
if env["tools"]:
|
||||
|
@ -40,6 +40,7 @@ def get_doc_classes():
|
||||
"MMCurve",
|
||||
|
||||
"MMSdf3dRender",
|
||||
"MMSdf3dColor",
|
||||
|
||||
"MMSdf3dTfTranslate",
|
||||
"MMSdf3dTfScale",
|
||||
@ -51,6 +52,15 @@ def get_doc_classes():
|
||||
"MMSdf3dShapeCone",
|
||||
"MMSdf3dShapeCapsule",
|
||||
"MMSdf3dShapeBox",
|
||||
|
||||
"MMSdf3dOpSmoothBool",
|
||||
"MMSdf3dOpRounded",
|
||||
"MMSdf3dOpRevolution",
|
||||
"MMSdf3dOpRepeat",
|
||||
"MMSdf3dOpMorph",
|
||||
"MMSdf3dOpElongation",
|
||||
"MMSdf3dOpCircleRepeat",
|
||||
"MMSdf3dOpBool",
|
||||
]
|
||||
|
||||
def get_doc_path():
|
||||
|
@ -1,140 +1,101 @@
|
||||
|
||||
#include "sdf3d_color.h"
|
||||
|
||||
#include "../../algos/mm_algos.h"
|
||||
#include "../../editor/mm_graph_node.h"
|
||||
#include "../mm_material.h"
|
||||
|
||||
Ref<Resource> Sdf3dColor::get_input() {
|
||||
return input;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dColor::get_input() {
|
||||
return input;
|
||||
}
|
||||
|
||||
void Sdf3dColor::set_input(const Ref<Resource> &val) {
|
||||
input = val;
|
||||
void MMSdf3dColor::set_input(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<Resource> Sdf3dColor::get_output() {
|
||||
return output;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dColor::get_output() {
|
||||
return output;
|
||||
}
|
||||
|
||||
void Sdf3dColor::set_output(const Ref<Resource> &val) {
|
||||
output = val;
|
||||
void MMSdf3dColor::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||
output = val;
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
|
||||
float Sdf3dColor::get_color() const {
|
||||
return color;
|
||||
float MMSdf3dColor::get_color() const {
|
||||
return color;
|
||||
}
|
||||
|
||||
void Sdf3dColor::set_color(const float val) {
|
||||
color = val;
|
||||
void MMSdf3dColor::set_color(const float val) {
|
||||
color = val;
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
void MMSdf3dColor::_init_properties() {
|
||||
if (!input.is_valid()) {
|
||||
input.instance();
|
||||
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input->set_slot_name(">>> Input ");
|
||||
|
||||
//tool;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> output;
|
||||
//export(float) ;
|
||||
float color = 0.5;
|
||||
if (!input->is_connected("changed", this, "on_input_changed")) {
|
||||
input->connect("changed", this, "on_input_changed");
|
||||
}
|
||||
|
||||
void Sdf3dColor::_init_properties() {
|
||||
if (!output.is_valid()) {
|
||||
output.instance();
|
||||
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
if (!input) {
|
||||
input = MMNodeUniversalProperty.new();
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||
output->set_slot_name(">>> Output >>>");
|
||||
output->set_get_value_from_owner(true);
|
||||
|
||||
register_input_property(input);
|
||||
register_output_property(output);
|
||||
}
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input.slot_name = ">>> Input ";
|
||||
|
||||
if (!input.is_connected("changed", self, "on_input_changed")) {
|
||||
input.connect("changed", self, "on_input_changed");
|
||||
void MMSdf3dColor::_register_methods(MMGraphNode *mm_graph_node) {
|
||||
mm_graph_node->add_slot_label_universal(input);
|
||||
mm_graph_node->add_slot_label_universal(output);
|
||||
mm_graph_node->add_slot_float("get_color", "set_color", "Color", 0.01);
|
||||
}
|
||||
|
||||
|
||||
if (!output) {
|
||||
output = MMNodeUniversalProperty.new();
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
Vector2 MMSdf3dColor::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
Vector2 v = input->get_value_sdf3d(uv3);
|
||||
v.y = color;
|
||||
return v;
|
||||
}
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
output.slot_name = ">>> Output >>>";
|
||||
output.get_value_from_owner = true;
|
||||
register_input_property(input);
|
||||
register_output_property(output);
|
||||
void MMSdf3dColor::on_input_changed() {
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dColor::_register_methods(const Variant &mm_graph_node) {
|
||||
mm_graph_node.add_slot_label_universal(input);
|
||||
mm_graph_node.add_slot_label_universal(output);
|
||||
mm_graph_node.add_slot_float("get_color", "set_color", "Color", 0.01);
|
||||
MMSdf3dColor::MMSdf3dColor() {
|
||||
color = 0.5;
|
||||
}
|
||||
|
||||
|
||||
Vector2 Sdf3dColor::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
Vector2 v = input.get_value_sdf3d(uv3);
|
||||
v.y = color;
|
||||
return v;
|
||||
MMSdf3dColor::~MMSdf3dColor() {
|
||||
}
|
||||
|
||||
//color;
|
||||
void MMSdf3dColor::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &MMSdf3dColor::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMSdf3dColor::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
|
||||
|
||||
float Sdf3dColor::get_color() {
|
||||
return color;
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dColor::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dColor::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_color"), &MMSdf3dColor::get_color);
|
||||
ClassDB::bind_method(D_METHOD("set_color", "value"), &MMSdf3dColor::set_color);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "color"), "set_color", "get_color");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdf3dColor::on_input_changed);
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dColor::set_color(const float val) {
|
||||
color = val;
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dColor::on_input_changed() {
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Sdf3dColor::Sdf3dColor() {
|
||||
input;
|
||||
output;
|
||||
color = 0.5;
|
||||
}
|
||||
|
||||
Sdf3dColor::~Sdf3dColor() {
|
||||
}
|
||||
|
||||
|
||||
static void Sdf3dColor::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &Sdf3dColor::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &Sdf3dColor::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dColor::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dColor::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_color"), &Sdf3dColor::get_color);
|
||||
ClassDB::bind_method(D_METHOD("set_color", "value"), &Sdf3dColor::set_color);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "color"), "set_color", "get_color");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dColor::_init_properties);
|
||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dColor::_register_methods);
|
||||
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dColor::_get_property_value_sdf3d);
|
||||
ClassDB::bind_method(D_METHOD("get_color"), &Sdf3dColor::get_color);
|
||||
ClassDB::bind_method(D_METHOD("set_color", "val"), &Sdf3dColor::set_color);
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &Sdf3dColor::on_input_changed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,43 +1,37 @@
|
||||
#ifndef SDF3D_COLOR_H
|
||||
#define SDF3D_COLOR_H
|
||||
#ifndef MM_SDF3D_COLOR_H
|
||||
#define MM_SDF3D_COLOR_H
|
||||
|
||||
#include "../mm_node.h"
|
||||
#include "../mm_node_universal_property.h"
|
||||
|
||||
class Sdf3dColor : public MMNode {
|
||||
GDCLASS(Sdf3dColor, MMNode);
|
||||
class MMSdf3dColor : public MMNode {
|
||||
GDCLASS(MMSdf3dColor, MMNode);
|
||||
|
||||
public:
|
||||
public:
|
||||
Ref<MMNodeUniversalProperty> get_input();
|
||||
void set_input(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input();
|
||||
void set_input(const Ref<Resource> &val);
|
||||
Ref<MMNodeUniversalProperty> get_output();
|
||||
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_output();
|
||||
void set_output(const Ref<Resource> &val);
|
||||
float get_color() const;
|
||||
void set_color(const float val);
|
||||
|
||||
float get_color() const;
|
||||
void set_color(const float val);
|
||||
void _init_properties();
|
||||
void _register_methods(MMGraphNode *mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
|
||||
void _init_properties();
|
||||
void _register_methods(const Variant &mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
float get_color();
|
||||
void set_color(const float val);
|
||||
void on_input_changed();
|
||||
void on_input_changed();
|
||||
|
||||
Sdf3dColor();
|
||||
~Sdf3dColor();
|
||||
MMSdf3dColor();
|
||||
~MMSdf3dColor();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
//export(Resource)
|
||||
Ref<Resource> input;
|
||||
//export(Resource)
|
||||
Ref<Resource> output;
|
||||
//export(float)
|
||||
float color = 0.5;
|
||||
//color
|
||||
Ref<MMNodeUniversalProperty> input;
|
||||
Ref<MMNodeUniversalProperty> output;
|
||||
float color;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,188 +1,141 @@
|
||||
|
||||
#include "sdf3d_op_bool.h"
|
||||
|
||||
#include "../../algos/mm_algos.h"
|
||||
#include "../../editor/mm_graph_node.h"
|
||||
#include "../mm_material.h"
|
||||
|
||||
Ref<Resource> Sdf3dOpBool::get_input1() {
|
||||
return input1;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpBool::get_input1() {
|
||||
return input1;
|
||||
}
|
||||
|
||||
void Sdf3dOpBool::set_input1(const Ref<Resource> &val) {
|
||||
input1 = val;
|
||||
void MMSdf3dOpBool::set_input1(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input1 = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<Resource> Sdf3dOpBool::get_input2() {
|
||||
return input2;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpBool::get_input2() {
|
||||
return input2;
|
||||
}
|
||||
|
||||
void Sdf3dOpBool::set_input2(const Ref<Resource> &val) {
|
||||
input2 = val;
|
||||
void MMSdf3dOpBool::set_input2(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input2 = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<Resource> Sdf3dOpBool::get_output() {
|
||||
return output;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpBool::get_output() {
|
||||
return output;
|
||||
}
|
||||
|
||||
void Sdf3dOpBool::set_output(const Ref<Resource> &val) {
|
||||
output = val;
|
||||
void MMSdf3dOpBool::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||
output = val;
|
||||
}
|
||||
|
||||
|
||||
int Sdf3dOpBool::get_operation() const {
|
||||
return operation;
|
||||
int MMSdf3dOpBool::get_operation() const {
|
||||
return operation;
|
||||
}
|
||||
|
||||
void Sdf3dOpBool::set_operation(const int val) {
|
||||
operation = val;
|
||||
void MMSdf3dOpBool::set_operation(const int val) {
|
||||
operation = val;
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
void MMSdf3dOpBool::_init_properties() {
|
||||
if (!input1.is_valid()) {
|
||||
input1.instance();
|
||||
input1->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
input1->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input1->set_slot_name(">>> Input 1 ");
|
||||
|
||||
//tool;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input1;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input2;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> output;
|
||||
//export(int, "Union,Substraction,Intersection") ;
|
||||
int operation = 0;
|
||||
if (!input1->is_connected("changed", this, "on_input_changed")) {
|
||||
input1->connect("changed", this, "on_input_changed");
|
||||
}
|
||||
|
||||
void Sdf3dOpBool::_init_properties() {
|
||||
if (!input2.is_valid()) {
|
||||
input2.instance();
|
||||
input2->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
if (!input1) {
|
||||
input1 = MMNodeUniversalProperty.new();
|
||||
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
input2->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
// input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input2->set_slot_name(">>> Input 2 ");
|
||||
|
||||
if (!input2->is_connected("changed", this, "on_input_changed")) {
|
||||
input2->connect("changed", this, "on_input_changed");
|
||||
}
|
||||
|
||||
if (!output.is_valid()) {
|
||||
output.instance();
|
||||
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||
output->set_slot_name(">>> Output >>>");
|
||||
output->set_get_value_from_owner(true);
|
||||
|
||||
register_input_property(input1);
|
||||
register_input_property(input2);
|
||||
register_output_property(output);
|
||||
}
|
||||
|
||||
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input1.slot_name = ">>> Input 1 ";
|
||||
void MMSdf3dOpBool::_register_methods(MMGraphNode *mm_graph_node) {
|
||||
mm_graph_node->add_slot_label_universal(input1);
|
||||
mm_graph_node->add_slot_label_universal(input2);
|
||||
mm_graph_node->add_slot_label_universal(output);
|
||||
|
||||
if (!input1.is_connected("changed", self, "on_input_changed")) {
|
||||
input1.connect("changed", self, "on_input_changed");
|
||||
Array arr;
|
||||
arr.push_back("Union");
|
||||
arr.push_back("Substraction");
|
||||
arr.push_back("Intersection");
|
||||
|
||||
mm_graph_node->add_slot_enum("get_operation", "set_operation", "Operation", arr);
|
||||
}
|
||||
|
||||
Vector2 MMSdf3dOpBool::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
Vector2 s1 = input1->get_value_sdf3d(uv3);
|
||||
Vector2 s2 = input2->get_value_sdf3d(uv3);
|
||||
|
||||
if (!input2) {
|
||||
input2 = MMNodeUniversalProperty.new();
|
||||
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
if (operation == 0) {
|
||||
return MMAlgos::sdf3dc_union(s1, s2);
|
||||
} else if (operation == 1) {
|
||||
return MMAlgos::sdf3dc_sub(s1, s2);
|
||||
} else if (operation == 2) {
|
||||
return MMAlgos::sdf3dc_inter(s1, s2);
|
||||
}
|
||||
|
||||
return Vector2();
|
||||
}
|
||||
|
||||
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
// input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input2.slot_name = ">>> Input 2 ";
|
||||
|
||||
if (!input2.is_connected("changed", self, "on_input_changed")) {
|
||||
input2.connect("changed", self, "on_input_changed");
|
||||
void MMSdf3dOpBool::on_input_changed() {
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
|
||||
if (!output) {
|
||||
output = MMNodeUniversalProperty.new();
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
MMSdf3dOpBool::MMSdf3dOpBool() {
|
||||
operation = 0;
|
||||
}
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
output.slot_name = ">>> Output >>>";
|
||||
output.get_value_from_owner = true;
|
||||
register_input_property(input1);
|
||||
register_input_property(input2);
|
||||
register_output_property(output);
|
||||
MMSdf3dOpBool::~MMSdf3dOpBool() {
|
||||
}
|
||||
|
||||
void MMSdf3dOpBool::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input1"), &MMSdf3dOpBool::get_input1);
|
||||
ClassDB::bind_method(D_METHOD("set_input1", "value"), &MMSdf3dOpBool::set_input1);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input1", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input1", "get_input1");
|
||||
|
||||
void Sdf3dOpBool::_register_methods(const Variant &mm_graph_node) {
|
||||
mm_graph_node.add_slot_label_universal(input1);
|
||||
mm_graph_node.add_slot_label_universal(input2);
|
||||
mm_graph_node.add_slot_label_universal(output);
|
||||
mm_graph_node.add_slot_enum("get_operation", "set_operation", "Operation", [ "Union", "Substraction", "Intersection" ]);
|
||||
ClassDB::bind_method(D_METHOD("get_input2"), &MMSdf3dOpBool::get_input2);
|
||||
ClassDB::bind_method(D_METHOD("set_input2", "value"), &MMSdf3dOpBool::set_input2);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input2", "get_input2");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dOpBool::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dOpBool::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_operation"), &MMSdf3dOpBool::get_operation);
|
||||
ClassDB::bind_method(D_METHOD("set_operation", "value"), &MMSdf3dOpBool::set_operation);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation"), "set_operation", "get_operation");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdf3dOpBool::on_input_changed);
|
||||
}
|
||||
|
||||
|
||||
Vector2 Sdf3dOpBool::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
Vector2 s1 = input1.get_value_sdf3d(uv3);
|
||||
Vector2 s2 = input2.get_value_sdf3d(uv3);
|
||||
|
||||
if (operation == 0) {
|
||||
return MMAlgos.sdf3dc_union(s1, s2);
|
||||
}
|
||||
|
||||
|
||||
else if (operation == 1) {
|
||||
return MMAlgos.sdf3dc_sub(s1, s2);
|
||||
}
|
||||
|
||||
|
||||
else if (operation == 2) {
|
||||
return MMAlgos.sdf3dc_inter(s1, s2);
|
||||
}
|
||||
|
||||
return Vector2();
|
||||
}
|
||||
|
||||
//operation;
|
||||
|
||||
int Sdf3dOpBool::get_operation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpBool::set_operation(const int val) {
|
||||
operation = val;
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpBool::on_input_changed() {
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Sdf3dOpBool::Sdf3dOpBool() {
|
||||
input1;
|
||||
input2;
|
||||
output;
|
||||
operation = 0;
|
||||
}
|
||||
|
||||
Sdf3dOpBool::~Sdf3dOpBool() {
|
||||
}
|
||||
|
||||
|
||||
static void Sdf3dOpBool::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input1"), &Sdf3dOpBool::get_input1);
|
||||
ClassDB::bind_method(D_METHOD("set_input1", "value"), &Sdf3dOpBool::set_input1);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input1", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input1", "get_input1");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_input2"), &Sdf3dOpBool::get_input2);
|
||||
ClassDB::bind_method(D_METHOD("set_input2", "value"), &Sdf3dOpBool::set_input2);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input2", "get_input2");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dOpBool::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dOpBool::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_operation"), &Sdf3dOpBool::get_operation);
|
||||
ClassDB::bind_method(D_METHOD("set_operation", "value"), &Sdf3dOpBool::set_operation);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation"), "set_operation", "get_operation");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dOpBool::_init_properties);
|
||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dOpBool::_register_methods);
|
||||
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dOpBool::_get_property_value_sdf3d);
|
||||
ClassDB::bind_method(D_METHOD("get_operation"), &Sdf3dOpBool::get_operation);
|
||||
ClassDB::bind_method(D_METHOD("set_operation", "val"), &Sdf3dOpBool::set_operation);
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &Sdf3dOpBool::on_input_changed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,48 +1,42 @@
|
||||
#ifndef SDF3D_OP_BOOL_H
|
||||
#define SDF3D_OP_BOOL_H
|
||||
#ifndef MM_SDF3D_OP_BOOL_H
|
||||
#define MM_SDF3D_OP_BOOL_H
|
||||
|
||||
#include "../mm_node.h"
|
||||
#include "../mm_node_universal_property.h"
|
||||
|
||||
class Sdf3dOpBool : public MMNode {
|
||||
GDCLASS(Sdf3dOpBool, MMNode);
|
||||
class MMSdf3dOpBool : public MMNode {
|
||||
GDCLASS(MMSdf3dOpBool, MMNode);
|
||||
|
||||
public:
|
||||
public:
|
||||
Ref<MMNodeUniversalProperty> get_input1();
|
||||
void set_input1(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input1();
|
||||
void set_input1(const Ref<Resource> &val);
|
||||
Ref<MMNodeUniversalProperty> get_input2();
|
||||
void set_input2(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input2();
|
||||
void set_input2(const Ref<Resource> &val);
|
||||
Ref<MMNodeUniversalProperty> get_output();
|
||||
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_output();
|
||||
void set_output(const Ref<Resource> &val);
|
||||
int get_operation() const;
|
||||
void set_operation(const int val);
|
||||
|
||||
int get_operation() const;
|
||||
void set_operation(const int val);
|
||||
void _init_properties();
|
||||
void _register_methods(MMGraphNode *mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
|
||||
void _init_properties();
|
||||
void _register_methods(const Variant &mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
int get_operation();
|
||||
void set_operation(const int val);
|
||||
void on_input_changed();
|
||||
void on_input_changed();
|
||||
|
||||
Sdf3dOpBool();
|
||||
~Sdf3dOpBool();
|
||||
MMSdf3dOpBool();
|
||||
~MMSdf3dOpBool();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
//export(Resource)
|
||||
Ref<Resource> input1;
|
||||
//export(Resource)
|
||||
Ref<Resource> input2;
|
||||
//export(Resource)
|
||||
Ref<Resource> output;
|
||||
//export(int, "Union,Substraction,Intersection")
|
||||
int operation = 0;
|
||||
//operation
|
||||
Ref<MMNodeUniversalProperty> input1;
|
||||
Ref<MMNodeUniversalProperty> input2;
|
||||
Ref<MMNodeUniversalProperty> output;
|
||||
//export(int, "Union,Substraction,Intersection")
|
||||
int operation;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,140 +1,99 @@
|
||||
|
||||
#include "sdf3d_op_circle_repeat.h"
|
||||
|
||||
#include "../../algos/mm_algos.h"
|
||||
#include "../../editor/mm_graph_node.h"
|
||||
#include "../mm_material.h"
|
||||
|
||||
Ref<Resource> Sdf3dOpCircleRepeat::get_input() {
|
||||
return input;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpCircleRepeat::get_input() {
|
||||
return input;
|
||||
}
|
||||
|
||||
void Sdf3dOpCircleRepeat::set_input(const Ref<Resource> &val) {
|
||||
input = val;
|
||||
void MMSdf3dOpCircleRepeat::set_input(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<Resource> Sdf3dOpCircleRepeat::get_output() {
|
||||
return output;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpCircleRepeat::get_output() {
|
||||
return output;
|
||||
}
|
||||
|
||||
void Sdf3dOpCircleRepeat::set_output(const Ref<Resource> &val) {
|
||||
output = val;
|
||||
void MMSdf3dOpCircleRepeat::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||
output = val;
|
||||
}
|
||||
|
||||
|
||||
int Sdf3dOpCircleRepeat::get_count() const {
|
||||
return count;
|
||||
int MMSdf3dOpCircleRepeat::get_count() const {
|
||||
return count;
|
||||
}
|
||||
|
||||
void Sdf3dOpCircleRepeat::set_count(const int val) {
|
||||
count = val;
|
||||
void MMSdf3dOpCircleRepeat::set_count(const int val) {
|
||||
count = val;
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
void MMSdf3dOpCircleRepeat::_init_properties() {
|
||||
if (!input.is_valid()) {
|
||||
input.instance();
|
||||
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input->set_slot_name(">>> Input ");
|
||||
|
||||
//tool;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> output;
|
||||
//export(int) ;
|
||||
int count = 5;
|
||||
if (!input->is_connected("changed", this, "on_input_changed")) {
|
||||
input->connect("changed", this, "on_input_changed");
|
||||
}
|
||||
|
||||
void Sdf3dOpCircleRepeat::_init_properties() {
|
||||
if (!output.is_valid()) {
|
||||
output.instance();
|
||||
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
if (!input) {
|
||||
input = MMNodeUniversalProperty.new();
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||
output->set_slot_name(">>> Output >>>");
|
||||
output->set_get_value_from_owner(true);
|
||||
|
||||
register_input_property(input);
|
||||
register_output_property(output);
|
||||
}
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input.slot_name = ">>> Input ";
|
||||
|
||||
if (!input.is_connected("changed", self, "on_input_changed")) {
|
||||
input.connect("changed", self, "on_input_changed");
|
||||
void MMSdf3dOpCircleRepeat::_register_methods(MMGraphNode *mm_graph_node) {
|
||||
mm_graph_node->add_slot_label_universal(input);
|
||||
mm_graph_node->add_slot_label_universal(output);
|
||||
mm_graph_node->add_slot_int("get_count", "set_count", "Count");
|
||||
}
|
||||
|
||||
|
||||
if (!output) {
|
||||
output = MMNodeUniversalProperty.new();
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
Vector2 MMSdf3dOpCircleRepeat::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
//todo make seed a class variable probably into MMNode;
|
||||
Vector3 new_uv = MMAlgos::circle_repeat_transform(uv3, count);
|
||||
return input->get_value_sdf3d(new_uv);
|
||||
}
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
output.slot_name = ">>> Output >>>";
|
||||
output.get_value_from_owner = true;
|
||||
register_input_property(input);
|
||||
register_output_property(output);
|
||||
void MMSdf3dOpCircleRepeat::on_input_changed() {
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpCircleRepeat::_register_methods(const Variant &mm_graph_node) {
|
||||
mm_graph_node.add_slot_label_universal(input);
|
||||
mm_graph_node.add_slot_label_universal(output);
|
||||
mm_graph_node.add_slot_int("get_count", "set_count", "Count");
|
||||
MMSdf3dOpCircleRepeat::MMSdf3dOpCircleRepeat() {
|
||||
count = 5;
|
||||
}
|
||||
|
||||
|
||||
Vector2 Sdf3dOpCircleRepeat::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
//todo make seed a class variable probably into MMNode;
|
||||
Vector3 new_uv = MMAlgos.circle_repeat_transform(uv3, count);
|
||||
return input.get_value_sdf3d(new_uv);
|
||||
MMSdf3dOpCircleRepeat::~MMSdf3dOpCircleRepeat() {
|
||||
}
|
||||
|
||||
//count;
|
||||
void MMSdf3dOpCircleRepeat::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &MMSdf3dOpCircleRepeat::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMSdf3dOpCircleRepeat::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
|
||||
|
||||
int Sdf3dOpCircleRepeat::get_count() {
|
||||
return count;
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dOpCircleRepeat::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dOpCircleRepeat::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_count"), &MMSdf3dOpCircleRepeat::get_count);
|
||||
ClassDB::bind_method(D_METHOD("set_count", "value"), &MMSdf3dOpCircleRepeat::set_count);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdf3dOpCircleRepeat::on_input_changed);
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpCircleRepeat::set_count(const int val) {
|
||||
count = val;
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpCircleRepeat::on_input_changed() {
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Sdf3dOpCircleRepeat::Sdf3dOpCircleRepeat() {
|
||||
input;
|
||||
output;
|
||||
count = 5;
|
||||
}
|
||||
|
||||
Sdf3dOpCircleRepeat::~Sdf3dOpCircleRepeat() {
|
||||
}
|
||||
|
||||
|
||||
static void Sdf3dOpCircleRepeat::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &Sdf3dOpCircleRepeat::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &Sdf3dOpCircleRepeat::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dOpCircleRepeat::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dOpCircleRepeat::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_count"), &Sdf3dOpCircleRepeat::get_count);
|
||||
ClassDB::bind_method(D_METHOD("set_count", "value"), &Sdf3dOpCircleRepeat::set_count);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dOpCircleRepeat::_init_properties);
|
||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dOpCircleRepeat::_register_methods);
|
||||
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dOpCircleRepeat::_get_property_value_sdf3d);
|
||||
ClassDB::bind_method(D_METHOD("get_count"), &Sdf3dOpCircleRepeat::get_count);
|
||||
ClassDB::bind_method(D_METHOD("set_count", "val"), &Sdf3dOpCircleRepeat::set_count);
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &Sdf3dOpCircleRepeat::on_input_changed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,43 +1,37 @@
|
||||
#ifndef SDF3D_OP_CIRCLE_REPEAT_H
|
||||
#define SDF3D_OP_CIRCLE_REPEAT_H
|
||||
#ifndef MM_SDF3D_OP_CIRCLE_REPEAT_H
|
||||
#define MM_SDF3D_OP_CIRCLE_REPEAT_H
|
||||
|
||||
#include "../mm_node.h"
|
||||
#include "../mm_node_universal_property.h"
|
||||
|
||||
class Sdf3dOpCircleRepeat : public MMNode {
|
||||
GDCLASS(Sdf3dOpCircleRepeat, MMNode);
|
||||
class MMSdf3dOpCircleRepeat : public MMNode {
|
||||
GDCLASS(MMSdf3dOpCircleRepeat, MMNode);
|
||||
|
||||
public:
|
||||
public:
|
||||
Ref<MMNodeUniversalProperty> get_input();
|
||||
void set_input(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input();
|
||||
void set_input(const Ref<Resource> &val);
|
||||
Ref<MMNodeUniversalProperty> get_output();
|
||||
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_output();
|
||||
void set_output(const Ref<Resource> &val);
|
||||
int get_count() const;
|
||||
void set_count(const int val);
|
||||
|
||||
int get_count() const;
|
||||
void set_count(const int val);
|
||||
void _init_properties();
|
||||
void _register_methods(MMGraphNode *mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
|
||||
void _init_properties();
|
||||
void _register_methods(const Variant &mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
int get_count();
|
||||
void set_count(const int val);
|
||||
void on_input_changed();
|
||||
void on_input_changed();
|
||||
|
||||
Sdf3dOpCircleRepeat();
|
||||
~Sdf3dOpCircleRepeat();
|
||||
MMSdf3dOpCircleRepeat();
|
||||
~MMSdf3dOpCircleRepeat();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
//export(Resource)
|
||||
Ref<Resource> input;
|
||||
//export(Resource)
|
||||
Ref<Resource> output;
|
||||
//export(int)
|
||||
int count = 5;
|
||||
//count
|
||||
Ref<MMNodeUniversalProperty> input;
|
||||
Ref<MMNodeUniversalProperty> output;
|
||||
int count;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,140 +1,99 @@
|
||||
|
||||
#include "sdf3d_op_elongation.h"
|
||||
|
||||
#include "../../algos/mm_algos.h"
|
||||
#include "../../editor/mm_graph_node.h"
|
||||
#include "../mm_material.h"
|
||||
|
||||
Ref<Resource> Sdf3dOpElongation::get_input() {
|
||||
return input;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpElongation::get_input() {
|
||||
return input;
|
||||
}
|
||||
|
||||
void Sdf3dOpElongation::set_input(const Ref<Resource> &val) {
|
||||
input = val;
|
||||
void MMSdf3dOpElongation::set_input(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<Resource> Sdf3dOpElongation::get_output() {
|
||||
return output;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpElongation::get_output() {
|
||||
return output;
|
||||
}
|
||||
|
||||
void Sdf3dOpElongation::set_output(const Ref<Resource> &val) {
|
||||
output = val;
|
||||
void MMSdf3dOpElongation::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||
output = val;
|
||||
}
|
||||
|
||||
|
||||
Vector3 Sdf3dOpElongation::get_length() {
|
||||
return length;
|
||||
Vector3 MMSdf3dOpElongation::get_length() {
|
||||
return length;
|
||||
}
|
||||
|
||||
void Sdf3dOpElongation::set_length(const Vector3 &val) {
|
||||
length = val;
|
||||
void MMSdf3dOpElongation::set_length(const Vector3 &val) {
|
||||
length = val;
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
void MMSdf3dOpElongation::_init_properties() {
|
||||
if (!input.is_valid()) {
|
||||
input.instance();
|
||||
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input->set_slot_name(">>> Input ");
|
||||
|
||||
//tool;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> output;
|
||||
//export(Vector3) ;
|
||||
Vector3 length = Vector3(0.2, 0, 0);
|
||||
if (!input->is_connected("changed", this, "on_input_changed")) {
|
||||
input->connect("changed", this, "on_input_changed");
|
||||
}
|
||||
|
||||
void Sdf3dOpElongation::_init_properties() {
|
||||
if (!output.is_valid()) {
|
||||
output.instance();
|
||||
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
if (!input) {
|
||||
input = MMNodeUniversalProperty.new();
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||
output->set_slot_name(">>> Output >>>");
|
||||
output->set_get_value_from_owner(true);
|
||||
|
||||
register_input_property(input);
|
||||
register_output_property(output);
|
||||
}
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input.slot_name = ">>> Input ";
|
||||
|
||||
if (!input.is_connected("changed", self, "on_input_changed")) {
|
||||
input.connect("changed", self, "on_input_changed");
|
||||
void MMSdf3dOpElongation::_register_methods(MMGraphNode *mm_graph_node) {
|
||||
mm_graph_node->add_slot_label_universal(input);
|
||||
mm_graph_node->add_slot_label_universal(output);
|
||||
mm_graph_node->add_slot_vector3("get_length", "set_length", "Length", 0.01);
|
||||
}
|
||||
|
||||
|
||||
if (!output) {
|
||||
output = MMNodeUniversalProperty.new();
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
Vector2 MMSdf3dOpElongation::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
//$in($uv - clamp($uv, -abs(vec3($x, $y, $z)), abs(vec3($x, $y, $z))));
|
||||
Vector3 new_uv = uv3 - MMAlgos::clampv3(uv3, -MMAlgos::absv3(length), MMAlgos::absv3(length));
|
||||
return input->get_value_sdf3d(new_uv);
|
||||
}
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
output.slot_name = ">>> Output >>>";
|
||||
output.get_value_from_owner = true;
|
||||
register_input_property(input);
|
||||
register_output_property(output);
|
||||
void MMSdf3dOpElongation::on_input_changed() {
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpElongation::_register_methods(const Variant &mm_graph_node) {
|
||||
mm_graph_node.add_slot_label_universal(input);
|
||||
mm_graph_node.add_slot_label_universal(output);
|
||||
mm_graph_node.add_slot_vector3("get_length", "set_length", "Length", 0.01);
|
||||
MMSdf3dOpElongation::MMSdf3dOpElongation() {
|
||||
length = Vector3(0.2, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
Vector2 Sdf3dOpElongation::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
//$in($uv - clamp($uv, -abs(vec3($x, $y, $z)), abs(vec3($x, $y, $z))));
|
||||
Vector3 new_uv = uv3 - MMAlgos.clampv3(uv3, -MMAlgos.absv3(length), MMAlgos.absv3(length));
|
||||
return input.get_value_sdf3d(new_uv);
|
||||
MMSdf3dOpElongation::~MMSdf3dOpElongation() {
|
||||
}
|
||||
|
||||
//length;
|
||||
void MMSdf3dOpElongation::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &MMSdf3dOpElongation::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMSdf3dOpElongation::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
|
||||
|
||||
Vector3 Sdf3dOpElongation::get_length() {
|
||||
return length;
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dOpElongation::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dOpElongation::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_length"), &MMSdf3dOpElongation::get_length);
|
||||
ClassDB::bind_method(D_METHOD("set_length", "value"), &MMSdf3dOpElongation::set_length);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "length"), "set_length", "get_length");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdf3dOpElongation::on_input_changed);
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpElongation::set_length(const Vector3 &val) {
|
||||
length = val;
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpElongation::on_input_changed() {
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Sdf3dOpElongation::Sdf3dOpElongation() {
|
||||
input;
|
||||
output;
|
||||
length = Vector3(0.2, 0, 0);
|
||||
}
|
||||
|
||||
Sdf3dOpElongation::~Sdf3dOpElongation() {
|
||||
}
|
||||
|
||||
|
||||
static void Sdf3dOpElongation::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &Sdf3dOpElongation::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &Sdf3dOpElongation::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dOpElongation::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dOpElongation::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_length"), &Sdf3dOpElongation::get_length);
|
||||
ClassDB::bind_method(D_METHOD("set_length", "value"), &Sdf3dOpElongation::set_length);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "length"), "set_length", "get_length");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dOpElongation::_init_properties);
|
||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dOpElongation::_register_methods);
|
||||
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dOpElongation::_get_property_value_sdf3d);
|
||||
ClassDB::bind_method(D_METHOD("get_length"), &Sdf3dOpElongation::get_length);
|
||||
ClassDB::bind_method(D_METHOD("set_length", "val"), &Sdf3dOpElongation::set_length);
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &Sdf3dOpElongation::on_input_changed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,43 +1,37 @@
|
||||
#ifndef SDF3D_OP_ELONGATION_H
|
||||
#define SDF3D_OP_ELONGATION_H
|
||||
#ifndef MM_SDF3D_OP_ELONGATION_H
|
||||
#define MM_SDF3D_OP_ELONGATION_H
|
||||
|
||||
#include "../mm_node.h"
|
||||
#include "../mm_node_universal_property.h"
|
||||
|
||||
class Sdf3dOpElongation : public MMNode {
|
||||
GDCLASS(Sdf3dOpElongation, MMNode);
|
||||
class MMSdf3dOpElongation : public MMNode {
|
||||
GDCLASS(MMSdf3dOpElongation, MMNode);
|
||||
|
||||
public:
|
||||
public:
|
||||
Ref<MMNodeUniversalProperty> get_input();
|
||||
void set_input(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input();
|
||||
void set_input(const Ref<Resource> &val);
|
||||
Ref<MMNodeUniversalProperty> get_output();
|
||||
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_output();
|
||||
void set_output(const Ref<Resource> &val);
|
||||
Vector3 get_length();
|
||||
void set_length(const Vector3 &val);
|
||||
|
||||
Vector3 get_length();
|
||||
void set_length(const Vector3 &val);
|
||||
void _init_properties();
|
||||
void _register_methods(MMGraphNode *mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
|
||||
void _init_properties();
|
||||
void _register_methods(const Variant &mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
Vector3 get_length();
|
||||
void set_length(const Vector3 &val);
|
||||
void on_input_changed();
|
||||
void on_input_changed();
|
||||
|
||||
Sdf3dOpElongation();
|
||||
~Sdf3dOpElongation();
|
||||
MMSdf3dOpElongation();
|
||||
~MMSdf3dOpElongation();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
//export(Resource)
|
||||
Ref<Resource> input;
|
||||
//export(Resource)
|
||||
Ref<Resource> output;
|
||||
//export(Vector3)
|
||||
Vector3 length = Vector3(0.2, 0, 0);
|
||||
//length
|
||||
Ref<MMNodeUniversalProperty> input;
|
||||
Ref<MMNodeUniversalProperty> output;
|
||||
Vector3 length;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,143 +1,102 @@
|
||||
|
||||
#include "sdf3d_op_extrusion.h"
|
||||
|
||||
#include "../../algos/mm_algos.h"
|
||||
#include "../../editor/mm_graph_node.h"
|
||||
#include "../mm_material.h"
|
||||
|
||||
Ref<Resource> Sdf3dOpExtrusion::get_input() {
|
||||
return input;
|
||||
Ref<MMNodeUniversalProperty> Sdf3dOpExtrusion::get_input() {
|
||||
return input;
|
||||
}
|
||||
|
||||
void Sdf3dOpExtrusion::set_input(const Ref<Resource> &val) {
|
||||
input = val;
|
||||
void Sdf3dOpExtrusion::set_input(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<Resource> Sdf3dOpExtrusion::get_output() {
|
||||
return output;
|
||||
Ref<MMNodeUniversalProperty> Sdf3dOpExtrusion::get_output() {
|
||||
return output;
|
||||
}
|
||||
|
||||
void Sdf3dOpExtrusion::set_output(const Ref<Resource> &val) {
|
||||
output = val;
|
||||
void Sdf3dOpExtrusion::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||
output = val;
|
||||
}
|
||||
|
||||
|
||||
float Sdf3dOpExtrusion::get_length() const {
|
||||
return length;
|
||||
return length;
|
||||
}
|
||||
|
||||
void Sdf3dOpExtrusion::set_length(const float val) {
|
||||
length = val;
|
||||
length = val;
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
void Sdf3dOpExtrusion::_init_properties() {
|
||||
if (!input.is_valid()) {
|
||||
input.instance();
|
||||
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
|
||||
}
|
||||
|
||||
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
input->set_slot_name(">>> Input ");
|
||||
|
||||
//tool;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> output;
|
||||
//export(float) ;
|
||||
float length = 0.25;
|
||||
if (!input->is_connected("changed", this, "on_input_changed")) {
|
||||
input->connect("changed", this, "on_input_changed");
|
||||
}
|
||||
|
||||
void Sdf3dOpExtrusion::_init_properties() {
|
||||
if (!output.is_valid()) {
|
||||
output.instance();
|
||||
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
if (!input) {
|
||||
input = MMNodeUniversalProperty.new();
|
||||
input.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);
|
||||
|
||||
register_input_property(input);
|
||||
register_output_property(output);
|
||||
}
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
input.slot_name = ">>> Input ";
|
||||
|
||||
if (!input.is_connected("changed", self, "on_input_changed")) {
|
||||
input.connect("changed", self, "on_input_changed");
|
||||
void Sdf3dOpExtrusion::_register_methods(MMGraphNode *mm_graph_node) {
|
||||
mm_graph_node->add_slot_label_universal(input);
|
||||
mm_graph_node->add_slot_label_universal(output);
|
||||
mm_graph_node->add_slot_float("get_length", "set_length", "Length", 0.01);
|
||||
}
|
||||
|
||||
|
||||
if (!output) {
|
||||
output = MMNodeUniversalProperty.new();
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
Vector2 Sdf3dOpExtrusion::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
//vec2 $(name_uv)_w = vec2($in($uv.xz+vec2(0.5)),abs($uv.y)-$d);
|
||||
//ret min(max($(name_uv)_w.x,$(name_uv)_w.y),0.0)+length(max($(name_uv)_w,0.0));
|
||||
float f = input->get_value(Vector2(uv3.x, uv3.z) + Vector2(0.5, 0.5));
|
||||
Vector2 w = Vector2(f, ABS(uv3.y) - length);
|
||||
float ff = MIN(MAX(w.x, w.y), 0.0) + MMAlgos::maxv2(w, Vector2()).length();
|
||||
return Vector2(ff, 0);
|
||||
}
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
output.slot_name = ">>> Output >>>";
|
||||
output.get_value_from_owner = true;
|
||||
register_input_property(input);
|
||||
register_output_property(output);
|
||||
void Sdf3dOpExtrusion::on_input_changed() {
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpExtrusion::_register_methods(const Variant &mm_graph_node) {
|
||||
mm_graph_node.add_slot_label_universal(input);
|
||||
mm_graph_node.add_slot_label_universal(output);
|
||||
mm_graph_node.add_slot_float("get_length", "set_length", "Length", 0.01);
|
||||
Sdf3dOpExtrusion::Sdf3dOpExtrusion() {
|
||||
length = 0.25;
|
||||
}
|
||||
|
||||
|
||||
Vector2 Sdf3dOpExtrusion::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
//vec2 $(name_uv)_w = vec2($in($uv.xz+vec2(0.5)),abs($uv.y)-$d);
|
||||
//ret min(max($(name_uv)_w.x,$(name_uv)_w.y),0.0)+length(max($(name_uv)_w,0.0));
|
||||
float f = input.get_value(Vector2(uv3.x, uv3.z) + Vector2(0.5, 0.5));
|
||||
Vector2 w = Vector2(f, abs(uv3.y) - length);
|
||||
float ff = min(max(w.x,w.y),0.0) + MMAlgos.maxv2(w, Vector2()).length();
|
||||
return Vector2(ff, 0);
|
||||
Sdf3dOpExtrusion::~Sdf3dOpExtrusion() {
|
||||
}
|
||||
|
||||
//length;
|
||||
void Sdf3dOpExtrusion::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &Sdf3dOpExtrusion::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &Sdf3dOpExtrusion::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
|
||||
|
||||
float Sdf3dOpExtrusion::get_length() {
|
||||
return length;
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dOpExtrusion::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dOpExtrusion::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_length"), &Sdf3dOpExtrusion::get_length);
|
||||
ClassDB::bind_method(D_METHOD("set_length", "value"), &Sdf3dOpExtrusion::set_length);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), "set_length", "get_length");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &Sdf3dOpExtrusion::on_input_changed);
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpExtrusion::set_length(const float val) {
|
||||
length = val;
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpExtrusion::on_input_changed() {
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Sdf3dOpExtrusion::Sdf3dOpExtrusion() {
|
||||
input;
|
||||
output;
|
||||
length = 0.25;
|
||||
}
|
||||
|
||||
Sdf3dOpExtrusion::~Sdf3dOpExtrusion() {
|
||||
}
|
||||
|
||||
|
||||
static void Sdf3dOpExtrusion::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &Sdf3dOpExtrusion::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &Sdf3dOpExtrusion::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dOpExtrusion::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dOpExtrusion::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_length"), &Sdf3dOpExtrusion::get_length);
|
||||
ClassDB::bind_method(D_METHOD("set_length", "value"), &Sdf3dOpExtrusion::set_length);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), "set_length", "get_length");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dOpExtrusion::_init_properties);
|
||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dOpExtrusion::_register_methods);
|
||||
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dOpExtrusion::_get_property_value_sdf3d);
|
||||
ClassDB::bind_method(D_METHOD("get_length"), &Sdf3dOpExtrusion::get_length);
|
||||
ClassDB::bind_method(D_METHOD("set_length", "val"), &Sdf3dOpExtrusion::set_length);
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &Sdf3dOpExtrusion::on_input_changed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,43 +1,37 @@
|
||||
#ifndef SDF3D_OP_EXTRUSION_H
|
||||
#define SDF3D_OP_EXTRUSION_H
|
||||
#ifndef MM_SDF3D_OP_EXTRUSION_H
|
||||
#define MM_SDF3D_OP_EXTRUSION_H
|
||||
|
||||
#include "../mm_node.h"
|
||||
#include "../mm_node_universal_property.h"
|
||||
|
||||
class Sdf3dOpExtrusion : public MMNode {
|
||||
GDCLASS(Sdf3dOpExtrusion, MMNode);
|
||||
GDCLASS(Sdf3dOpExtrusion, MMNode);
|
||||
|
||||
public:
|
||||
public:
|
||||
Ref<MMNodeUniversalProperty> get_input();
|
||||
void set_input(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input();
|
||||
void set_input(const Ref<Resource> &val);
|
||||
Ref<MMNodeUniversalProperty> get_output();
|
||||
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_output();
|
||||
void set_output(const Ref<Resource> &val);
|
||||
float get_length() const;
|
||||
void set_length(const float val);
|
||||
|
||||
float get_length() const;
|
||||
void set_length(const float val);
|
||||
void _init_properties();
|
||||
void _register_methods(MMGraphNode *mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
|
||||
void _init_properties();
|
||||
void _register_methods(const Variant &mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
float get_length();
|
||||
void set_length(const float val);
|
||||
void on_input_changed();
|
||||
void on_input_changed();
|
||||
|
||||
Sdf3dOpExtrusion();
|
||||
~Sdf3dOpExtrusion();
|
||||
Sdf3dOpExtrusion();
|
||||
~Sdf3dOpExtrusion();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
//export(Resource)
|
||||
Ref<Resource> input;
|
||||
//export(Resource)
|
||||
Ref<Resource> output;
|
||||
//export(float)
|
||||
float length = 0.25;
|
||||
//length
|
||||
Ref<MMNodeUniversalProperty> input;
|
||||
Ref<MMNodeUniversalProperty> output;
|
||||
float length;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,174 +1,127 @@
|
||||
|
||||
#include "sdf3d_op_morph.h"
|
||||
|
||||
#include "../../algos/mm_algos.h"
|
||||
#include "../../editor/mm_graph_node.h"
|
||||
#include "../mm_material.h"
|
||||
|
||||
Ref<Resource> Sdf3dOpMorph::get_input1() {
|
||||
return input1;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpMorph::get_input1() {
|
||||
return input1;
|
||||
}
|
||||
|
||||
void Sdf3dOpMorph::set_input1(const Ref<Resource> &val) {
|
||||
input1 = val;
|
||||
void MMSdf3dOpMorph::set_input1(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input1 = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<Resource> Sdf3dOpMorph::get_input2() {
|
||||
return input2;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpMorph::get_input2() {
|
||||
return input2;
|
||||
}
|
||||
|
||||
void Sdf3dOpMorph::set_input2(const Ref<Resource> &val) {
|
||||
input2 = val;
|
||||
void MMSdf3dOpMorph::set_input2(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input2 = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<Resource> Sdf3dOpMorph::get_output() {
|
||||
return output;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpMorph::get_output() {
|
||||
return output;
|
||||
}
|
||||
|
||||
void Sdf3dOpMorph::set_output(const Ref<Resource> &val) {
|
||||
output = val;
|
||||
void MMSdf3dOpMorph::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||
output = val;
|
||||
}
|
||||
|
||||
|
||||
float Sdf3dOpMorph::get_amount() const {
|
||||
return amount;
|
||||
float MMSdf3dOpMorph::get_amount() const {
|
||||
return amount;
|
||||
}
|
||||
|
||||
void Sdf3dOpMorph::set_amount(const float val) {
|
||||
amount = val;
|
||||
void MMSdf3dOpMorph::set_amount(const float val) {
|
||||
amount = val;
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
void MMSdf3dOpMorph::_init_properties() {
|
||||
if (!input1.is_valid()) {
|
||||
input1.instance();
|
||||
input1->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
input1->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input1->set_slot_name(">>> Input 1 ");
|
||||
|
||||
//tool;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input1;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input2;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> output;
|
||||
//export(float) ;
|
||||
float amount = 0.5;
|
||||
if (!input1->is_connected("changed", this, "on_input_changed")) {
|
||||
input1->connect("changed", this, "on_input_changed");
|
||||
}
|
||||
|
||||
void Sdf3dOpMorph::_init_properties() {
|
||||
if (!input2.is_valid()) {
|
||||
input2.instance();
|
||||
input2->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
if (!input1) {
|
||||
input1 = MMNodeUniversalProperty.new();
|
||||
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
input2->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
// input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input2->set_slot_name(">>> Input 2 ");
|
||||
|
||||
if (!input2->is_connected("changed", this, "on_input_changed")) {
|
||||
input2->connect("changed", this, "on_input_changed");
|
||||
}
|
||||
|
||||
if (!output.is_valid()) {
|
||||
output.instance();
|
||||
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||
output->set_slot_name(">>> Output >>>");
|
||||
output->set_get_value_from_owner(true);
|
||||
|
||||
register_input_property(input1);
|
||||
register_input_property(input2);
|
||||
register_output_property(output);
|
||||
}
|
||||
|
||||
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input1.slot_name = ">>> Input 1 ";
|
||||
|
||||
if (!input1.is_connected("changed", self, "on_input_changed")) {
|
||||
input1.connect("changed", self, "on_input_changed");
|
||||
void MMSdf3dOpMorph::_register_methods(MMGraphNode *mm_graph_node) {
|
||||
mm_graph_node->add_slot_label_universal(input1);
|
||||
mm_graph_node->add_slot_label_universal(input2);
|
||||
mm_graph_node->add_slot_label_universal(output);
|
||||
mm_graph_node->add_slot_float("get_amount", "set_amount", "Amount", 0.01);
|
||||
}
|
||||
|
||||
|
||||
if (!input2) {
|
||||
input2 = MMNodeUniversalProperty.new();
|
||||
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
Vector2 MMSdf3dOpMorph::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
Vector2 s1 = input1->get_value_sdf3d(uv3);
|
||||
Vector2 s2 = input2->get_value_sdf3d(uv3);
|
||||
//mix($in1($uv), $in2($uv), $amount);
|
||||
return s1.linear_interpolate(s2, amount);
|
||||
}
|
||||
|
||||
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
// input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input2.slot_name = ">>> Input 2 ";
|
||||
|
||||
if (!input2.is_connected("changed", self, "on_input_changed")) {
|
||||
input2.connect("changed", self, "on_input_changed");
|
||||
void MMSdf3dOpMorph::on_input_changed() {
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
|
||||
if (!output) {
|
||||
output = MMNodeUniversalProperty.new();
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
MMSdf3dOpMorph::MMSdf3dOpMorph() {
|
||||
amount = 0.5;
|
||||
}
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
output.slot_name = ">>> Output >>>";
|
||||
output.get_value_from_owner = true;
|
||||
register_input_property(input1);
|
||||
register_input_property(input2);
|
||||
register_output_property(output);
|
||||
MMSdf3dOpMorph::~MMSdf3dOpMorph() {
|
||||
}
|
||||
|
||||
void MMSdf3dOpMorph::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input1"), &MMSdf3dOpMorph::get_input1);
|
||||
ClassDB::bind_method(D_METHOD("set_input1", "value"), &MMSdf3dOpMorph::set_input1);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input1", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input1", "get_input1");
|
||||
|
||||
void Sdf3dOpMorph::_register_methods(const Variant &mm_graph_node) {
|
||||
mm_graph_node.add_slot_label_universal(input1);
|
||||
mm_graph_node.add_slot_label_universal(input2);
|
||||
mm_graph_node.add_slot_label_universal(output);
|
||||
mm_graph_node.add_slot_float("get_amount", "set_amount", "Amount", 0.01);
|
||||
ClassDB::bind_method(D_METHOD("get_input2"), &MMSdf3dOpMorph::get_input2);
|
||||
ClassDB::bind_method(D_METHOD("set_input2", "value"), &MMSdf3dOpMorph::set_input2);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input2", "get_input2");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dOpMorph::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dOpMorph::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_amount"), &MMSdf3dOpMorph::get_amount);
|
||||
ClassDB::bind_method(D_METHOD("set_amount", "value"), &MMSdf3dOpMorph::set_amount);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "amount"), "set_amount", "get_amount");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdf3dOpMorph::on_input_changed);
|
||||
}
|
||||
|
||||
|
||||
Vector2 Sdf3dOpMorph::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
Vector2 s1 = input1.get_value_sdf3d(uv3);
|
||||
Vector2 s2 = input2.get_value_sdf3d(uv3);
|
||||
//mix($in1($uv), $in2($uv), $amount);
|
||||
return lerp(s1, s2, amount);
|
||||
}
|
||||
|
||||
//amount;
|
||||
|
||||
float Sdf3dOpMorph::get_amount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpMorph::set_amount(const float val) {
|
||||
amount = val;
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpMorph::on_input_changed() {
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Sdf3dOpMorph::Sdf3dOpMorph() {
|
||||
input1;
|
||||
input2;
|
||||
output;
|
||||
amount = 0.5;
|
||||
}
|
||||
|
||||
Sdf3dOpMorph::~Sdf3dOpMorph() {
|
||||
}
|
||||
|
||||
|
||||
static void Sdf3dOpMorph::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input1"), &Sdf3dOpMorph::get_input1);
|
||||
ClassDB::bind_method(D_METHOD("set_input1", "value"), &Sdf3dOpMorph::set_input1);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input1", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input1", "get_input1");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_input2"), &Sdf3dOpMorph::get_input2);
|
||||
ClassDB::bind_method(D_METHOD("set_input2", "value"), &Sdf3dOpMorph::set_input2);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input2", "get_input2");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dOpMorph::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dOpMorph::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_amount"), &Sdf3dOpMorph::get_amount);
|
||||
ClassDB::bind_method(D_METHOD("set_amount", "value"), &Sdf3dOpMorph::set_amount);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "amount"), "set_amount", "get_amount");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dOpMorph::_init_properties);
|
||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dOpMorph::_register_methods);
|
||||
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dOpMorph::_get_property_value_sdf3d);
|
||||
ClassDB::bind_method(D_METHOD("get_amount"), &Sdf3dOpMorph::get_amount);
|
||||
ClassDB::bind_method(D_METHOD("set_amount", "val"), &Sdf3dOpMorph::set_amount);
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &Sdf3dOpMorph::on_input_changed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,48 +1,41 @@
|
||||
#ifndef SDF3D_OP_MORPH_H
|
||||
#define SDF3D_OP_MORPH_H
|
||||
#ifndef MM_SDF3D_OP_MORPH_H
|
||||
#define MM_SDF3D_OP_MORPH_H
|
||||
|
||||
#include "../mm_node.h"
|
||||
#include "../mm_node_universal_property.h"
|
||||
|
||||
class Sdf3dOpMorph : public MMNode {
|
||||
GDCLASS(Sdf3dOpMorph, MMNode);
|
||||
class MMSdf3dOpMorph : public MMNode {
|
||||
GDCLASS(MMSdf3dOpMorph, MMNode);
|
||||
|
||||
public:
|
||||
public:
|
||||
Ref<MMNodeUniversalProperty> get_input1();
|
||||
void set_input1(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input1();
|
||||
void set_input1(const Ref<Resource> &val);
|
||||
Ref<MMNodeUniversalProperty> get_input2();
|
||||
void set_input2(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input2();
|
||||
void set_input2(const Ref<Resource> &val);
|
||||
Ref<MMNodeUniversalProperty> get_output();
|
||||
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_output();
|
||||
void set_output(const Ref<Resource> &val);
|
||||
float get_amount() const;
|
||||
void set_amount(const float val);
|
||||
|
||||
float get_amount() const;
|
||||
void set_amount(const float val);
|
||||
void _init_properties();
|
||||
void _register_methods(MMGraphNode *mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
|
||||
void _init_properties();
|
||||
void _register_methods(const Variant &mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
float get_amount();
|
||||
void set_amount(const float val);
|
||||
void on_input_changed();
|
||||
void on_input_changed();
|
||||
|
||||
Sdf3dOpMorph();
|
||||
~Sdf3dOpMorph();
|
||||
MMSdf3dOpMorph();
|
||||
~MMSdf3dOpMorph();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
//export(Resource)
|
||||
Ref<Resource> input1;
|
||||
//export(Resource)
|
||||
Ref<Resource> input2;
|
||||
//export(Resource)
|
||||
Ref<Resource> output;
|
||||
//export(float)
|
||||
float amount = 0.5;
|
||||
//amount
|
||||
Ref<MMNodeUniversalProperty> input1;
|
||||
Ref<MMNodeUniversalProperty> input2;
|
||||
Ref<MMNodeUniversalProperty> output;
|
||||
float amount;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,173 +1,115 @@
|
||||
|
||||
#include "sdf3d_op_repeat.h"
|
||||
|
||||
#include "../../algos/mm_algos.h"
|
||||
#include "../../editor/mm_graph_node.h"
|
||||
#include "../mm_material.h"
|
||||
|
||||
Ref<Resource> Sdf3dOpRepeat::get_input() {
|
||||
return input;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpRepeat::get_input() {
|
||||
return input;
|
||||
}
|
||||
|
||||
void Sdf3dOpRepeat::set_input(const Ref<Resource> &val) {
|
||||
input = val;
|
||||
void MMSdf3dOpRepeat::set_input(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<Resource> Sdf3dOpRepeat::get_output() {
|
||||
return output;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpRepeat::get_output() {
|
||||
return output;
|
||||
}
|
||||
|
||||
void Sdf3dOpRepeat::set_output(const Ref<Resource> &val) {
|
||||
output = val;
|
||||
void MMSdf3dOpRepeat::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||
output = val;
|
||||
}
|
||||
|
||||
|
||||
Vector2 Sdf3dOpRepeat::get_col_row() {
|
||||
return col_row;
|
||||
Vector2 MMSdf3dOpRepeat::get_col_row() {
|
||||
return col_row;
|
||||
}
|
||||
|
||||
void Sdf3dOpRepeat::set_col_row(const Vector2 &val) {
|
||||
col_row = val;
|
||||
void MMSdf3dOpRepeat::set_col_row(const Vector2 &val) {
|
||||
col_row = val;
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
|
||||
float Sdf3dOpRepeat::get_rotation() const {
|
||||
return rotation;
|
||||
float MMSdf3dOpRepeat::get_rotation() const {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
void Sdf3dOpRepeat::set_rotation(const float val) {
|
||||
rotation = val;
|
||||
void MMSdf3dOpRepeat::set_rotation(const float val) {
|
||||
rotation = val;
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
void MMSdf3dOpRepeat::_init_properties() {
|
||||
if (!input.is_valid()) {
|
||||
input.instance();
|
||||
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input->set_slot_name(">>> Input ");
|
||||
|
||||
//tool;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> output;
|
||||
//export(Vector2) ;
|
||||
Vector2 col_row = Vector2(3, 3);
|
||||
//export(float) ;
|
||||
float rotation = 0.3;
|
||||
if (!input->is_connected("changed", this, "on_input_changed")) {
|
||||
input->connect("changed", this, "on_input_changed");
|
||||
}
|
||||
|
||||
void Sdf3dOpRepeat::_init_properties() {
|
||||
if (!output.is_valid()) {
|
||||
output.instance();
|
||||
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
if (!input) {
|
||||
input = MMNodeUniversalProperty.new();
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||
output->set_slot_name(">>> Output >>>");
|
||||
output->set_get_value_from_owner(true);
|
||||
|
||||
register_input_property(input);
|
||||
register_output_property(output);
|
||||
}
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input.slot_name = ">>> Input ";
|
||||
|
||||
if (!input.is_connected("changed", self, "on_input_changed")) {
|
||||
input.connect("changed", self, "on_input_changed");
|
||||
void MMSdf3dOpRepeat::_register_methods(MMGraphNode *mm_graph_node) {
|
||||
mm_graph_node->add_slot_label_universal(input);
|
||||
mm_graph_node->add_slot_label_universal(output);
|
||||
mm_graph_node->add_slot_vector2("get_col_row", "set_col_row", "Col,Row", 1);
|
||||
mm_graph_node->add_slot_float("get_rotation", "set_rotation", "Rotation", 0.01);
|
||||
}
|
||||
|
||||
|
||||
if (!output) {
|
||||
output = MMNodeUniversalProperty.new();
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
Vector2 MMSdf3dOpRepeat::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
//todo make seed a class variable probably into MMNode;
|
||||
Vector3 new_uv = MMAlgos::sdf3d_repeat(uv3, col_row, rotation, 1);
|
||||
return input->get_value_sdf3d(new_uv);
|
||||
}
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
output.slot_name = ">>> Output >>>";
|
||||
output.get_value_from_owner = true;
|
||||
register_input_property(input);
|
||||
register_output_property(output);
|
||||
void MMSdf3dOpRepeat::on_input_changed() {
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpRepeat::_register_methods(const Variant &mm_graph_node) {
|
||||
mm_graph_node.add_slot_label_universal(input);
|
||||
mm_graph_node.add_slot_label_universal(output);
|
||||
mm_graph_node.add_slot_vector2("get_col_row", "set_col_row", "Col,Row", 1);
|
||||
mm_graph_node.add_slot_float("get_rotation", "set_rotation", "Rotation", 0.01);
|
||||
MMSdf3dOpRepeat::MMSdf3dOpRepeat() {
|
||||
col_row = Vector2(3, 3);
|
||||
rotation = 0.3;
|
||||
}
|
||||
|
||||
|
||||
Vector2 Sdf3dOpRepeat::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
//todo make seed a class variable probably into MMNode;
|
||||
Vector3 new_uv = MMAlgos.sdf3d_repeat(uv3, col_row, rotation, 1);
|
||||
return input.get_value_sdf3d(new_uv);
|
||||
MMSdf3dOpRepeat::~MMSdf3dOpRepeat() {
|
||||
}
|
||||
|
||||
//col_row;
|
||||
void MMSdf3dOpRepeat::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &MMSdf3dOpRepeat::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMSdf3dOpRepeat::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
|
||||
|
||||
Vector2 Sdf3dOpRepeat::get_col_row() {
|
||||
return col_row;
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dOpRepeat::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dOpRepeat::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_col_row"), &MMSdf3dOpRepeat::get_col_row);
|
||||
ClassDB::bind_method(D_METHOD("set_col_row", "value"), &MMSdf3dOpRepeat::set_col_row);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "col_row"), "set_col_row", "get_col_row");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_rotation"), &MMSdf3dOpRepeat::get_rotation);
|
||||
ClassDB::bind_method(D_METHOD("set_rotation", "value"), &MMSdf3dOpRepeat::set_rotation);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotation"), "set_rotation", "get_rotation");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdf3dOpRepeat::on_input_changed);
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpRepeat::set_col_row(const Vector2 &val) {
|
||||
col_row = val;
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
//rotation;
|
||||
|
||||
float Sdf3dOpRepeat::get_rotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpRepeat::set_rotation(const float val) {
|
||||
rotation = val;
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpRepeat::on_input_changed() {
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Sdf3dOpRepeat::Sdf3dOpRepeat() {
|
||||
input;
|
||||
output;
|
||||
col_row = Vector2(3, 3);
|
||||
rotation = 0.3;
|
||||
}
|
||||
|
||||
Sdf3dOpRepeat::~Sdf3dOpRepeat() {
|
||||
}
|
||||
|
||||
|
||||
static void Sdf3dOpRepeat::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &Sdf3dOpRepeat::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &Sdf3dOpRepeat::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dOpRepeat::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dOpRepeat::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_col_row"), &Sdf3dOpRepeat::get_col_row);
|
||||
ClassDB::bind_method(D_METHOD("set_col_row", "value"), &Sdf3dOpRepeat::set_col_row);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "col_row"), "set_col_row", "get_col_row");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_rotation"), &Sdf3dOpRepeat::get_rotation);
|
||||
ClassDB::bind_method(D_METHOD("set_rotation", "value"), &Sdf3dOpRepeat::set_rotation);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotation"), "set_rotation", "get_rotation");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dOpRepeat::_init_properties);
|
||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dOpRepeat::_register_methods);
|
||||
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dOpRepeat::_get_property_value_sdf3d);
|
||||
ClassDB::bind_method(D_METHOD("get_col_row"), &Sdf3dOpRepeat::get_col_row);
|
||||
ClassDB::bind_method(D_METHOD("set_col_row", "val"), &Sdf3dOpRepeat::set_col_row);
|
||||
ClassDB::bind_method(D_METHOD("get_rotation"), &Sdf3dOpRepeat::get_rotation);
|
||||
ClassDB::bind_method(D_METHOD("set_rotation", "val"), &Sdf3dOpRepeat::set_rotation);
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &Sdf3dOpRepeat::on_input_changed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,51 +1,41 @@
|
||||
#ifndef SDF3D_OP_REPEAT_H
|
||||
#define SDF3D_OP_REPEAT_H
|
||||
#ifndef MM_SDF3D_OP_REPEAT_H
|
||||
#define MM_SDF3D_OP_REPEAT_H
|
||||
|
||||
#include "../mm_node.h"
|
||||
#include "../mm_node_universal_property.h"
|
||||
|
||||
class Sdf3dOpRepeat : public MMNode {
|
||||
GDCLASS(Sdf3dOpRepeat, MMNode);
|
||||
class MMSdf3dOpRepeat : public MMNode {
|
||||
GDCLASS(MMSdf3dOpRepeat, MMNode);
|
||||
|
||||
public:
|
||||
public:
|
||||
Ref<MMNodeUniversalProperty> get_input();
|
||||
void set_input(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input();
|
||||
void set_input(const Ref<Resource> &val);
|
||||
Ref<MMNodeUniversalProperty> get_output();
|
||||
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_output();
|
||||
void set_output(const Ref<Resource> &val);
|
||||
Vector2 get_col_row();
|
||||
void set_col_row(const Vector2 &val);
|
||||
|
||||
Vector2 get_col_row();
|
||||
void set_col_row(const Vector2 &val);
|
||||
float get_rotation() const;
|
||||
void set_rotation(const float val);
|
||||
|
||||
float get_rotation() const;
|
||||
void set_rotation(const float val);
|
||||
void _init_properties();
|
||||
void _register_methods(MMGraphNode *mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
|
||||
void _init_properties();
|
||||
void _register_methods(const Variant &mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
Vector2 get_col_row();
|
||||
void set_col_row(const Vector2 &val);
|
||||
float get_rotation();
|
||||
void set_rotation(const float val);
|
||||
void on_input_changed();
|
||||
void on_input_changed();
|
||||
|
||||
Sdf3dOpRepeat();
|
||||
~Sdf3dOpRepeat();
|
||||
MMSdf3dOpRepeat();
|
||||
~MMSdf3dOpRepeat();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
//export(Resource)
|
||||
Ref<Resource> input;
|
||||
//export(Resource)
|
||||
Ref<Resource> output;
|
||||
//export(Vector2)
|
||||
Vector2 col_row = Vector2(3, 3);
|
||||
//export(float)
|
||||
float rotation = 0.3;
|
||||
//col_row
|
||||
//rotation
|
||||
Ref<MMNodeUniversalProperty> input;
|
||||
Ref<MMNodeUniversalProperty> output;
|
||||
Vector2 col_row;
|
||||
float rotation;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,141 +1,99 @@
|
||||
|
||||
#include "sdf3d_op_revolution.h"
|
||||
|
||||
#include "../../algos/mm_algos.h"
|
||||
#include "../../editor/mm_graph_node.h"
|
||||
#include "../mm_material.h"
|
||||
|
||||
Ref<Resource> Sdf3dOpRevolution::get_input() {
|
||||
return input;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpRevolution::get_input() {
|
||||
return input;
|
||||
}
|
||||
|
||||
void Sdf3dOpRevolution::set_input(const Ref<Resource> &val) {
|
||||
input = val;
|
||||
void MMSdf3dOpRevolution::set_input(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<Resource> Sdf3dOpRevolution::get_output() {
|
||||
return output;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpRevolution::get_output() {
|
||||
return output;
|
||||
}
|
||||
|
||||
void Sdf3dOpRevolution::set_output(const Ref<Resource> &val) {
|
||||
output = val;
|
||||
void MMSdf3dOpRevolution::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||
output = val;
|
||||
}
|
||||
|
||||
|
||||
float Sdf3dOpRevolution::get_offset() const {
|
||||
return offset;
|
||||
float MMSdf3dOpRevolution::get_offset() const {
|
||||
return offset;
|
||||
}
|
||||
|
||||
void Sdf3dOpRevolution::set_offset(const float val) {
|
||||
offset = val;
|
||||
void MMSdf3dOpRevolution::set_offset(const float val) {
|
||||
offset = val;
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
void MMSdf3dOpRevolution::_init_properties() {
|
||||
if (!input.is_valid()) {
|
||||
input.instance();
|
||||
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
|
||||
}
|
||||
|
||||
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
input->set_slot_name(">>> Input ");
|
||||
|
||||
//tool;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> output;
|
||||
//export(float) ;
|
||||
float offset = 0.25;
|
||||
if (!input->is_connected("changed", this, "on_input_changed")) {
|
||||
input->connect("changed", this, "on_input_changed");
|
||||
}
|
||||
|
||||
void Sdf3dOpRevolution::_init_properties() {
|
||||
if (!output.is_valid()) {
|
||||
output.instance();
|
||||
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
if (!input) {
|
||||
input = MMNodeUniversalProperty.new();
|
||||
input.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);
|
||||
register_input_property(input);
|
||||
register_output_property(output);
|
||||
}
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
input.slot_name = ">>> Input ";
|
||||
|
||||
if (!input.is_connected("changed", self, "on_input_changed")) {
|
||||
input.connect("changed", self, "on_input_changed");
|
||||
void MMSdf3dOpRevolution::_register_methods(MMGraphNode *mm_graph_node) {
|
||||
mm_graph_node->add_slot_label_universal(input);
|
||||
mm_graph_node->add_slot_label_universal(output);
|
||||
mm_graph_node->add_slot_float("get_offset", "set_offset", "Offset", 0.01);
|
||||
}
|
||||
|
||||
|
||||
if (!output) {
|
||||
output = MMNodeUniversalProperty.new();
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
Vector2 MMSdf3dOpRevolution::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
//vec2 $(name_uv)_q = vec2(length($uv.xy) - $d + 0.5, $uv.z + 0.5);
|
||||
Vector2 uv = Vector2(Vector2(uv3.x, uv3.y).length() - offset + 0.5, uv3.z + 0.5);
|
||||
float f = input->get_value(uv);
|
||||
return Vector2(f, 0);
|
||||
}
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
output.slot_name = ">>> Output >>>";
|
||||
output.get_value_from_owner = true;
|
||||
register_input_property(input);
|
||||
register_output_property(output);
|
||||
void MMSdf3dOpRevolution::on_input_changed() {
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpRevolution::_register_methods(const Variant &mm_graph_node) {
|
||||
mm_graph_node.add_slot_label_universal(input);
|
||||
mm_graph_node.add_slot_label_universal(output);
|
||||
mm_graph_node.add_slot_float("get_offset", "set_offset", "Offset", 0.01);
|
||||
MMSdf3dOpRevolution::MMSdf3dOpRevolution() {
|
||||
offset = 0.25;
|
||||
}
|
||||
|
||||
|
||||
Vector2 Sdf3dOpRevolution::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
//vec2 $(name_uv)_q = vec2(length($uv.xy) - $d + 0.5, $uv.z + 0.5);
|
||||
Vector2 uv = Vector2(Vector2(uv3.x, uv3.y).length() - offset + 0.5, uv3.z + 0.5);
|
||||
float f = input.get_value(uv);
|
||||
return Vector2(f, 0);
|
||||
MMSdf3dOpRevolution::~MMSdf3dOpRevolution() {
|
||||
}
|
||||
|
||||
//offset;
|
||||
void MMSdf3dOpRevolution::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &MMSdf3dOpRevolution::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMSdf3dOpRevolution::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
|
||||
|
||||
float Sdf3dOpRevolution::get_offset() {
|
||||
return offset;
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dOpRevolution::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dOpRevolution::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_offset"), &MMSdf3dOpRevolution::get_offset);
|
||||
ClassDB::bind_method(D_METHOD("set_offset", "value"), &MMSdf3dOpRevolution::set_offset);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset"), "set_offset", "get_offset");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdf3dOpRevolution::on_input_changed);
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpRevolution::set_offset(const float val) {
|
||||
offset = val;
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpRevolution::on_input_changed() {
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Sdf3dOpRevolution::Sdf3dOpRevolution() {
|
||||
input;
|
||||
output;
|
||||
offset = 0.25;
|
||||
}
|
||||
|
||||
Sdf3dOpRevolution::~Sdf3dOpRevolution() {
|
||||
}
|
||||
|
||||
|
||||
static void Sdf3dOpRevolution::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &Sdf3dOpRevolution::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &Sdf3dOpRevolution::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dOpRevolution::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dOpRevolution::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_offset"), &Sdf3dOpRevolution::get_offset);
|
||||
ClassDB::bind_method(D_METHOD("set_offset", "value"), &Sdf3dOpRevolution::set_offset);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset"), "set_offset", "get_offset");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dOpRevolution::_init_properties);
|
||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dOpRevolution::_register_methods);
|
||||
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dOpRevolution::_get_property_value_sdf3d);
|
||||
ClassDB::bind_method(D_METHOD("get_offset"), &Sdf3dOpRevolution::get_offset);
|
||||
ClassDB::bind_method(D_METHOD("set_offset", "val"), &Sdf3dOpRevolution::set_offset);
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &Sdf3dOpRevolution::on_input_changed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,43 +1,37 @@
|
||||
#ifndef SDF3D_OP_REVOLUTION_H
|
||||
#define SDF3D_OP_REVOLUTION_H
|
||||
#ifndef MM_SDF3D_OP_REVOLUTION_H
|
||||
#define MM_SDF3D_OP_REVOLUTION_H
|
||||
|
||||
#include "../mm_node.h"
|
||||
#include "../mm_node_universal_property.h"
|
||||
|
||||
class Sdf3dOpRevolution : public MMNode {
|
||||
GDCLASS(Sdf3dOpRevolution, MMNode);
|
||||
class MMSdf3dOpRevolution : public MMNode {
|
||||
GDCLASS(MMSdf3dOpRevolution, MMNode);
|
||||
|
||||
public:
|
||||
public:
|
||||
Ref<MMNodeUniversalProperty> get_input();
|
||||
void set_input(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input();
|
||||
void set_input(const Ref<Resource> &val);
|
||||
Ref<MMNodeUniversalProperty> get_output();
|
||||
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_output();
|
||||
void set_output(const Ref<Resource> &val);
|
||||
float get_offset() const;
|
||||
void set_offset(const float val);
|
||||
|
||||
float get_offset() const;
|
||||
void set_offset(const float val);
|
||||
void _init_properties();
|
||||
void _register_methods(MMGraphNode *mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
|
||||
void _init_properties();
|
||||
void _register_methods(const Variant &mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
float get_offset();
|
||||
void set_offset(const float val);
|
||||
void on_input_changed();
|
||||
void on_input_changed();
|
||||
|
||||
Sdf3dOpRevolution();
|
||||
~Sdf3dOpRevolution();
|
||||
MMSdf3dOpRevolution();
|
||||
~MMSdf3dOpRevolution();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
//export(Resource)
|
||||
Ref<Resource> input;
|
||||
//export(Resource)
|
||||
Ref<Resource> output;
|
||||
//export(float)
|
||||
float offset = 0.25;
|
||||
//offset
|
||||
Ref<MMNodeUniversalProperty> input;
|
||||
Ref<MMNodeUniversalProperty> output;
|
||||
float offset;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,141 +1,100 @@
|
||||
|
||||
#include "sdf3d_op_rounded.h"
|
||||
|
||||
#include "../../algos/mm_algos.h"
|
||||
#include "../../editor/mm_graph_node.h"
|
||||
#include "../mm_material.h"
|
||||
|
||||
Ref<Resource> Sdf3dOpRounded::get_input() {
|
||||
return input;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpRounded::get_input() {
|
||||
return input;
|
||||
}
|
||||
|
||||
void Sdf3dOpRounded::set_input(const Ref<Resource> &val) {
|
||||
input = val;
|
||||
void MMSdf3dOpRounded::set_input(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<Resource> Sdf3dOpRounded::get_output() {
|
||||
return output;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpRounded::get_output() {
|
||||
return output;
|
||||
}
|
||||
|
||||
void Sdf3dOpRounded::set_output(const Ref<Resource> &val) {
|
||||
output = val;
|
||||
void MMSdf3dOpRounded::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||
output = val;
|
||||
}
|
||||
|
||||
|
||||
float Sdf3dOpRounded::get_radius() const {
|
||||
return radius;
|
||||
float MMSdf3dOpRounded::get_radius() const {
|
||||
return radius;
|
||||
}
|
||||
|
||||
void Sdf3dOpRounded::set_radius(const float val) {
|
||||
radius = val;
|
||||
void MMSdf3dOpRounded::set_radius(const float val) {
|
||||
radius = val;
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
void MMSdf3dOpRounded::_init_properties() {
|
||||
if (!input.is_valid()) {
|
||||
input.instance();
|
||||
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input->set_slot_name(">>> Input ");
|
||||
|
||||
//tool;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> output;
|
||||
//export(float) ;
|
||||
float radius = 0.15;
|
||||
if (!input->is_connected("changed", this, "on_input_changed")) {
|
||||
input->connect("changed", this, "on_input_changed");
|
||||
}
|
||||
|
||||
void Sdf3dOpRounded::_init_properties() {
|
||||
if (!output.is_valid()) {
|
||||
output.instance();
|
||||
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
if (!input) {
|
||||
input = MMNodeUniversalProperty.new();
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||
output->set_slot_name(">>> Output >>>");
|
||||
output->set_get_value_from_owner(true);
|
||||
|
||||
register_input_property(input);
|
||||
register_output_property(output);
|
||||
}
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input.slot_name = ">>> Input ";
|
||||
|
||||
if (!input.is_connected("changed", self, "on_input_changed")) {
|
||||
input.connect("changed", self, "on_input_changed");
|
||||
void MMSdf3dOpRounded::_register_methods(MMGraphNode *mm_graph_node) {
|
||||
mm_graph_node->add_slot_label_universal(input);
|
||||
mm_graph_node->add_slot_label_universal(output);
|
||||
mm_graph_node->add_slot_float("get_radius", "set_radius", "Radius", 0.01);
|
||||
}
|
||||
|
||||
|
||||
if (!output) {
|
||||
output = MMNodeUniversalProperty.new();
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
Vector2 MMSdf3dOpRounded::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
Vector2 v = input->get_value_sdf3d(uv3);
|
||||
//vec2($(name_uv)_v.x-$r, $(name_uv)_v.y);
|
||||
v.x -= radius;
|
||||
return v;
|
||||
}
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
output.slot_name = ">>> Output >>>";
|
||||
output.get_value_from_owner = true;
|
||||
register_input_property(input);
|
||||
register_output_property(output);
|
||||
void MMSdf3dOpRounded::on_input_changed() {
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpRounded::_register_methods(const Variant &mm_graph_node) {
|
||||
mm_graph_node.add_slot_label_universal(input);
|
||||
mm_graph_node.add_slot_label_universal(output);
|
||||
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01);
|
||||
MMSdf3dOpRounded::MMSdf3dOpRounded() {
|
||||
radius = 0.15;
|
||||
}
|
||||
|
||||
|
||||
Vector2 Sdf3dOpRounded::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
Vector2 v = input.get_value_sdf3d(uv3);
|
||||
//vec2($(name_uv)_v.x-$r, $(name_uv)_v.y);
|
||||
v.x -= radius;
|
||||
return v;
|
||||
MMSdf3dOpRounded::~MMSdf3dOpRounded() {
|
||||
}
|
||||
|
||||
//radius;
|
||||
void MMSdf3dOpRounded::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &MMSdf3dOpRounded::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMSdf3dOpRounded::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
|
||||
|
||||
float Sdf3dOpRounded::get_radius() {
|
||||
return radius;
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dOpRounded::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dOpRounded::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_radius"), &MMSdf3dOpRounded::get_radius);
|
||||
ClassDB::bind_method(D_METHOD("set_radius", "value"), &MMSdf3dOpRounded::set_radius);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdf3dOpRounded::on_input_changed);
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpRounded::set_radius(const float val) {
|
||||
radius = val;
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpRounded::on_input_changed() {
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Sdf3dOpRounded::Sdf3dOpRounded() {
|
||||
input;
|
||||
output;
|
||||
radius = 0.15;
|
||||
}
|
||||
|
||||
Sdf3dOpRounded::~Sdf3dOpRounded() {
|
||||
}
|
||||
|
||||
|
||||
static void Sdf3dOpRounded::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &Sdf3dOpRounded::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &Sdf3dOpRounded::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dOpRounded::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dOpRounded::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_radius"), &Sdf3dOpRounded::get_radius);
|
||||
ClassDB::bind_method(D_METHOD("set_radius", "value"), &Sdf3dOpRounded::set_radius);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dOpRounded::_init_properties);
|
||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dOpRounded::_register_methods);
|
||||
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dOpRounded::_get_property_value_sdf3d);
|
||||
ClassDB::bind_method(D_METHOD("get_radius"), &Sdf3dOpRounded::get_radius);
|
||||
ClassDB::bind_method(D_METHOD("set_radius", "val"), &Sdf3dOpRounded::set_radius);
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &Sdf3dOpRounded::on_input_changed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,43 +1,42 @@
|
||||
#ifndef SDF3D_OP_ROUNDED_H
|
||||
#define SDF3D_OP_ROUNDED_H
|
||||
#ifndef MM_SDF3D_OP_ROUNDED_H
|
||||
#define MM_SDF3D_OP_ROUNDED_H
|
||||
|
||||
#include "../mm_node.h"
|
||||
#include "../mm_node_universal_property.h"
|
||||
|
||||
class Sdf3dOpRounded : public MMNode {
|
||||
GDCLASS(Sdf3dOpRounded, MMNode);
|
||||
class MMSdf3dOpRounded : public MMNode {
|
||||
GDCLASS(MMSdf3dOpRounded, MMNode);
|
||||
|
||||
public:
|
||||
public:
|
||||
Ref<MMNodeUniversalProperty> get_input();
|
||||
void set_input(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input();
|
||||
void set_input(const Ref<Resource> &val);
|
||||
Ref<MMNodeUniversalProperty> get_output();
|
||||
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_output();
|
||||
void set_output(const Ref<Resource> &val);
|
||||
float get_radius() const;
|
||||
void set_radius(const float val);
|
||||
|
||||
float get_radius() const;
|
||||
void set_radius(const float val);
|
||||
void _init_properties();
|
||||
void _register_methods(MMGraphNode *mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
|
||||
void _init_properties();
|
||||
void _register_methods(const Variant &mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
float get_radius();
|
||||
void set_radius(const float val);
|
||||
void on_input_changed();
|
||||
void on_input_changed();
|
||||
|
||||
Sdf3dOpRounded();
|
||||
~Sdf3dOpRounded();
|
||||
MMSdf3dOpRounded();
|
||||
~MMSdf3dOpRounded();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
//export(Resource)
|
||||
Ref<Resource> input;
|
||||
//export(Resource)
|
||||
Ref<Resource> output;
|
||||
//export(float)
|
||||
float radius = 0.15;
|
||||
//radius
|
||||
//tool
|
||||
//export(MMNodeUniversalProperty)
|
||||
Ref<MMNodeUniversalProperty> input;
|
||||
//export(MMNodeUniversalProperty)
|
||||
Ref<MMNodeUniversalProperty> output;
|
||||
//export(float)
|
||||
float radius = 0.15;
|
||||
//radius
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,221 +1,157 @@
|
||||
|
||||
#include "sdf3d_op_smooth_bool.h"
|
||||
|
||||
#include "../../algos/mm_algos.h"
|
||||
#include "../../editor/mm_graph_node.h"
|
||||
#include "../mm_material.h"
|
||||
|
||||
Ref<Resource> Sdf3dOpSmoothBool::get_input1() {
|
||||
return input1;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpSmoothBool::get_input1() {
|
||||
return input1;
|
||||
}
|
||||
|
||||
void Sdf3dOpSmoothBool::set_input1(const Ref<Resource> &val) {
|
||||
input1 = val;
|
||||
void MMSdf3dOpSmoothBool::set_input1(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input1 = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<Resource> Sdf3dOpSmoothBool::get_input2() {
|
||||
return input2;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpSmoothBool::get_input2() {
|
||||
return input2;
|
||||
}
|
||||
|
||||
void Sdf3dOpSmoothBool::set_input2(const Ref<Resource> &val) {
|
||||
input2 = val;
|
||||
void MMSdf3dOpSmoothBool::set_input2(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input2 = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<Resource> Sdf3dOpSmoothBool::get_output() {
|
||||
return output;
|
||||
Ref<MMNodeUniversalProperty> MMSdf3dOpSmoothBool::get_output() {
|
||||
return output;
|
||||
}
|
||||
|
||||
void Sdf3dOpSmoothBool::set_output(const Ref<Resource> &val) {
|
||||
output = val;
|
||||
void MMSdf3dOpSmoothBool::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||
output = val;
|
||||
}
|
||||
|
||||
|
||||
int Sdf3dOpSmoothBool::get_operation() const {
|
||||
return operation;
|
||||
int MMSdf3dOpSmoothBool::get_operation() const {
|
||||
return operation;
|
||||
}
|
||||
|
||||
void Sdf3dOpSmoothBool::set_operation(const int val) {
|
||||
operation = val;
|
||||
void MMSdf3dOpSmoothBool::set_operation(const int val) {
|
||||
operation = val;
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
|
||||
float Sdf3dOpSmoothBool::get_smoothness() const {
|
||||
return smoothness;
|
||||
float MMSdf3dOpSmoothBool::get_smoothness() const {
|
||||
return smoothness;
|
||||
}
|
||||
|
||||
void Sdf3dOpSmoothBool::set_smoothness(const float val) {
|
||||
smoothness = val;
|
||||
void MMSdf3dOpSmoothBool::set_smoothness(const float val) {
|
||||
smoothness = val;
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
void MMSdf3dOpSmoothBool::_init_properties() {
|
||||
if (!input1.is_valid()) {
|
||||
input1.instance();
|
||||
input1->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
input1->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input1->set_slot_name(">>> Input 1 ");
|
||||
|
||||
//tool;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input1;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input2;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> output;
|
||||
//export(int, "Union,Substraction,Intersection") ;
|
||||
int operation = 0;
|
||||
//export(float) ;
|
||||
float smoothness = 0.15;
|
||||
if (!input1->is_connected("changed", this, "on_input_changed")) {
|
||||
input1->connect("changed", this, "on_input_changed");
|
||||
}
|
||||
|
||||
void Sdf3dOpSmoothBool::_init_properties() {
|
||||
if (!input2.is_valid()) {
|
||||
input2.instance();
|
||||
input2->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
if (!input1) {
|
||||
input1 = MMNodeUniversalProperty.new();
|
||||
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
input2->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
// input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input2->set_slot_name(">>> Input 2 ");
|
||||
|
||||
if (!input2->is_connected("changed", this, "on_input_changed")) {
|
||||
input2->connect("changed", this, "on_input_changed");
|
||||
}
|
||||
|
||||
if (!output.is_valid()) {
|
||||
output.instance();
|
||||
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||
}
|
||||
|
||||
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||
output->set_slot_name(">>> Output >>>");
|
||||
output->set_get_value_from_owner(true);
|
||||
|
||||
register_input_property(input1);
|
||||
register_input_property(input2);
|
||||
register_output_property(output);
|
||||
}
|
||||
|
||||
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input1.slot_name = ">>> Input 1 ";
|
||||
void MMSdf3dOpSmoothBool::_register_methods(MMGraphNode *mm_graph_node) {
|
||||
mm_graph_node->add_slot_label_universal(input1);
|
||||
mm_graph_node->add_slot_label_universal(input2);
|
||||
mm_graph_node->add_slot_label_universal(output);
|
||||
|
||||
if (!input1.is_connected("changed", self, "on_input_changed")) {
|
||||
input1.connect("changed", self, "on_input_changed");
|
||||
Array arr;
|
||||
arr.push_back("Union");
|
||||
arr.push_back("Substraction");
|
||||
arr.push_back("Intersection");
|
||||
|
||||
mm_graph_node->add_slot_enum("get_operation", "set_operation", "Operation", arr);
|
||||
mm_graph_node->add_slot_float("get_smoothness", "set_smoothness", "Smoothness", 0.01);
|
||||
}
|
||||
|
||||
Vector2 MMSdf3dOpSmoothBool::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
Vector2 s1 = input1->get_value_sdf3d(uv3);
|
||||
Vector2 s2 = input2->get_value_sdf3d(uv3);
|
||||
|
||||
if (!input2) {
|
||||
input2 = MMNodeUniversalProperty.new();
|
||||
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
if (operation == 0) {
|
||||
return MMAlgos::sdf3d_smooth_union(s1, s2, smoothness);
|
||||
} else if (operation == 1) {
|
||||
return MMAlgos::sdf3d_smooth_subtraction(s1, s2, smoothness);
|
||||
} else if (operation == 2) {
|
||||
return MMAlgos::sdf3d_smooth_intersection(s1, s2, smoothness);
|
||||
}
|
||||
|
||||
return Vector2();
|
||||
}
|
||||
|
||||
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
// input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||
input2.slot_name = ">>> Input 2 ";
|
||||
|
||||
if (!input2.is_connected("changed", self, "on_input_changed")) {
|
||||
input2.connect("changed", self, "on_input_changed");
|
||||
void MMSdf3dOpSmoothBool::on_input_changed() {
|
||||
emit_changed();
|
||||
output->do_emit_changed();
|
||||
}
|
||||
|
||||
|
||||
if (!output) {
|
||||
output = MMNodeUniversalProperty.new();
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
||||
MMSdf3dOpSmoothBool::MMSdf3dOpSmoothBool() {
|
||||
operation = 0;
|
||||
smoothness = 0.15;
|
||||
}
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
output.slot_name = ">>> Output >>>";
|
||||
output.get_value_from_owner = true;
|
||||
register_input_property(input1);
|
||||
register_input_property(input2);
|
||||
register_output_property(output);
|
||||
MMSdf3dOpSmoothBool::~MMSdf3dOpSmoothBool() {
|
||||
}
|
||||
|
||||
void MMSdf3dOpSmoothBool::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input1"), &MMSdf3dOpSmoothBool::get_input1);
|
||||
ClassDB::bind_method(D_METHOD("set_input1", "value"), &MMSdf3dOpSmoothBool::set_input1);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input1", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input1", "get_input1");
|
||||
|
||||
void Sdf3dOpSmoothBool::_register_methods(const Variant &mm_graph_node) {
|
||||
mm_graph_node.add_slot_label_universal(input1);
|
||||
mm_graph_node.add_slot_label_universal(input2);
|
||||
mm_graph_node.add_slot_label_universal(output);
|
||||
mm_graph_node.add_slot_enum("get_operation", "set_operation", "Operation", [ "Union", "Substraction", "Intersection" ]);
|
||||
mm_graph_node.add_slot_float("get_smoothness", "set_smoothness", "Smoothness", 0.01);
|
||||
ClassDB::bind_method(D_METHOD("get_input2"), &MMSdf3dOpSmoothBool::get_input2);
|
||||
ClassDB::bind_method(D_METHOD("set_input2", "value"), &MMSdf3dOpSmoothBool::set_input2);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input2", "get_input2");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dOpSmoothBool::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dOpSmoothBool::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_operation"), &MMSdf3dOpSmoothBool::get_operation);
|
||||
ClassDB::bind_method(D_METHOD("set_operation", "value"), &MMSdf3dOpSmoothBool::set_operation);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation"), "set_operation", "get_operation");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_smoothness"), &MMSdf3dOpSmoothBool::get_smoothness);
|
||||
ClassDB::bind_method(D_METHOD("set_smoothness", "value"), &MMSdf3dOpSmoothBool::set_smoothness);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "smoothness"), "set_smoothness", "get_smoothness");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdf3dOpSmoothBool::on_input_changed);
|
||||
}
|
||||
|
||||
|
||||
Vector2 Sdf3dOpSmoothBool::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||
Vector2 s1 = input1.get_value_sdf3d(uv3);
|
||||
Vector2 s2 = input2.get_value_sdf3d(uv3);
|
||||
|
||||
if (operation == 0) {
|
||||
return MMAlgos.sdf3d_smooth_union(s1, s2, smoothness);
|
||||
}
|
||||
|
||||
|
||||
else if (operation == 1) {
|
||||
return MMAlgos.sdf3d_smooth_subtraction(s1, s2, smoothness);
|
||||
}
|
||||
|
||||
|
||||
else if (operation == 2) {
|
||||
return MMAlgos.sdf3d_smooth_intersection(s1, s2, smoothness);
|
||||
}
|
||||
|
||||
return Vector2();
|
||||
}
|
||||
|
||||
//operation;
|
||||
|
||||
int Sdf3dOpSmoothBool::get_operation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpSmoothBool::set_operation(const int val) {
|
||||
operation = val;
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
//smoothness;
|
||||
|
||||
float Sdf3dOpSmoothBool::get_smoothness() {
|
||||
return smoothness;
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpSmoothBool::set_smoothness(const float val) {
|
||||
smoothness = val;
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void Sdf3dOpSmoothBool::on_input_changed() {
|
||||
emit_changed();
|
||||
output.emit_changed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Sdf3dOpSmoothBool::Sdf3dOpSmoothBool() {
|
||||
input1;
|
||||
input2;
|
||||
output;
|
||||
operation = 0;
|
||||
smoothness = 0.15;
|
||||
}
|
||||
|
||||
Sdf3dOpSmoothBool::~Sdf3dOpSmoothBool() {
|
||||
}
|
||||
|
||||
|
||||
static void Sdf3dOpSmoothBool::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input1"), &Sdf3dOpSmoothBool::get_input1);
|
||||
ClassDB::bind_method(D_METHOD("set_input1", "value"), &Sdf3dOpSmoothBool::set_input1);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input1", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input1", "get_input1");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_input2"), &Sdf3dOpSmoothBool::get_input2);
|
||||
ClassDB::bind_method(D_METHOD("set_input2", "value"), &Sdf3dOpSmoothBool::set_input2);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input2", "get_input2");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dOpSmoothBool::get_output);
|
||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dOpSmoothBool::set_output);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_operation"), &Sdf3dOpSmoothBool::get_operation);
|
||||
ClassDB::bind_method(D_METHOD("set_operation", "value"), &Sdf3dOpSmoothBool::set_operation);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation"), "set_operation", "get_operation");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_smoothness"), &Sdf3dOpSmoothBool::get_smoothness);
|
||||
ClassDB::bind_method(D_METHOD("set_smoothness", "value"), &Sdf3dOpSmoothBool::set_smoothness);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "smoothness"), "set_smoothness", "get_smoothness");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dOpSmoothBool::_init_properties);
|
||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dOpSmoothBool::_register_methods);
|
||||
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dOpSmoothBool::_get_property_value_sdf3d);
|
||||
ClassDB::bind_method(D_METHOD("get_operation"), &Sdf3dOpSmoothBool::get_operation);
|
||||
ClassDB::bind_method(D_METHOD("set_operation", "val"), &Sdf3dOpSmoothBool::set_operation);
|
||||
ClassDB::bind_method(D_METHOD("get_smoothness"), &Sdf3dOpSmoothBool::get_smoothness);
|
||||
ClassDB::bind_method(D_METHOD("set_smoothness", "val"), &Sdf3dOpSmoothBool::set_smoothness);
|
||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &Sdf3dOpSmoothBool::on_input_changed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,56 +1,46 @@
|
||||
#ifndef SDF3D_OP_SMOOTH_BOOL_H
|
||||
#define SDF3D_OP_SMOOTH_BOOL_H
|
||||
#ifndef MM_SDF3D_OP_SMOOTH_BOOL_H
|
||||
#define MM_SDF3D_OP_SMOOTH_BOOL_H
|
||||
|
||||
#include "../mm_node.h"
|
||||
#include "../mm_node_universal_property.h"
|
||||
|
||||
class Sdf3dOpSmoothBool : public MMNode {
|
||||
GDCLASS(Sdf3dOpSmoothBool, MMNode);
|
||||
class MMSdf3dOpSmoothBool : public MMNode {
|
||||
GDCLASS(MMSdf3dOpSmoothBool, MMNode);
|
||||
|
||||
public:
|
||||
public:
|
||||
Ref<MMNodeUniversalProperty> get_input1();
|
||||
void set_input1(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input1();
|
||||
void set_input1(const Ref<Resource> &val);
|
||||
Ref<MMNodeUniversalProperty> get_input2();
|
||||
void set_input2(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input2();
|
||||
void set_input2(const Ref<Resource> &val);
|
||||
Ref<MMNodeUniversalProperty> get_output();
|
||||
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_output();
|
||||
void set_output(const Ref<Resource> &val);
|
||||
int get_operation() const;
|
||||
void set_operation(const int val);
|
||||
|
||||
int get_operation() const;
|
||||
void set_operation(const int val);
|
||||
float get_smoothness() const;
|
||||
void set_smoothness(const float val);
|
||||
|
||||
float get_smoothness() const;
|
||||
void set_smoothness(const float val);
|
||||
void _init_properties();
|
||||
void _register_methods(MMGraphNode *mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
|
||||
void _init_properties();
|
||||
void _register_methods(const Variant &mm_graph_node);
|
||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||
int get_operation();
|
||||
void set_operation(const int val);
|
||||
float get_smoothness();
|
||||
void set_smoothness(const float val);
|
||||
void on_input_changed();
|
||||
void on_input_changed();
|
||||
|
||||
Sdf3dOpSmoothBool();
|
||||
~Sdf3dOpSmoothBool();
|
||||
MMSdf3dOpSmoothBool();
|
||||
~MMSdf3dOpSmoothBool();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
//export(Resource)
|
||||
Ref<Resource> input1;
|
||||
//export(Resource)
|
||||
Ref<Resource> input2;
|
||||
//export(Resource)
|
||||
Ref<Resource> output;
|
||||
//export(int, "Union,Substraction,Intersection")
|
||||
int operation = 0;
|
||||
//export(float)
|
||||
float smoothness = 0.15;
|
||||
//operation
|
||||
//smoothness
|
||||
Ref<MMNodeUniversalProperty> input1;
|
||||
Ref<MMNodeUniversalProperty> input2;
|
||||
Ref<MMNodeUniversalProperty> output;
|
||||
//export(int, "Union,Substraction,Intersection")
|
||||
int operation;
|
||||
float smoothness;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -61,6 +61,7 @@ SOFTWARE.
|
||||
#include "nodes/simple/image.h"
|
||||
#include "nodes/simple/shape.h"
|
||||
|
||||
#include "nodes/sdf3d/sdf3d_color.h"
|
||||
#include "nodes/sdf3d/sdf3d_render.h"
|
||||
|
||||
#include "nodes/sdf3d/sdf3d_tf_rotate.h"
|
||||
@ -74,6 +75,15 @@ SOFTWARE.
|
||||
#include "nodes/sdf3d/sdf3d_shape_sphere.h"
|
||||
#include "nodes/sdf3d/sdf3d_shape_torus.h"
|
||||
|
||||
#include "nodes/sdf3d/sdf3d_op_bool.h"
|
||||
#include "nodes/sdf3d/sdf3d_op_circle_repeat.h"
|
||||
#include "nodes/sdf3d/sdf3d_op_elongation.h"
|
||||
#include "nodes/sdf3d/sdf3d_op_morph.h"
|
||||
#include "nodes/sdf3d/sdf3d_op_repeat.h"
|
||||
#include "nodes/sdf3d/sdf3d_op_revolution.h"
|
||||
#include "nodes/sdf3d/sdf3d_op_rounded.h"
|
||||
#include "nodes/sdf3d/sdf3d_op_smooth_bool.h"
|
||||
|
||||
static _MMAlgos *_mm_algos_singleton = nullptr;
|
||||
|
||||
void register_material_maker_types() {
|
||||
@ -125,6 +135,8 @@ void register_material_maker_types() {
|
||||
ClassDB::register_class<MMCurve>();
|
||||
MMAlgos::register_node_class("Simple", "MMCurve");
|
||||
|
||||
ClassDB::register_class<MMSdf3dColor>();
|
||||
MMAlgos::register_node_class("SDF3D", "MMSdf3dColor");
|
||||
ClassDB::register_class<MMSdf3dRender>();
|
||||
MMAlgos::register_node_class("SDF3D", "MMSdf3dRender");
|
||||
|
||||
@ -148,6 +160,23 @@ void register_material_maker_types() {
|
||||
ClassDB::register_class<MMSdf3dShapeBox>();
|
||||
MMAlgos::register_node_class("SDF3D - Shape", "MMSdf3dShapeBox");
|
||||
|
||||
ClassDB::register_class<MMSdf3dOpSmoothBool>();
|
||||
MMAlgos::register_node_class("SDF3D - OP", "MMSdf3dOpSmoothBool");
|
||||
ClassDB::register_class<MMSdf3dOpRounded>();
|
||||
MMAlgos::register_node_class("SDF3D - OP", "MMSdf3dOpRounded");
|
||||
ClassDB::register_class<MMSdf3dOpRevolution>();
|
||||
MMAlgos::register_node_class("SDF3D - OP", "MMSdf3dOpRevolution");
|
||||
ClassDB::register_class<MMSdf3dOpRepeat>();
|
||||
MMAlgos::register_node_class("SDF3D - OP", "MMSdf3dOpRepeat");
|
||||
ClassDB::register_class<MMSdf3dOpMorph>();
|
||||
MMAlgos::register_node_class("SDF3D - OP", "MMSdf3dOpMorph");
|
||||
ClassDB::register_class<MMSdf3dOpElongation>();
|
||||
MMAlgos::register_node_class("SDF3D - OP", "MMSdf3dOpElongation");
|
||||
ClassDB::register_class<MMSdf3dOpCircleRepeat>();
|
||||
MMAlgos::register_node_class("SDF3D - OP", "MMSdf3dOpCircleRepeat");
|
||||
ClassDB::register_class<MMSdf3dOpBool>();
|
||||
MMAlgos::register_node_class("SDF3D - OP", "MMSdf3dOpBool");
|
||||
|
||||
_mm_algos_singleton = memnew(_MMAlgos);
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton()));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user