mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-03 14:45:57 +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/bricks.cpp",
|
||||
"nodes/pattern/beehive.cpp",
|
||||
|
||||
"nodes/other/output_image.cpp",
|
||||
]
|
||||
|
||||
if env["tools"]:
|
||||
|
@ -92,6 +92,8 @@ def get_doc_classes():
|
||||
"MMIching",
|
||||
"MMBricks",
|
||||
"MMBeehive",
|
||||
|
||||
"MMOutputImage",
|
||||
]
|
||||
|
||||
def get_doc_path():
|
||||
|
@ -1,110 +1,74 @@
|
||||
|
||||
#include "output_image.h"
|
||||
|
||||
#include "../../algos/mm_algos.h"
|
||||
#include "../../editor/mm_graph_node.h"
|
||||
#include "../mm_material.h"
|
||||
|
||||
Ref<Resource> OutputImage::get_image() {
|
||||
return image;
|
||||
Ref<MMNodeUniversalProperty> MMOutputImage::get_image() {
|
||||
return image;
|
||||
}
|
||||
|
||||
void OutputImage::set_image(const Ref<Resource> &val) {
|
||||
image = val;
|
||||
void MMOutputImage::set_image(const Ref<MMNodeUniversalProperty> &val) {
|
||||
image = val;
|
||||
}
|
||||
|
||||
|
||||
String OutputImage::get_postfix() {
|
||||
return postfix;
|
||||
String MMOutputImage::get_postfix() {
|
||||
return postfix;
|
||||
}
|
||||
|
||||
void OutputImage::set_postfix(const String &val) {
|
||||
postfix = val;
|
||||
void MMOutputImage::set_postfix(const String &val) {
|
||||
postfix = val;
|
||||
set_dirty(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//tool;
|
||||
//export(Resource) ;
|
||||
Ref<Resource> image;
|
||||
//export(String) ;
|
||||
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::_init_properties() {
|
||||
image.instance();
|
||||
image->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_IMAGE);
|
||||
image->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
|
||||
image->set_slot_name("image");
|
||||
register_input_property(image);
|
||||
}
|
||||
|
||||
|
||||
void OutputImage::_register_methods(const Variant &mm_graph_node) {
|
||||
mm_graph_node.add_slot_texture_universal(image);
|
||||
mm_graph_node.add_slot_line_edit("get_postfix", "set_postfix", "postfix");
|
||||
void MMOutputImage::_register_methods(MMGraphNode *mm_graph_node) {
|
||||
mm_graph_node->add_slot_texture_universal(image);
|
||||
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) {
|
||||
return;
|
||||
if (!img.is_valid()) {
|
||||
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();
|
||||
|
||||
if (!img) {
|
||||
return;
|
||||
MMOutputImage::MMOutputImage() {
|
||||
}
|
||||
|
||||
String matpath = material.get_path();
|
||||
|
||||
if (matpath == "") {
|
||||
return;
|
||||
MMOutputImage::~MMOutputImage() {
|
||||
}
|
||||
|
||||
String matbn = matpath.get_basename();
|
||||
String final_file_name = matbn + postfix + ".png";
|
||||
img.save_png(final_file_name);
|
||||
void MMOutputImage::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_image"), &MMOutputImage::get_image);
|
||||
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
|
||||
#define OUTPUT_IMAGE_H
|
||||
#ifndef MM_OUTPUT_IMAGE_H
|
||||
#define MM_OUTPUT_IMAGE_H
|
||||
|
||||
#include "../mm_node.h"
|
||||
#include "../mm_node_universal_property.h"
|
||||
|
||||
class OutputImage : public MMNode {
|
||||
GDCLASS(OutputImage, MMNode);
|
||||
class MMOutputImage : public MMNode {
|
||||
GDCLASS(MMOutputImage, 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);
|
||||
String get_postfix();
|
||||
void set_postfix(const String &val);
|
||||
|
||||
String get_postfix();
|
||||
void set_postfix(const String &val);
|
||||
void _init_properties();
|
||||
void _register_methods(MMGraphNode *mm_graph_node);
|
||||
void _render(const Ref<MMMaterial> &material);
|
||||
|
||||
void _init_properties();
|
||||
void _register_methods(const Variant &mm_graph_node);
|
||||
void _render(const Variant &material);
|
||||
String get_postfix();
|
||||
void set_postfix(const String &pf);
|
||||
MMOutputImage();
|
||||
~MMOutputImage();
|
||||
|
||||
OutputImage();
|
||||
~OutputImage();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
//export(Resource)
|
||||
Ref<Resource> image;
|
||||
//export(String)
|
||||
String postfix = "";
|
||||
Ref<MMNodeUniversalProperty> image;
|
||||
String postfix;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -117,6 +117,8 @@ SOFTWARE.
|
||||
#include "nodes/pattern/truchet.h"
|
||||
#include "nodes/pattern/weave.h"
|
||||
|
||||
#include "nodes/other/output_image.h"
|
||||
|
||||
static _MMAlgos *_mm_algos_singleton = nullptr;
|
||||
|
||||
void register_material_maker_types() {
|
||||
@ -267,6 +269,9 @@ void register_material_maker_types() {
|
||||
ClassDB::register_class<MMBeehive>();
|
||||
MMAlgos::register_node_class("Patterns", "MMBeehive");
|
||||
|
||||
ClassDB::register_class<MMOutputImage>();
|
||||
MMAlgos::register_node_class("Output", "MMOutputImage");
|
||||
|
||||
_mm_algos_singleton = memnew(_MMAlgos);
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton()));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user