mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-19 22:24:23 +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",
|
||||
|
||||
"nodes/uniform/uniform.cpp",
|
||||
"nodes/uniform/greyscale_uniform.cpp",
|
||||
]
|
||||
|
||||
if env["tools"]:
|
||||
|
@ -21,6 +21,7 @@ def get_doc_classes():
|
||||
"MatMakerGDEditor",
|
||||
|
||||
"MMUniform",
|
||||
"GreyscaleUniform ",
|
||||
]
|
||||
|
||||
def get_doc_path():
|
||||
|
@ -1,68 +1,50 @@
|
||||
|
||||
#include "greyscale_uniform.h"
|
||||
|
||||
#include "../../editor/mm_graph_node.h"
|
||||
|
||||
Ref<Resource> GreyscaleUniform::get_uniform() {
|
||||
return uniform;
|
||||
Ref<MMNodeUniversalProperty> GreyscaleUniform::get_uniform() {
|
||||
return uniform;
|
||||
}
|
||||
|
||||
void GreyscaleUniform::set_uniform(const Ref<Resource> &val) {
|
||||
uniform = val;
|
||||
void GreyscaleUniform::set_uniform(const Ref<MMNodeUniversalProperty> &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));
|
||||
}
|
||||
|
||||
|
||||
//tool;
|
||||
//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->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_COLOR);
|
||||
register_output_property(uniform);
|
||||
}
|
||||
|
||||
uniform.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_COLOR;
|
||||
register_output_property(uniform);
|
||||
void GreyscaleUniform::_register_methods(MMGraphNode *mm_graph_node) {
|
||||
mm_graph_node->add_slot_float_universal(uniform);
|
||||
}
|
||||
|
||||
|
||||
void GreyscaleUniform::_register_methods(const Variant &mm_graph_node) {
|
||||
mm_graph_node.add_slot_float_universal(uniform);
|
||||
Color GreyscaleUniform::_get_value_for(const Vector2 &uv, const int pseed) {
|
||||
float f = uniform->get_value(uv);
|
||||
return Color(f, f, f, 1);
|
||||
}
|
||||
|
||||
|
||||
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() {
|
||||
}
|
||||
|
||||
GreyscaleUniform::GreyscaleUniform() {
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
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<MMNodeUniversalProperty>"), "set_uniform", "get_uniform");
|
||||
|
||||
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
|
||||
#define GREYSCALE_UNIFORM_H
|
||||
|
||||
#include "../mm_node.h"
|
||||
#include "../mm_node_universal_property.h"
|
||||
|
||||
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 set_uniform(const Ref<Resource> &val);
|
||||
void _init_properties();
|
||||
void _register_methods(MMGraphNode *mm_graph_node);
|
||||
Color _get_value_for(const Vector2 &uv, const int pseed);
|
||||
|
||||
void _init_properties();
|
||||
void _register_methods(const Variant &mm_graph_node);
|
||||
Color _get_value_for(const Vector2 &uv, const int pseed);
|
||||
GreyscaleUniform();
|
||||
~GreyscaleUniform();
|
||||
|
||||
GreyscaleUniform();
|
||||
~GreyscaleUniform();
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
//tool
|
||||
//export(Resource)
|
||||
Ref<Resource> uniform;
|
||||
Ref<MMNodeUniversalProperty> uniform;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -42,6 +42,7 @@ SOFTWARE.
|
||||
#include "editor_plugin.h"
|
||||
#endif
|
||||
|
||||
#include "nodes/uniform/greyscale_uniform.h"
|
||||
#include "nodes/uniform/uniform.h"
|
||||
|
||||
static _MMAlgos *_mm_algos_singleton = nullptr;
|
||||
@ -61,7 +62,9 @@ void register_material_maker_types() {
|
||||
ClassDB::register_class<MatMakerGDEditor>();
|
||||
|
||||
ClassDB::register_class<MMUniform>();
|
||||
ClassDB::register_class<GreyscaleUniform>();
|
||||
MMAlgos::register_node_class("Uniform", "MMUniform");
|
||||
MMAlgos::register_node_class("Uniform", "GreyscaleUniform");
|
||||
|
||||
_mm_algos_singleton = memnew(_MMAlgos);
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton()));
|
||||
|
Loading…
Reference in New Issue
Block a user