Pixel-Composer/scripts/node_dynasurf/node_dynasurf.gml

112 lines
3.8 KiB
Text
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;
outputs[| 0] = nodeValue("dynaSurf", self, JUNCTION_CONNECT.output, VALUE_TYPE.dynaSurface, noone);
2023-09-11 16:08:58 +02:00
custom_input_index = ds_list_size(inputs);
custom_output_index = ds_list_size(outputs);
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);
_output.inputs[| 0].setFrom(_input.outputs[| 0]);
2023-09-11 16:08:58 +02:00
var _yy = -32 + 24;
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;
_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)
_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)
_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 = ds_list_size(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();
2023-09-11 16:08:58 +02:00
for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) {
var _n = nodes[| i];
if(is_instanceof(_n, Node_DynaSurf_Out))
_dyna.drawFn = _n.outputs[| 0].getValue();
if(is_instanceof(_n, Node_DynaSurf_Out_Width))
_dyna.widthFn = _n.outputs[| 0].getValue();
if(is_instanceof(_n, Node_DynaSurf_Out_Height))
_dyna.heightFn = _n.outputs[| 0].getValue();
}
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 [];
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