[3D Transform] Add camera object in 3D preview.

This commit is contained in:
Tanasart 2024-08-26 11:54:36 +07:00
parent c1b18c3471
commit a88a6d8e1a
14 changed files with 382 additions and 193 deletions

View file

@ -2,8 +2,8 @@
"$GMObject":"",
"%Name":"Obj_FirebaseFirestore_Document_Set",
"eventList":[
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":7,"eventType":6,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":7,"eventType":6,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
],
"managed":true,
"name":"Obj_FirebaseFirestore_Document_Set",

View file

@ -2,8 +2,8 @@
"$GMObject":"",
"%Name":"o_dialog_file_name_action",
"eventList":[
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
],
"managed":true,
"name":"o_dialog_file_name_action",

View file

@ -22,9 +22,9 @@ event_inherited();
tb_edit.align = fa_left;
tb_edit.font = f_p2;
node = noone;
display_list = [];
type = 1;
node = noone;
display_list = [];
type = 1;
junction_list = noone;
function setNode(node, type) {
@ -88,7 +88,7 @@ event_inherited();
draw_text_add(ed_x + ui(8), _y + hg / 2 - 1, disp[0]);
}
} else {
var ind = junction_list[| disp];
var ind = junction_list[disp];
draw_set_text(f_p2, fa_left, fa_center, ind.color_display);
draw_text_add(hg + ui(8), _y + hg / 2 - 1, ind.name);
}

View file

@ -2,10 +2,10 @@
"$GMObject":"",
"%Name":"o_dialog_menubox",
"eventList":[
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":1,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":1,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
],
"managed":true,
"name":"o_dialog_menubox",

View file

@ -2,25 +2,25 @@
"$GMObject":"",
"%Name":"o_main",
"eventList":[
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":2,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":5,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":2,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":3,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":4,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":20,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":60,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":62,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":68,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":69,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":70,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":9,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":10,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":2,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":5,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":2,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":3,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":4,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":20,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":60,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":62,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":68,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":69,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":70,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":9,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":10,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
],
"managed":true,
"name":"o_main",

View file

