pandemonium_engine/modules/material_maker/nodes/uniform/uniform.cpp

44 lines
1.1 KiB
C++
Raw Normal View History

2022-06-16 15:29:08 +02:00
#include "uniform.h"
#include "../../editor/mm_graph_node.h"
2022-06-16 15:29:08 +02:00
Ref<MMNodeUniversalProperty> MMUniform::get_uniform() {
return uniform;
2022-06-16 15:29:08 +02:00
}
void MMUniform::set_uniform(const Ref<MMNodeUniversalProperty> &val) {
uniform = val;
2022-06-16 15:29:08 +02:00
}
void MMUniform::_init_properties() {
if (!uniform.is_valid()) {
uniform.instance();
uniform->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_COLOR);
uniform->set_default_value(Color(1, 1, 1, 1));
}
2022-06-16 15:29:08 +02:00
uniform->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_COLOR);
register_output_property(uniform);
2022-06-16 15:29:08 +02:00
}
void MMUniform::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_color_universal(uniform);
2022-06-16 15:29:08 +02:00
}
Color MMUniform::_get_value_for(const Vector2 &uv, const int pseed) {
return uniform->get_value(uv);
2022-06-16 15:29:08 +02:00
}
MMUniform::MMUniform() {
2022-06-16 15:29:08 +02:00
}
MMUniform::~MMUniform() {
2022-06-16 15:29:08 +02:00
}
void MMUniform::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_uniform"), &MMUniform::get_uniform);
ClassDB::bind_method(D_METHOD("set_uniform", "value"), &MMUniform::set_uniform);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "uniform", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_uniform", "get_uniform");
}