Cleaned up 3 more sdf3d nodes.

This commit is contained in:
Relintai 2022-06-17 12:07:24 +02:00
parent 3bbaaa3af0
commit 5c67416ad5
9 changed files with 300 additions and 456 deletions

View File

@ -70,6 +70,10 @@ sources = [
"nodes/simple/curve.cpp",
"nodes/sdf3d/sdf3d_tf_translate.cpp",
"nodes/sdf3d/sdf3d_tf_scale.cpp",
"nodes/sdf3d/sdf3d_tf_rotate.cpp",
"nodes/sdf3d/sdf3d_shape_torus.cpp",
]
if env["tools"]:

View File

@ -40,6 +40,10 @@ def get_doc_classes():
"MMCurve",
"MMSdf3dTfTranslate",
"MMSdf3dTfScale",
"MMSdf3dTfRotate",
"MMSdf3dShapeTorus",
]
def get_doc_path():

View File

@ -1,179 +1,112 @@
#include "sdf3d_shape_torus.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Sdf3dShapeTorus::get_output() {
return output;
Ref<MMNodeUniversalProperty> MMSdf3dShapeTorus::get_output() {
return output;
}
void Sdf3dShapeTorus::set_output(const Ref<Resource> &val) {
output = val;
void MMSdf3dShapeTorus::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
int Sdf3dShapeTorus::get_axis() const {
return axis;
int MMSdf3dShapeTorus::get_axis() const {
return axis;
}
void Sdf3dShapeTorus::set_axis(const int val) {
axis = val;
void MMSdf3dShapeTorus::set_axis(const int val) {
axis = val;
emit_changed();
output->do_emit_changed();
}
float Sdf3dShapeTorus::get_major_radius() const {
return major_radius;
float MMSdf3dShapeTorus::get_major_radius() const {
return major_radius;
}
void Sdf3dShapeTorus::set_major_radius(const float val) {
major_radius = val;
void MMSdf3dShapeTorus::set_major_radius(const float val) {
major_radius = val;
emit_changed();
output->do_emit_changed();
}
float Sdf3dShapeTorus::get_minor_radius() const {
return minor_radius;
float MMSdf3dShapeTorus::get_minor_radius() const {
return minor_radius;
}
void Sdf3dShapeTorus::set_minor_radius(const float val) {
minor_radius = val;
void MMSdf3dShapeTorus::set_minor_radius(const float val) {
minor_radius = val;
emit_changed();
output->do_emit_changed();
}
void MMSdf3dShapeTorus::_init_properties() {
if (!output.is_valid()) {
output.instance();
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
}
//tool;
//export(Resource) ;
Ref<Resource> output;
//export(int, "X,Y,Z") ;
int axis = 2;
//export(float) ;
float major_radius = 0.3;
//export(float) ;
float minor_radius = 0.15;
void Sdf3dShapeTorus::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.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_output_property(output);
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Output >>>";
output.get_value_from_owner = true;
register_output_property(output);
void MMSdf3dShapeTorus::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(output);
Array arr;
arr.push_back("X");
arr.push_back("Y");
arr.push_back("Z");
mm_graph_node->add_slot_enum("get_axis", "set_axis", "Axis", arr);
mm_graph_node->add_slot_float("get_major_radius", "set_major_radius", "Major_radius", 0.01);
mm_graph_node->add_slot_float("get_minor_radius", "set_minor_radius", "Minor_radius", 0.01);
}
Vector2 MMSdf3dShapeTorus::_get_property_value_sdf3d(const Vector3 &uv3) {
if (axis == 0) {
return MMAlgos::sdf3d_torus_x(uv3, major_radius, minor_radius);
}
void Sdf3dShapeTorus::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_enum("get_axis", "set_axis", "Axis", [ "X", "Y", "Z" ]);
mm_graph_node.add_slot_float("get_major_radius", "set_major_radius", "Major_radius", 0.01);
mm_graph_node.add_slot_float("get_minor_radius", "set_minor_radius", "Minor_radius", 0.01);
else if (axis == 1) {
return MMAlgos::sdf3d_torus_y(uv3, major_radius, minor_radius);
}
else if (axis == 2) {
return MMAlgos::sdf3d_torus_z(uv3, major_radius, minor_radius);
}
return Vector2();
}
Vector2 Sdf3dShapeTorus::_get_property_value_sdf3d(const Vector3 &uv3) {
if (axis == 0) {
return MMAlgos.sdf3d_torus_x(uv3, major_radius, minor_radius);
MMSdf3dShapeTorus::MMSdf3dShapeTorus() {
axis = 2;
major_radius = 0.3;
minor_radius = 0.15;
}
else if (axis == 1) {
return MMAlgos.sdf3d_torus_y(uv3, major_radius, minor_radius);
MMSdf3dShapeTorus::~MMSdf3dShapeTorus() {
}
void MMSdf3dShapeTorus::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dShapeTorus::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dShapeTorus::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
else if (axis == 2) {
return MMAlgos.sdf3d_torus_z(uv3, major_radius, minor_radius);
ClassDB::bind_method(D_METHOD("get_axis"), &MMSdf3dShapeTorus::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "value"), &MMSdf3dShapeTorus::set_axis);
ADD_PROPERTY(PropertyInfo(Variant::INT, "axis"), "set_axis", "get_axis");
ClassDB::bind_method(D_METHOD("get_major_radius"), &MMSdf3dShapeTorus::get_major_radius);
ClassDB::bind_method(D_METHOD("set_major_radius", "value"), &MMSdf3dShapeTorus::set_major_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "major_radius"), "set_major_radius", "get_major_radius");
ClassDB::bind_method(D_METHOD("get_minor_radius"), &MMSdf3dShapeTorus::get_minor_radius);
ClassDB::bind_method(D_METHOD("set_minor_radius", "value"), &MMSdf3dShapeTorus::set_minor_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "minor_radius"), "set_minor_radius", "get_minor_radius");
}
return Vector2();
}
//axis;
int Sdf3dShapeTorus::get_axis() {
return axis;
}
void Sdf3dShapeTorus::set_axis(const int val) {
axis = val;
emit_changed();
output.emit_changed();
}
//major_radius;
float Sdf3dShapeTorus::get_major_radius() {
return major_radius;
}
void Sdf3dShapeTorus::set_major_radius(const float val) {
major_radius = val;
emit_changed();
output.emit_changed();
}
//minor_radius;
float Sdf3dShapeTorus::get_minor_radius() {
return minor_radius;
}
void Sdf3dShapeTorus::set_minor_radius(const float val) {
minor_radius = val;
emit_changed();
output.emit_changed();
}
}
Sdf3dShapeTorus::Sdf3dShapeTorus() {
output;
axis = 2;
major_radius = 0.3;
minor_radius = 0.15;
}
Sdf3dShapeTorus::~Sdf3dShapeTorus() {
}
static void Sdf3dShapeTorus::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dShapeTorus::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dShapeTorus::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_axis"), &Sdf3dShapeTorus::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "value"), &Sdf3dShapeTorus::set_axis);
ADD_PROPERTY(PropertyInfo(Variant::INT, "axis"), "set_axis", "get_axis");
ClassDB::bind_method(D_METHOD("get_major_radius"), &Sdf3dShapeTorus::get_major_radius);
ClassDB::bind_method(D_METHOD("set_major_radius", "value"), &Sdf3dShapeTorus::set_major_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "major_radius"), "set_major_radius", "get_major_radius");
ClassDB::bind_method(D_METHOD("get_minor_radius"), &Sdf3dShapeTorus::get_minor_radius);
ClassDB::bind_method(D_METHOD("set_minor_radius", "value"), &Sdf3dShapeTorus::set_minor_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "minor_radius"), "set_minor_radius", "get_minor_radius");
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dShapeTorus::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dShapeTorus::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dShapeTorus::_get_property_value_sdf3d);
ClassDB::bind_method(D_METHOD("get_axis"), &Sdf3dShapeTorus::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "val"), &Sdf3dShapeTorus::set_axis);
ClassDB::bind_method(D_METHOD("get_major_radius"), &Sdf3dShapeTorus::get_major_radius);
ClassDB::bind_method(D_METHOD("set_major_radius", "val"), &Sdf3dShapeTorus::set_major_radius);
ClassDB::bind_method(D_METHOD("get_minor_radius"), &Sdf3dShapeTorus::get_minor_radius);
ClassDB::bind_method(D_METHOD("set_minor_radius", "val"), &Sdf3dShapeTorus::set_minor_radius);
}

