mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-03 22:55:55 +01:00
Cleaned up MMOutputImage.
This commit is contained in:
parent
3fbf9713f7
commit
d5437adaa2
@ -122,6 +122,8 @@ sources = [
|
|||||||
"nodes/pattern/iching.cpp",
|
"nodes/pattern/iching.cpp",
|
||||||
"nodes/pattern/bricks.cpp",
|
"nodes/pattern/bricks.cpp",
|
||||||
"nodes/pattern/beehive.cpp",
|
"nodes/pattern/beehive.cpp",
|
||||||
|
|
||||||
|
"nodes/other/output_image.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
if env["tools"]:
|
if env["tools"]:
|
||||||
|
@ -92,6 +92,8 @@ def get_doc_classes():
|
|||||||
"MMIching",
|
"MMIching",
|
||||||
"MMBricks",
|
"MMBricks",
|
||||||
"MMBeehive",
|
"MMBeehive",
|
||||||
|
|
||||||
|
"MMOutputImage",
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_doc_path():
|
def get_doc_path():
|
||||||
|
@ -1,110 +1,74 @@
|
|||||||
|
|
||||||
#include "output_image.h"
|
#include "output_image.h"
|
||||||
|
|
||||||
|
#include "../../algos/mm_algos.h"
|
||||||
|
#include "../../editor/mm_graph_node.h"
|
||||||
|
#include "../mm_material.h"
|
||||||
|
|
||||||
Ref<Resource> OutputImage::get_image() {
|
Ref<MMNodeUniversalProperty> MMOutputImage::get_image() {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputImage::set_image(const Ref<Resource> &val) {
|
void MMOutputImage::set_image(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
image = val;
|
image = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String MMOutputImage::get_postfix() {
|
||||||
String OutputImage::get_postfix() {
|
return postfix;
|
||||||
return postfix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputImage::set_postfix(const String &val) {
|
void MMOutputImage::set_postfix(const String &val) {
|
||||||
postfix = val;
|
postfix = val;
|
||||||
|
set_dirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMOutputImage::_init_properties() {
|
||||||
|
image.instance();
|
||||||
//tool;
|
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
|
||||||
//export(Resource) ;
|
image->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||||
Ref<Resource> image;
|
image->set_slot_name("image");
|
||||||
//export(String) ;
|
register_input_property(image);
|
||||||
String postfix = "";
|
|
||||||
|
|
||||||
void OutputImage::_init_properties() {
|
|
||||||
image = MMNodeUniversalProperty.new();
|
|
||||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE;
|
|
||||||
image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL;
|
|
||||||
image.slot_name = "image";
|
|
||||||
register_input_property(image);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMOutputImage::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
void OutputImage::_register_methods(const Variant &mm_graph_node) {
|
mm_graph_node->add_slot_texture_universal(image);
|
||||||
mm_graph_node.add_slot_texture_universal(image);
|
mm_graph_node->add_slot_line_edit("get_postfix", "set_postfix", "postfix");
|
||||||
mm_graph_node.add_slot_line_edit("get_postfix", "set_postfix", "postfix");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMOutputImage::_render(const Ref<MMMaterial> &material) {
|
||||||
|
if (!image.is_valid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void OutputImage::_render(const Variant &material) {
|
Ref<Image> img = image->get_active_image();
|
||||||
|
|
||||||
if (!image) {
|
if (!img.is_valid()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String matpath = material->get_path();
|
||||||
|
|
||||||
|
if (matpath == "") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String matbn = matpath.get_basename();
|
||||||
|
String final_file_name = matbn + postfix + ".png";
|
||||||
|
img->save_png(final_file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Image> img = image.get_active_image();
|
MMOutputImage::MMOutputImage() {
|
||||||
|
|
||||||
if (!img) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String matpath = material.get_path();
|
MMOutputImage::~MMOutputImage() {
|
||||||
|
|
||||||
if (matpath == "") {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String matbn = matpath.get_basename();
|
void MMOutputImage::_bind_methods() {
|
||||||
String final_file_name = matbn + postfix + ".png";
|
ClassDB::bind_method(D_METHOD("get_image"), &MMOutputImage::get_image);
|
||||||
img.save_png(final_file_name);
|
ClassDB::bind_method(D_METHOD("set_image", "value"), &MMOutputImage::set_image);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_image", "get_image");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_postfix"), &MMOutputImage::get_postfix);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_postfix", "value"), &MMOutputImage::set_postfix);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "postfix"), "set_postfix", "get_postfix");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String OutputImage::get_postfix() {
|
|
||||||
return postfix;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void OutputImage::set_postfix(const String &pf) {
|
|
||||||
postfix = pf;
|
|
||||||
set_dirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
OutputImage::OutputImage() {
|
|
||||||
image;
|
|
||||||
postfix = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
OutputImage::~OutputImage() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void OutputImage::_bind_methods() {
|
|
||||||
ClassDB::bind_method(D_METHOD("get_image"), &OutputImage::get_image);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_image", "value"), &OutputImage::set_image);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_image", "get_image");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_postfix"), &OutputImage::get_postfix);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_postfix", "value"), &OutputImage::set_postfix);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "postfix"), "set_postfix", "get_postfix");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_init_properties"), &OutputImage::_init_properties);
|
|
||||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &OutputImage::_register_methods);
|
|
||||||
ClassDB::bind_method(D_METHOD("_render", "material"), &OutputImage::_render);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_postfix"), &OutputImage::get_postfix);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_postfix", "pf"), &OutputImage::set_postfix);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,36 +1,31 @@
|
|||||||
#ifndef OUTPUT_IMAGE_H
|
#ifndef MM_OUTPUT_IMAGE_H
|
||||||
#define OUTPUT_IMAGE_H
|
#define MM_OUTPUT_IMAGE_H
|
||||||
|
|
||||||
|
#include "../mm_node.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class OutputImage : public MMNode {
|
class MMOutputImage : public MMNode {
|
||||||
GDCLASS(OutputImage, MMNode);
|
GDCLASS(MMOutputImage, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_image();
|
||||||
|
void set_image(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_image();
|
String get_postfix();
|
||||||
void set_image(const Ref<Resource> &val);
|
void set_postfix(const String &val);
|
||||||
|
|
||||||
String get_postfix();
|
void _init_properties();
|
||||||
void set_postfix(const String &val);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
|
void _render(const Ref<MMMaterial> &material);
|
||||||
|
|
||||||
void _init_properties();
|
MMOutputImage();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
~MMOutputImage();
|
||||||
void _render(const Variant &material);
|
|
||||||
String get_postfix();
|
|
||||||
void set_postfix(const String &pf);
|
|
||||||
|
|
||||||
OutputImage();
|
protected:
|
||||||
~OutputImage();
|
static void _bind_methods();
|
||||||
|
|
||||||
protected:
|
Ref<MMNodeUniversalProperty> image;
|
||||||
static void _bind_methods();
|
String postfix;
|
||||||
|
|
||||||
//tool
|
|
||||||
//export(Resource)
|
|
||||||
Ref<Resource> image;
|
|
||||||
//export(String)
|
|
||||||
String postfix = "";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -117,6 +117,8 @@ SOFTWARE.
|
|||||||
#include "nodes/pattern/truchet.h"
|
#include "nodes/pattern/truchet.h"
|
||||||
#include "nodes/pattern/weave.h"
|
#include "nodes/pattern/weave.h"
|
||||||
|
|
||||||
|
#include "nodes/other/output_image.h"
|
||||||
|
|
||||||
static _MMAlgos *_mm_algos_singleton = nullptr;
|
static _MMAlgos *_mm_algos_singleton = nullptr;
|
||||||
|
|
||||||
void register_material_maker_types() {
|
void register_material_maker_types() {
|
||||||
@ -267,6 +269,9 @@ void register_material_maker_types() {
|
|||||||
ClassDB::register_class<MMBeehive>();
|
ClassDB::register_class<MMBeehive>();
|
||||||
MMAlgos::register_node_class("Patterns", "MMBeehive");
|
MMAlgos::register_node_class("Patterns", "MMBeehive");
|
||||||
|
|
||||||
|
ClassDB::register_class<MMOutputImage>();
|
||||||
|
MMAlgos::register_node_class("Output", "MMOutputImage");
|
||||||
|
|
||||||
_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