2023-02-28 09:43:01 +01:00
|
|
|
function Node_Anim_Curve(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2023-02-14 05:32:32 +01:00
|
|
|
name = "Evaluate Curve";
|
2022-01-13 05:24:03 +01:00
|
|
|
update_on_frame = true;
|
|
|
|
|
2024-05-02 11:05:02 +02:00
|
|
|
setDimension(96, 48);
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(0, nodeValue("Curve", self, JUNCTION_CONNECT.input, VALUE_TYPE.curve, CURVE_DEF_01));
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[1] = nodeValue_Float("Progress", self, 0)
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(2, nodeValue_Float("Minimum", self, 0));
|
|
|
|
newInput(3, nodeValue_Float("Maximum", self, 1));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(4, nodeValue_Bool("Animated", self, false));
|
2023-10-07 09:09:18 +02:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0] = nodeValue_Output("Curve", self, VALUE_TYPE.float, []);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-10-07 09:09:18 +02:00
|
|
|
input_display_list = [ 0, 4, 1, 2, 3 ];
|
|
|
|
|
|
|
|
static step = function() {
|
|
|
|
var _anim = getSingleValue(4);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[1].setVisible(!_anim);
|
2023-10-07 09:09:18 +02:00
|
|
|
}
|
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
2022-01-13 05:24:03 +01:00
|
|
|
var curve = _data[0];
|
2023-10-09 16:07:33 +02:00
|
|
|
var time = _data[4]? CURRENT_FRAME / (TOTAL_FRAMES - 1) : _data[1];
|
2022-01-13 05:24:03 +01:00
|
|
|
var _min = _data[2];
|
|
|
|
var _max = _data[3];
|
2023-02-14 05:32:32 +01:00
|
|
|
var val = eval_curve_x(curve, time) * (_max - _min) + _min;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[0].editWidget.progress_draw = time;
|
2023-10-07 09:09:18 +02:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
2023-01-04 02:30:04 +01:00
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
2023-02-14 05:32:32 +01:00
|
|
|
draw_sprite_fit(s_node_curve_eval, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|