@ -6,6 +6,8 @@
#endregion
function menuCall(menu_id = "", menu = [], _x = 0, _y = 0, align = fa_left, context = noone) {
if(array_empty(menu)) return noone;
_x = _x == 0? mouse_mx + ui(4) : _x;
_y = _y == 0? mouse_my + ui(4) : _y;

View file

@ -1,17 +1,18 @@
function curveBox(_onModify) : widget() constructor {
onModify = _onModify;
curr_data = [];
onModify = _onModify;
curr_data = [];
anc_mirror = [];
h = 200;
curve_surface = surface_create(1, 1);
node_dragging = -1;
node_drag_typ = -1;
node_drag_break = false;
h = 200;
height_drag = false;
height_my = 0;
height_ss = 0;
show_coord = false;
height_drag = false;
height_my = 0;
height_ss = 0;
show_coord = false;
minx = 0; maxx = 1;
miny = 0; maxy = 1;
@ -30,6 +31,12 @@ function curveBox(_onModify) : widget() constructor {
grid_step = 0.10;
grid_show = true;
scale_control = true;
control_zoom = 64;
selecting = noone;
select_type = 0;
cw = 0;
ch = 0;
@ -39,7 +46,7 @@ function curveBox(_onModify) : widget() constructor {
tb_shift.label = "Shift";
tb_scale.label = "Scale";
static get_x = function(val) { return cw * (val - minx) / (maxx - minx); }
static get_x = function(val) { return cw * (val - minx) / (maxx - minx) ; }
static get_y = function(val) { return ch * (1 - (val - miny) / (maxy - miny)); }
static setInteract = function(interactable = noone) {
@ -81,8 +88,8 @@ function curveBox(_onModify) : widget() constructor {
var _h = h - ui(4);
var _amo = array_length(_data);
var _shf = _amo % 6;
var _amo = array_length(_data);
_shf = _amo % 6;
var points = (_amo - _shf) / 6;
var _shift = 0;
@ -107,7 +114,7 @@ function curveBox(_onModify) : widget() constructor {
curve_surface = surface_verify(curve_surface, cw, ch);
if(node_dragging != -1) { #region editing
if(node_dragging != -1) { // editing
show_coord = true;
_data = array_clone(_data);
@ -153,15 +160,30 @@ function curveBox(_onModify) : widget() constructor {
var _my = 1 - (_m[1] - _y) / ch;
_my = lerp(miny, maxy, _my);
var _w_spc = node_drag_typ > 0? _data[node_dragging + 6] - _px : _px - _data[node_dragging - 6];
if(key_mod_press(CTRL) || grid_snap) _mx = value_snap(_mx, grid_step);
_data[node_dragging - 2] = (_px - _mx) * node_drag_typ / _w_spc;
_data[node_dragging + 2] = (_mx - _px) * node_drag_typ / _w_spc;
var _scax = scale_control? (node_drag_typ > 0? _data[node_dragging + 6] - _px : _px - _data[node_dragging - 6]) : control_zoom / cw;
var _scay = scale_control? _scax : control_zoom / ch;
if(key_mod_press(CTRL) || grid_snap) _mx = value_snap(_mx, grid_step);
if(key_mod_press(CTRL) || grid_snap) _my = value_snap(_my, grid_step);
_data[node_dragging - 1] = clamp(_py - _my, -1, 1) * node_drag_typ / _w_spc;
_data[node_dragging + 3] = clamp(_my - _py, -1, 1) * node_drag_typ / _w_spc;
if(node_drag_break) {
if(node_drag_typ == 1) {
_data[node_dragging + 2] = (_mx - _px) * node_drag_typ / _scax;
_data[node_dragging + 3] = clamp(_my - _py, -1, 1) * node_drag_typ / _scay;
} else {
_data[node_dragging - 2] = (_px - _mx) * node_drag_typ / _scax;
_data[node_dragging - 1] = clamp(_py - _my, -1, 1) * node_drag_typ / _scay;
}
} else {
_data[node_dragging - 2] = (_px - _mx) * node_drag_typ / _scax;
_data[node_dragging + 2] = (_mx - _px) * node_drag_typ / _scax;
_data[node_dragging - 1] = clamp(_py - _my, -1, 1) * node_drag_typ / _scay;
_data[node_dragging + 3] = clamp(_my - _py, -1, 1) * node_drag_typ / _scay;
}
display_pos_x = node_drag_typ? _data[node_dragging - 2] : _data[node_dragging + 2];
display_pos_y = node_drag_typ? _data[node_dragging - 1] : _data[node_dragging + 3];
@ -177,7 +199,7 @@ function curveBox(_onModify) : widget() constructor {
UNDO_HOLDING = false;
}
} #endregion
}
var node_hovering = -1;
var node_hover_typ = -1;
@ -234,13 +256,16 @@ function curveBox(_onModify) : widget() constructor {
var _x0 = _data[ind + 2];
var _y0 = _data[ind + 3];
var _w_prev = i > 0? _x0 - _data[ind - 6 + 2] : 1;
var _w_next = i < points - 1? _data[ind + 6 + 2] - _x0 : 1;
var _sca_bx = scale_control? (i > 0? _x0 - _data[ind - 6 + 2] : 1) : control_zoom / cw;
var _sca_by = scale_control? _sca_bx : control_zoom / ch;
var bx0 = _x0 + _data[ind + 0] * _w_prev;
var by0 = _y0 + _data[ind + 1] * _w_prev;
var ax0 = _x0 + _data[ind + 4] * _w_next;
var ay0 = _y0 + _data[ind + 5] * _w_next;
var _sca_ax = scale_control? (i < points - 1? _data[ind + 6 + 2] - _x0 : 1) : control_zoom / cw;
var _sca_ay = scale_control? _sca_ax : control_zoom / ch;
var bx0 = _x0 + _data[ind + 0] * _sca_bx;
var by0 = _y0 + _data[ind + 1] * _sca_by;
var ax0 = _x0 + _data[ind + 4] * _sca_ax;
var ay0 = _y0 + _data[ind + 5] * _sca_ay;
// print($"{_x0}, {_y0} | {_data[ind + 0]}, {_data[ind + 1]} | {_data[ind + 4]}, {_data[ind + 5]}");
@ -435,7 +460,7 @@ function curveBox(_onModify) : widget() constructor {
}
#endregion
if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + cw, _y + ch)) { #region
if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + cw, _y + ch)) {
show_coord = true;
hovering = true;
@ -462,41 +487,86 @@ function curveBox(_onModify) : widget() constructor {
node_dragging = node_hovering;
node_drag_typ = node_hover_typ;
if(node_hover_typ != 0) {
var _cax = _data[node_dragging - 2];
var _cay = _data[node_dragging - 1];
var _cbx = _data[node_dragging + 2];
var _cby = _data[node_dragging + 3];
node_drag_break = key_mod_press(SHIFT);
if(_cax != -_cbx || _cay != -_cby)
node_drag_break = true;
}
}
} else if(mouse_press(mb_right, active)) {
var node_point = (node_hovering - _shf - 2) / 6;
if(node_hover_typ == 0 && node_point > 0 && node_point < points - 1) {
array_delete(_data, _shf + node_point * 6, 6);
if(onModify(_data))
UNDO_HOLDING = true;
}
// var node_point = (node_hovering - _shf - 2) / 6;
// if(node_hover_typ == 0 && node_point > 0 && node_point < points - 1) {
// array_delete(_data, _shf + node_point * 6, 6);
// if(onModify(_data)) UNDO_HOLDING = true;
// }
}
if(node_hovering == -1 && mouse_press(mb_right, active)) {
menuCall("widget_curve", [
menuItemGroup(__txt("Presets"), [
[ [THEME.curve_presets, 0], function() { onModify(CURVE_DEF_00); } ],
[ [THEME.curve_presets, 1], function() { onModify(CURVE_DEF_11); } ],
[ [THEME.curve_presets, 2], function() { onModify(CURVE_DEF_01); } ],
[ [THEME.curve_presets, 3], function() { onModify(CURVE_DEF_10); } ],
]),
-1,
menuItem(__txt("Reset View"), function() {
minx = 0; maxx = 1;
miny = 0; maxy = 1;
}),
menuItem(grid_show? __txt("Hide grid") : __txt("Show grid"), function() { grid_show = !grid_show; }),
menuItem(__txt("Snap to grid"), function() { grid_snap = !grid_snap; },,, function() { return grid_snap } ),
menuItemGroup(__txt("Grid size"), [
[ "1%", function() { grid_step = 0.01; } ],
[ "5%", function() { grid_step = 0.05; } ],
[ "10%", function() { grid_step = 0.10; } ],
[ "25%", function() { grid_step = 0.25; } ],
]),
], rx + _m[0], ry + _m[1]);
if(mouse_press(mb_right, active)) {
var rmx = rx + _m[0];
var rmy = ry + _m[1];
if(node_hovering == -1 || node_hover_typ != 0) {
menuCall("widget_curve", [
menuItemGroup(__txt("Presets"), [
[ [THEME.curve_presets, 0], function() /*=>*/ { onModify(CURVE_DEF_00); } ],
[ [THEME.curve_presets, 1], function() /*=>*/ { onModify(CURVE_DEF_11); } ],
[ [THEME.curve_presets, 2], function() /*=>*/ { onModify(CURVE_DEF_01); } ],
[ [THEME.curve_presets, 3], function() /*=>*/ { onModify(CURVE_DEF_10); } ],
]),
-1,
menuItem(__txt("Reset View"), function() /*=>*/ {
minx = 0; maxx = 1;
miny = 0; maxy = 1;
}),
menuItem(__txt("Grid"), function() /*=>*/ { grid_show = !grid_show; }, noone, noone, function() /*=>*/ {return grid_show}),
menuItem(__txt("Snap to grid"), function() /*=>*/ { grid_snap = !grid_snap; }, noone, noone, function() /*=>*/ {return grid_snap}),
menuItemGroup(__txt("Grid size"), [
[ "1%", function() /*=>*/ { grid_step = 0.01; } ],
[ "5%", function() /*=>*/ { grid_step = 0.05; } ],
[ "10%", function() /*=>*/ { grid_step = 0.10; } ],
[ "25%", function() /*=>*/ { grid_step = 0.25; } ],
]),
menuItem(__txt("Scale Controls"), function() /*=>*/ { scale_control = !scale_control; }, noone, noone, function() /*=>*/ {return scale_control} ),
], rmx, rmy);
} else {
selecting = node_hovering;
select_type = node_hover_typ;
select_data = _data;
var node_point = (selecting - _shf - 2) / 6;
var _menu = [];
array_push(_menu, menuItem(__txt("Reset Controls"), function() /*=>*/ {
var node_point = (selecting - _shf - 2) / 6;
var _ind = _shf + node_point * 6;
select_data[@ _ind + 0] = -1 / 3;
select_data[@ _ind + 1] = 0;
select_data[@ _ind + 4] = 1 / 3;
select_data[@ _ind + 5] = 0;
onModify(select_data);
}));
if(node_point > 0 && node_point < points - 1) {
array_push(_menu, menuItem(__txt("Delete Anchor"), function() /*=>*/ {
var node_point = (selecting - _shf - 2) / 6;
array_delete(select_data, _shf + node_point * 6, 6);
onModify(select_data);
}, THEME.cross));
}
menuCall("widget_curve", _menu, rmx, rmy);
}
}
} #endregion
}
draw_surface(curve_surface, _x, _y);

View file

@ -6,7 +6,29 @@
#macro CURVE_DEF_10 [0, 1, /**/ 0, 0, 0, 1, 1/3, -1/3, /**/ -1/3, 1/3, 1, 0, 0, 0]
#macro CURVE_DEF_11 [0, 1, /**/ 0, 0, 0, 1, 1/3, 0, /**/ -1/3, 0, 1, 1, 0, 0]
function draw_curve(x0, y0, _w, _h, _bz, minx = 0, maxx = 1, miny = 0, maxy = 1, _shift = 0, _scale = 1) { #region
//////////////////////////////////////////////////////////////////////////////////////////// DRAW ////////////////////////////////////////////////////////////////////////////////////////////
function eval_curve_segment_t_position(_t, bbz) {
var _t2 = _t * _t;
var _t3 = _t * _t * _t;
var _T = 1 - _t;
var _T2 = _T * _T;
var _T3 = _T * _T * _T;
return [
_T3 * 0
+ 3 * _T2 * _t * bbz[1]
+ 3 * _T * _t2 * bbz[3]
+ _t3 * 1,
_T3 * bbz[0]
+ 3 * _T2 * _t * bbz[2]
+ 3 * _T * _t2 * bbz[4]
+ _t3 * bbz[5]
];
}
function draw_curve(x0, y0, _w, _h, _bz, minx = 0, maxx = 1, miny = 0, maxy = 1, _shift = 0, _scale = 1) {
var _amo = array_length(_bz);
var _shf = _amo % 6;
@ -19,22 +41,15 @@ function draw_curve(x0, y0, _w, _h, _bz, minx = 0, maxx = 1, miny = 0, maxy = 1,
for( var i = 0; i < segments; i++ ) {
var ind = _shf + i * 6;
var _x0 = _bz[ind + 2];
var _y0 = _bz[ind + 3];
var ax0 = _x0 + _bz[ind + 4];
var ay0 = _y0 + _bz[ind + 5];
var _x1 = _bz[ind + 6 + 2];
var _y1 = _bz[ind + 6 + 3];
var bx1 = _x1 + _bz[ind + 6 + 0];
var by1 = _y1 + _bz[ind + 6 + 1];
var _x0 = _bz[ind + 2];
var _y0 = _bz[ind + 3];
var _x1 = _bz[ind + 6 + 2];
var _y1 = _bz[ind + 6 + 3];
var _xr = _x1 - _x0;
var _yr = _y1 - _y0;
var smp = ceil(_xr / rngx * 32);
var bbz = [ _y0, ax0, ay0, bx1, by1, _y1 ];
//if(_x1 < minx) continue;
var smp = max(abs(_yr) * _h / 2, ceil(_xr / rngx * 32));
if(i == 0) {
var _rx = _x0 * _scale + _shift;
@ -62,6 +77,14 @@ function draw_curve(x0, y0, _w, _h, _bz, minx = 0, maxx = 1, miny = 0, maxy = 1,
draw_line(x0 + _w, _ny, _nx, _ny);
}
var ax0 = _bz[ind + 4] + _x0;
var ay0 = _bz[ind + 5] + _y0;
var bx1 = _bz[ind + 6 + 0] + _x1;
var by1 = _bz[ind + 6 + 1] + _y1;
var bbz = [ _y0, ax0, ay0, bx1, by1, _y1 ];
// print($"{i}, {bbz}")
for(var j = 0; j <= smp; j++) {
var t = j / smp;
var _r = eval_curve_segment_t_position(t, bbz);
@ -85,36 +108,21 @@ function draw_curve(x0, y0, _w, _h, _bz, minx = 0, maxx = 1, miny = 0, maxy = 1,
if(_nx > x0 + _w) return;
}
}
} #endregion
}
function eval_curve_segment_t_position(_t, _bz) { #region
var _t2 = _t * _t;
var _t3 = _t * _t * _t;
var _T = 1 - _t;
var _T2 = _T * _T;
var _T3 = _T * _T * _T;
return [
_T3 * 0
+ 3 * _T2 * _t * _bz[1]
+ 3 * _T * _t2 * _bz[3]
+ _t3 * 1,
_T3 * _bz[0]
+ 3 * _T2 * _t * _bz[2]
+ 3 * _T * _t2 * _bz[4]
+ _t3 * _bz[5]
];
} #endregion
//////////////////////////////////////////////////////////////////////////////////////////// EVAL ////////////////////////////////////////////////////////////////////////////////////////////
function eval_curve_segment_t(_bz, t) { #region
return power(1 - t, 3) * _bz[0]
+ 3 * power(1 - t, 2) * t * _bz[2]
+ 3 * (1 - t) * power(t, 2) * _bz[4]
+ power(t, 3) * _bz[5];
} #endregion
function eval_curve_segment_t(_bz, t) {
// if(_bz[1] == 0 && _bz[2] == 0 && _bz[3] == 0 && _bz[4] == 0)
// return lerp(_bz[0], _bz[5], t);
return power(1 - t, 3) * _bz[0]
+ 3 * power(1 - t, 2) * t * _bz[2]
+ 3 * (1 - t) * power(t, 2) * _bz[4]
+ power(t, 3) * _bz[5];
}
function eval_curve_x(_bz, _x, _tolr = 0.00001) { #region
function eval_curve_x(_bz, _x, _tolr = 0.00001) {
static _CURVE_DEF_01 = [0, 1, /**/ 0, 0, 0, 0, 1/3, 1/3, /**/ -1/3, -1/3, 1, 1, 0, 0];
static _CURVE_DEF_10 = [0, 1, /**/ 0, 0, 0, 1, 1/3, -1/3, /**/ -1/3, 1/3, 1, 0, 0, 0];
static _CURVE_DEF_11 = [0, 1, /**/ 0, 0, 0, 1, 1/3, 0, /**/ -1/3, 0, 1, 1, 0, 0];
@ -160,9 +168,9 @@ function eval_curve_x(_bz, _x, _tolr = 0.00001) { #region
}
return array_safe_get_fast(_bz, array_length(_bz) - 3);
} #endregion
}
function eval_curve_segment_x(_bz, _x, _tolr = 0.00001) { #region
function eval_curve_segment_x(_bz, _x, _tolr = 0.00001) {
var st = 0;
var ed = 1;
@ -172,7 +180,9 @@ function eval_curve_segment_x(_bz, _x, _tolr = 0.00001) { #region
if(_x <= 0) return _bz[0];
if(_x >= 1) return _bz[5];
if(_bz[0] == _bz[2] && _bz[0] == _bz[4] && _bz[0] == _bz[5]) return _bz[0];
// if(_bz[1] == 0 && _bz[2] == 0 && _bz[3] == 0 && _bz[4] == 0)
// return lerp(_bz[0], _bz[5], _x);
repeat(_binRep) {
var _1xt = 1 - _xt;
@ -214,7 +224,9 @@ function eval_curve_segment_x(_bz, _x, _tolr = 0.00001) { #region
_xt = clamp(_xt, 0, 1);
return eval_curve_segment_t(_bz, _xt);
} #endregion
}
//////////////////////////////////////////////////////////////////////////////////////////// MISC ////////////////////////////////////////////////////////////////////////////////////////////
function bezier_range(bz) { return [ min(bz[0], bz[2], bz[4], bz[5]), max(bz[0], bz[2], bz[4], bz[5]) ]; }
@ -232,7 +244,7 @@ function curveMap(_bz, _prec = 32, _tolr = 0.00001) constructor {
for( var i = 0; i < _prec; i++ )
map[i] = eval_curve_x(bz, i * size, tolr);
static get = function(i) { #region
static get = function(i) {
INLINE
var _ind = clamp(i, 0, 1) * (prec - 1);
@ -242,10 +254,10 @@ function curveMap(_bz, _prec = 32, _tolr = 0.00001) constructor {
if(_indL == _indH) return map[_ind];
return lerp(map[_indL], map[_indH], _indF);
} #endregion
}
}
function draw_curve_bezier(x0, y0, cx0, cy0, cx1, cy1, x1, y1, prec = 32) { #region
function draw_curve_bezier(x0, y0, cx0, cy0, cx1, cy1, x1, y1, prec = 32) {
var ox, oy, nx, ny;
var _st = 1 / prec;
@ -269,4 +281,4 @@ function draw_curve_bezier(x0, y0, cx0, cy0, cx1, cy1, x1, y1, prec = 32) { #reg
ox = nx;
oy = ny;
}
} #endregion
}

View file

@ -34,7 +34,7 @@ function __3dObject() constructor {
material_index = [];
texture_flip = false;
static checkParameter = function(params = {}, forceUpdate = false) { #region
static checkParameter = function(params = {}, forceUpdate = false) {
var _keys = struct_get_names(params);
var check = false;
for( var i = 0, n = array_length(_keys); i < n; i++ ) {
@ -45,11 +45,11 @@ function __3dObject() constructor {
}
if(forceUpdate || check) onParameterUpdate();
} #endregion
}
static onParameterUpdate = function() {}
static generateNormal = function(_s = normal_draw_size) { #region
static generateNormal = function(_s = normal_draw_size) {
if(render_type != pr_trianglelist) return;
NVB = array_create(object_counts);
@ -69,9 +69,9 @@ function __3dObject() constructor {
}
vertex_end(NVB[i]);
}
} #endregion
}
static buildVertex = function(_vertex) { #region
static buildVertex = function(_vertex) {
var _buffer = vertex_create_buffer();
vertex_begin(_buffer, VF);
switch(VF) {
@ -96,9 +96,9 @@ function __3dObject() constructor {
vertex_end(_buffer);
return _buffer;
} #endregion
}
static build = function(_buffer = VB, _vertex = vertex, counts = object_counts) { #region
static build = function(_buffer = VB, _vertex = vertex, counts = object_counts) {
if(is_array(_buffer)) {
for( var i = 0, n = array_length(_buffer); i < n; i++ )
if(_buffer[i] != noone) vertex_delete_buffer(_buffer[i])
@ -111,7 +111,7 @@ function __3dObject() constructor {
_res[i] = buildVertex(_vertex[i]);
return _res;
} #endregion
}
static preSubmitVertex = function(scene = {}) {}
static postSubmitVertex = function(scene = {}) {}
@ -126,16 +126,16 @@ function __3dObject() constructor {
static submit = function(scene = {}, shader = noone) { submitVertex(scene, shader); }
static submitUI = function(scene = {}, shader = noone) { submitVertex(scene, shader); }
static submitSel = function(scene = {}, shader = noone) { #region
static submitSel = function(scene = {}, shader = noone) {
var _s = variable_clone(scene);
_s.show_normal = false;
submitVertex(_s, sh_d3d_silhouette);
} #endregion
}
static submitShader = function(scene = {}, shader = noone) {}
static submitShadow = function(scene = {}, object = noone) {}
static submitVertex = function(scene = {}, shader = noone, param = defDrawParam) { #region
static submitVertex = function(scene = {}, shader = noone, param = defDrawParam) {
var _shader = sh_d3d_default;
switch(VF) {
@ -193,7 +193,7 @@ function __3dObject() constructor {
shader_reset();
if(scene.show_normal) { #region
if(scene.show_normal) {
if(NVB == noone) generateNormal();
if(NVB != noone) {
shader_set(sh_d3d_wireframe);
@ -203,16 +203,16 @@ function __3dObject() constructor {
vertex_submit(NVB[i], pr_linelist, -1);
shader_reset();
}
} #endregion
}
transform.clearMatrix();
matrix_set(matrix_world, matrix_build_identity());
postSubmitVertex(scene);
} #endregion
}
static clone = function(_vertex = true, cloneBuffer = false) { #region
static clone = function(_vertex = true, cloneBuffer = false) {
var _obj = new __3dObject();
if(_vertex) {
@ -251,14 +251,14 @@ function __3dObject() constructor {
_obj.texture_flip = texture_flip;
return _obj;
} #endregion
}
static destroy = function() { #region
static destroy = function() {
for( var i = 0, n = array_length(VB); i < n; i++ )
vertex_delete_buffer(VB[i]);
VB = [];
onDestroy();
} #endregion
}
static onDestroy = function() { }

View file

@ -39,7 +39,7 @@
LATEST_VERSION = 1_16_00;
VERSION = 1_17_11_0;
SAVE_VERSION = 1_17_10_0;
VERSION_STRING = "1.17.11.003";
VERSION_STRING = "1.17.11.004";
BUILD_NUMBER = 1_17_11_0;
HOTKEYS = ds_map_create();

View file

@ -104,20 +104,20 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
}
static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) {
var _rot = inputs[1].display_data.angle_display;
var _rot = inputs[1].display_data.angle_display;
tools = _rot == QUARTERNION_DISPLAY.quarterion? tool_quate : tool_euler;
if(_rot == QUARTERNION_DISPLAY.euler && isUsingTool("Rotate"))
PANEL_PREVIEW.tool_current = noone;
var object = getPreviewObjects();
if(array_empty(object)) return;
object = object[0];
var preObj = getPreviewObjects();
if(array_empty(preObj)) return;
preObj = preObj[0];
var _pos = inputs[0].getValue(,,, true);
var _vpos = new __vec3( _pos[0], _pos[1], _pos[2] );
if(isUsingTool("Transform")) drawGizmoPosition(0, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel);
else if(isUsingTool("Rotate")) drawGizmoRotation(1, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel);
if(isUsingTool("Transform")) drawGizmoPosition(0, preObj, _vpos, active, params, _mx, _my, _snx, _sny, _panel);
else if(isUsingTool("Rotate")) drawGizmoRotation(1, preObj, _vpos, active, params, _mx, _my, _snx, _sny, _panel);
else if(isUsingTool("Move Target")) {
var _lkpos = inputs[in_d3d + 10].getValue(,,, true);
var _lkvpos = new __vec3( _lkpos[0], _lkpos[1], _lkpos[2] );
@ -157,7 +157,7 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
if(index == in_d3d + 9) PANEL_PREVIEW.tool_current = noone;
}
static step = function() { #region
static step = function() {
var _proj = getInputData(in_d3d + 3);
var _posm = getInputData(in_d3d + 9);
var _ao = getInputData(in_d3d + 17);
@ -190,14 +190,14 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
tool_attribute.context = 1;
break;
}
} #endregion
}
static preProcessData = function(_data) {}
static submitShadow = function() {}
static submitShader = function() {}
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
static processData = function(_output, _data, _output_index, _array_index = 0) {
#region data
var _pos = _data[0];
var _rot = _data[1];
@ -374,18 +374,18 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
surface_depth_disable(true);
return [ _finalRender, _normal, _depth ];
} #endregion
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {}
static getPreviewObject = function() { #region
static getPreviewObject = function() {
var _scene = array_safe_get_fast(all_inputs, in_d3d + 4, noone);
if(is_array(_scene))
_scene = array_safe_get_fast(_scene, preview_index, noone);
return _scene;
} #endregion
}
static getPreviewObjects = function() { #region
static getPreviewObjects = function() {
var _posm = getInputData(in_d3d + 9);
var _scene = array_safe_get_fast(all_inputs, in_d3d + 4, noone);
@ -399,18 +399,18 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
}
return [ object, _scene ];
} #endregion
}
static getPreviewObjectOutline = function() { return isUsingTool("Move Target")? [ lookat ] : [ object ]; }
static doSerialize = function(_map) { #region
static doSerialize = function(_map) {
_map.camera_base_length = in_cam;
} #endregion
}
static postDeserialize = function() { #region
static postDeserialize = function() {
var _tlen = struct_try_get(load_map, "camera_base_length", in_d3d + 22);
for( var i = _tlen; i < in_cam; i++ )
array_insert(load_map.inputs, i, noone);
} #endregion
}
}

View file

@ -4,13 +4,14 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y,
preview_channel = 1;
object = new __3dPlane();
object.checkParameter({ normal: 2 });
objectPreview = new __3dPlane();
objectPreview.checkParameter({ normal: 2 });
objectPreview = new __3dPlane();
materialPreview = new __d3dMaterial();
object.checkParameter({ normal: 2 });
objectPreview.checkParameter({ normal: 2 });
objectPreview.materials[0] = materialPreview;
camObj = new __3dCamera_object();
camera = camera_create();
newInput(in_mesh + 0, nodeValue_Surface("Surface", self))
@ -62,6 +63,11 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y,
var _proj = _data[in_mesh + 1];
var _fov = _data[in_mesh + 2];
var _tile = _data[in_mesh + 3];
camObj.transform.position.set(new __vec3(0, 0, 2));
camObj.transform.rotation = new BBMOD_Quaternion().FromEuler(0, -90, 180);
camObj.transform.scale.set(.5, .5, .5);
if(!is_surface(_surf)) return 0;
if(_output_index == 0) {
@ -109,10 +115,11 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y,
return 0;
}
static getPreviewObject = function() { return objectPreview; }
static getPreviewValues = function() { return outputs[1].getValue(); }
static getPreviewObject = function() { return objectPreview; }
static getPreviewObjects = function() { return [ camObj, objectPreview ]; }
static getPreviewValues = function() { return outputs[1].getValue(); }
static getGraphPreviewSurface = function() { return noone; }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover = false, _focus = false) {
if(!previewable) return;

View file

@ -117,7 +117,7 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
newInput(28, nodeValue_Float("Shape Scale", self, 1))
.setDisplay(VALUE_DISPLAY.slider);
newInput(29, nodeValue_Slider_Range("Curve", self, [ 0, 1 ]));
newInput(29, nodeValue("Curve", self, CONNECT_TYPE.input, VALUE_TYPE.curve, CURVE_DEF_01));
outputs[0] = nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone);
@ -125,7 +125,8 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
["Output", false], 0, 6,
["Transform", false], 15, 3, 16, 17, 19, 28,
["Shape", false], 14, 2, 9, 4, 13, 5, 7, 8, 21, 22, 23, 24, 25, 26, 27,
["Render", true], 10, 12, 20, 29, 18,
["Render", true], 10, 18,
["Height", true, 12], 29, 20,
["Background", true, 1], 11,
];
@ -241,7 +242,7 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
var _tile = _data[18];
var _rotat = _data[19];
var _level = _data[20];
var _levelO = _data[29];
var _curve = _data[29];
var _shpSca = _data[28];
var _center = [ 0, 0 ];
@ -556,9 +557,10 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
shader_set_i("drawBG", _bg);
shader_set_i("drawDF", _df);
shader_set_2("dfLevel", _level);
shader_set_2("dfLevelOut", _levelO);
shader_set_i("tile", _tile);
shader_set_f("corner", _corner);
shader_set_f("w_curve", _curve);
shader_set_i("w_amount", array_length(_curve));
shader_set_2("center", _center);
shader_set_2("scale", _scale );

View file

@ -9,10 +9,11 @@ uniform int aa;
uniform int sides;
uniform int tile;
uniform int drawBG;
uniform int drawDF;
uniform vec2 dfLevel;
uniform vec2 dfLevelOut;
uniform int drawBG;
uniform int drawDF;
uniform vec2 dfLevel;
uniform float w_curve[64];
uniform int w_amount;
uniform float rotation;
uniform float angle;
@ -49,6 +50,99 @@ float dot2(in vec2 v ) { return dot(v,v); }
mat2 rot(in float ang) { return mat2(cos(ang), - sin(ang), sin(ang), cos(ang)); }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
return _y0 * pow(1. - prog, 3.) +
ay0 * 3. * pow(1. - prog, 2.) * prog +
by1 * 3. * (1. - prog) * pow(prog, 2.) +
_y1 * pow(prog, 3.);
}
float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) {
float st = 0.;
float ed = 1.;
float _prec = 0.0001;
float _xt = _x;
int _binRep = 8;
if(_x <= 0.) return _y0;
if(_x >= 1.) return _y1;
if(_y0 == ay0 && _y0 == by1 && _y0 == _y1) return _y0;
for(int i = 0; i < _binRep; i++) {
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
+ pow(_xt, 3.);
if(abs(_ftx - _x) < _prec)
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
if(_xt < _x) st = _xt;
else ed = _xt;
_xt = (st + ed) / 2.;
}
int _newRep = 16;
for(int i = 0; i < _newRep; i++) {
float slope = ( 9. * ax0 - 9. * bx1 + 3.) * _xt * _xt
+ (-12. * ax0 + 6. * bx1) * _xt
+ 3. * ax0;
float _ftx = 3. * pow(1. - _xt, 2.) * _xt * ax0
+ 3. * (1. - _xt) * pow(_xt, 2.) * bx1
+ pow(_xt, 3.)
- _x;
_xt -= _ftx / slope;
if(abs(_ftx) < _prec)
break;
}
_xt = clamp(_xt, 0., 1.);
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
}
float curveEval(in float[64] curve, in int amo, in float _x) {
int _shf = amo - int(floor(float(amo) / 6.) * 6.);
int _segs = (amo - _shf) / 6 - 1;
float _shift = _shf > 0? curve[0] : 0.;
float _scale = _shf > 1? curve[1] : 1.;
_x = _x / _scale - _shift;
_x = clamp(_x, 0., 1.);
for( int i = 0; i < _segs; i++ ) {
int ind = _shf + i * 6;
float _x0 = curve[ind + 2];
float _y0 = curve[ind + 3];
//float bx0 = _x0 + curve[ind + 0];
//float by0 = _y0 + curve[ind + 1];
float ax0 = _x0 + curve[ind + 4];
float ay0 = _y0 + curve[ind + 5];
float _x1 = curve[ind + 6 + 2];
float _y1 = curve[ind + 6 + 3];
float bx1 = _x1 + curve[ind + 6 + 0];
float by1 = _y1 + curve[ind + 6 + 1];
//float ax1 = _x1 + curve[ind + 6 + 4];
//float ay1 = _y1 + curve[ind + 6 + 5];
if(_x < _x0) continue;
if(_x > _x1) continue;
return eval_curve_segment_x(_y0, ax0, ay0, bx1, by1, _y1, (_x - _x0) / (_x1 - _x0));
}
return curve[0];
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float sdRegularPolygon(in vec2 p, in float r, in int n, in float ang ) {
// these 4 lines can be precomputed for a given shape
float an = PI / float(n);
@ -298,6 +392,8 @@ float sdArrow( in vec2 p, float w1, float w2, float k ) { // The arrow goes from
return si*sqrt(di);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void main() {
vec2 coord = (v_vTexcoord - center) * mat2(cos(rotation), -sin(rotation), sin(rotation), cos(rotation)) / scale;
vec2 ratio = dimension / dimension.y;
@ -348,12 +444,12 @@ void main() {
color = cc;
if(drawDF == 1) {
color = -d;
color = smoothstep(dfLevelOut[0], dfLevelOut[1], clamp((color - dfLevel.x) / (dfLevel.y - dfLevel.x), 0., 1.));
color = clamp((color - dfLevel.x) / (dfLevel.y - dfLevel.x), 0., 1.);
color = curveEval(w_curve, w_amount, color);
color *= cc;
}
if(drawBG == 0)
gl_FragColor = vec4(v_vColour.rgb, color);
else
gl_FragColor = mix(bgColor, v_vColour, color);
if(drawBG == 0) gl_FragColor = vec4(v_vColour.rgb, v_vColour.a * color);
else gl_FragColor = mix(bgColor, v_vColour, color);
}