View File

@ -1,53 +1,40 @@
#ifndef SDF3D_SHAPE_TORUS_H
#define SDF3D_SHAPE_TORUS_H
#ifndef MM_SDF3D_SHAPE_TORUS_H
#define MM_SDF3D_SHAPE_TORUS_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Sdf3dShapeTorus : public MMNode {
GDCLASS(Sdf3dShapeTorus, MMNode);
class MMSdf3dShapeTorus : public MMNode {
GDCLASS(MMSdf3dShapeTorus, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
int get_axis() const;
void set_axis(const int val);
int get_axis() const;
void set_axis(const int val);
float get_major_radius() const;
void set_major_radius(const float val);
float get_major_radius() const;
void set_major_radius(const float val);
float get_minor_radius() const;
void set_minor_radius(const float val);
float get_minor_radius() const;
void set_minor_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);
int get_axis();
void set_axis(const int val);
float get_major_radius();
void set_major_radius(const float val);
float get_minor_radius();
void set_minor_radius(const float val);
MMSdf3dShapeTorus();
~MMSdf3dShapeTorus();
Sdf3dShapeTorus();
~Sdf3dShapeTorus();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(int, "X,Y,Z")
int axis = 2;
//export(float)
float major_radius = 0.3;
//export(float)
float minor_radius = 0.15;
//axis
//major_radius
//minor_radius
Ref<MMNodeUniversalProperty> output;
//export(int, "X,Y,Z")
int axis;
float major_radius;
float minor_radius;
};
#endif

