mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-11 13:21:10 +01:00
Cleaned up the rest of the sdf3d shapes.
This commit is contained in:
parent
c39cfd2c05
commit
e0895460e5
@ -76,6 +76,11 @@ sources = [
|
|||||||
"nodes/sdf3d/sdf3d_tf_rotate.cpp",
|
"nodes/sdf3d/sdf3d_tf_rotate.cpp",
|
||||||
|
|
||||||
"nodes/sdf3d/sdf3d_shape_torus.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",
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -46,6 +46,11 @@ def get_doc_classes():
|
|||||||
"MMSdf3dTfRotate",
|
"MMSdf3dTfRotate",
|
||||||
|
|
||||||
"MMSdf3dShapeTorus",
|
"MMSdf3dShapeTorus",
|
||||||
|
"MMSdf3dShapeSphere",
|
||||||
|
"MMSdf3dShapeCylinder",
|
||||||
|
"MMSdf3dShapeCone",
|
||||||
|
"MMSdf3dShapeCapsule",
|
||||||
|
"MMSdf3dShapeBox",
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_doc_path():
|
def get_doc_path():
|
||||||
|
@ -1,131 +1,79 @@
|
|||||||
|
|
||||||
#include "sdf3d_shape_box.h"
|
#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;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeBox::set_output(const Ref<Resource> &val) {
|
void MMSdf3dShapeBox::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
output = val;
|
output = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector3 MMSdf3dShapeBox::get_size() {
|
||||||
Vector3 Sdf3dShapeBox::get_size() {
|
return size;
|
||||||
return size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeBox::set_size(const Vector3 &val) {
|
void MMSdf3dShapeBox::set_size(const Vector3 &val) {
|
||||||
size = val;
|
size = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMSdf3dShapeBox::get_radius() const {
|
||||||
float Sdf3dShapeBox::get_radius() const {
|
return radius;
|
||||||
return radius;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeBox::set_radius(const float val) {
|
void MMSdf3dShapeBox::set_radius(const float val) {
|
||||||
radius = 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;
|
register_output_property(output);
|
||||||
//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;
|
void MMSdf3dShapeBox::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
output.slot_name = ">>> Output >>>";
|
mm_graph_node->add_slot_label_universal(output);
|
||||||
output.get_value_from_owner = true;
|
mm_graph_node->add_slot_vector3("get_size", "set_size", "Size", 0.01);
|
||||||
register_output_property(output);
|
mm_graph_node->add_slot_float("get_radius", "set_radius", "Radius", 0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMSdf3dShapeBox::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||||
void Sdf3dShapeBox::_register_methods(const Variant &mm_graph_node) {
|
return MMAlgos::sdf3d_box(uv3, size.x, size.y, size.z, radius);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMSdf3dShapeBox::MMSdf3dShapeBox() {
|
||||||
Vector2 Sdf3dShapeBox::_get_property_value_sdf3d(const Vector3 &uv3) {
|
size = Vector3(0.3, 0.25, 0.25);
|
||||||
return MMAlgos.sdf3d_box(uv3, size.x, size.y, size.z, radius);
|
radius = 0.01;
|
||||||
}
|
}
|
||||||
|
|
||||||
//size;
|
MMSdf3dShapeBox::~MMSdf3dShapeBox() {
|
||||||
|
|
||||||
Vector3 Sdf3dShapeBox::get_size() {
|
|
||||||
return size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
void Sdf3dShapeBox::set_size(const Vector3 &val) {
|
ClassDB::bind_method(D_METHOD("get_size"), &MMSdf3dShapeBox::get_size);
|
||||||
size = val;
|
ClassDB::bind_method(D_METHOD("set_size", "value"), &MMSdf3dShapeBox::set_size);
|
||||||
emit_changed();
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size"), "set_size", "get_size");
|
||||||
output.emit_changed();
|
|
||||||
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
//radius;
|
|
||||||
|
|
||||||
float Sdf3dShapeBox::get_radius() {
|
|
||||||
return radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Sdf3dShapeBox::set_radius(const float val) {
|
|
||||||
radius = val;
|
|
||||||
emit_changed();
|
|
||||||
output.emit_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Sdf3dShapeBox::Sdf3dShapeBox() {
|
|
||||||
output;
|
|
||||||
size = Vector3(0.3, 0.25, 0.25);
|
|
||||||
radius = 0.01;
|
|
||||||
}
|
|
||||||
|
|
||||||
Sdf3dShapeBox::~Sdf3dShapeBox() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
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);
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,45 +1,35 @@
|
|||||||
#ifndef SDF3D_SHAPE_BOX_H
|
#ifndef MM_SDF3D_SHAPE_BOX_H
|
||||||
#define SDF3D_SHAPE_BOX_H
|
#define MM_SDF3D_SHAPE_BOX_H
|
||||||
|
|
||||||
|
#include "../mm_node.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class Sdf3dShapeBox : public MMNode {
|
class MMSdf3dShapeBox : public MMNode {
|
||||||
GDCLASS(Sdf3dShapeBox, MMNode);
|
GDCLASS(MMSdf3dShapeBox, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_output();
|
||||||
|
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_output();
|
Vector3 get_size();
|
||||||
void set_output(const Ref<Resource> &val);
|
void set_size(const Vector3 &val);
|
||||||
|
|
||||||
Vector3 get_size();
|
float get_radius() const;
|
||||||
void set_size(const Vector3 &val);
|
void set_radius(const float val);
|
||||||
|
|
||||||
float get_radius() const;
|
void _init_properties();
|
||||||
void set_radius(const float val);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
|
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||||
|
|
||||||
void _init_properties();
|
MMSdf3dShapeBox();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
~MMSdf3dShapeBox();
|
||||||
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();
|
protected:
|
||||||
~Sdf3dShapeBox();
|
static void _bind_methods();
|
||||||
|
|
||||||
protected:
|
Ref<MMNodeUniversalProperty> output;
|
||||||
static void _bind_methods();
|
Vector3 size;
|
||||||
|
float radius;
|
||||||
//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
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,229 +1,158 @@
|
|||||||
|
|
||||||
#include "sdf3d_shape_capsule.h"
|
#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;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeCapsule::set_output(const Ref<Resource> &val) {
|
void MMSdf3dShapeCapsule::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
output = val;
|
output = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MMSdf3dShapeCapsule::get_axis() const {
|
||||||
int Sdf3dShapeCapsule::get_axis() const {
|
return axis;
|
||||||
return axis;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeCapsule::set_axis(const int val) {
|
void MMSdf3dShapeCapsule::set_axis(const int val) {
|
||||||
axis = val;
|
axis = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMSdf3dShapeCapsule::get_length() const {
|
||||||
float Sdf3dShapeCapsule::get_length() const {
|
return length;
|
||||||
return length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeCapsule::set_length(const float val) {
|
void MMSdf3dShapeCapsule::set_length(const float val) {
|
||||||
length = val;
|
length = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMSdf3dShapeCapsule::get_radius() const {
|
||||||
float Sdf3dShapeCapsule::get_radius() const {
|
return radius;
|
||||||
return radius;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeCapsule::set_radius(const float val) {
|
void MMSdf3dShapeCapsule::set_radius(const float val) {
|
||||||
radius = 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;
|
register_output_property(output);
|
||||||
//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 MMSdf3dShapeCapsule::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
|
mm_graph_node->add_slot_label_universal(output);
|
||||||
|
|
||||||
void Sdf3dShapeCapsule::_init_properties() {
|
Array arr;
|
||||||
|
arr.push_back("X");
|
||||||
|
arr.push_back("Y");
|
||||||
|
arr.push_back("Z");
|
||||||
|
|
||||||
if (!output) {
|
mm_graph_node->add_slot_enum("get_axis", "set_axis", "Axis", arr);
|
||||||
output = MMNodeUniversalProperty.new();
|
mm_graph_node->add_slot_float("get_length", "set_length", "Length", 0.01);
|
||||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
mm_graph_node->add_slot_float("get_radius", "set_radius", "Radius", 0.01);
|
||||||
|
mm_graph_node->add_slot_curve();
|
||||||
}
|
}
|
||||||
|
|
||||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
Vector2 MMSdf3dShapeCapsule::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||||
output.slot_name = ">>> Output >>>";
|
if (axis == 0) {
|
||||||
output.get_value_from_owner = true;
|
return sdf3d_capsule_x(uv3, radius, length);
|
||||||
register_output_property(output);
|
} else if (axis == 1) {
|
||||||
|
return sdf3d_capsule_y(uv3, radius, length);
|
||||||
|
} 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));
|
||||||
|
|
||||||
void Sdf3dShapeCapsule::_register_methods(const Variant &mm_graph_node) {
|
Vector2 MMSdf3dShapeCapsule::sdf3d_capsule_y(const Vector3 &p, const float r, const float l) {
|
||||||
mm_graph_node.add_slot_label_universal(output);
|
Vector3 v = p;
|
||||||
mm_graph_node.add_slot_enum("get_axis", "set_axis", "Axis", [ "X", "Y", "Z" ]);
|
v.y -= CLAMP(v.y, -l, l);
|
||||||
mm_graph_node.add_slot_float("get_length", "set_length", "Length", 0.01);
|
float cx = CLAMP(0.5 + 0.5 * p.y / l, 0.0, 1.0);
|
||||||
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01);
|
float cp = MMAlgos::curve(cx, points);
|
||||||
mm_graph_node.add_slot_curve();
|
float f = v.length() - r * cp;
|
||||||
|
return Vector2(f, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMSdf3dShapeCapsule::sdf3d_capsule_x(const Vector3 &p, const float r, const float l) {
|
||||||
Vector2 Sdf3dShapeCapsule::_get_property_value_sdf3d(const Vector3 &uv3) {
|
Vector3 v = p;
|
||||||
|
v.x -= CLAMP(v.x, -l, l);
|
||||||
if (axis == 0) {
|
float cx = CLAMP(0.5 + 0.5 * p.x / l, 0.0, 1.0);
|
||||||
return sdf3d_capsule_x(uv3, radius, length);
|
float cp = MMAlgos::curve(cx, points);
|
||||||
|
float f = v.length() - r * cp;
|
||||||
|
return Vector2(f, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMSdf3dShapeCapsule::sdf3d_capsule_z(const Vector3 &p, const float r, const float l) {
|
||||||
else if (axis == 1) {
|
Vector3 v = p;
|
||||||
return sdf3d_capsule_y(uv3, radius, length);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdf3dShapeCapsule::_curve_changed() {
|
||||||
else if (axis == 2) {
|
emit_changed();
|
||||||
return sdf3d_capsule_z(uv3, radius, length);
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Vector2();
|
MMSdf3dShapeCapsule::MMSdf3dShapeCapsule() {
|
||||||
|
axis = 1;
|
||||||
|
length = 0.3;
|
||||||
|
radius = 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//vec3 $(name_uv)_p = $uv;
|
MMSdf3dShapeCapsule::~MMSdf3dShapeCapsule() {
|
||||||
//$(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) {
|
|
||||||
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);
|
|
||||||
float f = v.length() - r * cp;
|
|
||||||
return Vector2(f, 0.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdf3dShapeCapsule::_notification(int p_what) {
|
||||||
Vector2 Sdf3dShapeCapsule::sdf3d_capsule_x(const Vector3 &p, const float r, const float l) {
|
if (p_what == NOTIFICATION_POSTINITIALIZE) {
|
||||||
Vector3 v = p;
|
init_points_11();
|
||||||
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);
|
|
||||||
float f = v.length() - r * cp;
|
|
||||||
return Vector2(f, 0.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
Vector2 Sdf3dShapeCapsule::sdf3d_capsule_z(const Vector3 &p, const float r, const float l) {
|
ClassDB::bind_method(D_METHOD("get_axis"), &MMSdf3dShapeCapsule::get_axis);
|
||||||
Vector3 v = p;
|
ClassDB::bind_method(D_METHOD("set_axis", "value"), &MMSdf3dShapeCapsule::set_axis);
|
||||||
v.z -= clamp(v.z, -l, l);
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "axis"), "set_axis", "get_axis");
|
||||||
float cx = clamp(0.5 + 0.5 * p.z / l, 0.0, 1.0);
|
|
||||||
float cp = MMAlgos.curve(cx, points_array);
|
ClassDB::bind_method(D_METHOD("get_length"), &MMSdf3dShapeCapsule::get_length);
|
||||||
float f = v.length() - r * cp;
|
ClassDB::bind_method(D_METHOD("set_length", "value"), &MMSdf3dShapeCapsule::set_length);
|
||||||
return Vector2(f, 0.0);
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), "set_length", "get_length");
|
||||||
|
|
||||||
|
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("_curve_changed"), &MMSdf3dShapeCapsule::_curve_changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
//axis;
|
|
||||||
|
|
||||||
int Sdf3dShapeCapsule::get_axis() {
|
|
||||||
return axis;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Sdf3dShapeCapsule::set_axis(const int val) {
|
|
||||||
axis = val;
|
|
||||||
emit_changed();
|
|
||||||
output.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;
|
|
||||||
axis = 1;
|
|
||||||
length = 0.3;
|
|
||||||
radius = 0.2;
|
|
||||||
}
|
|
||||||
|
|
||||||
Sdf3dShapeCapsule::~Sdf3dShapeCapsule() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
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);
|
|
||||||
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);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,61 +1,48 @@
|
|||||||
#ifndef SDF3D_SHAPE_CAPSULE_H
|
#ifndef MM_SDF3D_SHAPE_CAPSULE_H
|
||||||
#define 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 {
|
class MMSdf3dShapeCapsule : public CurveBase {
|
||||||
GDCLASS(Sdf3dShapeCapsule, CurveBase);
|
GDCLASS(MMSdf3dShapeCapsule, CurveBase);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_output();
|
||||||
|
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_output();
|
int get_axis() const;
|
||||||
void set_output(const Ref<Resource> &val);
|
void set_axis(const int val);
|
||||||
|
|
||||||
int get_axis() const;
|
float get_length() const;
|
||||||
void set_axis(const int val);
|
void set_length(const float val);
|
||||||
|
|
||||||
float get_length() const;
|
float get_radius() const;
|
||||||
void set_length(const float val);
|
void set_radius(const float val);
|
||||||
|
|
||||||
float get_radius() const;
|
void _init_properties();
|
||||||
void set_radius(const float val);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
|
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||||
|
|
||||||
void _init();
|
Vector2 sdf3d_capsule_y(const Vector3 &p, const float r, const float l);
|
||||||
void _init_properties();
|
Vector2 sdf3d_capsule_x(const Vector3 &p, const float r, const float l);
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
Vector2 sdf3d_capsule_z(const Vector3 &p, const float r, const float l);
|
||||||
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();
|
void _curve_changed();
|
||||||
~Sdf3dShapeCapsule();
|
|
||||||
|
|
||||||
protected:
|
MMSdf3dShapeCapsule();
|
||||||
static void _bind_methods();
|
~MMSdf3dShapeCapsule();
|
||||||
|
|
||||||
//tool
|
protected:
|
||||||
//export(Resource)
|
void _notification(int p_what);
|
||||||
Ref<Resource> output;
|
|
||||||
//export(int, "X,Y,Z")
|
static void _bind_methods();
|
||||||
int axis = 1;
|
|
||||||
//export(float)
|
Ref<MMNodeUniversalProperty> output;
|
||||||
float length = 0.3;
|
//export(int, "X,Y,Z")
|
||||||
//export(float)
|
int axis;
|
||||||
float radius = 0.2;
|
float length;
|
||||||
//vec3 $(name_uv)_p = $uv;
|
float radius;
|
||||||
//$(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
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,161 +1,101 @@
|
|||||||
|
|
||||||
#include "sdf3d_shape_cone.h"
|
#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;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeCone::set_output(const Ref<Resource> &val) {
|
void MMSdf3dShapeCone::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
output = val;
|
output = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MMSdf3dShapeCone::get_axis() const {
|
||||||
int Sdf3dShapeCone::get_axis() const {
|
return axis;
|
||||||
return axis;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeCone::set_axis(const int val) {
|
void MMSdf3dShapeCone::set_axis(const int val) {
|
||||||
axis = val;
|
axis = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMSdf3dShapeCone::get_angle() const {
|
||||||
float Sdf3dShapeCone::get_angle() const {
|
return angle;
|
||||||
return angle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeCone::set_angle(const float val) {
|
void MMSdf3dShapeCone::set_angle(const float val) {
|
||||||
angle = 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||||
//tool;
|
output->set_slot_name(">>> Output >>>");
|
||||||
//export(Resource) ;
|
output->set_get_value_from_owner(true);
|
||||||
Ref<Resource> output;
|
register_output_property(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;
|
void MMSdf3dShapeCone::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
output.slot_name = ">>> Output >>>";
|
mm_graph_node->add_slot_label_universal(output);
|
||||||
output.get_value_from_owner = true;
|
|
||||||
register_output_property(output);
|
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 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);
|
||||||
|
}
|
||||||
|
|
||||||
void Sdf3dShapeCone::_register_methods(const Variant &mm_graph_node) {
|
return Vector2();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMSdf3dShapeCone::MMSdf3dShapeCone() {
|
||||||
Vector2 Sdf3dShapeCone::_get_property_value_sdf3d(const Vector3 &uv3) {
|
axis = 2;
|
||||||
|
angle = 30;
|
||||||
if (axis == 0) {
|
|
||||||
return MMAlgos.sdf3d_cone_px(uv3, angle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMSdf3dShapeCone::~MMSdf3dShapeCone() {
|
||||||
else if (axis == 1) {
|
|
||||||
return MMAlgos.sdf3d_cone_nx(uv3, angle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
else if (axis == 2) {
|
ClassDB::bind_method(D_METHOD("get_axis"), &MMSdf3dShapeCone::get_axis);
|
||||||
return MMAlgos.sdf3d_cone_py(uv3, angle);
|
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"), &MMSdf3dShapeCone::get_angle);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_angle", "value"), &MMSdf3dShapeCone::set_angle);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angle"), "set_angle", "get_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;
|
|
||||||
axis = 2;
|
|
||||||
angle = 30;
|
|
||||||
}
|
|
||||||
|
|
||||||
Sdf3dShapeCone::~Sdf3dShapeCone() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
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);
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,45 +1,36 @@
|
|||||||
#ifndef SDF3D_SHAPE_CONE_H
|
#ifndef MM_SDF3D_SHAPE_CONE_H
|
||||||
#define SDF3D_SHAPE_CONE_H
|
#define MM_SDF3D_SHAPE_CONE_H
|
||||||
|
|
||||||
|
#include "../mm_node.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class Sdf3dShapeCone : public MMNode {
|
class MMSdf3dShapeCone : public MMNode {
|
||||||
GDCLASS(Sdf3dShapeCone, MMNode);
|
GDCLASS(MMSdf3dShapeCone, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_output();
|
||||||
|
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_output();
|
int get_axis() const;
|
||||||
void set_output(const Ref<Resource> &val);
|
void set_axis(const int val);
|
||||||
|
|
||||||
int get_axis() const;
|
float get_angle() const;
|
||||||
void set_axis(const int val);
|
void set_angle(const float val);
|
||||||
|
|
||||||
float get_angle() const;
|
void _init_properties();
|
||||||
void set_angle(const float val);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
|
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||||
|
|
||||||
void _init_properties();
|
MMSdf3dShapeCone();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
~MMSdf3dShapeCone();
|
||||||
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();
|
protected:
|
||||||
~Sdf3dShapeCone();
|
static void _bind_methods();
|
||||||
|
|
||||||
protected:
|
Ref<MMNodeUniversalProperty> output;
|
||||||
static void _bind_methods();
|
//export(int, "+X,-X,+Y,-Y,+Z,-Z")
|
||||||
|
int axis;
|
||||||
//tool
|
float angle;
|
||||||
//export(Resource)
|
|
||||||
Ref<Resource> output;
|
|
||||||
//export(int, "+X,-X,+Y,-Y,+Z,-Z")
|
|
||||||
int axis = 2;
|
|
||||||
//export(float)
|
|
||||||
float angle = 30;
|
|
||||||
//axis
|
|
||||||
//angle
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,179 +1,112 @@
|
|||||||
|
|
||||||
#include "sdf3d_shape_cylinder.h"
|
#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;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeCylinder::set_output(const Ref<Resource> &val) {
|
void MMSdf3dShapeCylinder::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
output = val;
|
output = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MMSdf3dShapeCylinder::get_axis() const {
|
||||||
int Sdf3dShapeCylinder::get_axis() const {
|
return axis;
|
||||||
return axis;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeCylinder::set_axis(const int val) {
|
void MMSdf3dShapeCylinder::set_axis(const int val) {
|
||||||
axis = val;
|
axis = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMSdf3dShapeCylinder::get_length() const {
|
||||||
float Sdf3dShapeCylinder::get_length() const {
|
return length;
|
||||||
return length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeCylinder::set_length(const float val) {
|
void MMSdf3dShapeCylinder::set_length(const float val) {
|
||||||
length = val;
|
length = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMSdf3dShapeCylinder::get_radius() const {
|
||||||
float Sdf3dShapeCylinder::get_radius() const {
|
return radius;
|
||||||
return radius;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeCylinder::set_radius(const float val) {
|
void MMSdf3dShapeCylinder::set_radius(const float val) {
|
||||||
radius = 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||||
//tool;
|
output->set_slot_name(">>> Output >>>");
|
||||||
//export(Resource) ;
|
output->set_get_value_from_owner(true);
|
||||||
Ref<Resource> output;
|
register_output_property(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;
|
void MMSdf3dShapeCylinder::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
output.slot_name = ">>> Output >>>";
|
mm_graph_node->add_slot_label_universal(output);
|
||||||
output.get_value_from_owner = true;
|
|
||||||
register_output_property(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_length", "set_length", "Length", 0.01);
|
||||||
|
mm_graph_node->add_slot_float("get_radius", "set_radius", "Radius", 0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMSdf3dShapeCylinder::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||||
|
if (axis == 0) {
|
||||||
|
return MMAlgos::sdf3d_cylinder_x(uv3, radius, length);
|
||||||
|
}
|
||||||
|
|
||||||
void Sdf3dShapeCylinder::_register_methods(const Variant &mm_graph_node) {
|
else if (axis == 1) {
|
||||||
mm_graph_node.add_slot_label_universal(output);
|
return MMAlgos::sdf3d_cylinder_y(uv3, radius, length);
|
||||||
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);
|
else if (axis == 2) {
|
||||||
|
return MMAlgos::sdf3d_cylinder_z(uv3, radius, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Vector2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMSdf3dShapeCylinder::MMSdf3dShapeCylinder() {
|
||||||
Vector2 Sdf3dShapeCylinder::_get_property_value_sdf3d(const Vector3 &uv3) {
|
axis = 1;
|
||||||
|
length = 0.25;
|
||||||
if (axis == 0) {
|
radius = 0.25;
|
||||||
return MMAlgos.sdf3d_cylinder_x(uv3, radius, length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMSdf3dShapeCylinder::~MMSdf3dShapeCylinder() {
|
||||||
else if (axis == 1) {
|
|
||||||
return MMAlgos.sdf3d_cylinder_y(uv3, radius, length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
else if (axis == 2) {
|
ClassDB::bind_method(D_METHOD("get_axis"), &MMSdf3dShapeCylinder::get_axis);
|
||||||
return MMAlgos.sdf3d_cylinder_z(uv3, radius, length);
|
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"), &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"), &MMSdf3dShapeCylinder::get_radius);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_radius", "value"), &MMSdf3dShapeCylinder::set_radius);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
axis = 1;
|
|
||||||
length = 0.25;
|
|
||||||
radius = 0.25;
|
|
||||||
}
|
|
||||||
|
|
||||||
Sdf3dShapeCylinder::~Sdf3dShapeCylinder() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
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);
|
|
||||||
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);
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,53 +1,40 @@
|
|||||||
#ifndef SDF3D_SHAPE_CYLINDER_H
|
#ifndef MM_SDF3D_SHAPE_CYLINDER_H
|
||||||
#define SDF3D_SHAPE_CYLINDER_H
|
#define MM_SDF3D_SHAPE_CYLINDER_H
|
||||||
|
|
||||||
|
#include "../mm_node.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class Sdf3dShapeCylinder : public MMNode {
|
class MMSdf3dShapeCylinder : public MMNode {
|
||||||
GDCLASS(Sdf3dShapeCylinder, MMNode);
|
GDCLASS(MMSdf3dShapeCylinder, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_output();
|
||||||
|
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_output();
|
int get_axis() const;
|
||||||
void set_output(const Ref<Resource> &val);
|
void set_axis(const int val);
|
||||||
|
|
||||||
int get_axis() const;
|
float get_length() const;
|
||||||
void set_axis(const int val);
|
void set_length(const float val);
|
||||||
|
|
||||||
float get_length() const;
|
float get_radius() const;
|
||||||
void set_length(const float val);
|
void set_radius(const float val);
|
||||||
|
|
||||||
float get_radius() const;
|
void _init_properties();
|
||||||
void set_radius(const float val);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
|
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||||
|
|
||||||
void _init_properties();
|
MMSdf3dShapeCylinder();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
~MMSdf3dShapeCylinder();
|
||||||
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();
|
protected:
|
||||||
~Sdf3dShapeCylinder();
|
static void _bind_methods();
|
||||||
|
|
||||||
protected:
|
Ref<MMNodeUniversalProperty> output;
|
||||||
static void _bind_methods();
|
//export(int, "X,Y,Z")
|
||||||
|
int axis;
|
||||||
//tool
|
float length;
|
||||||
//export(Resource)
|
float radius;
|
||||||
Ref<Resource> output;
|
|
||||||
//export(int, "X,Y,Z")
|
|
||||||
int axis = 1;
|
|
||||||
//export(float)
|
|
||||||
float length = 0.25;
|
|
||||||
//export(float)
|
|
||||||
float radius = 0.25;
|
|
||||||
//axis
|
|
||||||
//length
|
|
||||||
//radius
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,98 +1,63 @@
|
|||||||
|
|
||||||
#include "sdf3d_shape_sphere.h"
|
#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;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeSphere::set_output(const Ref<Resource> &val) {
|
void MMSdf3dShapeSphere::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
output = val;
|
output = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMSdf3dShapeSphere::get_radius() const {
|
||||||
float Sdf3dShapeSphere::get_radius() const {
|
return radius;
|
||||||
return radius;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dShapeSphere::set_radius(const float val) {
|
void MMSdf3dShapeSphere::set_radius(const float val) {
|
||||||
radius = 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;
|
register_output_property(output);
|
||||||
//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;
|
void MMSdf3dShapeSphere::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
output.slot_name = ">>> Output >>>";
|
mm_graph_node->add_slot_label_universal(output);
|
||||||
output.get_value_from_owner = true;
|
mm_graph_node->add_slot_float("get_radius", "set_radius", "Radius", 0.01);
|
||||||
register_output_property(output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMSdf3dShapeSphere::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||||
void Sdf3dShapeSphere::_register_methods(const Variant &mm_graph_node) {
|
return MMAlgos::sdf3d_sphere(uv3, radius);
|
||||||
mm_graph_node.add_slot_label_universal(output);
|
|
||||||
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMSdf3dShapeSphere::MMSdf3dShapeSphere() {
|
||||||
Vector2 Sdf3dShapeSphere::_get_property_value_sdf3d(const Vector3 &uv3) {
|
radius = 0.5;
|
||||||
return MMAlgos.sdf3d_sphere(uv3, radius);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//radius;
|
MMSdf3dShapeSphere::~MMSdf3dShapeSphere() {
|
||||||
|
|
||||||
float Sdf3dShapeSphere::get_radius() {
|
|
||||||
return radius;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
void Sdf3dShapeSphere::set_radius(const float val) {
|
ClassDB::bind_method(D_METHOD("get_radius"), &MMSdf3dShapeSphere::get_radius);
|
||||||
radius = val;
|
ClassDB::bind_method(D_METHOD("set_radius", "value"), &MMSdf3dShapeSphere::set_radius);
|
||||||
emit_changed();
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
|
||||||
output.emit_changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Sdf3dShapeSphere::Sdf3dShapeSphere() {
|
|
||||||
output;
|
|
||||||
radius = 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
Sdf3dShapeSphere::~Sdf3dShapeSphere() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,37 +1,31 @@
|
|||||||
#ifndef SDF3D_SHAPE_SPHERE_H
|
#ifndef MM_SDF3D_SHAPE_SPHERE_H
|
||||||
#define SDF3D_SHAPE_SPHERE_H
|
#define MM_SDF3D_SHAPE_SPHERE_H
|
||||||
|
|
||||||
|
#include "../mm_node.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class Sdf3dShapeSphere : public MMNode {
|
class MMSdf3dShapeSphere : public MMNode {
|
||||||
GDCLASS(Sdf3dShapeSphere, MMNode);
|
GDCLASS(MMSdf3dShapeSphere, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_output();
|
||||||
|
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_output();
|
float get_radius() const;
|
||||||
void set_output(const Ref<Resource> &val);
|
void set_radius(const float val);
|
||||||
|
|
||||||
float get_radius() const;
|
void _init_properties();
|
||||||
void set_radius(const float val);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
|
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||||
|
|
||||||
void _init_properties();
|
MMSdf3dShapeSphere();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
~MMSdf3dShapeSphere();
|
||||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
|
||||||
float get_radius();
|
|
||||||
void set_radius(const float val);
|
|
||||||
|
|
||||||
Sdf3dShapeSphere();
|
protected:
|
||||||
~Sdf3dShapeSphere();
|
static void _bind_methods();
|
||||||
|
|
||||||
protected:
|
Ref<MMNodeUniversalProperty> output;
|
||||||
static void _bind_methods();
|
float radius;
|
||||||
|
|
||||||
//tool
|
|
||||||
//export(Resource)
|
|
||||||
Ref<Resource> output;
|
|
||||||
//export(float)
|
|
||||||
float radius = 0.5;
|
|
||||||
//radius
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -67,6 +67,11 @@ SOFTWARE.
|
|||||||
#include "nodes/sdf3d/sdf3d_tf_scale.h"
|
#include "nodes/sdf3d/sdf3d_tf_scale.h"
|
||||||
#include "nodes/sdf3d/sdf3d_tf_translate.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"
|
#include "nodes/sdf3d/sdf3d_shape_torus.h"
|
||||||
|
|
||||||
static _MMAlgos *_mm_algos_singleton = nullptr;
|
static _MMAlgos *_mm_algos_singleton = nullptr;
|
||||||
@ -132,6 +137,16 @@ void register_material_maker_types() {
|
|||||||
|
|
||||||
ClassDB::register_class<MMSdf3dShapeTorus>();
|
ClassDB::register_class<MMSdf3dShapeTorus>();
|
||||||
MMAlgos::register_node_class("SDF3D - Shape", "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);
|
_mm_algos_singleton = memnew(_MMAlgos);
|
||||||
Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton()));
|
Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton()));
|
||||||
|
Loading…
Reference in New Issue
Block a user