Cleaned up the rest of the sdf3d shapes.

This commit is contained in:
Relintai 2022-06-17 13:17:08 +02:00
parent c39cfd2c05
commit e0895460e5
13 changed files with 499 additions and 810 deletions

View File

@ -76,6 +76,11 @@ sources = [
"nodes/sdf3d/sdf3d_tf_rotate.cpp",
"nodes/sdf3d/sdf3d_shape_torus.cpp",
"nodes/sdf3d/sdf3d_shape_sphere.cpp",
"nodes/sdf3d/sdf3d_shape_cylinder.cpp",
"nodes/sdf3d/sdf3d_shape_cone.cpp",
"nodes/sdf3d/sdf3d_shape_capsule.cpp",
"nodes/sdf3d/sdf3d_shape_box.cpp",
]

View File

@ -46,6 +46,11 @@ def get_doc_classes():
"MMSdf3dTfRotate",
"MMSdf3dShapeTorus",
"MMSdf3dShapeSphere",
"MMSdf3dShapeCylinder",
"MMSdf3dShapeCone",
"MMSdf3dShapeCapsule",
"MMSdf3dShapeBox",
]
def get_doc_path():

View File

@ -1,131 +1,79 @@
#include "sdf3d_shape_box.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Sdf3dShapeBox::get_output() {
Ref<MMNodeUniversalProperty> MMSdf3dShapeBox::get_output() {
return output;
}
void Sdf3dShapeBox::set_output(const Ref<Resource> &val) {
output = val;
void MMSdf3dShapeBox::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
Vector3 Sdf3dShapeBox::get_size() {
Vector3 MMSdf3dShapeBox::get_size() {
return size;
}
void Sdf3dShapeBox::set_size(const Vector3 &val) {
size = val;
void MMSdf3dShapeBox::set_size(const Vector3 &val) {
size = val;
emit_changed();
output->do_emit_changed();
}
float Sdf3dShapeBox::get_radius() const {
float MMSdf3dShapeBox::get_radius() const {
return radius;
}
void Sdf3dShapeBox::set_radius(const float val) {
radius = val;
void MMSdf3dShapeBox::set_radius(const float val) {
radius = val;
emit_changed();
output->do_emit_changed();
}
void MMSdf3dShapeBox::_init_properties() {
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);
//tool;
//export(Resource) ;
Ref<Resource> output;
//export(Vector3) ;
Vector3 size = Vector3(0.3, 0.25, 0.25);
//export(float) ;
float radius = 0.01;
void Sdf3dShapeBox::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Output >>>";
output.get_value_from_owner = true;
register_output_property(output);
}
void Sdf3dShapeBox::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_vector3("get_size", "set_size", "Size", 0.01);
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01);
void MMSdf3dShapeBox::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(output);
mm_graph_node->add_slot_vector3("get_size", "set_size", "Size", 0.01);
mm_graph_node->add_slot_float("get_radius", "set_radius", "Radius", 0.01);
}
Vector2 Sdf3dShapeBox::_get_property_value_sdf3d(const Vector3 &uv3) {
return MMAlgos.sdf3d_box(uv3, size.x, size.y, size.z, radius);
Vector2 MMSdf3dShapeBox::_get_property_value_sdf3d(const Vector3 &uv3) {
return MMAlgos::sdf3d_box(uv3, size.x, size.y, size.z, radius);
}
//size;
Vector3 Sdf3dShapeBox::get_size() {
return size;
}
void Sdf3dShapeBox::set_size(const Vector3 &val) {
size = val;
emit_changed();
output.emit_changed();
}
//radius;
float Sdf3dShapeBox::get_radius() {
return radius;
}
void Sdf3dShapeBox::set_radius(const float val) {
radius = val;
emit_changed();
output.emit_changed();
}
}
Sdf3dShapeBox::Sdf3dShapeBox() {
output;
MMSdf3dShapeBox::MMSdf3dShapeBox() {
size = Vector3(0.3, 0.25, 0.25);
radius = 0.01;
}
}
Sdf3dShapeBox::~Sdf3dShapeBox() {
}
MMSdf3dShapeBox::~MMSdf3dShapeBox() {
}
void MMSdf3dShapeBox::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dShapeBox::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dShapeBox::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
static void Sdf3dShapeBox::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dShapeBox::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dShapeBox::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_size"), &Sdf3dShapeBox::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &Sdf3dShapeBox::set_size);
ClassDB::bind_method(D_METHOD("get_size"), &MMSdf3dShapeBox::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &MMSdf3dShapeBox::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size"), "set_size", "get_size");
ClassDB::bind_method(D_METHOD("get_radius"), &Sdf3dShapeBox::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "value"), &Sdf3dShapeBox::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &MMSdf3dShapeBox::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "value"), &MMSdf3dShapeBox::set_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dShapeBox::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dShapeBox::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dShapeBox::_get_property_value_sdf3d);
ClassDB::bind_method(D_METHOD("get_size"), &Sdf3dShapeBox::get_size);
ClassDB::bind_method(D_METHOD("set_size", "val"), &Sdf3dShapeBox::set_size);
ClassDB::bind_method(D_METHOD("get_radius"), &Sdf3dShapeBox::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "val"), &Sdf3dShapeBox::set_radius);
}
}

