2024-07-26 09:38:39 +02:00
|
|
|
function Node_Vector3(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2024-02-20 09:29:36 +01:00
|
|
|
name = "Vector3";
|
|
|
|
color = COLORS.node_blend_number;
|
2024-03-28 14:18:02 +01:00
|
|
|
setDimension(96, 32 + 24 * 3);
|
2024-02-20 09:29:36 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[0] = nodeValue_Float("x", self, 0)
|
2024-02-20 09:29:36 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[1] = nodeValue_Float("y", self, 0)
|
2024-02-20 09:29:36 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[2] = nodeValue_Float("z", self, 0)
|
2024-02-20 09:29:36 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(3, nodeValue_Bool("Integer", self, false));
|
2024-02-20 09:29:36 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0] = nodeValue_Output("Vector", self, VALUE_TYPE.float, [ 0, 0, 0 ])
|
2024-02-20 09:29:36 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
2024-07-26 09:38:39 +02:00
|
|
|
static step = function() {
|
2024-02-20 09:29:36 +01:00
|
|
|
var int = getInputData(3);
|
2024-07-26 09:38:39 +02:00
|
|
|
for( var i = 0; i < 3; i++ )
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[i].setType(int? VALUE_TYPE.integer : VALUE_TYPE.float);
|
2024-02-20 09:29:36 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0].setType(int? VALUE_TYPE.integer : VALUE_TYPE.float);
|
2024-07-26 09:38:39 +02:00
|
|
|
}
|
2024-02-20 09:29:36 +01:00
|
|
|
|
2024-07-26 09:38:39 +02:00
|
|
|
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
2024-02-20 09:29:36 +01:00
|
|
|
var vec = [ _data[0], _data[1], _data[2] ];
|
|
|
|
for( var i = 0, n = array_length(vec); i < n; i++ )
|
|
|
|
vec[i] = _data[3]? round(vec[i]) : vec[i];
|
|
|
|
|
|
|
|
return vec;
|
2024-07-26 09:38:39 +02:00
|
|
|
}
|
2024-02-20 09:29:36 +01:00
|
|
|
|
2024-07-26 09:38:39 +02:00
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
2024-02-20 09:29:36 +01:00
|
|
|
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
|
|
|
|
var vec = getSingleValue(0,, true);
|
2024-03-31 05:36:11 +02:00
|
|
|
var v0 = array_safe_get_fast(vec, 0);
|
|
|
|
var v1 = array_safe_get_fast(vec, 1);
|
|
|
|
var v2 = array_safe_get_fast(vec, 2);
|
2024-02-20 09:29:36 +01:00
|
|
|
|
|
|
|
var str = $"{v0}\n{v1}\n{v2}";
|
|
|
|
|
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
|
|
var ss = string_scale(str, bbox.w, bbox.h);
|
|
|
|
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
|
2024-07-26 09:38:39 +02:00
|
|
|
}
|
|
|
|
}
|