mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-21 07:04:22 +01:00
Also cleaned up GreyscaleUniform.
This commit is contained in:
parent
c2a373a9cf
commit
bf11ab2a43
@ -51,6 +51,7 @@ sources = [
|
|||||||
"editor/widgets/polygon_edit/polygon_view.cpp",
|
"editor/widgets/polygon_edit/polygon_view.cpp",
|
||||||
|
|
||||||
"nodes/uniform/uniform.cpp",
|
"nodes/uniform/uniform.cpp",
|
||||||
|
"nodes/uniform/greyscale_uniform.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
if env["tools"]:
|
if env["tools"]:
|
||||||
|
@ -21,6 +21,7 @@ def get_doc_classes():
|
|||||||
"MatMakerGDEditor",
|
"MatMakerGDEditor",
|
||||||
|
|
||||||
"MMUniform",
|
"MMUniform",
|
||||||
|
"GreyscaleUniform ",
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_doc_path():
|
def get_doc_path():
|
||||||
|
@ -1,68 +1,50 @@
|
|||||||
|
|
||||||
#include "greyscale_uniform.h"
|
#include "greyscale_uniform.h"
|
||||||
|
|
||||||
|
#include "../../editor/mm_graph_node.h"
|
||||||
|
|
||||||
Ref<Resource> GreyscaleUniform::get_uniform() {
|
Ref<MMNodeUniversalProperty> GreyscaleUniform::get_uniform() {
|
||||||
return uniform;
|
return uniform;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GreyscaleUniform::set_uniform(const Ref<Resource> &val) {
|
void GreyscaleUniform::set_uniform(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
uniform = val;
|
uniform = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GreyscaleUniform::_init_properties() {
|
||||||
|
if (!uniform.is_valid()) {
|
||||||
|
uniform.instance();
|
||||||
|
uniform->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
|
||||||
|
uniform->set_default_value(0.5);
|
||||||
|
uniform->set_slot_name("Value (Color)");
|
||||||
|
uniform->set_value_step(0.01);
|
||||||
|
uniform->set_value_range(Vector2(0, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
uniform->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_COLOR);
|
||||||
//tool;
|
register_output_property(uniform);
|
||||||
//export(Resource) ;
|
|
||||||
Ref<Resource> uniform;
|
|
||||||
|
|
||||||
void GreyscaleUniform::_init_properties() {
|
|
||||||
|
|
||||||
if (!uniform) {
|
|
||||||
uniform = MMNodeUniversalProperty.new();
|
|
||||||
uniform.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
|
|
||||||
uniform.set_default_value(0.5);
|
|
||||||
uniform.slot_name = "Value (Color)";
|
|
||||||
uniform.value_step = 0.01;
|
|
||||||
uniform.value_range = Vector2(0, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uniform.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_COLOR;
|
void GreyscaleUniform::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
register_output_property(uniform);
|
mm_graph_node->add_slot_float_universal(uniform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color GreyscaleUniform::_get_value_for(const Vector2 &uv, const int pseed) {
|
||||||
void GreyscaleUniform::_register_methods(const Variant &mm_graph_node) {
|
float f = uniform->get_value(uv);
|
||||||
mm_graph_node.add_slot_float_universal(uniform);
|
return Color(f, f, f, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GreyscaleUniform::GreyscaleUniform() {
|
||||||
Color GreyscaleUniform::_get_value_for(const Vector2 &uv, const int pseed) {
|
|
||||||
float f = uniform.get_value(uv);
|
|
||||||
return Color(f, f, f, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GreyscaleUniform::~GreyscaleUniform() {
|
||||||
}
|
}
|
||||||
|
|
||||||
GreyscaleUniform::GreyscaleUniform() {
|
void GreyscaleUniform::_bind_methods() {
|
||||||
uniform;
|
ClassDB::bind_method(D_METHOD("get_uniform"), &GreyscaleUniform::get_uniform);
|
||||||
}
|
ClassDB::bind_method(D_METHOD("set_uniform", "value"), &GreyscaleUniform::set_uniform);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "uniform", PROPERTY_HINT_RESOURCE_TYPE, "Ref<MMNodeUniversalProperty>"), "set_uniform", "get_uniform");
|
||||||
GreyscaleUniform::~GreyscaleUniform() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void GreyscaleUniform::_bind_methods() {
|
|
||||||
ClassDB::bind_method(D_METHOD("get_uniform"), &GreyscaleUniform::get_uniform);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_uniform", "value"), &GreyscaleUniform::set_uniform);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "uniform", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_uniform", "get_uniform");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_init_properties"), &GreyscaleUniform::_init_properties);
|
|
||||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &GreyscaleUniform::_register_methods);
|
|
||||||
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &GreyscaleUniform::_get_value_for);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("_init_properties"), &GreyscaleUniform::_init_properties);
|
||||||
|
ClassDB::bind_method(D_METHOD("_get_value_for", "uv", "pseed"), &GreyscaleUniform::_get_value_for);
|
||||||
|
}
|
||||||
|
@ -1,29 +1,27 @@
|
|||||||
#ifndef GREYSCALE_UNIFORM_H
|
#ifndef GREYSCALE_UNIFORM_H
|
||||||
#define GREYSCALE_UNIFORM_H
|
#define GREYSCALE_UNIFORM_H
|
||||||
|
|
||||||
|
#include "../mm_node.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class GreyscaleUniform : public MMNode {
|
class GreyscaleUniform : public MMNode {
|
||||||
GDCLASS(GreyscaleUniform, MMNode);
|
GDCLASS(GreyscaleUniform, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_uniform();
|
||||||
|
void set_uniform(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_uniform();
|
void _init_properties();
|
||||||
void set_uniform(const Ref<Resource> &val);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
|
Color _get_value_for(const Vector2 &uv, const int pseed);
|
||||||
|
|
||||||
void _init_properties();
|
GreyscaleUniform();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
~GreyscaleUniform();
|
||||||
Color _get_value_for(const Vector2 &uv, const int pseed);
|
|
||||||
|
|
||||||
GreyscaleUniform();
|
protected:
|
||||||
~GreyscaleUniform();
|
static void _bind_methods();
|
||||||
|
|
||||||
protected:
|
Ref<MMNodeUniversalProperty> uniform;
|
||||||
static void _bind_methods();
|
|
||||||
|
|
||||||
//tool
|
|
||||||
//export(Resource)
|
|
||||||
Ref<Resource> uniform;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,6 +42,7 @@ SOFTWARE.
|
|||||||
#include "editor_plugin.h"
|
#include "editor_plugin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "nodes/uniform/greyscale_uniform.h"
|
||||||
#include "nodes/uniform/uniform.h"
|
#include "nodes/uniform/uniform.h"
|
||||||
|
|
||||||
static _MMAlgos *_mm_algos_singleton = nullptr;
|
static _MMAlgos *_mm_algos_singleton = nullptr;
|
||||||
@ -61,7 +62,9 @@ void register_material_maker_types() {
|
|||||||
ClassDB::register_class<MatMakerGDEditor>();
|
ClassDB::register_class<MatMakerGDEditor>();
|
||||||
|
|
||||||
ClassDB::register_class<MMUniform>();
|
ClassDB::register_class<MMUniform>();
|
||||||
|
ClassDB::register_class<GreyscaleUniform>();
|
||||||
MMAlgos::register_node_class("Uniform", "MMUniform");
|
MMAlgos::register_node_class("Uniform", "MMUniform");
|
||||||
|
MMAlgos::register_node_class("Uniform", "GreyscaleUniform");
|
||||||
|
|
||||||
_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