Pixel-Composer/scripts/node_armature_sample/node_armature_sample.gml

62 lines
1.8 KiB
Text
Raw Normal View History

2023-07-14 20:34:35 +02:00
function Node_Armature_Sample(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
2024-03-28 14:18:02 +01:00
name = "Armature Sample";
setDimension(96, 72);
2023-07-14 20:34:35 +02:00
2024-08-18 09:13:41 +02:00
newInput(0, nodeValue_Armature("Armature", self, noone))
2023-07-14 20:34:35 +02:00
.setVisible(true, true)
.rejectArray();
2024-08-18 06:16:20 +02:00
newInput(1, nodeValue_Text("Bone name", self, ""));
2023-07-14 20:34:35 +02:00
2024-08-18 09:13:41 +02:00
newInput(2, nodeValue_Float("Sample point", self, 0))
.setDisplay(VALUE_DISPLAY.slider);
2023-07-14 20:34:35 +02:00
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Position", self, VALUE_TYPE.integer, [ 0, 0 ]))
2023-07-14 20:34:35 +02:00
.setDisplay(VALUE_DISPLAY.vector);
2023-09-14 16:29:39 +02:00
#region ++++ attributes ++++
2023-07-14 20:34:35 +02:00
attributes.display_name = true;
attributes.display_bone = 0;
array_push(attributeEditors, "Display");
array_push(attributeEditors, ["Display name", function() { return attributes.display_name; },
new checkBox(function() {
attributes.display_name = !attributes.display_name;
})]);
array_push(attributeEditors, ["Display bone", function() { return attributes.display_bone; },
new scrollBox(["Octahedral", "Stick"], function(ind) {
attributes.display_bone = ind;
})]);
2023-09-14 16:29:39 +02:00
#endregion
2023-07-14 20:34:35 +02:00
2024-03-14 14:35:19 +01:00
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
var _b = getInputData(0);
2023-07-14 20:34:35 +02:00
if(_b == noone) return;
_b.draw(attributes, false, _x, _y, _s, _mx, _my);
2023-09-14 16:29:39 +02:00
} #endregion
2023-07-14 20:34:35 +02:00
2023-09-26 14:35:25 +02:00
static update = function() { #region
var _bone = getInputData(0);
var _name = getInputData(1);
var _prog = getInputData(2);
2023-07-14 20:34:35 +02:00
if(_bone == noone) return;
_name = string_trim(_name);
var _b = _bone.findBoneByName(_name);
if(_b == noone) {
2024-08-08 06:57:51 +02:00
outputs[0].setValue([0, 0]);
2023-07-14 20:34:35 +02:00
return;
}
var _p = _b.getPoint(_prog);
2024-08-08 06:57:51 +02:00
outputs[0].setValue([_p.x, _p.y]);
2023-09-14 16:29:39 +02:00
} #endregion
2023-07-14 20:34:35 +02:00
2023-09-14 16:29:39 +02:00
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
2023-07-14 20:34:35 +02:00
var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_armature_sample, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
2023-09-14 16:29:39 +02:00
} #endregion
2023-07-14 20:34:35 +02:00
}