Pixel-Composer/scripts/node_atlas_get/node_atlas_get.gml

60 lines
1.7 KiB
Plaintext
Raw Normal View History

2023-04-16 15:26:52 +02:00
function Node_Atlas_Get(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Atlas Get";
previewable = true;
2023-10-06 11:51:11 +02:00
inputs[| 0] = nodeValue("Atlas", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone)
2023-04-16 15:26:52 +02:00
.setVisible(true, true);
outputs[| 0] = nodeValue("Surface", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, [])
.setArrayDepth(1);
outputs[| 1] = nodeValue("Position", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [])
.setDisplay(VALUE_DISPLAY.vector)
.setArrayDepth(1);
outputs[| 2] = nodeValue("Rotation", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [])
.setArrayDepth(1);
outputs[| 3] = nodeValue("Scale", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [])
.setDisplay(VALUE_DISPLAY.vector)
.setArrayDepth(1);
outputs[| 4] = nodeValue("Blend", self, JUNCTION_CONNECT.output, VALUE_TYPE.color, [])
.setArrayDepth(1);
outputs[| 5] = nodeValue("Alpha", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [])
.setArrayDepth(1);
2023-07-06 19:49:16 +02:00
static update = function(frame = PROJECT.animator.current_frame) {
var atl = getInputData(0);
2023-04-16 15:26:52 +02:00
if(atl == noone) return;
if(is_array(atl) && array_length(atl) == 0) return;
if(!is_array(atl))
atl = [ atl ];
var surf = [];
var posi = [];
var rota = [];
var scal = [];
var blns = [];
var alph = [];
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(atl); i < n; i++ ) {
2023-10-06 11:51:11 +02:00
surf[i] = atl[i].getSurface();
2023-04-16 15:26:52 +02:00
posi[i] = atl[i].position;
rota[i] = atl[i].rotation;
scal[i] = atl[i].scale;
blns[i] = atl[i].blend;
alph[i] = atl[i].alpha;
}
outputs[| 0].setValue(surf);
outputs[| 1].setValue(posi);
outputs[| 2].setValue(rota);
outputs[| 3].setValue(scal);
outputs[| 4].setValue(blns);
outputs[| 5].setValue(alph);
}
}