2023-07-08 20:29:23 +02:00
|
|
|
function Node_Rate_Remap(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
|
|
|
name = "Rate Remap";
|
2023-10-02 14:41:44 +02:00
|
|
|
use_cache = CACHE_USE.manual;
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2024-08-07 11:48:39 +02:00
|
|
|
inputs[| 0] = nodeValue_Surface("Surface", self);
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2024-08-07 13:20:45 +02:00
|
|
|
inputs[| 1] = nodeValue_Float("Framerate", self, 10)
|
2024-06-10 05:53:25 +02:00
|
|
|
.setValidator(VV_min(1));
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2024-08-07 13:20:45 +02:00
|
|
|
inputs[| 2] = nodeValue_Bool("Active", self, true);
|
2023-07-08 20:29:23 +02:00
|
|
|
active_index = 2;
|
|
|
|
|
2024-08-07 13:20:45 +02:00
|
|
|
outputs[| 0] = nodeValue_Output("Surface", self, VALUE_TYPE.surface, noone);
|
2023-07-08 20:29:23 +02:00
|
|
|
|
|
|
|
input_display_list = [ 2,
|
2023-12-23 09:39:55 +01:00
|
|
|
["Remap", false], 0, 1
|
2023-07-08 20:29:23 +02:00
|
|
|
];
|
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
2023-07-08 20:29:23 +02:00
|
|
|
var _surf = _data[0];
|
|
|
|
var _rate = _data[1];
|
2023-10-09 16:07:33 +02:00
|
|
|
var _time = CURRENT_FRAME;
|
2023-07-08 20:29:23 +02:00
|
|
|
var _step = PROJECT.animator.framerate / _rate;
|
|
|
|
var _targ = floor(_time / _step) * _step;
|
|
|
|
|
|
|
|
cacheCurrentFrameIndex(_surf, _array_index);
|
|
|
|
var s = getCacheFrameIndex(_targ, _array_index);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|