Pixel-Composer/scripts/node_atlas_get/node_atlas_get.gml

63 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;
2024-08-08 06:57:51 +02:00
inputs[0] = nodeValue_Surface("Atlas", self)
2023-04-16 15:26:52 +02:00
.setVisible(true, true);
2024-08-08 06:57:51 +02:00
outputs[0] = nodeValue_Output("Surface", self, VALUE_TYPE.surface, [])
2023-04-16 15:26:52 +02:00
.setArrayDepth(1);
2024-08-08 06:57:51 +02:00
outputs[1] = nodeValue_Output("Position", self, VALUE_TYPE.float, [])
2023-04-16 15:26:52 +02:00
.setDisplay(VALUE_DISPLAY.vector)
.setArrayDepth(1);
2024-08-08 06:57:51 +02:00
outputs[2] = nodeValue_Output("Rotation", self, VALUE_TYPE.float, [])
2023-04-16 15:26:52 +02:00
.setArrayDepth(1);
2024-08-08 06:57:51 +02:00
outputs[3] = nodeValue_Output("Scale", self, VALUE_TYPE.float, [])
2023-04-16 15:26:52 +02:00
.setDisplay(VALUE_DISPLAY.vector)
.setArrayDepth(1);
2024-08-08 06:57:51 +02:00
outputs[4] = nodeValue_Output("Blend", self, VALUE_TYPE.color, [])
2023-04-16 15:26:52 +02:00
.setArrayDepth(1);
2024-08-08 06:57:51 +02:00
outputs[5] = nodeValue_Output("Alpha", self, VALUE_TYPE.float, [])
2023-04-16 15:26:52 +02:00
.setArrayDepth(1);
2023-10-09 16:07:33 +02:00
static update = function(frame = CURRENT_FRAME) {
var atl = getInputData(0);
2023-04-16 15:26:52 +02:00
if(atl == noone) return;
2024-04-27 05:10:20 +02:00
if(!is_array(atl)) atl = [ atl ];
if(array_empty(atl)) return;
2023-04-16 15:26:52 +02:00
2024-04-27 05:10:20 +02:00
var n = array_length(atl);
var surf = array_create(n);
var posi = array_create(n);
var rota = array_create(n);
var scal = array_create(n);
var blns = array_create(n);
var alph = array_create(n);
2023-04-16 15:26:52 +02:00
2024-04-27 05:10:20 +02:00
for( var i = 0; i < n; i++ ) {
var _at = atl[i];
if(!is_instanceof(_at, SurfaceAtlas)) continue;
surf[i] = _at.getSurface();
posi[i] = [ _at.x, _at.y ];
rota[i] = _at.rotation;
scal[i] = [ _at.sx, _at.sy ];
blns[i] = _at.blend;
alph[i] = _at.alpha;
2023-04-16 15:26:52 +02:00
}
2024-08-08 06:57:51 +02:00
outputs[0].setValue(surf);
outputs[1].setValue(posi);
outputs[2].setValue(rota);
outputs[3].setValue(scal);
outputs[4].setValue(blns);
outputs[5].setValue(alph);
2023-04-16 15:26:52 +02:00
}
}