View File

@ -1,14 +1,15 @@
#ifndef SDF3D_SHAPE_BOX_H
#define SDF3D_SHAPE_BOX_H
#ifndef MM_SDF3D_SHAPE_BOX_H
#define MM_SDF3D_SHAPE_BOX_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Sdf3dShapeBox : public MMNode {
GDCLASS(Sdf3dShapeBox, MMNode);
class MMSdf3dShapeBox : public MMNode {
GDCLASS(MMSdf3dShapeBox, MMNode);
public:
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Vector3 get_size();
void set_size(const Vector3 &val);
@ -17,29 +18,18 @@ class Sdf3dShapeBox : public MMNode {
void set_radius(const float val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _register_methods(MMGraphNode *mm_graph_node);
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
Vector3 get_size();
void set_size(const Vector3 &val);
float get_radius();
void set_radius(const float val);
Sdf3dShapeBox();
~Sdf3dShapeBox();
MMSdf3dShapeBox();
~MMSdf3dShapeBox();
protected:
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(Vector3)
Vector3 size = Vector3(0.3, 0.25, 0.25);
//export(float)
float radius = 0.01;
//size
//radius
Ref<MMNodeUniversalProperty> output;
Vector3 size;
float radius;
};
#endif

View File

@ -1,229 +1,158 @@
#include "sdf3d_shape_capsule.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Sdf3dShapeCapsule::get_output() {
Ref<MMNodeUniversalProperty> MMSdf3dShapeCapsule::get_output() {
return output;
}
void Sdf3dShapeCapsule::set_output(const Ref<Resource> &val) {
output = val;
void MMSdf3dShapeCapsule::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
int Sdf3dShapeCapsule::get_axis() const {
int MMSdf3dShapeCapsule::get_axis() const {
return axis;
}
void Sdf3dShapeCapsule::set_axis(const int val) {
axis = val;
void MMSdf3dShapeCapsule::set_axis(const int val) {
axis = val;
emit_changed();
output->do_emit_changed();
}
float Sdf3dShapeCapsule::get_length() const {
float MMSdf3dShapeCapsule::get_length() const {
return length;
}
void Sdf3dShapeCapsule::set_length(const float val) {
length = val;
void MMSdf3dShapeCapsule::set_length(const float val) {
length = val;
emit_changed();
output->do_emit_changed();
}
float Sdf3dShapeCapsule::get_radius() const {
float MMSdf3dShapeCapsule::get_radius() const {
return radius;
}
void Sdf3dShapeCapsule::set_radius(const float val) {
radius = val;
void MMSdf3dShapeCapsule::set_radius(const float val) {
radius = val;
emit_changed();
output->do_emit_changed();
}
void MMSdf3dShapeCapsule::_init_properties() {
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);
//tool;
//export(Resource) ;
Ref<Resource> output;
//export(int, "X,Y,Z") ;
int axis = 1;
//export(float) ;
float length = 0.3;
//export(float) ;
float radius = 0.2;
void Sdf3dShapeCapsule::_init() {
init_points_11();
}
void Sdf3dShapeCapsule::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Output >>>";
output.get_value_from_owner = true;
register_output_property(output);
}
void MMSdf3dShapeCapsule::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(output);
void Sdf3dShapeCapsule::_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_length", "set_length", "Length", 0.01);
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01);
mm_graph_node.add_slot_curve();
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_length", "set_length", "Length", 0.01);
mm_graph_node->add_slot_float("get_radius", "set_radius", "Radius", 0.01);
mm_graph_node->add_slot_curve();
}
Vector2 Sdf3dShapeCapsule::_get_property_value_sdf3d(const Vector3 &uv3) {
Vector2 MMSdf3dShapeCapsule::_get_property_value_sdf3d(const Vector3 &uv3) {
if (axis == 0) {
return sdf3d_capsule_x(uv3, radius, length);
}
else if (axis == 1) {
} else if (axis == 1) {
return sdf3d_capsule_y(uv3, radius, length);
}
else if (axis == 2) {
} else if (axis == 2) {
return sdf3d_capsule_z(uv3, radius, length);
}
}
return Vector2();
}
//vec3 $(name_uv)_p = $uv;
//$(name_uv)_p.$axis -= clamp($(name_uv)_p.$axis, -$l, $l);
//return length($(name_uv)_p) - $r * $profile(clamp(0.5+0.5*($uv).$axis/$l, 0.0, 1.0));
//vec3 $(name_uv)_p = $uv;
//$(name_uv)_p.$axis -= clamp($(name_uv)_p.$axis, -$l, $l);
//return length($(name_uv)_p) - $r * $profile(clamp(0.5+0.5*($uv).$axis/$l, 0.0, 1.0));
Vector2 Sdf3dShapeCapsule::sdf3d_capsule_y(const Vector3 &p, const float r, const float l) {
Vector2 MMSdf3dShapeCapsule::sdf3d_capsule_y(const Vector3 &p, const float r, const float l) {
Vector3 v = p;
v.y -= clamp(v.y, -l, l);
float cx = clamp(0.5 + 0.5 * p.y / l, 0.0, 1.0);
float cp = MMAlgos.curve(cx, points_array);
v.y -= CLAMP(v.y, -l, l);
float cx = CLAMP(0.5 + 0.5 * p.y / l, 0.0, 1.0);
float cp = MMAlgos::curve(cx, points);
float f = v.length() - r * cp;
return Vector2(f, 0.0);
}
Vector2 Sdf3dShapeCapsule::sdf3d_capsule_x(const Vector3 &p, const float r, const float l) {
Vector2 MMSdf3dShapeCapsule::sdf3d_capsule_x(const Vector3 &p, const float r, const float l) {
Vector3 v = p;
v.x -= clamp(v.x, -l, l);
float cx = clamp(0.5 + 0.5 * p.x / l, 0.0, 1.0);
float cp = MMAlgos.curve(cx, points_array);
v.x -= CLAMP(v.x, -l, l);
float cx = CLAMP(0.5 + 0.5 * p.x / l, 0.0, 1.0);
float cp = MMAlgos::curve(cx, points);
float f = v.length() - r * cp;
return Vector2(f, 0.0);
}
Vector2 Sdf3dShapeCapsule::sdf3d_capsule_z(const Vector3 &p, const float r, const float l) {
Vector2 MMSdf3dShapeCapsule::sdf3d_capsule_z(const Vector3 &p, const float r, const float l) {
Vector3 v = p;
v.z -= clamp(v.z, -l, l);
float cx = clamp(0.5 + 0.5 * p.z / l, 0.0, 1.0);
float cp = MMAlgos.curve(cx, points_array);
v.z -= CLAMP(v.z, -l, l);
float cx = CLAMP(0.5 + 0.5 * p.z / l, 0.0, 1.0);
float cp = MMAlgos::curve(cx, points);
float f = v.length() - r * cp;
return Vector2(f, 0.0);
}
//axis;
int Sdf3dShapeCapsule::get_axis() {
return axis;
}
void Sdf3dShapeCapsule::set_axis(const int val) {
axis = val;
void MMSdf3dShapeCapsule::_curve_changed() {
emit_changed();
output.emit_changed();
output->do_emit_changed();
}
//length;
float Sdf3dShapeCapsule::get_length() {
return length;
}
void Sdf3dShapeCapsule::set_length(const float val) {
length = val;
emit_changed();
output.emit_changed();
}
//radius;
float Sdf3dShapeCapsule::get_radius() {
return radius;
}
void Sdf3dShapeCapsule::set_radius(const float val) {
radius = val;
emit_changed();
output.emit_changed();
}
void Sdf3dShapeCapsule::_curve_changed() {
emit_changed();
output.emit_changed();
}
}
Sdf3dShapeCapsule::Sdf3dShapeCapsule() {
output;
MMSdf3dShapeCapsule::MMSdf3dShapeCapsule() {
axis = 1;
length = 0.3;
radius = 0.2;
}
MMSdf3dShapeCapsule::~MMSdf3dShapeCapsule() {
}
void MMSdf3dShapeCapsule::_notification(int p_what) {
if (p_what == NOTIFICATION_POSTINITIALIZE) {
init_points_11();
}
}
Sdf3dShapeCapsule::~Sdf3dShapeCapsule() {
}
void MMSdf3dShapeCapsule::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dShapeCapsule::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dShapeCapsule::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
static void Sdf3dShapeCapsule::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dShapeCapsule::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dShapeCapsule::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"), &Sdf3dShapeCapsule::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "value"), &Sdf3dShapeCapsule::set_axis);
ClassDB::bind_method(D_METHOD("get_axis"), &MMSdf3dShapeCapsule::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "value"), &MMSdf3dShapeCapsule::set_axis);
ADD_PROPERTY(PropertyInfo(Variant::INT, "axis"), "set_axis", "get_axis");
ClassDB::bind_method(D_METHOD("get_length"), &Sdf3dShapeCapsule::get_length);
ClassDB::bind_method(D_METHOD("set_length", "value"), &Sdf3dShapeCapsule::set_length);
ClassDB::bind_method(D_METHOD("get_length"), &MMSdf3dShapeCapsule::get_length);
ClassDB::bind_method(D_METHOD("set_length", "value"), &MMSdf3dShapeCapsule::set_length);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), "set_length", "get_length");
ClassDB::bind_method(D_METHOD("get_radius"), &Sdf3dShapeCapsule::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "value"), &Sdf3dShapeCapsule::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &MMSdf3dShapeCapsule::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "value"), &MMSdf3dShapeCapsule::set_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
ClassDB::bind_method(D_METHOD("sdf3d_capsule_y", "p", "r", "l"), &MMSdf3dShapeCapsule::sdf3d_capsule_y);
ClassDB::bind_method(D_METHOD("sdf3d_capsule_x", "p", "r", "l"), &MMSdf3dShapeCapsule::sdf3d_capsule_x);
ClassDB::bind_method(D_METHOD("sdf3d_capsule_z", "p", "r", "l"), &MMSdf3dShapeCapsule::sdf3d_capsule_z);
ClassDB::bind_method(D_METHOD("_init"), &Sdf3dShapeCapsule::_init);
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dShapeCapsule::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dShapeCapsule::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dShapeCapsule::_get_property_value_sdf3d);
ClassDB::bind_method(D_METHOD("sdf3d_capsule_y", "p", "r", "l"), &Sdf3dShapeCapsule::sdf3d_capsule_y);
ClassDB::bind_method(D_METHOD("sdf3d_capsule_x", "p", "r", "l"), &Sdf3dShapeCapsule::sdf3d_capsule_x);
ClassDB::bind_method(D_METHOD("sdf3d_capsule_z", "p", "r", "l"), &Sdf3dShapeCapsule::sdf3d_capsule_z);
ClassDB::bind_method(D_METHOD("get_axis"), &Sdf3dShapeCapsule::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "val"), &Sdf3dShapeCapsule::set_axis);
ClassDB::bind_method(D_METHOD("get_length"), &Sdf3dShapeCapsule::get_length);
ClassDB::bind_method(D_METHOD("set_length", "val"), &Sdf3dShapeCapsule::set_length);
ClassDB::bind_method(D_METHOD("get_radius"), &Sdf3dShapeCapsule::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "val"), &Sdf3dShapeCapsule::set_radius);
ClassDB::bind_method(D_METHOD("_curve_changed"), &Sdf3dShapeCapsule::_curve_changed);
}
ClassDB::bind_method(D_METHOD("_curve_changed"), &MMSdf3dShapeCapsule::_curve_changed);
}

View File

@ -1,14 +1,15 @@
#ifndef SDF3D_SHAPE_CAPSULE_H
#define SDF3D_SHAPE_CAPSULE_H
#ifndef MM_SDF3D_SHAPE_CAPSULE_H
#define MM_SDF3D_SHAPE_CAPSULE_H
#include "../bases/curve_base.h"
#include "../mm_node_universal_property.h"
class Sdf3dShapeCapsule : public CurveBase {
GDCLASS(Sdf3dShapeCapsule, CurveBase);
class MMSdf3dShapeCapsule : public CurveBase {
GDCLASS(MMSdf3dShapeCapsule, CurveBase);
public:
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
int get_axis() const;
void set_axis(const int val);
@ -19,43 +20,29 @@ class Sdf3dShapeCapsule : public CurveBase {
float get_radius() const;
void set_radius(const float val);
void _init();
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _register_methods(MMGraphNode *mm_graph_node);
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
Vector2 sdf3d_capsule_y(const Vector3 &p, const float r, const float l);
Vector2 sdf3d_capsule_x(const Vector3 &p, const float r, const float l);
Vector2 sdf3d_capsule_z(const Vector3 &p, const float r, const float l);
int get_axis();
void set_axis(const int val);
float get_length();
void set_length(const float val);
float get_radius();
void set_radius(const float val);
void _curve_changed();
Sdf3dShapeCapsule();
~Sdf3dShapeCapsule();
MMSdf3dShapeCapsule();
~MMSdf3dShapeCapsule();
protected:
void _notification(int p_what);
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
Ref<MMNodeUniversalProperty> output;
//export(int, "X,Y,Z")
int axis = 1;
//export(float)
float length = 0.3;
//export(float)
float radius = 0.2;
//vec3 $(name_uv)_p = $uv;
//$(name_uv)_p.$axis -= clamp($(name_uv)_p.$axis, -$l, $l);
//return length($(name_uv)_p) - $r * $profile(clamp(0.5+0.5*($uv).$axis/$l, 0.0, 1.0))
//axis
//length
//radius
int axis;
float length;
float radius;
};
#endif

View File

@ -1,161 +1,101 @@
#include "sdf3d_shape_cone.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Sdf3dShapeCone::get_output() {
Ref<MMNodeUniversalProperty> MMSdf3dShapeCone::get_output() {
return output;
}
void Sdf3dShapeCone::set_output(const Ref<Resource> &val) {
output = val;
void MMSdf3dShapeCone::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
int Sdf3dShapeCone::get_axis() const {
int MMSdf3dShapeCone::get_axis() const {
return axis;
}
void Sdf3dShapeCone::set_axis(const int val) {
axis = val;
void MMSdf3dShapeCone::set_axis(const int val) {
axis = val;
emit_changed();
output->do_emit_changed();
}
float Sdf3dShapeCone::get_angle() const {
float MMSdf3dShapeCone::get_angle() const {
return angle;
}
void Sdf3dShapeCone::set_angle(const float val) {
angle = val;
void MMSdf3dShapeCone::set_angle(const float val) {
angle = val;
emit_changed();
output->do_emit_changed();
}
void MMSdf3dShapeCone::_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,-X,+Y,-Y,+Z,-Z") ;
int axis = 2;
//export(float) ;
float angle = 30;
void Sdf3dShapeCone::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Output >>>";
output.get_value_from_owner = true;
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);
}
void MMSdf3dShapeCone::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(output);
void Sdf3dShapeCone::_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", "-X", "+Y", "-Y", "+Z", "-Z" ]);
mm_graph_node.add_slot_float("get_angle", "set_angle", "Angle", 1);
Array arr;
arr.push_back("+X");
arr.push_back("-X");
arr.push_back("+Y");
arr.push_back("-Y");
arr.push_back("+Z");
arr.push_back("-Z");
mm_graph_node->add_slot_enum("get_axis", "set_axis", "Axis", arr);
mm_graph_node->add_slot_float("get_angle", "set_angle", "Angle", 1);
}
Vector2 Sdf3dShapeCone::_get_property_value_sdf3d(const Vector3 &uv3) {
Vector2 MMSdf3dShapeCone::_get_property_value_sdf3d(const Vector3 &uv3) {
if (axis == 0) {
return MMAlgos.sdf3d_cone_px(uv3, angle);
}
else if (axis == 1) {
return MMAlgos.sdf3d_cone_nx(uv3, angle);
}
else if (axis == 2) {
return MMAlgos.sdf3d_cone_py(uv3, angle);
}
else if (axis == 3) {
return MMAlgos.sdf3d_cone_ny(uv3, angle);
}
else if (axis == 4) {
return MMAlgos.sdf3d_cone_pz(uv3, angle);
}
else if (axis == 5) {
return MMAlgos.sdf3d_cone_nz(uv3, angle);
}
return MMAlgos::sdf3d_cone_px(uv3, angle);
} else if (axis == 1) {
return MMAlgos::sdf3d_cone_nx(uv3, angle);
} else if (axis == 2) {
return MMAlgos::sdf3d_cone_py(uv3, angle);
} else if (axis == 3) {
return MMAlgos::sdf3d_cone_ny(uv3, angle);
} else if (axis == 4) {
return MMAlgos::sdf3d_cone_pz(uv3, angle);
} else if (axis == 5) {
return MMAlgos::sdf3d_cone_nz(uv3, angle);
}
return Vector2();
}
//axis;
int Sdf3dShapeCone::get_axis() {
return axis;
}
void Sdf3dShapeCone::set_axis(const int val) {
axis = val;
emit_changed();
output.emit_changed();
}
//angle;
float Sdf3dShapeCone::get_angle() {
return angle;
}
void Sdf3dShapeCone::set_angle(const float val) {
angle = val;
emit_changed();
output.emit_changed();
}
}
Sdf3dShapeCone::Sdf3dShapeCone() {
output;
MMSdf3dShapeCone::MMSdf3dShapeCone() {
axis = 2;
angle = 30;
}
}
Sdf3dShapeCone::~Sdf3dShapeCone() {
}
MMSdf3dShapeCone::~MMSdf3dShapeCone() {
}
void MMSdf3dShapeCone::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dShapeCone::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dShapeCone::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
static void Sdf3dShapeCone::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dShapeCone::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dShapeCone::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"), &Sdf3dShapeCone::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "value"), &Sdf3dShapeCone::set_axis);
ClassDB::bind_method(D_METHOD("get_axis"), &MMSdf3dShapeCone::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "value"), &MMSdf3dShapeCone::set_axis);
ADD_PROPERTY(PropertyInfo(Variant::INT, "axis"), "set_axis", "get_axis");
ClassDB::bind_method(D_METHOD("get_angle"), &Sdf3dShapeCone::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "value"), &Sdf3dShapeCone::set_angle);
ClassDB::bind_method(D_METHOD("get_angle"), &MMSdf3dShapeCone::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "value"), &MMSdf3dShapeCone::set_angle);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angle"), "set_angle", "get_angle");
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dShapeCone::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dShapeCone::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dShapeCone::_get_property_value_sdf3d);
ClassDB::bind_method(D_METHOD("get_axis"), &Sdf3dShapeCone::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "val"), &Sdf3dShapeCone::set_axis);
ClassDB::bind_method(D_METHOD("get_angle"), &Sdf3dShapeCone::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "val"), &Sdf3dShapeCone::set_angle);
}
}

