mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-04-10 05:42:37 +02:00
MMSDF3dTfTranslate node.
This commit is contained in:
parent
edf682cace
commit
3bbaaa3af0
@ -68,6 +68,8 @@ sources = [
|
|||||||
"nodes/simple/shape.cpp",
|
"nodes/simple/shape.cpp",
|
||||||
"nodes/simple/image.cpp",
|
"nodes/simple/image.cpp",
|
||||||
"nodes/simple/curve.cpp",
|
"nodes/simple/curve.cpp",
|
||||||
|
|
||||||
|
"nodes/sdf3d/sdf3d_tf_translate.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
if env["tools"]:
|
if env["tools"]:
|
||||||
|
@ -38,6 +38,8 @@ def get_doc_classes():
|
|||||||
"MMShape",
|
"MMShape",
|
||||||
"MMImage",
|
"MMImage",
|
||||||
"MMCurve",
|
"MMCurve",
|
||||||
|
|
||||||
|
"MMSdf3dTfTranslate",
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_doc_path():
|
def get_doc_path():
|
||||||
|
@ -514,6 +514,10 @@ Ref<Image> MMNodeUniversalProperty::get_active_image() {
|
|||||||
return default_image;
|
return default_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMNodeUniversalProperty::do_emit_changed() {
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
|
||||||
MMNodeUniversalProperty::MMNodeUniversalProperty() {
|
MMNodeUniversalProperty::MMNodeUniversalProperty() {
|
||||||
default_type = DEFAULT_TYPE_INT;
|
default_type = DEFAULT_TYPE_INT;
|
||||||
default_int = 0;
|
default_int = 0;
|
||||||
@ -624,6 +628,8 @@ void MMNodeUniversalProperty::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_default_value", "val"), &MMNodeUniversalProperty::set_default_value);
|
ClassDB::bind_method(D_METHOD("set_default_value", "val"), &MMNodeUniversalProperty::set_default_value);
|
||||||
ClassDB::bind_method(D_METHOD("get_active_image"), &MMNodeUniversalProperty::get_active_image);
|
ClassDB::bind_method(D_METHOD("get_active_image"), &MMNodeUniversalProperty::get_active_image);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("do_emit_changed"), &MMNodeUniversalProperty::do_emit_changed);
|
||||||
|
|
||||||
BIND_ENUM_CONSTANT(SLOT_TYPE_NONE);
|
BIND_ENUM_CONSTANT(SLOT_TYPE_NONE);
|
||||||
BIND_ENUM_CONSTANT(SLOT_TYPE_IMAGE);
|
BIND_ENUM_CONSTANT(SLOT_TYPE_IMAGE);
|
||||||
BIND_ENUM_CONSTANT(SLOT_TYPE_INT);
|
BIND_ENUM_CONSTANT(SLOT_TYPE_INT);
|
||||||
|
@ -105,6 +105,8 @@ public:
|
|||||||
void set_default_value(const Variant &val);
|
void set_default_value(const Variant &val);
|
||||||
Ref<Image> get_active_image();
|
Ref<Image> get_active_image();
|
||||||
|
|
||||||
|
void do_emit_changed();
|
||||||
|
|
||||||
MMNodeUniversalProperty();
|
MMNodeUniversalProperty();
|
||||||
~MMNodeUniversalProperty();
|
~MMNodeUniversalProperty();
|
||||||
|
|
||||||
|
@ -1,139 +1,97 @@
|
|||||||
|
|
||||||
#include "sdf3d_tf_translate.h"
|
#include "sdf3d_tf_translate.h"
|
||||||
|
|
||||||
|
#include "../../algos/mm_algos.h"
|
||||||
|
#include "../../editor/mm_graph_node.h"
|
||||||
|
#include "../mm_material.h"
|
||||||
|
|
||||||
Ref<Resource> Sdf3dTfTranslate::get_input() {
|
Ref<MMNodeUniversalProperty> MMSdf3dTfTranslate::get_input() {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dTfTranslate::set_input(const Ref<Resource> &val) {
|
void MMSdf3dTfTranslate::set_input(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
input = val;
|
input = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<MMNodeUniversalProperty> MMSdf3dTfTranslate::get_output() {
|
||||||
Ref<Resource> Sdf3dTfTranslate::get_output() {
|
return output;
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dTfTranslate::set_output(const Ref<Resource> &val) {
|
void MMSdf3dTfTranslate::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
output = val;
|
output = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector3 MMSdf3dTfTranslate::get_translation() {
|
||||||
Vector3 Sdf3dTfTranslate::get_translation() {
|
return translation;
|
||||||
return translation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdf3dTfTranslate::set_translation(const Vector3 &val) {
|
void MMSdf3dTfTranslate::set_translation(const Vector3 &val) {
|
||||||
translation = val;
|
translation = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdf3dTfTranslate::_init_properties() {
|
||||||
|
if (!input.is_valid()) {
|
||||||
|
input.instance();
|
||||||
|
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||||
|
}
|
||||||
|
|
||||||
|
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||||
|
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
||||||
|
input->set_slot_name(">>> Input ");
|
||||||
|
|
||||||
//tool;
|
if (!input->is_connected("changed", this, "on_input_changed")) {
|
||||||
//export(Resource) ;
|
input->connect("changed", this, "on_input_changed");
|
||||||
Ref<Resource> input;
|
}
|
||||||
//export(Resource) ;
|
|
||||||
Ref<Resource> output;
|
|
||||||
//export(Vector3) ;
|
|
||||||
Vector3 translation = Vector3();
|
|
||||||
|
|
||||||
void Sdf3dTfTranslate::_init_properties() {
|
if (!output.is_valid()) {
|
||||||
|
output.instance();
|
||||||
|
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_VECTOR2);
|
||||||
|
}
|
||||||
|
|
||||||
if (!input) {
|
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||||
input = MMNodeUniversalProperty.new();
|
output->set_slot_name(">>> Output >>>");
|
||||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
output->set_get_value_from_owner(true);
|
||||||
|
|
||||||
|
register_input_property(input);
|
||||||
|
register_output_property(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
void MMSdf3dTfTranslate::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
// input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2;
|
mm_graph_node->add_slot_label_universal(input);
|
||||||
input.slot_name = ">>> Input ";
|
mm_graph_node->add_slot_label_universal(output);
|
||||||
|
mm_graph_node->add_slot_vector3("get_translation", "set_translation", "Translation", 0.01);
|
||||||
if (!input.is_connected("changed", self, "on_input_changed")) {
|
|
||||||
input.connect("changed", self, "on_input_changed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMSdf3dTfTranslate::_get_property_value_sdf3d(const Vector3 &uv3) {
|
||||||
if (!output) {
|
//$in($uv-vec3($x, $y, $z));
|
||||||
output = MMNodeUniversalProperty.new();
|
return input->get_value_sdf3d(uv3 - translation);
|
||||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
void MMSdf3dTfTranslate::on_input_changed() {
|
||||||
output.slot_name = ">>> Output >>>";
|
emit_changed();
|
||||||
output.get_value_from_owner = true;
|
output->do_emit_changed();
|
||||||
register_input_property(input);
|
|
||||||
register_output_property(output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMSdf3dTfTranslate::MMSdf3dTfTranslate() {
|
||||||
void Sdf3dTfTranslate::_register_methods(const Variant &mm_graph_node) {
|
|
||||||
mm_graph_node.add_slot_label_universal(input);
|
|
||||||
mm_graph_node.add_slot_label_universal(output);
|
|
||||||
mm_graph_node.add_slot_vector3("get_translation", "set_translation", "Translation", 0.01);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMSdf3dTfTranslate::~MMSdf3dTfTranslate() {
|
||||||
Vector2 Sdf3dTfTranslate::_get_property_value_sdf3d(const Vector3 &uv3) {
|
|
||||||
//$in($uv-vec3($x, $y, $z));
|
|
||||||
return input.get_value_sdf3d(uv3 - translation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//translation;
|
void MMSdf3dTfTranslate::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_input"), &MMSdf3dTfTranslate::get_input);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMSdf3dTfTranslate::set_input);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input", "get_input");
|
||||||
|
|
||||||
Vector3 Sdf3dTfTranslate::get_translation() {
|
ClassDB::bind_method(D_METHOD("get_output"), &MMSdf3dTfTranslate::get_output);
|
||||||
return translation;
|
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdf3dTfTranslate::set_output);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_translation"), &MMSdf3dTfTranslate::get_translation);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_translation", "value"), &MMSdf3dTfTranslate::set_translation);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "translation"), "set_translation", "get_translation");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdf3dTfTranslate::on_input_changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Sdf3dTfTranslate::set_translation(const Vector3 &val) {
|
|
||||||
translation = val;
|
|
||||||
emit_changed();
|
|
||||||
output.emit_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Sdf3dTfTranslate::on_input_changed() {
|
|
||||||
emit_changed();
|
|
||||||
output.emit_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Sdf3dTfTranslate::Sdf3dTfTranslate() {
|
|
||||||
input;
|
|
||||||
output;
|
|
||||||
translation = Vector3();
|
|
||||||
}
|
|
||||||
|
|
||||||
Sdf3dTfTranslate::~Sdf3dTfTranslate() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void Sdf3dTfTranslate::_bind_methods() {
|
|
||||||
ClassDB::bind_method(D_METHOD("get_input"), &Sdf3dTfTranslate::get_input);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &Sdf3dTfTranslate::set_input);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_output"), &Sdf3dTfTranslate::get_output);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &Sdf3dTfTranslate::set_output);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_translation"), &Sdf3dTfTranslate::get_translation);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_translation", "value"), &Sdf3dTfTranslate::set_translation);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "translation"), "set_translation", "get_translation");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Sdf3dTfTranslate::_init_properties);
|
|
||||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Sdf3dTfTranslate::_register_methods);
|
|
||||||
ClassDB::bind_method(D_METHOD("_get_property_value_sdf3d", "uv3"), &Sdf3dTfTranslate::_get_property_value_sdf3d);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_translation"), &Sdf3dTfTranslate::get_translation);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_translation", "val"), &Sdf3dTfTranslate::set_translation);
|
|
||||||
ClassDB::bind_method(D_METHOD("on_input_changed"), &Sdf3dTfTranslate::on_input_changed);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,43 +1,37 @@
|
|||||||
#ifndef SDF3D_TF_TRANSLATE_H
|
#ifndef MM_SDF3D_TF_TRANSLATE_H
|
||||||
#define SDF3D_TF_TRANSLATE_H
|
#define MM_SDF3D_TF_TRANSLATE_H
|
||||||
|
|
||||||
|
#include "../mm_node.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class Sdf3dTfTranslate : public MMNode {
|
class MMSdf3dTfTranslate : public MMNode {
|
||||||
GDCLASS(Sdf3dTfTranslate, MMNode);
|
GDCLASS(MMSdf3dTfTranslate, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_input();
|
||||||
|
void set_input(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_input();
|
Ref<MMNodeUniversalProperty> get_output();
|
||||||
void set_input(const Ref<Resource> &val);
|
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_output();
|
Vector3 get_translation();
|
||||||
void set_output(const Ref<Resource> &val);
|
void set_translation(const Vector3 &val);
|
||||||
|
|
||||||
Vector3 get_translation();
|
void _init_properties();
|
||||||
void set_translation(const Vector3 &val);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
|
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
||||||
|
|
||||||
void _init_properties();
|
void on_input_changed();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
|
||||||
Vector2 _get_property_value_sdf3d(const Vector3 &uv3);
|
|
||||||
Vector3 get_translation();
|
|
||||||
void set_translation(const Vector3 &val);
|
|
||||||
void on_input_changed();
|
|
||||||
|
|
||||||
Sdf3dTfTranslate();
|
MMSdf3dTfTranslate();
|
||||||
~Sdf3dTfTranslate();
|
~MMSdf3dTfTranslate();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
//tool
|
Ref<MMNodeUniversalProperty> input;
|
||||||
//export(Resource)
|
Ref<MMNodeUniversalProperty> output;
|
||||||
Ref<Resource> input;
|
Vector3 translation;
|
||||||
//export(Resource)
|
|
||||||
Ref<Resource> output;
|
|
||||||
//export(Vector3)
|
|
||||||
Vector3 translation = Vector3();
|
|
||||||
//translation
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -61,6 +61,8 @@ SOFTWARE.
|
|||||||
#include "nodes/simple/image.h"
|
#include "nodes/simple/image.h"
|
||||||
#include "nodes/simple/shape.h"
|
#include "nodes/simple/shape.h"
|
||||||
|
|
||||||
|
#include "nodes/sdf3d/sdf3d_tf_translate.h"
|
||||||
|
|
||||||
static _MMAlgos *_mm_algos_singleton = nullptr;
|
static _MMAlgos *_mm_algos_singleton = nullptr;
|
||||||
|
|
||||||
void register_material_maker_types() {
|
void register_material_maker_types() {
|
||||||
@ -112,6 +114,9 @@ void register_material_maker_types() {
|
|||||||
ClassDB::register_class<MMCurve>();
|
ClassDB::register_class<MMCurve>();
|
||||||
MMAlgos::register_node_class("Simple", "MMCurve");
|
MMAlgos::register_node_class("Simple", "MMCurve");
|
||||||
|
|
||||||
|
ClassDB::register_class<MMSdf3dTfTranslate>();
|
||||||
|
MMAlgos::register_node_class("SDF3D", "MMSdf3dTfTranslate");
|
||||||
|
|
||||||
_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