View File

@ -1,139 +1,97 @@
#include "sdf3d_tf_rotate.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Sdf3dTfRotate::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMSdf3dTfRotate::get_input() {
return input;
}
void Sdf3dTfRotate::set_input(const Ref<Resource> &val) {
input = val;
void MMSdf3dTfRotate::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
Ref<Resource> Sdf3dTfRotate::get_output() {
return output;
Ref<MMNodeUniversalProperty> MMSdf3dTfRotate::get_output() {
return output;
}
void Sdf3dTfRotate::set_output(const Ref<Resource> &val) {
output = val;
void MMSdf3dTfRotate::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
Vector3 Sdf3dTfRotate::get_rotation() {
return rotation;
Vector3 MMSdf3dTfRotate::get_rotation() {
return rotation;
}
void Sdf3dTfRotate::set_rotation(const Vector3 &val) {
rotation = val;
void MMSdf3dTfRotate::set_rotation(const Vector3 &val) {
rotation = val;
emit_changed();
output->do_emit_changed();
}
void MMSdf3dTfRotate::_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 rotation = Vector3();
if (!input->is_connected("changed", this, "on_input_changed")) {
input->connect("changed", this, "on_input_changed");
}
void Sdf3dTfRotate::_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 MMSdf3dTfRotate::_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_rotation", "set_rotation", "Rotation", 0.01);
}
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
Vector2 MMSdf3dTfRotate::_get_property_value_sdf3d(const Vector3 &uv3) {
//$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251));
return input->get_value_sdf3d(MMAlgos::rotate3d(uv3, -rotation * 0.01745329251));
}
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 MMSdf3dTfRotate::on_input_changed() {
emit_changed();
output->do_emit_changed();
}
void Sdf3dTfRotate::_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_rotation", "set_rotation", "Rotation", 0.01);
MMSdf3dTfRotate::MMSdf3dTfRotate() {
}
Vector2 Sdf3dTfRotate::_get_property_value_sdf3d(const Vector3 &uv3) {
//$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251));
return input.get_value_sdf3d(MMAlgos.rotate3d(uv3, -rotation * 0.01745329251));
MMSdf3dTfRotate::~MMSdf3dTfRotate() {
}
//rotation;
void MMSdf3dTfRotate::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input"), &MMSdf3dTfRotate::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMSdf3dTfRotate::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
Vector3 Sdf3dTfRotate::get_rotation() {
return rotation;
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dTfRotate::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dTfRotate::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_rotation"), &MMSdf3dTfRotate::get_rotation);
ClassDB::bind_method(D_METHOD("set_rotation", "value"), &MMSdf3dTfRotate::set_rotation);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation"), "set_rotation", "get_rotation");
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdf3dTfRotate::on_input_changed);
}
void Sdf3dTfRotate::set_rotation(const Vector3 &val) {
rotation = val;
emit_changed();
output.emit_changed();
}
void Sdf3dTfRotate::on_input_changed() {
emit_changed();
output.emit_changed();
}
}
Sdf3dTfRotate::Sdf3dTfRotate() {
input;
output;
rotation = Vector3();
}
Sdf3dTfRotate::~Sdf3dTfRotate() {
}
static void Sdf3dTfRotate::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input"), &Sdf3dTfRotate::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &Sdf3dTfRotate::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"), &Sdf3dTfRotate::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dTfRotate::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_rotation"), &Sdf3dTfRotate::get_rotation);
ClassDB::bind_method(D_METHOD("set_rotation", "value"), &Sdf3dTfRotate::set_rotation);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation"), "set_rotation", "get_rotation");
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dTfRotate::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dTfRotate::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dTfRotate::_get_property_value_sdf3d);
ClassDB::bind_method(D_METHOD("get_rotation"), &Sdf3dTfRotate::get_rotation);
ClassDB::bind_method(D_METHOD("set_rotation", "val"), &Sdf3dTfRotate::set_rotation);
ClassDB::bind_method(D_METHOD("on_input_changed"), &Sdf3dTfRotate::on_input_changed);
}