View File

@ -1,14 +1,15 @@
#ifndef SDF3D_SHAPE_CONE_H
#define SDF3D_SHAPE_CONE_H
#ifndef MM_SDF3D_SHAPE_CONE_H
#define MM_SDF3D_SHAPE_CONE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Sdf3dShapeCone : public MMNode {
GDCLASS(Sdf3dShapeCone, MMNode);
class MMSdf3dShapeCone : public MMNode {
GDCLASS(MMSdf3dShapeCone, MMNode);
public:
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
int get_axis() const;
void set_axis(const int val);
@ -17,29 +18,19 @@ class Sdf3dShapeCone : public MMNode {
void set_angle(const float val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _register_methods(MMGraphNode *mm_graph_node);
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
int get_axis();
void set_axis(const int val);
float get_angle();
void set_angle(const float val);
Sdf3dShapeCone();
~Sdf3dShapeCone();
MMSdf3dShapeCone();
~MMSdf3dShapeCone();
protected:
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
Ref<MMNodeUniversalProperty> output;
//export(int, "+X,-X,+Y,-Y,+Z,-Z")
int axis = 2;
//export(float)
float angle = 30;
//axis
//angle
int axis;
float angle;
};
#endif

View File

@ -1,179 +1,112 @@
#include "sdf3d_shape_cylinder.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Sdf3dShapeCylinder::get_output() {
Ref<MMNodeUniversalProperty> MMSdf3dShapeCylinder::get_output() {
return output;
}
void Sdf3dShapeCylinder::set_output(const Ref<Resource> &val) {
output = val;
void MMSdf3dShapeCylinder::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
int Sdf3dShapeCylinder::get_axis() const {
int MMSdf3dShapeCylinder::get_axis() const {
return axis;
}
void Sdf3dShapeCylinder::set_axis(const int val) {
axis = val;
void MMSdf3dShapeCylinder::set_axis(const int val) {
axis = val;
emit_changed();
output->do_emit_changed();
}
float Sdf3dShapeCylinder::get_length() const {
float MMSdf3dShapeCylinder::get_length() const {
return length;
}
void Sdf3dShapeCylinder::set_length(const float val) {
length = val;
void MMSdf3dShapeCylinder::set_length(const float val) {
length = val;
emit_changed();
output->do_emit_changed();
}
float Sdf3dShapeCylinder::get_radius() const {
float MMSdf3dShapeCylinder::get_radius() const {
return radius;
}
void Sdf3dShapeCylinder::set_radius(const float val) {
radius = val;
void MMSdf3dShapeCylinder::set_radius(const float val) {
radius = val;
emit_changed();
output->do_emit_changed();
}
void MMSdf3dShapeCylinder::_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 = 1;
//export(float) ;
float length = 0.25;
//export(float) ;
float radius = 0.25;
void Sdf3dShapeCylinder::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Output >>>";
output.get_value_from_owner = true;
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);
}
void MMSdf3dShapeCylinder::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(output);
void Sdf3dShapeCylinder::_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_length", "set_length", "Length", 0.01);
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01);
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_length", "set_length", "Length", 0.01);
mm_graph_node->add_slot_float("get_radius", "set_radius", "Radius", 0.01);
}
Vector2 Sdf3dShapeCylinder::_get_property_value_sdf3d(const Vector3 &uv3) {
Vector2 MMSdf3dShapeCylinder::_get_property_value_sdf3d(const Vector3 &uv3) {
if (axis == 0) {
return MMAlgos.sdf3d_cylinder_x(uv3, radius, length);
}
return MMAlgos::sdf3d_cylinder_x(uv3, radius, length);
}
else if (axis == 1) {
return MMAlgos.sdf3d_cylinder_y(uv3, radius, length);
}
return MMAlgos::sdf3d_cylinder_y(uv3, radius, length);
}
else if (axis == 2) {
return MMAlgos.sdf3d_cylinder_z(uv3, radius, length);
}
return MMAlgos::sdf3d_cylinder_z(uv3, radius, length);
}
return Vector2();
}
//axis;
int Sdf3dShapeCylinder::get_axis() {
return axis;
}
void Sdf3dShapeCylinder::set_axis(const int val) {
axis = val;
emit_changed();
output.emit_changed();
}
//length;
float Sdf3dShapeCylinder::get_length() {
return length;
}
void Sdf3dShapeCylinder::set_length(const float val) {
length = val;
emit_changed();
output.emit_changed();
}
//radius;
float Sdf3dShapeCylinder::get_radius() {
return radius;
}
void Sdf3dShapeCylinder::set_radius(const float val) {
radius = val;
emit_changed();
output.emit_changed();
}
}
Sdf3dShapeCylinder::Sdf3dShapeCylinder() {
output;
MMSdf3dShapeCylinder::MMSdf3dShapeCylinder() {
axis = 1;
length = 0.25;
radius = 0.25;
}
}
Sdf3dShapeCylinder::~Sdf3dShapeCylinder() {
}
MMSdf3dShapeCylinder::~MMSdf3dShapeCylinder() {
}
void MMSdf3dShapeCylinder::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dShapeCylinder::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dShapeCylinder::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
static void Sdf3dShapeCylinder::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dShapeCylinder::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dShapeCylinder::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"), &Sdf3dShapeCylinder::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "value"), &Sdf3dShapeCylinder::set_axis);
ClassDB::bind_method(D_METHOD("get_axis"), &MMSdf3dShapeCylinder::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "value"), &MMSdf3dShapeCylinder::set_axis);
ADD_PROPERTY(PropertyInfo(Variant::INT, "axis"), "set_axis", "get_axis");
ClassDB::bind_method(D_METHOD("get_length"), &Sdf3dShapeCylinder::get_length);
ClassDB::bind_method(D_METHOD("set_length", "value"), &Sdf3dShapeCylinder::set_length);
ClassDB::bind_method(D_METHOD("get_length"), &MMSdf3dShapeCylinder::get_length);
ClassDB::bind_method(D_METHOD("set_length", "value"), &MMSdf3dShapeCylinder::set_length);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), "set_length", "get_length");
ClassDB::bind_method(D_METHOD("get_radius"), &Sdf3dShapeCylinder::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "value"), &Sdf3dShapeCylinder::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &MMSdf3dShapeCylinder::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "value"), &MMSdf3dShapeCylinder::set_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dShapeCylinder::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dShapeCylinder::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dShapeCylinder::_get_property_value_sdf3d);
ClassDB::bind_method(D_METHOD("get_axis"), &Sdf3dShapeCylinder::get_axis);
ClassDB::bind_method(D_METHOD("set_axis", "val"), &Sdf3dShapeCylinder::set_axis);
ClassDB::bind_method(D_METHOD("get_length"), &Sdf3dShapeCylinder::get_length);
ClassDB::bind_method(D_METHOD("set_length", "val"), &Sdf3dShapeCylinder::set_length);
ClassDB::bind_method(D_METHOD("get_radius"), &Sdf3dShapeCylinder::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "val"), &Sdf3dShapeCylinder::set_radius);
}
}

