Pixel-Composer/scripts/node_grid_warp/node_grid_warp.gml

71 lines
2.0 KiB
Plaintext
Raw Normal View History

2024-10-10 13:13:21 +02:00
function Node_Grid_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Grid Warp";
newInput(0, nodeValue_Surface("Surface in", self));
newInput(1, nodeValue_Bool("Active", self, true));
active_index = 1;
newInput(2, nodeValue_Int("Grid", self, 1, "Amount of grid subdivision. Higher number means more grid, detail."))
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 4, 1 ] })
.rejectArray();
2024-10-10 13:13:21 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
function createNewInput() {
var index = array_length(inputs);
var i = index - input_fix_len;
newInput(index, nodeValue_Vec2($"Anchor {i}", self, [ 0, 0 ]))
.setUnitRef(function(index) /*=>*/ {return getDimension(index)});
array_push(input_display_list, index);
return inputs[index];
}
2024-10-10 13:13:21 +02:00
input_display_list = [ 1, 0,
["Mesh", false], 2,
["Anchors", true],
2024-10-10 13:13:21 +02:00
];
setDynamicInput(1, false);
2024-10-10 13:13:21 +02:00
attribute_surface_depth();
attribute_interpolation();
static resetDisplay = function() {
input_display_list = array_clone(input_display_list_raw, 1);
for( var i = input_display_len, n = array_length(inputs); i < n; i++ )
array_push(input_display_list, i);
}
2024-10-10 13:13:21 +02:00
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
var mx = (_mx - _x) / _s;
var my = (_my - _y) / _s;
}
static step = function() {
}
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _surf = _data[0];
var _grid = _data[2];
var _aamo = (_grid + 1) * (_grid + 1);
var _iamo = getInputAmount();
if(_iamo < _aamo) {
repeat(_aamo - _iamo) createNewInput();
resetDisplay();
} else if(_iamo > _aamo) {
array_resize(inputs, input_fix_len + _aamo);
resetDisplay();
}
2024-10-10 13:13:21 +02:00
}
}