View File

@ -1,43 +1,37 @@
#ifndef SDF3D_TF_ROTATE_H
#define SDF3D_TF_ROTATE_H
#ifndef MM_SDF3D_TF_ROTATE_H
#define MM_SDF3D_TF_ROTATE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Sdf3dTfRotate : public MMNode {
GDCLASS(Sdf3dTfRotate, MMNode);
class MMSdf3dTfRotate : public MMNode {
GDCLASS(MMSdf3dTfRotate, 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_rotation();
void set_rotation(const Vector3 &val);
Vector3 get_rotation();
void set_rotation(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_rotation();
void set_rotation(const Vector3 &val);
void on_input_changed();
void on_input_changed();
Sdf3dTfRotate();
~Sdf3dTfRotate();
MMSdf3dTfRotate();
~MMSdf3dTfRotate();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> input;
//export(Resource)
Ref<Resource> output;
//export(Vector3)
Vector3 rotation = Vector3();
//rotation
Ref<MMNodeUniversalProperty> input;
Ref<MMNodeUniversalProperty> output;
Vector3 rotation;
};
#endif

View File

@ -1,139 +1,98 @@
#include "sdf3d_tf_scale.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Sdf3dTfScale::get_input() {
return input;
Ref<MMNodeUniversalProperty> MMSdf3dTfScale::get_input() {
return input;
}
void Sdf3dTfScale::set_input(const Ref<Resource> &val) {
input = val;
void MMSdf3dTfScale::set_input(const Ref<MMNodeUniversalProperty> &val) {
input = val;
}
Ref<Resource> Sdf3dTfScale::get_output() {
return output;
Ref<MMNodeUniversalProperty> MMSdf3dTfScale::get_output() {
return output;
}
void Sdf3dTfScale::set_output(const Ref<Resource> &val) {
output = val;
void MMSdf3dTfScale::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
float Sdf3dTfScale::get_scale() const {
return scale;
float MMSdf3dTfScale::get_scale() const {
return scale;
}
void Sdf3dTfScale::set_scale(const float val) {
scale = val;
void MMSdf3dTfScale::set_scale(const float val) {
scale = val;
emit_changed();
output->do_emit_changed();
}
void MMSdf3dTfScale::_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 scale = 1;
if (!input->is_connected("changed", this, "on_input_changed")) {
input->connect("changed", this, "on_input_changed");
}
void Sdf3dTfScale::_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 MMSdf3dTfScale::_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_scale", "set_scale", "Scale", 0.01);
}
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
Vector2 MMSdf3dTfScale::_get_property_value_sdf3d(const Vector3 &uv3) {
//vec2 $(name_uv)_in = $in(($uv)/$s);
return input->get_value_sdf3d(uv3 / scale);
}
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 MMSdf3dTfScale::on_input_changed() {
emit_changed();
output->do_emit_changed();
}
void Sdf3dTfScale::_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_scale", "set_scale", "Scale", 0.01);
MMSdf3dTfScale::MMSdf3dTfScale() {
scale = 1;
}
Vector2 Sdf3dTfScale::_get_property_value_sdf3d(const Vector3 &uv3) {
//vec2 $(name_uv)_in = $in(($uv)/$s);
return input.get_value_sdf3d(uv3 / scale);
MMSdf3dTfScale::~MMSdf3dTfScale() {
}
//scale;
void MMSdf3dTfScale::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input"), &MMSdf3dTfScale::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMSdf3dTfScale::set_input);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
float Sdf3dTfScale::get_scale() {
return scale;
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dTfScale::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dTfScale::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_scale"), &MMSdf3dTfScale::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "value"), &MMSdf3dTfScale::set_scale);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale"), "set_scale", "get_scale");
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdf3dTfScale::on_input_changed);
}
void Sdf3dTfScale::set_scale(const float val) {
scale = val;
emit_changed();
output.emit_changed();
}
void Sdf3dTfScale::on_input_changed() {
emit_changed();
output.emit_changed();
}
}
Sdf3dTfScale::Sdf3dTfScale() {
input;
output;
scale = 1;
}
Sdf3dTfScale::~Sdf3dTfScale() {
}
static void Sdf3dTfScale::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input"), &Sdf3dTfScale::get_input);
ClassDB::bind_method(D_METHOD("set_input", "value"), &Sdf3dTfScale::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"), &Sdf3dTfScale::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dTfScale::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_scale"), &Sdf3dTfScale::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "value"), &Sdf3dTfScale::set_scale);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale"), "set_scale", "get_scale");
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dTfScale::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dTfScale::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dTfScale::_get_property_value_sdf3d);
ClassDB::bind_method(D_METHOD("get_scale"), &Sdf3dTfScale::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "val"), &Sdf3dTfScale::set_scale);
ClassDB::bind_method(D_METHOD("on_input_changed"), &Sdf3dTfScale::on_input_changed);
}