View File

@ -1,14 +1,15 @@
#ifndef SDF3D_SHAPE_CYLINDER_H
#define SDF3D_SHAPE_CYLINDER_H
#ifndef MM_SDF3D_SHAPE_CYLINDER_H
#define MM_SDF3D_SHAPE_CYLINDER_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Sdf3dShapeCylinder : public MMNode {
GDCLASS(Sdf3dShapeCylinder, MMNode);
class MMSdf3dShapeCylinder : public MMNode {
GDCLASS(MMSdf3dShapeCylinder, MMNode);
public:
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
int get_axis() const;
void set_axis(const int val);
@ -20,34 +21,20 @@ class Sdf3dShapeCylinder : public MMNode {
void set_radius(const float val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _register_methods(MMGraphNode *mm_graph_node);
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
int get_axis();
void set_axis(const int val);
float get_length();
void set_length(const float val);
float get_radius();
void set_radius(const float val);
Sdf3dShapeCylinder();
~Sdf3dShapeCylinder();
MMSdf3dShapeCylinder();
~MMSdf3dShapeCylinder();
protected:
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
Ref<MMNodeUniversalProperty> output;
//export(int, "X,Y,Z")
int axis = 1;
//export(float)
float length = 0.25;
//export(float)
float radius = 0.25;
//axis
//length
//radius
int axis;
float length;
float radius;
};
#endif

View File

@ -1,98 +1,63 @@
#include "sdf3d_shape_sphere.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> Sdf3dShapeSphere::get_output() {
Ref<MMNodeUniversalProperty> MMSdf3dShapeSphere::get_output() {
return output;
}
void Sdf3dShapeSphere::set_output(const Ref<Resource> &val) {
output = val;
void MMSdf3dShapeSphere::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
float Sdf3dShapeSphere::get_radius() const {
float MMSdf3dShapeSphere::get_radius() const {
return radius;
}
void Sdf3dShapeSphere::set_radius(const float val) {
radius = val;
void MMSdf3dShapeSphere::set_radius(const float val) {
radius = val;
emit_changed();
output->do_emit_changed();
}
void MMSdf3dShapeSphere::_init_properties() {
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);
//tool;
//export(Resource) ;
Ref<Resource> output;
//export(float) ;
float radius = 0.5;
void Sdf3dShapeSphere::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Output >>>";
output.get_value_from_owner = true;
register_output_property(output);
}
void Sdf3dShapeSphere::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01);
void MMSdf3dShapeSphere::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(output);
mm_graph_node->add_slot_float("get_radius", "set_radius", "Radius", 0.01);
}
Vector2 Sdf3dShapeSphere::_get_property_value_sdf3d(const Vector3 &uv3) {
return MMAlgos.sdf3d_sphere(uv3, radius);
Vector2 MMSdf3dShapeSphere::_get_property_value_sdf3d(const Vector3 &uv3) {
return MMAlgos::sdf3d_sphere(uv3, radius);
}
//radius;
float Sdf3dShapeSphere::get_radius() {
return radius;
}
void Sdf3dShapeSphere::set_radius(const float val) {
radius = val;
emit_changed();
output.emit_changed();
}
}
Sdf3dShapeSphere::Sdf3dShapeSphere() {
output;
MMSdf3dShapeSphere::MMSdf3dShapeSphere() {
radius = 0.5;
}
}
Sdf3dShapeSphere::~Sdf3dShapeSphere() {
}
MMSdf3dShapeSphere::~MMSdf3dShapeSphere() {
}
void MMSdf3dShapeSphere::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dShapeSphere::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dShapeSphere::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
static void Sdf3dShapeSphere::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dShapeSphere::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dShapeSphere::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"), &Sdf3dShapeSphere::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "value"), &Sdf3dShapeSphere::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &MMSdf3dShapeSphere::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "value"), &MMSdf3dShapeSphere::set_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dShapeSphere::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dShapeSphere::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dShapeSphere::_get_property_value_sdf3d);
ClassDB::bind_method(D_METHOD("get_radius"), &Sdf3dShapeSphere::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "val"), &Sdf3dShapeSphere::set_radius);
}
}

