2023-09-05 20:31:36 +02:00
|
|
|
enum QUARTERNION_DISPLAY {
|
|
|
|
quarterion,
|
|
|
|
euler,
|
|
|
|
}
|
|
|
|
|
|
|
|
function quarternionBox(_onModify) : widget() constructor {
|
|
|
|
onModify = _onModify;
|
|
|
|
current_value = [];
|
|
|
|
|
|
|
|
onModifyIndex = function(index, val) {
|
|
|
|
var v = toNumber(val);
|
|
|
|
|
|
|
|
if(is_callable(onModify))
|
|
|
|
return onModify(index, v);
|
|
|
|
return noone;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = 4;
|
|
|
|
axis = [ "x", "y", "z", "w" ];
|
2023-09-28 15:10:41 +02:00
|
|
|
tooltip = new tooltipSelector("Angle type", [__txt("Quaternion"), __txt("Euler")]);
|
2023-09-05 20:31:36 +02:00
|
|
|
|
|
|
|
disp_w = noone;
|
|
|
|
clickable = true;
|
|
|
|
|
|
|
|
onModifySingle[0] = function(val) { return onModifyIndex(0, val); }
|
|
|
|
onModifySingle[1] = function(val) { return onModifyIndex(1, val); }
|
|
|
|
onModifySingle[2] = function(val) { return onModifyIndex(2, val); }
|
|
|
|
onModifySingle[3] = function(val) { return onModifyIndex(3, val); }
|
|
|
|
|
|
|
|
for(var i = 0; i < 4; i++) {
|
|
|
|
tb[i] = new textBox(TEXTBOX_INPUT.number, onModifySingle[i]);
|
|
|
|
tb[i].slidable = true;
|
2024-03-26 04:03:45 +01:00
|
|
|
tb[i].label = axis[i];
|
2023-09-05 20:31:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static setSlideSpeed = function(speed) {
|
|
|
|
for(var i = 0; i < size; i++)
|
2023-11-15 14:42:53 +01:00
|
|
|
tb[i].setSlidable(speed);
|
2023-09-05 20:31:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static setInteract = function(interactable) {
|
|
|
|
self.interactable = interactable;
|
|
|
|
|
|
|
|
for( var i = 0; i < size; i++ )
|
|
|
|
tb[i].interactable = interactable;
|
|
|
|
}
|
|
|
|
|
|
|
|
static register = function(parent = noone) {
|
|
|
|
for( var i = 0; i < size; i++ )
|
|
|
|
tb[i].register(parent);
|
|
|
|
}
|
|
|
|
|
2024-03-28 14:18:02 +01:00
|
|
|
static isHovering = function() {
|
|
|
|
for( var i = 0, n = array_length(tb); i < n; i++ ) if(tb[i].isHovering()) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-03-31 11:10:14 +02:00
|
|
|
static apply = function() {
|
|
|
|
for( var i = 0; i < size; i++ ) {
|
|
|
|
tb[i].apply();
|
|
|
|
current_value[i] = toNumber(tb[i]._input_text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-05 20:31:36 +02:00
|
|
|
static drawParam = function(params) {
|
2024-03-27 11:51:14 +01:00
|
|
|
setParam(params);
|
|
|
|
for(var i = 0; i < 4; i++) tb[i].setParam(params);
|
2024-03-26 04:03:45 +01:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
return draw(params.x, params.y, params.w, params.h, params.data, params.display_data, params.m);
|
2023-09-05 20:31:36 +02:00
|
|
|
}
|
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
static draw = function(_x, _y, _w, _h, _data, _display_data, _m) {
|
2023-09-05 20:31:36 +02:00
|
|
|
x = _x;
|
|
|
|
y = _y;
|
|
|
|
w = _w;
|
|
|
|
h = _h;
|
|
|
|
|
|
|
|
if(!is_array(_data)) return 0;
|
|
|
|
if(array_empty(_data)) return 0;
|
|
|
|
if(is_array(_data[0])) return 0;
|
|
|
|
|
|
|
|
current_value = _data;
|
|
|
|
|
2024-03-29 05:20:49 +01:00
|
|
|
var _bs = min(_h, ui(32));
|
2023-10-02 08:57:44 +02:00
|
|
|
var _disp = struct_try_get(_display_data, "angle_display");
|
2023-09-05 20:31:36 +02:00
|
|
|
|
2024-03-29 05:20:49 +01:00
|
|
|
if((_w - _bs) / 2 > ui(64)) {
|
|
|
|
var bx = _x + _w - _bs;
|
|
|
|
var by = _y + _h / 2 - _bs / 2;
|
|
|
|
tooltip.index = _disp;
|
|
|
|
|
|
|
|
if(buttonInstant(THEME.button_hide, bx, by, _bs, _bs, _m, iactive, ihover, tooltip, THEME.unit_angle, _disp, c_white) == 2) {
|
|
|
|
clickable = false;
|
|
|
|
_display_data.angle_display = (_disp + 1) % 2;
|
|
|
|
}
|
|
|
|
_w -= _bs + ui(8);
|
2023-09-05 20:31:36 +02:00
|
|
|
}
|
|
|
|
|
2023-09-17 13:23:24 +02:00
|
|
|
size = _disp? 3 : 4;
|
2023-09-05 20:31:36 +02:00
|
|
|
var ww = _w / size;
|
|
|
|
var bx = _x;
|
|
|
|
disp_w = disp_w == noone? ww : lerp_float(disp_w, ww, 3);
|
|
|
|
|
2023-11-15 14:42:53 +01:00
|
|
|
var _dispDat = _data;
|
|
|
|
|
2024-03-24 06:44:34 +01:00
|
|
|
draw_sprite_stretched_ext(THEME.textbox, 3, _x, _y, _w, _h, c_white, 1);
|
|
|
|
draw_sprite_stretched_ext(THEME.textbox, 0, _x, _y, _w, _h, c_white, 0.5 + 0.5 * interactable);
|
|
|
|
|
2023-09-05 20:31:36 +02:00
|
|
|
for(var i = 0; i < size; i++) {
|
2023-11-15 14:42:53 +01:00
|
|
|
var _a = _dispDat[i];
|
|
|
|
|
2024-03-24 06:44:34 +01:00
|
|
|
tb[i].hide = true;
|
2023-09-05 20:31:36 +02:00
|
|
|
tb[i].setFocusHover(clickable && active, hover);
|
2024-03-24 08:01:24 +01:00
|
|
|
tb[i].draw(bx, _y, disp_w, _h, _a, _m);
|
2023-09-05 20:31:36 +02:00
|
|
|
|
|
|
|
bx += disp_w;
|
|
|
|
}
|
|
|
|
|
|
|
|
clickable = true;
|
|
|
|
resetFocus();
|
|
|
|
|
|
|
|
return _h;
|
|
|
|
}
|
|
|
|
|
2024-03-31 11:10:14 +02:00
|
|
|
static clone = function() { #region
|
|
|
|
var cln = new quarternionBox(onModify);
|
|
|
|
|
|
|
|
return cln;
|
|
|
|
} #endregion
|
2023-09-05 20:31:36 +02:00
|
|
|
}
|