View File

@ -1,43 +1,37 @@
#ifndef SDF3D_TF_SCALE_H
#define SDF3D_TF_SCALE_H
#ifndef MM_SDF3D_TF_SCALE_H
#define MM_SDF3D_TF_SCALE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Sdf3dTfScale : public MMNode {
GDCLASS(Sdf3dTfScale, MMNode);
class MMSdf3dTfScale : public MMNode {
GDCLASS(MMSdf3dTfScale, 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_scale() const;
void set_scale(const float val);
float get_scale() const;
void set_scale(const float val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
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_scale();
void set_scale(const float val);
void on_input_changed();
void on_input_changed();
Sdf3dTfScale();
~Sdf3dTfScale();
MMSdf3dTfScale();
~MMSdf3dTfScale();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> input;
//export(Resource)
Ref<Resource> output;
//export(float)
float scale = 1;
//scale
Ref<MMNodeUniversalProperty> input;
Ref<MMNodeUniversalProperty> output;
float scale;
};
#endif

View File

@ -61,8 +61,12 @@ SOFTWARE.
#include "nodes/simple/image.h"
#include "nodes/simple/shape.h"
#include "nodes/sdf3d/sdf3d_tf_rotate.h"
#include "nodes/sdf3d/sdf3d_tf_scale.h"
#include "nodes/sdf3d/sdf3d_tf_translate.h"
#include "nodes/sdf3d/sdf3d_shape_torus.h"
static _MMAlgos *_mm_algos_singleton = nullptr;
void register_material_maker_types() {
@ -115,7 +119,14 @@ void register_material_maker_types() {
MMAlgos::register_node_class("Simple", "MMCurve");
ClassDB::register_class<MMSdf3dTfTranslate>();
MMAlgos::register_node_class("SDF3D", "MMSdf3dTfTranslate");
MMAlgos::register_node_class("SDF3D - TF", "MMSdf3dTfTranslate");
ClassDB::register_class<MMSdf3dTfScale>();
MMAlgos::register_node_class("SDF3D - TF", "MMSdf3dTfScale");
ClassDB::register_class<MMSdf3dTfRotate>();
MMAlgos::register_node_class("SDF3D - TF", "MMSdf3dTfRotate");
ClassDB::register_class<MMSdf3dShapeTorus>();
MMAlgos::register_node_class("SDF3D - Shape", "MMSdf3dShapeTorus");
_mm_algos_singleton = memnew(_MMAlgos);
Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton()));