mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-06 08:05:54 +01:00
Cleaned up MMMirror, and MMRepeat.
This commit is contained in:
parent
3e1002c71d
commit
e1493ecac6
@ -59,6 +59,8 @@ sources = [
|
||||
"nodes/transform/shear.cpp",
|
||||
"nodes/transform/scale.cpp",
|
||||
"nodes/transform/rotate.cpp",
|
||||
"nodes/transform/repeat.cpp",
|
||||
"nodes/transform/mirror.cpp",
|
||||
]
|
||||
|
||||
if env["tools"]:
|
||||
|
@ -29,6 +29,8 @@ def get_doc_classes():
|
||||
"MMShear",
|
||||
"MMScale",
|
||||
"MMRotate",
|
||||
"MMRepeat",
|
||||
"MMMirror",
|
||||
]
|
||||
|
||||
def get_doc_path():
|
||||
|
@ -1,175 +1,119 @@
|
||||
|
||||
#include "mirror.h"
|
||||
|
||||
#include "../../algos/mm_algos.h"
|
||||
#include "../../editor/mm_graph_node.h"
|
||||
#include "../mm_material.h"
|
||||
|
||||
Ref<Resource> Mirror::get_image() {
|
||||
return image;
|
||||
Ref<MMNodeUniversalProperty> MMMirror::get_image() {
|
||||
return image;
|
||||
}
|
||||
|
||||
void Mirror::set_image(const Ref<Resource> &val) {
|
||||
image = val;
|
||||
void MMMirror::set_image(const Ref<MMNodeUniversalProperty> &val) {
|
||||
image = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<Resource> Mirror::get_input() {
|
||||
return input;
|
||||
Ref<MMNodeUniversalProperty> MMMirror::get_input() {
|
||||
return input;
|
||||
}
|
||||
|
||||
void Mirror::set_input(const Ref<Resource> &val) {
|
||||
input = val;
|
||||
void MMMirror::set_input(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input = val;
|
||||
}
|
||||
|
||||
|
||||
int Mirror::get_direction() const {
|
||||
return direction;
|
||||
int MMMirror::get_direction() const {
|
||||
return direction;
|
||||
}
|
||||
|
||||
void Mirror::set_direction(const int val) {
|
||||
direction = val;
|
||||
void MMMirror::set_direction(const int val) {
|
||||
direction = val;
|
||||
set_dirty(true);
|
||||
}
|
||||
|
||||
|
||||
float Mirror::get_offset() const {
|
||||
return offset;
|
||||
float MMMirror::get_offset() const {
|
||||
return offset;
|
||||
}
|
||||
|
||||
void Mirror::set_offset(const float val) {
|
||||
offset = val;
|
||||
void MMMirror::set_offset(const float val) {
|
||||
offset = val;
|
||||
set_dirty(true);
|
||||
}
|
||||
|
||||
void MMMirror::_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(">>> Input ");
|
||||
|
||||
//tool;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> image;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input;
|
||||
//export(int, "Horizontal,Vertical") ;
|
||||
int direction = 0;
|
||||
//export(float) ;
|
||||
float offset = 0;
|
||||
if (!image.is_valid()) {
|
||||
image.instance();
|
||||
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
|
||||
}
|
||||
|
||||
void Mirror::_init_properties() {
|
||||
|
||||
if (!input) {
|
||||
input = MMNodeUniversalProperty.new();
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
|
||||
input.set_default_value(Color(0, 0, 0, 1));
|
||||
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
image->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_IMAGE);
|
||||
//image.force_override = true;
|
||||
register_input_property(input);
|
||||
register_output_property(image);
|
||||
}
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
input.slot_name = ">>> Input ";
|
||||
void MMMirror::_register_methods(MMGraphNode *mm_graph_node) {
|
||||
mm_graph_node->add_slot_label_universal(input);
|
||||
mm_graph_node->add_slot_texture_universal(image);
|
||||
|
||||
if (!image) {
|
||||
image = MMNodeUniversalProperty.new();
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
|
||||
Array arr;
|
||||
arr.push_back("Horizontal");
|
||||
arr.push_back("Vertical");
|
||||
|
||||
mm_graph_node->add_slot_enum("get_direction", "set_direction", "Direction", arr);
|
||||
mm_graph_node->add_slot_float("get_offset", "set_offset", "offset", 0.01);
|
||||
}
|
||||
|
||||
//image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE;
|
||||
//image.force_override = true;
|
||||
register_input_property(input);
|
||||
register_output_property(image);
|
||||
void MMMirror::_render(const Ref<MMMaterial> &material) {
|
||||
Ref<Image> img = render_image(material);
|
||||
image->set_value(img);
|
||||
}
|
||||
|
||||
Color MMMirror::_get_value_for(const Vector2 &uv, const int pseed) {
|
||||
//$i(uvmirror_$direction($uv, $offset));
|
||||
|
||||
void Mirror::_register_methods(const Variant &mm_graph_node) {
|
||||
mm_graph_node.add_slot_label_universal(input);
|
||||
mm_graph_node.add_slot_texture_universal(image);
|
||||
mm_graph_node.add_slot_enum("get_direction", "set_direction", "Direction", [ "Horizontal", "Vertical" ]);
|
||||
mm_graph_node.add_slot_float("get_offset", "set_offset", "offset", 0.01);
|
||||
if (direction == 0) {
|
||||
return input->get_value(MMAlgos::uvmirror_h(uv, offset));
|
||||
}
|
||||
|
||||
else if (direction == 1) {
|
||||
return input->get_value(MMAlgos::uvmirror_v(uv, offset));
|
||||
}
|
||||
|
||||
return Color(0, 0, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
void Mirror::_render(const Variant &material) {
|
||||
Ref<Image> img = render_image(material);
|
||||
image.set_value(img);
|
||||
MMMirror::MMMirror() {
|
||||
direction = 0;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
|
||||
Color Mirror::_get_value_for(const Vector2 &uv, const int pseed) {
|
||||
//$i(uvmirror_$direction($uv, $offset));
|
||||
|
||||
if (direction == 0) {
|
||||
return input.get_value(MMAlgos.uvmirror_h(uv, offset));
|
||||
MMMirror::~MMMirror() {
|
||||
}
|
||||
|
||||
void MMMirror::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_image"), &MMMirror::get_image);
|
||||
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMMirror::set_image);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<MMNodeUniversalProperty>"), "set_image", "get_image");
|
||||
|
||||
else if (direction == 1) {
|
||||
return input.get_value(MMAlgos.uvmirror_v(uv, offset));
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &MMMirror::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMMirror::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<MMNodeUniversalProperty>"), "set_input", "get_input");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_direction"), &MMMirror::get_direction);
|
||||
ClassDB::bind_method(D_METHOD("set_direction", "value"), &MMMirror::set_direction);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "direction"), "set_direction", "get_direction");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_offset"), &MMMirror::get_offset);
|
||||
ClassDB::bind_method(D_METHOD("set_offset", "value"), &MMMirror::set_offset);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset"), "set_offset", "get_offset");
|
||||
}
|
||||
|
||||
return Color(0, 0, 0, 1);
|
||||
}
|
||||
|
||||
//direction;
|
||||
|
||||
int Mirror::get_direction() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
|
||||
void Mirror::set_direction(const int val) {
|
||||
direction = val;
|
||||
set_dirty(true);
|
||||
}
|
||||
|
||||
//offset;
|
||||
|
||||
float Mirror::get_offset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
void Mirror::set_offset(const float val) {
|
||||
offset = val;
|
||||
set_dirty(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Mirror::Mirror() {
|
||||
image;
|
||||
input;
|
||||
direction = 0;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
Mirror::~Mirror() {
|
||||
}
|
||||
|
||||
|
||||
static void Mirror::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_image"), &Mirror::get_image);
|
||||
ClassDB::bind_method(D_METHOD("set_image", "value"), &Mirror::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"), &Mirror::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &Mirror::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_direction"), &Mirror::get_direction);
|
||||
ClassDB::bind_method(D_METHOD("set_direction", "value"), &Mirror::set_direction);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "direction"), "set_direction", "get_direction");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_offset"), &Mirror::get_offset);
|
||||
ClassDB::bind_method(D_METHOD("set_offset", "value"), &Mirror::set_offset);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset"), "set_offset", "get_offset");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Mirror::_init_properties);
|
||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Mirror::_register_methods);
|
||||
ClassDB::bind_method(D_METHOD("_render", "material"), &Mirror::_render);
|
||||
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &Mirror::_get_value_for);
|
||||
ClassDB::bind_method(D_METHOD("get_direction"), &Mirror::get_direction);
|
||||
ClassDB::bind_method(D_METHOD("set_direction", "val"), &Mirror::set_direction);
|
||||
ClassDB::bind_method(D_METHOD("get_offset"), &Mirror::get_offset);
|
||||
ClassDB::bind_method(D_METHOD("set_offset", "val"), &Mirror::set_offset);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,51 +1,41 @@
|
||||
#ifndef MIRROR_H
|
||||
#define MIRROR_H
|
||||
#ifndef MM_MIRROR_H
|
||||
#define MM_MIRROR_H
|
||||
|
||||
#include "../mm_node.h"
|
||||
#include "../mm_node_universal_property.h"
|
||||
|
||||
class Mirror : public MMNode {
|
||||
GDCLASS(Mirror, MMNode);
|
||||
class MMMirror : public MMNode {
|
||||
GDCLASS(MMMirror, MMNode);
|
||||
|
||||
public:
|
||||
public:
|
||||
Ref<MMNodeUniversalProperty> get_image();
|
||||
void set_image(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_image();
|
||||
void set_image(const Ref<Resource> &val);
|
||||
Ref<MMNodeUniversalProperty> get_input();
|
||||
void set_input(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input();
|
||||
void set_input(const Ref<Resource> &val);
|
||||
int get_direction() const;
|
||||
void set_direction(const int val);
|
||||
|
||||
int get_direction() const;
|
||||
void set_direction(const int val);
|
||||
float get_offset() const;
|
||||
void set_offset(const float val);
|
||||
|
||||
float get_offset() const;
|
||||
void set_offset(const float val);
|
||||
void _init_properties();
|
||||
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();
|
||||
void _register_methods(const Variant &mm_graph_node);
|
||||
void _render(const Variant &material);
|
||||
Color _get_value_for(const Vector2 &uv, const int pseed);
|
||||
int get_direction();
|
||||
void set_direction(const int val);
|
||||
float get_offset();
|
||||
void set_offset(const float val);
|
||||
MMMirror();
|
||||
~MMMirror();
|
||||
|
||||
Mirror();
|
||||
~Mirror();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
//export(Resource)
|
||||
Ref<Resource> image;
|
||||
//export(Resource)
|
||||
Ref<Resource> input;
|
||||
//export(int, "Horizontal,Vertical")
|
||||
int direction = 0;
|
||||
//export(float)
|
||||
float offset = 0;
|
||||
//direction
|
||||
//offset
|
||||
Ref<MMNodeUniversalProperty> image;
|
||||
Ref<MMNodeUniversalProperty> input;
|
||||
//export(int, "Horizontal,Vertical")
|
||||
int direction;
|
||||
float offset;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,69 +1,51 @@
|
||||
|
||||
#include "repeat.h"
|
||||
|
||||
#include "../../algos/mm_algos.h"
|
||||
#include "../../editor/mm_graph_node.h"
|
||||
#include "../mm_material.h"
|
||||
|
||||
Ref<Resource> Repeat::get_input() {
|
||||
return input;
|
||||
Ref<MMNodeUniversalProperty> MMRepeat::get_input() {
|
||||
return input;
|
||||
}
|
||||
|
||||
void Repeat::set_input(const Ref<Resource> &val) {
|
||||
input = val;
|
||||
void MMRepeat::set_input(const Ref<MMNodeUniversalProperty> &val) {
|
||||
input = val;
|
||||
}
|
||||
|
||||
void MMRepeat::_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(">>> Apply >>>");
|
||||
//input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_COLOR;
|
||||
input->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
input->set_get_value_from_owner(true);
|
||||
|
||||
//tool;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> input;
|
||||
|
||||
void Repeat::_init_properties() {
|
||||
|
||||
if (!input) {
|
||||
input = MMNodeUniversalProperty.new();
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR;
|
||||
input.set_default_value(Color(0, 0, 0, 1));
|
||||
register_input_property(input);
|
||||
register_output_property(input);
|
||||
}
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
input.slot_name = ">>> Apply >>>";
|
||||
//input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_COLOR;
|
||||
input.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
||||
input.get_value_from_owner = true;
|
||||
register_input_property(input);
|
||||
register_output_property(input);
|
||||
void MMRepeat::_register_methods(MMGraphNode *mm_graph_node) {
|
||||
mm_graph_node->add_slot_label_universal(input);
|
||||
}
|
||||
|
||||
|
||||
void Repeat::_register_methods(const Variant &mm_graph_node) {
|
||||
mm_graph_node.add_slot_label_universal(input);
|
||||
Variant MMRepeat::_get_property_value(const Vector2 &uv) {
|
||||
return input->get_value(MMAlgos::fractv2(uv), true);
|
||||
}
|
||||
|
||||
|
||||
void Repeat::_get_property_value(const Vector2 &uv) {
|
||||
return input.get_value(MMAlgos.fractv2(uv), true);
|
||||
MMRepeat::MMRepeat() {
|
||||
}
|
||||
|
||||
MMRepeat::~MMRepeat() {
|
||||
}
|
||||
|
||||
Repeat::Repeat() {
|
||||
input;
|
||||
}
|
||||
|
||||
Repeat::~Repeat() {
|
||||
}
|
||||
|
||||
|
||||
static void Repeat::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &Repeat::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &Repeat::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input", "get_input");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_init_properties"), &Repeat::_init_properties);
|
||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &Repeat::_register_methods);
|
||||
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &Repeat::_get_property_value);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MMRepeat::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_input"), &MMRepeat::get_input);
|
||||
ClassDB::bind_method(D_METHOD("set_input", "value"), &MMRepeat::set_input);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_RESOURCE_TYPE, "Ref<MMNodeUniversalProperty>"), "set_input", "get_input");
|
||||
}
|
||||
|
@ -1,29 +1,27 @@
|
||||
#ifndef REPEAT_H
|
||||
#define REPEAT_H
|
||||
#ifndef MM_REPEAT_H
|
||||
#define MM_REPEAT_H
|
||||
|
||||
#include "../mm_node.h"
|
||||
#include "../mm_node_universal_property.h"
|
||||
|
||||
class Repeat : public MMNode {
|
||||
GDCLASS(Repeat, MMNode);
|
||||
class MMRepeat : public MMNode {
|
||||
GDCLASS(MMRepeat, MMNode);
|
||||
|
||||
public:
|
||||
public:
|
||||
Ref<MMNodeUniversalProperty> get_input();
|
||||
void set_input(const Ref<MMNodeUniversalProperty> &val);
|
||||
|
||||
Ref<Resource> get_input();
|
||||
void set_input(const Ref<Resource> &val);
|
||||
void _init_properties();
|
||||
void _register_methods(MMGraphNode *mm_graph_node);
|
||||
Variant _get_property_value(const Vector2 &uv);
|
||||
|
||||
void _init_properties();
|
||||
void _register_methods(const Variant &mm_graph_node);
|
||||
void _get_property_value(const Vector2 &uv);
|
||||
MMRepeat();
|
||||
~MMRepeat();
|
||||
|
||||
Repeat();
|
||||
~Repeat();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
//export(Resource)
|
||||
Ref<Resource> input;
|
||||
Ref<MMNodeUniversalProperty> input;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -45,6 +45,8 @@ SOFTWARE.
|
||||
#include "nodes/uniform/greyscale_uniform.h"
|
||||
#include "nodes/uniform/uniform.h"
|
||||
|
||||
#include "nodes/transform/mirror.h"
|
||||
#include "nodes/transform/repeat.h"
|
||||
#include "nodes/transform/rotate.h"
|
||||
#include "nodes/transform/scale.h"
|
||||
#include "nodes/transform/shear.h"
|
||||
@ -85,6 +87,10 @@ void register_material_maker_types() {
|
||||
MMAlgos::register_node_class("Transform", "MMScale");
|
||||
ClassDB::register_class<MMRotate>();
|
||||
MMAlgos::register_node_class("Transform", "MMRotate");
|
||||
ClassDB::register_class<MMRepeat>();
|
||||
MMAlgos::register_node_class("Transform", "MMRepeat");
|
||||
ClassDB::register_class<MMMirror>();
|
||||
MMAlgos::register_node_class("Transform", "MMMirror");
|
||||
|
||||
_mm_algos_singleton = memnew(_MMAlgos);
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton()));
|
||||
|
Loading…
Reference in New Issue
Block a user