2024-02-15 14:23:26 +01:00
|
|
|
function Node_Shape_Map(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
|
|
|
name = "Shape Map";
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[0] = nodeValue_Surface("Surface in", self);
|
2024-02-15 14:23:26 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[1] = nodeValue_Bool("Active", self, true);
|
2024-02-15 14:23:26 +01:00
|
|
|
active_index = 1;
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[2] = nodeValue_Enum_Scroll("Shape", self, 0, [ new scrollItem("Circle", s_node_shape_circle, 0),
|
2024-05-25 04:51:52 +02:00
|
|
|
new scrollItem("Polygon", s_node_shape_misc, 1), ]);
|
2024-02-15 14:23:26 +01:00
|
|
|
|
2024-08-12 13:42:05 +02:00
|
|
|
inputs[3] = nodeValue_Vec2("Map Scale", self, [ 4, 1 ]);
|
2024-02-15 14:23:26 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[4] = nodeValue_Float("Radius", self, 0.5);
|
2024-02-15 14:23:26 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[5] = nodeValue_Int("Sides", self, 4);
|
2024-02-15 14:23:26 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[6] = nodeValue_Float("Scale", self, 1)
|
2024-02-15 14:23:26 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 2, 0.01 ] });
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[7] = nodeValue_Rotation("Angle", self, 0);
|
2024-02-15 14:23:26 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0] = nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone);
|
2024-02-15 14:23:26 +01:00
|
|
|
|
|
|
|
input_display_list = [ 1,
|
|
|
|
["Surfaces", true], 0,
|
2024-03-17 14:24:24 +01:00
|
|
|
["Shape", false], 2, 5, 6, 7,
|
2024-02-15 14:23:26 +01:00
|
|
|
["Mapping", false], 3,
|
|
|
|
];
|
|
|
|
|
|
|
|
attribute_surface_depth();
|
|
|
|
attribute_oversample();
|
|
|
|
attribute_interpolation();
|
|
|
|
|
|
|
|
static step = function() { #region
|
|
|
|
var _shape = getInputData(2);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[5].setVisible(_shape == 1);
|
2024-02-15 14:23:26 +01:00
|
|
|
} #endregion
|
|
|
|
|
|
|
|
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
|
|
|
|
var _shape = _data[2];
|
|
|
|
var _scale = _data[3];
|
|
|
|
var _radius = _data[4];
|
|
|
|
var _sides = _data[5];
|
|
|
|
var _sca = _data[6];
|
|
|
|
var _rot = _data[7];
|
|
|
|
|
|
|
|
var _dim = surface_get_dimension(_data[0]);
|
|
|
|
|
|
|
|
if(_shape == 0) {
|
|
|
|
surface_set_shader(_outSurf, sh_shape_map_circle);
|
|
|
|
shader_set_interpolation(_data[0]);
|
2024-06-24 13:49:54 +02:00
|
|
|
shader_set_2("scale", _scale);
|
2024-02-15 14:23:26 +01:00
|
|
|
shader_set_f("txScale", _sca);
|
|
|
|
shader_set_f("angle", _rot);
|
|
|
|
|
|
|
|
draw_surface_safe(_data[0]);
|
|
|
|
surface_reset_shader();
|
|
|
|
|
|
|
|
} else if(_shape == 1) {
|
|
|
|
surface_set_shader(_outSurf, sh_shape_map_polygon);
|
|
|
|
shader_set_interpolation(_data[0]);
|
|
|
|
shader_set_f("sides", _sides);
|
2024-06-24 13:49:54 +02:00
|
|
|
shader_set_2("scale", _scale);
|
2024-02-15 14:23:26 +01:00
|
|
|
shader_set_f("txScale", _sca);
|
|
|
|
shader_set_f("angle", _rot);
|
|
|
|
|
|
|
|
draw_surface_safe(_data[0]);
|
|
|
|
surface_reset_shader();
|
|
|
|
}
|
|
|
|
|
|
|
|
return _outSurf;
|
|
|
|
} #endregion
|
|
|
|
}
|