View File

@ -1,37 +1,31 @@
#ifndef SDF3D_SHAPE_SPHERE_H
#define SDF3D_SHAPE_SPHERE_H
#ifndef MM_SDF3D_SHAPE_SPHERE_H
#define MM_SDF3D_SHAPE_SPHERE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class Sdf3dShapeSphere : public MMNode {
GDCLASS(Sdf3dShapeSphere, MMNode);
class MMSdf3dShapeSphere : public MMNode {
GDCLASS(MMSdf3dShapeSphere, MMNode);
public:
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
float get_radius() const;
void set_radius(const float val);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
void _register_methods(MMGraphNode *mm_graph_node);
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
float get_radius();
void set_radius(const float val);
Sdf3dShapeSphere();
~Sdf3dShapeSphere();
MMSdf3dShapeSphere();
~MMSdf3dShapeSphere();
protected:
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(float)
float radius = 0.5;
//radius
Ref<MMNodeUniversalProperty> output;
float radius;
};
#endif

View File

@ -67,6 +67,11 @@ SOFTWARE.
#include "nodes/sdf3d/sdf3d_tf_scale.h"
#include "nodes/sdf3d/sdf3d_tf_translate.h"
#include "nodes/sdf3d/sdf3d_shape_box.h"
#include "nodes/sdf3d/sdf3d_shape_capsule.h"
#include "nodes/sdf3d/sdf3d_shape_cone.h"
#include "nodes/sdf3d/sdf3d_shape_cylinder.h"
#include "nodes/sdf3d/sdf3d_shape_sphere.h"
#include "nodes/sdf3d/sdf3d_shape_torus.h"
static _MMAlgos *_mm_algos_singleton = nullptr;
@ -132,6 +137,16 @@ void register_material_maker_types() {
ClassDB::register_class<MMSdf3dShapeTorus>();
MMAlgos::register_node_class("SDF3D - Shape", "MMSdf3dShapeTorus");
ClassDB::register_class<MMSdf3dShapeSphere>();
MMAlgos::register_node_class("SDF3D - Shape", "MMSdf3dShapeSphere");
ClassDB::register_class<MMSdf3dShapeCylinder>();
MMAlgos::register_node_class("SDF3D - Shape", "MMSdf3dShapeCylinder");
ClassDB::register_class<MMSdf3dShapeCone>();
MMAlgos::register_node_class("SDF3D - Shape", "MMSdf3dShapeCone");
ClassDB::register_class<MMSdf3dShapeCapsule>();
MMAlgos::register_node_class("SDF3D - Shape", "MMSdf3dShapeCapsule");
ClassDB::register_class<MMSdf3dShapeBox>();
MMAlgos::register_node_class("SDF3D - Shape", "MMSdf3dShapeBox");
_mm_algos_singleton = memnew(_MMAlgos);
Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton()));