Pixel-Composer/scripts/node_dynasurf/node_dynasurf.gml

112 lines
3.7 KiB
Plaintext
Raw Normal View History

2023-09-11 16:08:58 +02:00
function Node_DynaSurf(_x, _y, _group = noone) : Node_Collection(_x, _y, _group) constructor {
name = "Dynamic Surface";
color = COLORS.node_blend_dynaSurf;
reset_all_child = true;
draw_input_overlay = false;
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("dynaSurf", self, VALUE_TYPE.dynaSurface, noone));
2023-09-11 16:08:58 +02:00
2024-08-08 06:57:51 +02:00
custom_input_index = array_length(inputs);
custom_output_index = array_length(outputs);
2023-09-11 16:08:58 +02:00
2024-05-03 13:40:46 +02:00
if(NODE_NEW_MANUAL) { #region
2023-09-11 16:08:58 +02:00
var _input = nodeBuild("Node_DynaSurf_In", -256, -32, self);
var _output = nodeBuild("Node_DynaSurf_Out", 256, -32, self);
2024-08-08 06:57:51 +02:00
_output.inputs[0].setFrom(_input.outputs[0]);
2023-09-11 16:08:58 +02:00
var _yy = -32 + 24;
2024-08-08 06:57:51 +02:00
var _nx = nodeBuild("Node_PCX_fn_var", 128, _yy, self).setDisplayName("x"); _output.inputs[1].setFrom(_nx .outputs[0]); _yy += 24;
var _ny = nodeBuild("Node_PCX_fn_var", 128, _yy, self).setDisplayName("y"); _output.inputs[2].setFrom(_ny .outputs[0]); _yy += 24;
var _nsx = nodeBuild("Node_PCX_fn_var", 128, _yy, self).setDisplayName("sx"); _output.inputs[3].setFrom(_nsx .outputs[0]); _yy += 24;
var _nsy = nodeBuild("Node_PCX_fn_var", 128, _yy, self).setDisplayName("sy"); _output.inputs[4].setFrom(_nsy .outputs[0]); _yy += 24;
var _nang = nodeBuild("Node_PCX_fn_var", 128, _yy, self).setDisplayName("angle"); _output.inputs[5].setFrom(_nang.outputs[0]); _yy += 24;
var _nclr = nodeBuild("Node_PCX_fn_var", 128, _yy, self).setDisplayName("color"); _output.inputs[6].setFrom(_nclr.outputs[0]); _yy += 24;
var _nalp = nodeBuild("Node_PCX_fn_var", 128, _yy, self).setDisplayName("alpha"); _output.inputs[7].setFrom(_nalp.outputs[0]); _yy += 24;
2023-09-11 16:08:58 +02:00
2024-08-08 06:57:51 +02:00
_nsx.inputs[0].setValue(1);
_nsy.inputs[0].setValue(1);
_nclr.inputs[0].setValue(c_white);
_nalp.inputs[0].setValue(1);
_yy += 64;
var _outW = nodeBuild("Node_DynaSurf_Out_Width", 256, _yy, self)
var _surW = nodeBuild("Node_PCX_fn_Surface_Width", 128, _yy, self)
2024-08-08 06:57:51 +02:00
_surW.inputs[0].setFrom(_input.outputs[0]);
_outW.inputs[0].setFrom(_surW.outputs[0]);
2023-09-11 16:08:58 +02:00
_yy += 64;
var _outH = nodeBuild("Node_DynaSurf_Out_Height", 256, _yy, self)
var _surH = nodeBuild("Node_PCX_fn_Surface_Height", 128, _yy, self)
2024-08-08 06:57:51 +02:00
_surH.inputs[0].setFrom(_input.outputs[0]);
_outH.inputs[0].setFrom(_surH.outputs[0]);
2023-10-02 10:45:30 +02:00
RENDER_ALL
2023-09-14 16:29:39 +02:00
} #endregion
2023-09-11 16:08:58 +02:00
2023-09-14 16:29:39 +02:00
static setRenderStatus = function(result) { #region
rendered = result;
if(result)
for( var i = 0, n = array_length(nodes); i < n; i++ ) {
var _n = nodes[i];
if(!is_instanceof(_n, Node_DynaSurf_Out) &&
!is_instanceof(_n, Node_DynaSurf_Out_Width) &&
!is_instanceof(_n, Node_DynaSurf_Out_Height))
continue;
if(_n.rendered) continue;
rendered = false;
break;
}
if(rendered) exitGroup();
if(!result && group != noone)
group.setRenderStatus(result);
2023-09-14 16:29:39 +02:00
} #endregion
2023-09-14 16:29:39 +02:00
static setDynamicSurface = function() { #region
var _dyna = new compute_dynaSurf();
for( var i = 0, n = array_length(nodes); i < n; i++ ) {
var _n = nodes[i];
2023-09-11 16:08:58 +02:00
if(is_instanceof(_n, Node_DynaSurf_Out))
2024-08-08 06:57:51 +02:00
_dyna.drawFn = _n.outputs[0].getValue();
2023-09-11 16:08:58 +02:00
if(is_instanceof(_n, Node_DynaSurf_Out_Width))
2024-08-08 06:57:51 +02:00
_dyna.widthFn = _n.outputs[0].getValue();
2023-09-11 16:08:58 +02:00
if(is_instanceof(_n, Node_DynaSurf_Out_Height))
2024-08-08 06:57:51 +02:00
_dyna.heightFn = _n.outputs[0].getValue();
2023-09-11 16:08:58 +02:00
}
2024-08-08 06:57:51 +02:00
outputs[0].setValue(_dyna);
2023-09-14 16:29:39 +02:00
} #endregion
static update = function() {}
}
2023-09-14 16:29:39 +02:00
function dynaSurf_output_getNextNode() { #region
if(!is_instanceof(group, Node_DynaSurf)) return [];
2024-08-08 06:57:51 +02:00
var junc = group.outputs[0];
var nodes = [];
2023-12-19 14:30:34 +01:00
for(var j = 0; j < array_length(junc.value_to); j++) {
var _to = junc.value_to[j];
if(!_to.node.isRenderActive()) continue;
if(!_to.node.active || _to.value_from == noone)
continue;
if(_to.value_from.node != group)
continue;
array_push(nodes, _to.node);
}
return nodes;
2023-09-14 16:29:39 +02:00
} #endregion