mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-28 22:57:15 +01:00
Cleaned up MMTranslate.
This commit is contained in:
parent
90f6ba8369
commit
20af76c795
@ -52,6 +52,8 @@ sources = [
|
|||||||
|
|
||||||
"nodes/uniform/uniform.cpp",
|
"nodes/uniform/uniform.cpp",
|
||||||
"nodes/uniform/greyscale_uniform.cpp",
|
"nodes/uniform/greyscale_uniform.cpp",
|
||||||
|
|
||||||
|
"nodes/transform/translate.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
if env["tools"]:
|
if env["tools"]:
|
||||||
|
@ -22,6 +22,8 @@ def get_doc_classes():
|
|||||||
|
|
||||||
"MMUniform",
|
"MMUniform",
|
||||||
"MMGreyscaleUniform",
|
"MMGreyscaleUniform",
|
||||||
|
|
||||||
|
"MMTranslate",
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_doc_path():
|
def get_doc_path():
|
||||||
|
@ -1,133 +1,87 @@
|
|||||||
|
|
||||||
#include "translate.h"
|
#include "translate.h"
|
||||||
|
|
||||||
|
#include "../../editor/mm_graph_node.h"
|
||||||
|
|
||||||
Ref<Resource> Translate::get_image() {
|
Ref<MMNodeUniversalProperty> MMTranslate::get_image() {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Translate::set_image(const Ref<Resource> &val) {
|
void MMTranslate::set_image(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
image = val;
|
image = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<MMNodeUniversalProperty> MMTranslate::get_input() {
|
||||||
Ref<Resource> Translate::get_input() {
|
return input;
|
||||||
return input;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Translate::set_input(const Ref<Resource> &val) {
|
void MMTranslate::set_input(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
input = val;
|
input = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMTranslate::get_translation() {
|
||||||
Vector2 Translate::get_translation() {
|
return translation;
|
||||||
return translation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Translate::set_translation(const Vector2 &val) {
|
void MMTranslate::set_translation(const Vector2 &val) {
|
||||||
translation = val;
|
translation = val;
|
||||||
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMTranslate::_init_properties() {
|
||||||
|
if (!input.is_valid()) {
|
||||||
|
input.instance();
|
||||||
|
input->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
|
||||||
|
input->set_default_value(Color(0, 0, 0, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
input->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||||
|
input->set_slot_name(">>> Input1 ");
|
||||||
|
|
||||||
//tool;
|
if (!image.is_valid()) {
|
||||||
//export(Resource) ;
|
image.instance();
|
||||||
Ref<Resource> image;
|
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
|
||||||
//export(Resource) ;
|
}
|
||||||
Ref<Resource> input;
|
|
||||||
//export(Vector2) ;
|
|
||||||
Vector2 translation = Vector2();
|
|
||||||
|
|
||||||
void Translate::_init_properties() {
|
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||||
|
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
|
||||||
if (!input) {
|
//image.force_override = true;
|
||||||
input = MMNodeUniversalProperty.new();
|
register_input_property(input);
|
||||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
|
register_output_property(image);
|
||||||
input.set_default_value(Color(0, 0, 0, 1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
void MMTranslate::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
input.slot_name = ">>> Input1 ";
|
mm_graph_node->add_slot_label_universal(input);
|
||||||
|
mm_graph_node->add_slot_texture_universal(image);
|
||||||
if (!image) {
|
mm_graph_node->add_slot_vector2("get_translation", "set_translation", "Translation", 0.01);
|
||||||
image = MMNodeUniversalProperty.new();
|
|
||||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
void MMTranslate::_render(const Ref<MMMaterial> &material) {
|
||||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
|
Ref<Image> img = render_image(material);
|
||||||
//image.force_override = true;
|
image->set_value(img);
|
||||||
register_input_property(input);
|
|
||||||
register_output_property(image);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color MMTranslate::_get_value_for(const Vector2 &uv, const int pseed) {
|
||||||
void Translate::_register_methods(const Variant &mm_graph_node) {
|
//$i($uv-vec2($translate_x, $translate_y));
|
||||||
mm_graph_node.add_slot_label_universal(input);
|
return input->get_value(uv - translation);
|
||||||
mm_graph_node.add_slot_texture_universal(image);
|
|
||||||
mm_graph_node.add_slot_vector2("get_translation", "set_translation", "Translation", 0.01);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMTranslate::MMTranslate() {
|
||||||
void Translate::_render(const Variant &material) {
|
|
||||||
Ref<Image> img = render_image(material);
|
|
||||||
image.set_value(img);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMTranslate::~MMTranslate() {
|
||||||
Color Translate::_get_value_for(const Vector2 &uv, const int pseed) {
|
|
||||||
//$i($uv-vec2($translate_x, $translate_y));
|
|
||||||
return input.get_value(uv - translation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//translation;
|
void MMTranslate::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_image"), &MMTranslate::get_image);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMTranslate::set_image);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<MMNodeUniversalProperty>"), "set_image", "get_image");
|
||||||
|
|
||||||
Vector2 Translate::get_translation() {
|
ClassDB::bind_method(D_METHOD("get_input"), &MMTranslate::get_input);
|
||||||
return translation;
|
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMTranslate::set_input);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<MMNodeUniversalProperty>"), "set_input", "get_input");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_translation"), &MMTranslate::get_translation);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_translation", "value"), &MMTranslate::set_translation);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "translation"), "set_translation", "get_translation");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Translate::set_translation(const Vector2 &val) {
|
|
||||||
translation = val;
|
|
||||||
set_dirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Translate::Translate() {
|
|
||||||
image;
|
|
||||||
input;
|
|
||||||
translation = Vector2();
|
|
||||||
}
|
|
||||||
|
|
||||||
Translate::~Translate() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void Translate::_bind_methods() {
|
|
||||||
ClassDB::bind_method(D_METHOD("get_image"), &Translate::get_image);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_image", "value"), &Translate::set_image);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_input"), &Translate::get_input);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &Translate::set_input);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_translation"), &Translate::get_translation);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_translation", "value"), &Translate::set_translation);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "translation"), "set_translation", "get_translation");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Translate::_init_properties);
|
|
||||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Translate::_register_methods);
|
|
||||||
ClassDB::bind_method(D_METHOD("_render", "material"), &Translate::_render);
|
|
||||||
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Translate::_get_value_for);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_translation"), &Translate::get_translation);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_translation", "val"), &Translate::set_translation);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,43 +1,36 @@
|
|||||||
#ifndef TRANSLATE_H
|
#ifndef MM_TRANSLATE_H
|
||||||
#define TRANSLATE_H
|
#define MM_TRANSLATE_H
|
||||||
|
|
||||||
|
#include "../mm_node.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class Translate : public MMNode {
|
class MMTranslate : public MMNode {
|
||||||
GDCLASS(Translate, MMNode);
|
GDCLASS(MMTranslate, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_image();
|
||||||
|
void set_image(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_image();
|
Ref<MMNodeUniversalProperty> get_input();
|
||||||
void set_image(const Ref<Resource> &val);
|
void set_input(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_input();
|
Vector2 get_translation();
|
||||||
void set_input(const Ref<Resource> &val);
|
void set_translation(const Vector2 &val);
|
||||||
|
|
||||||
Vector2 get_translation();
|
void _init_properties();
|
||||||
void set_translation(const Vector2 &val);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
|
void _render(const Ref<MMMaterial> &material);
|
||||||
|
Color _get_value_for(const Vector2 &uv, const int pseed);
|
||||||
|
|
||||||
void _init_properties();
|
MMTranslate();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
~MMTranslate();
|
||||||
void _render(const Variant &material);
|
|
||||||
Color _get_value_for(const Vector2 &uv, const int pseed);
|
|
||||||
Vector2 get_translation();
|
|
||||||
void set_translation(const Vector2 &val);
|
|
||||||
|
|
||||||
Translate();
|
protected:
|
||||||
~Translate();
|
static void _bind_methods();
|
||||||
|
|
||||||
protected:
|
Ref<MMNodeUniversalProperty> image;
|
||||||
static void _bind_methods();
|
Ref<MMNodeUniversalProperty> input;
|
||||||
|
Vector2 translation;
|
||||||
//tool
|
|
||||||
//export(Resource)
|
|
||||||
Ref<Resource> image;
|
|
||||||
//export(Resource)
|
|
||||||
Ref<Resource> input;
|
|
||||||
//export(Vector2)
|
|
||||||
Vector2 translation = Vector2();
|
|
||||||
//translation
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,6 +45,8 @@ SOFTWARE.
|
|||||||
#include "nodes/uniform/greyscale_uniform.h"
|
#include "nodes/uniform/greyscale_uniform.h"
|
||||||
#include "nodes/uniform/uniform.h"
|
#include "nodes/uniform/uniform.h"
|
||||||
|
|
||||||
|
#include "nodes/transform/translate.h"
|
||||||
|
|
||||||
static _MMAlgos *_mm_algos_singleton = nullptr;
|
static _MMAlgos *_mm_algos_singleton = nullptr;
|
||||||
|
|
||||||
void register_material_maker_types() {
|
void register_material_maker_types() {
|
||||||
@ -62,10 +64,13 @@ void register_material_maker_types() {
|
|||||||
ClassDB::register_class<MatMakerGDEditor>();
|
ClassDB::register_class<MatMakerGDEditor>();
|
||||||
|
|
||||||
ClassDB::register_class<MMUniform>();
|
ClassDB::register_class<MMUniform>();
|
||||||
ClassDB::register_class<MMGreyscaleUniform>();
|
|
||||||
MMAlgos::register_node_class("Uniform", "MMUniform");
|
MMAlgos::register_node_class("Uniform", "MMUniform");
|
||||||
|
ClassDB::register_class<MMGreyscaleUniform>();
|
||||||
MMAlgos::register_node_class("Uniform", "MMGreyscaleUniform");
|
MMAlgos::register_node_class("Uniform", "MMGreyscaleUniform");
|
||||||
|
|
||||||
|
ClassDB::register_class<MMTranslate>();
|
||||||
|
MMAlgos::register_node_class("Transform", "MMTranslate");
|
||||||
|
|
||||||
_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