diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 91efdea2a..eae98f85d 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -197,7 +197,8 @@ {"name":"sh_normal_light","order":1,"path":"shaders/sh_normal_light/sh_normal_light.yy",}, {"name":"node_tool","order":9,"path":"scripts/node_tool/node_tool.yy",}, {"name":"sh_find_pixel","order":3,"path":"shaders/sh_find_pixel/sh_find_pixel.yy",}, - {"name":"__node_3d_camera","order":10,"path":"scripts/__node_3d_camera/__node_3d_camera.yy",}, + {"name":"d3d_light_point","order":16,"path":"scripts/d3d_light_point/d3d_light_point.yy",}, + {"name":"node_3d_camera","order":10,"path":"scripts/node_3d_camera/node_3d_camera.yy",}, {"name":"panel_preview_window","order":1,"path":"scripts/panel_preview_window/panel_preview_window.yy",}, {"name":"sh_scale3x","order":29,"path":"shaders/sh_scale3x/sh_scale3x.yy",}, {"name":"__node_3d","order":8,"path":"scripts/__node_3d/__node_3d.yy",}, @@ -286,6 +287,7 @@ {"name":"s_node_armature_sample","order":18,"path":"sprites/s_node_armature_sample/s_node_armature_sample.yy",}, {"name":"o_dialog_notifications","order":6,"path":"objects/o_dialog_notifications/o_dialog_notifications.yy",}, {"name":"sh_draw_color","order":8,"path":"shaders/sh_draw_color/sh_draw_color.yy",}, + {"name":"d3d_scene","order":15,"path":"scripts/d3d_scene/d3d_scene.yy",}, {"name":"s_node_array_find","order":2,"path":"sprites/s_node_array_find/s_node_array_find.yy",}, {"name":"fd_rectangle_set_velocity_time_step","order":17,"path":"scripts/fd_rectangle_set_velocity_time_step/fd_rectangle_set_velocity_time_step.yy",}, {"name":"fd_rectangle_set_collision_mask_sprite","order":1,"path":"scripts/fd_rectangle_set_collision_mask_sprite/fd_rectangle_set_collision_mask_sprite.yy",}, @@ -1070,6 +1072,7 @@ {"name":"s_node_text_length","order":9,"path":"sprites/s_node_text_length/s_node_text_length.yy",}, {"name":"s_node_grid_hex","order":4,"path":"sprites/s_node_grid_hex/s_node_grid_hex.yy",}, {"name":"sh_fd_visualize_colorize_glsl","order":13,"path":"shaders/sh_fd_visualize_colorize_glsl/sh_fd_visualize_colorize_glsl.yy",}, + {"name":"node_3d_light_point","order":2,"path":"scripts/node_3d_light_point/node_3d_light_point.yy",}, {"name":"s_node_pb_draw_fill","order":14,"path":"sprites/s_node_pb_draw_fill/s_node_pb_draw_fill.yy",}, {"name":"s_node_rate_remap","order":4,"path":"sprites/s_node_rate_remap/s_node_rate_remap.yy",}, {"name":"node_pb_draw_semi_ellipse","order":6,"path":"scripts/node_pb_draw_semi_ellipse/node_pb_draw_semi_ellipse.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index aad0aa84a..43ee6572b 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -708,7 +708,8 @@ {"id":{"name":"sh_normal_light","path":"shaders/sh_normal_light/sh_normal_light.yy",},}, {"id":{"name":"node_tool","path":"scripts/node_tool/node_tool.yy",},}, {"id":{"name":"sh_find_pixel","path":"shaders/sh_find_pixel/sh_find_pixel.yy",},}, - {"id":{"name":"__node_3d_camera","path":"scripts/__node_3d_camera/__node_3d_camera.yy",},}, + {"id":{"name":"d3d_light_point","path":"scripts/d3d_light_point/d3d_light_point.yy",},}, + {"id":{"name":"node_3d_camera","path":"scripts/node_3d_camera/node_3d_camera.yy",},}, {"id":{"name":"panel_preview_window","path":"scripts/panel_preview_window/panel_preview_window.yy",},}, {"id":{"name":"sh_scale3x","path":"shaders/sh_scale3x/sh_scale3x.yy",},}, {"id":{"name":"__node_3d","path":"scripts/__node_3d/__node_3d.yy",},}, @@ -806,6 +807,7 @@ {"id":{"name":"s_node_armature_sample","path":"sprites/s_node_armature_sample/s_node_armature_sample.yy",},}, {"id":{"name":"o_dialog_notifications","path":"objects/o_dialog_notifications/o_dialog_notifications.yy",},}, {"id":{"name":"sh_draw_color","path":"shaders/sh_draw_color/sh_draw_color.yy",},}, + {"id":{"name":"d3d_scene","path":"scripts/d3d_scene/d3d_scene.yy",},}, {"id":{"name":"s_node_array_find","path":"sprites/s_node_array_find/s_node_array_find.yy",},}, {"id":{"name":"fd_rectangle_set_velocity_time_step","path":"scripts/fd_rectangle_set_velocity_time_step/fd_rectangle_set_velocity_time_step.yy",},}, {"id":{"name":"fd_rectangle_set_collision_mask_sprite","path":"scripts/fd_rectangle_set_collision_mask_sprite/fd_rectangle_set_collision_mask_sprite.yy",},}, @@ -1700,6 +1702,7 @@ {"id":{"name":"s_node_text_length","path":"sprites/s_node_text_length/s_node_text_length.yy",},}, {"id":{"name":"s_node_grid_hex","path":"sprites/s_node_grid_hex/s_node_grid_hex.yy",},}, {"id":{"name":"sh_fd_visualize_colorize_glsl","path":"shaders/sh_fd_visualize_colorize_glsl/sh_fd_visualize_colorize_glsl.yy",},}, + {"id":{"name":"node_3d_light_point","path":"scripts/node_3d_light_point/node_3d_light_point.yy",},}, {"id":{"name":"s_node_pb_draw_fill","path":"sprites/s_node_pb_draw_fill/s_node_pb_draw_fill.yy",},}, {"id":{"name":"s_node_rate_remap","path":"sprites/s_node_rate_remap/s_node_rate_remap.yy",},}, {"id":{"name":"s_node_3d_cube","path":"sprites/s_node_3d_cube/s_node_3d_cube.yy",},}, diff --git a/objects/o_dialog_graph_view/Create_0.gml b/objects/o_dialog_graph_view/Create_0.gml index a084d5157..31c602035 100644 --- a/objects/o_dialog_graph_view/Create_0.gml +++ b/objects/o_dialog_graph_view/Create_0.gml @@ -2,22 +2,40 @@ event_inherited(); #region data - dialog_w = ui(280); - dialog_h = ui(60 + 40 * 3); + dialog_w = ui(320); destroy_on_click_out = true; + display_parameter = {}; #endregion #region data - cb_grid = new checkBox(function() { - PANEL_GRAPH.show_grid = !PANEL_GRAPH.show_grid; - }) + properties = [ + [ + new checkBox(function() { display_parameter.show_grid = !display_parameter.show_grid; }), + __txt("Grid"), + function() { return display_parameter.show_grid }, + ], + [ + new checkBox(function() { display_parameter.show_dimension = !display_parameter.show_dimension; }), + __txtx("graph_visibility_dim", "Dimension"), + function() { return display_parameter.show_dimension }, + ], + [ + new checkBox(function() { display_parameter.show_compute = !display_parameter.show_compute; }), + __txtx("graph_visibility_compute", "Compute time"), + function() { return display_parameter.show_compute }, + ], + [ + new checkBox(function() { display_parameter.avoid_label = !display_parameter.avoid_label; }), + __txtx("graph_visibility_avoid_label", "Avoid Label"), + function() { return display_parameter.avoid_label }, + ], + [ + new slider(50, 100, 1, function(val) { display_parameter.preview_scale = val; }), + __txtx("graph_visibility_preview_scale", "Preview Scale"), + function() { return display_parameter.preview_scale }, + ], + ] - cb_dim = new checkBox(function() { - PANEL_GRAPH.show_dimension = !PANEL_GRAPH.show_dimension; - }) - - cb_com = new checkBox(function() { - PANEL_GRAPH.show_compute = !PANEL_GRAPH.show_compute; - }) + dialog_h = ui(60 + 40 * array_length(properties)); #endregion \ No newline at end of file diff --git a/objects/o_dialog_graph_view/Draw_64.gml b/objects/o_dialog_graph_view/Draw_64.gml index 1050f4875..738354c9d 100644 --- a/objects/o_dialog_graph_view/Draw_64.gml +++ b/objects/o_dialog_graph_view/Draw_64.gml @@ -12,24 +12,28 @@ if !ready exit; #region draw var yy = dialog_y + ui(64); + var ww = ui(128); + var wh = TEXTBOX_HEIGHT; - cb_grid.setFocusHover(sFOCUS, sHOVER); - cb_grid.register(); - draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text); - draw_text(dialog_x + ui(32), yy, __txt("Grid")); - cb_grid.draw(dialog_x + dialog_w - ui(48), yy, PANEL_GRAPH.show_grid, mouse_ui,, fa_center, fa_center); - - yy += ui(40); - cb_dim.setFocusHover(sFOCUS, sHOVER); - cb_dim.register(); - draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text); - draw_text(dialog_x + ui(32), yy, __txtx("graph_visibility_dim", "Dimension")); - cb_dim.draw(dialog_x + dialog_w - ui(48), yy, PANEL_GRAPH.show_dimension, mouse_ui,, fa_center, fa_center); - - yy += ui(40); - cb_com.setFocusHover(sFOCUS, sHOVER); - cb_com.register(); - draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text); - draw_text(dialog_x + ui(32), yy, __txtx("graph_visibility_compute", "Compute time")); - cb_com.draw(dialog_x + dialog_w - ui(48), yy, PANEL_GRAPH.show_compute, mouse_ui,, fa_center, fa_center); + for( var i = 0, n = array_length(properties); i < n; i++ ) { + var _prop = properties[i]; + + var _widg = _prop[0]; + var _text = _prop[1]; + var _data = _prop[2](); + + _widg.setFocusHover(sFOCUS, sHOVER); + _widg.register(); + + draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text); + draw_text(dialog_x + ui(32), yy, _text); + + var params = new widgetParam(dialog_x + dialog_w - ui(16) - ww, yy - wh / 2, ww, wh, _data); + if(is_instanceof(_widg, checkBox)) + params.halign = fa_center; + + _widg.drawParam(params); + + yy += ui(40); + } #endregion \ No newline at end of file diff --git a/objects/o_dialog_release_note/Create_0.gml b/objects/o_dialog_release_note/Create_0.gml index 2275f9b19..f9e52b7d4 100644 --- a/objects/o_dialog_release_note/Create_0.gml +++ b/objects/o_dialog_release_note/Create_0.gml @@ -8,76 +8,96 @@ event_inherited(); note = ""; - var link = "https://gist.githubusercontent.com/Ttanasart-pt/e7ab670299ce6b00cfd632646f3ac9a8/raw/1.0.0"; - note_get = http_get(link); + var _link = $"https://gist.githubusercontent.com/Ttanasart-pt/f21a140906a60c6e12c99ebfecec1645/raw/{VERSION_STRING}"; + note_get = http_get(_link); sp_note = new scrollPane(dialog_w - ui(80), dialog_h - ui(88), function(_y, _m) { draw_clear_alpha(COLORS.panel_bg_clear, 0); - BLEND_OVERRIDE - var yy = 0; + BLEND_ALPHA_MULP + var xx = ui(8); + var yy = ui(8); + var ww = sp_note.surface_w - ui(16); var txt = note; - while(string_length(txt) > 0) { - var nl = string_pos("\n", txt); - var line = string_copy(txt, 1, nl - 1); - var tab = 1; - while(string_char_at(line, tab) == " " && tab < string_length(line)) tab++; - line = string_copy(line, tab, string_length(line) - tab + 1); + var lines = string_split(txt, "\n"); + for( var i = 0, n = array_length(lines); i < n; i++ ) { + var line = lines[i]; + var _stx = string_split(string_trim(line), " "); + var _line = line; - if(nl == 0) { - line = txt; - txt = ""; + if(array_length(_stx) <= 1) { + draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text); + draw_text_line(xx + 0, _y + yy, line, -1, ww); + + yy += string_height_ext(_line, -1, ww); } else { - txt = string_copy(txt, nl + 1, string_length(txt) - nl); - } - - var sp = string_pos(" ", line); - var md = string_copy(line, 1, sp - 1); - var ww = dialog_w - ui(128); - var xx = (tab - 1) * ui(8); - - switch(md) { - case "#" : - draw_set_text(f_h3, fa_left, fa_top, COLORS._main_text_on_accent); - line = string_copy(line, sp + 1, string_length(line) - sp); - yy += ui(16); - draw_text_line(xx, _y + yy, line, -1, ww); + var _cont = array_create(array_length(_stx) - 1); + for( var j = 1, m = array_length(_stx); j < m; j++ ) + _cont[j - 1] = _stx[j]; + + _line = string_join_ext(" ", _cont); + + switch(_stx[0]) { + case "#" : + draw_set_text(f_h3, fa_left, fa_top, COLORS._main_text_sub); + yy += (!!i) * ui(16); + draw_text_line(xx, _y + yy, _line, -1, ww); - yy += ui(4); - break; - case "##" : - draw_set_text(f_h5, fa_left, fa_top, COLORS._main_text_on_accent); - line = string_copy(line, sp + 1, string_length(line) - sp); - yy += ui(8); - draw_text_line(xx + ui(16), _y + yy, line, -1, ww); - yy += ui(4); - break; - case "###" : - draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_accent); - line = string_copy(line, sp + 1, string_length(line) - sp); - yy += ui(8); - draw_text_line(xx + ui(16), _y + yy, line, -1, ww); - yy += ui(4); - break; - case "-" : - draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text); - line = string_copy(line, sp + 1, string_length(line) - sp); - draw_sprite_ui_uniform(THEME.text_bullet, 0, xx + ui(16), _y + yy + ui(10), 1, COLORS._main_icon); - draw_text_line(xx + ui(28), _y + yy, line, -1, ww); - break; - case "+" : - draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text); - line = string_copy(line, sp + 1, string_length(line) - sp); - draw_sprite_ui_uniform(THEME.text_bullet, 1, xx + ui(16), _y + yy + ui(10), 1, COLORS._main_value_positive); - draw_text_line(xx + ui(28), _y + yy, line, -1, ww); - break; - default : - draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text); - draw_text_line(xx + 0, _y + yy, line, -1, ww); - break; + yy += ui(4); + break; + case "##" : + draw_set_text(f_h5, fa_left, fa_top, COLORS._main_text_sub); + var _h = string_height_ext(_line, -1, ww); + yy += (!!i) * ui(16); + + draw_sprite_stretched_ext(THEME.group_label, 1, xx, yy - ui(4), ww, _h + ui(8), COLORS._main_icon, 1); + draw_text_line(xx + ui(16), _y + yy, _line, -1, ww); + yy += ui(8); + break; + case "###" : + draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_accent); + yy += (!!i) * ui(8); + draw_text_line(xx + ui(16), _y + yy, _line, -1, ww); + yy += ui(4); + break; + case "-" : + var _x = xx + ui(28); + if(string_char_at(line, 1) == "\t") + _x += ui(16); + + draw_sprite_ui_uniform(THEME.text_bullet, 0, _x - ui(12), _y + yy + ui(18), 1, COLORS._main_icon); + + var _lx = _x; + + draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text); + for( var j = 1, m = array_length(_stx); j < m; j++ ) { + var _word = (j > 1? " " : "") + _stx[j]; + + if(_x + string_width(_word) > ww) { + yy += line_get_height(); + _x = _lx; + } + + if(string_char_at(_word, 1) == "[") + draw_set_color(COLORS._main_text_accent); + else + draw_set_color(COLORS._main_text); + + draw_text(_x, _y + yy, _word); + _x += string_width(_word); + } + + yy += line_get_height(); + break; + default : + draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text); + draw_text_line(xx + 0, _y + yy, _line, -1, ww); + break; + } + + if(_stx[0] != "-") + yy += string_height_ext(_line, -1, ww); } - - yy += string_height_ext(line, -1, ww); } BLEND_NORMAL diff --git a/scripts/__VFX/__VFX.gml b/scripts/__VFX/__VFX.gml index 9d433084e..c5a8f0f6c 100644 --- a/scripts/__VFX/__VFX.gml +++ b/scripts/__VFX/__VFX.gml @@ -24,18 +24,16 @@ function __part(_node) constructor { turning = 0; turnSpd = 0 - ac = 0; - wig = 0; - spVec = [ 0, 0 ]; + accel = 0; + wig = 0; + spVec = [ 0, 0 ]; boundary_data = -1; - g = 0; - gDir = -90; - _gx = 0; - _gy = 0; - gx = 0; - gy = 0; + grav = 0; + gravDir = -90; + gravX = 0; + gravY = 0; scx = 1; scy = 1; @@ -69,8 +67,6 @@ function __part(_node) constructor { surf = _surf; x = _x; y = _y; - gx = 0; - gy = 0; prevx = undefined; prevy = undefined; @@ -81,13 +77,13 @@ function __part(_node) constructor { } static setPhysic = function(_sx, _sy, _ac, _g, _gDir, _wig, _turn, _turnSpd) { - speedx = _sx; - speedy = _sy; - ac = _ac; - g = _g; - gDir = _gDir; - _gx = lengthdir_x(g, gDir); - _gy = lengthdir_y(g, gDir); + speedx = _sx; + speedy = _sy; + accel = _ac; + grav = _g; + gravDir = _gDir; + gravX = lengthdir_x(grav, gravDir); + gravY = lengthdir_y(grav, gravDir); turning = _turn; turnSpd = _turnSpd; @@ -139,7 +135,7 @@ function __part(_node) constructor { var dirr = point_direction(0, 0, speedx, speedy); var diss = point_distance(0, 0, speedx, speedy); - diss += ac; + diss = max(0, diss + accel); if(speedx != 0 || speedy != 0) { if(wig != 0) @@ -151,15 +147,8 @@ function __part(_node) constructor { } } - speedx = lengthdir_x(diss, dirr) + _gx; - speedy = lengthdir_y(diss, dirr) + _gy; - - //if(_gx != 0 || _gy != 0) { - // gx += _gx; - // gy += _gy; - // x += gx; - // y += gy; - //} + speedx = lengthdir_x(diss, dirr) + gravX; + speedy = lengthdir_y(diss, dirr) + gravY; if(follow) rot = spVec[1]; else rot += rot_s; diff --git a/scripts/__node_3d_camera/__node_3d_camera.gml b/scripts/__node_3d_camera/__node_3d_camera.gml deleted file mode 100644 index 86c6bfb66..000000000 --- a/scripts/__node_3d_camera/__node_3d_camera.gml +++ /dev/null @@ -1,11 +0,0 @@ -function Node_3D_Camera(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constructor { - name = "3D Camera"; - - static update = function(frame = PROJECT.animator.current_frame) { - - } - - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { - - } -} \ No newline at end of file diff --git a/scripts/__node_3d_light/__node_3d_light.gml b/scripts/__node_3d_light/__node_3d_light.gml index b068d7ceb..9d2f96873 100644 --- a/scripts/__node_3d_light/__node_3d_light.gml +++ b/scripts/__node_3d_light/__node_3d_light.gml @@ -1,4 +1,4 @@ -function Node_3D_Light(_x, _y, _group = noone) : Node_3DObject(_x, _y, _group) constructor { +function Node_3D_Light(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) constructor { name = "3D Light"; object = new __3dLight(); @@ -21,8 +21,8 @@ function Node_3D_Light(_x, _y, _group = noone) : Node_3DObject(_x, _y, _group) c var _col = inputs[| input_d3d_index + 0].getValue(); var _int = inputs[| input_d3d_index + 1].getValue(); - object.color = _col; - object.intensity = _int; + object.color = _col; + object.intensity = _int; outputs[| 0].setValue(object); } diff --git a/scripts/__node_3d_mesh/__node_3d_mesh.gml b/scripts/__node_3d_mesh/__node_3d_mesh.gml index 539521466..c3c1b0852 100644 --- a/scripts/__node_3d_mesh/__node_3d_mesh.gml +++ b/scripts/__node_3d_mesh/__node_3d_mesh.gml @@ -1,4 +1,4 @@ -function Node_3D_Mesh(_x, _y, _group = noone) : Node_3DObject(_x, _y, _group) constructor { +function Node_3D_Mesh(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) constructor { name = "3D Mesh"; input_mesh_index = ds_list_size(inputs); diff --git a/scripts/__node_3d_object/__node_3d_object.gml b/scripts/__node_3d_object/__node_3d_object.gml index 1c476601c..0faa410e5 100644 --- a/scripts/__node_3d_object/__node_3d_object.gml +++ b/scripts/__node_3d_object/__node_3d_object.gml @@ -1,4 +1,4 @@ -function Node_3DObject(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constructor { +function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constructor { name = "3D Object"; h = 64; min_h = h; @@ -472,9 +472,9 @@ function Node_3DObject(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constru outputs[| 0].setValue(object); } + static submitShader = function(params = {}, shader = noone) { object.submitShader(params, shader); } + static submitUI = function(params = {}, shader = noone) { object.submitUI(params, shader); } static submit = function(params = {}, shader = noone) { object.submit(params, shader); } static submitSel = function(params = {}, shader = noone) { object.submitSel(params, shader); } - - static update = function(frame = PROJECT.animator.current_frame) {} } \ No newline at end of file diff --git a/scripts/d3d_camera/d3d_camera.gml b/scripts/d3d_camera/d3d_camera.gml index 91d0d2dc6..fe864ac6a 100644 --- a/scripts/d3d_camera/d3d_camera.gml +++ b/scripts/d3d_camera/d3d_camera.gml @@ -1,12 +1,21 @@ +enum CAMERA_PROJECTION { + perspective, + orthograph +} + function __3dCamera() constructor { position = new __vec3(); + rotation = new BBMOD_Quaternion(); focus = new __vec3(); up = new __vec3(0, 0, -1); + useFocus = true; focus_angle_x = 0; focus_angle_y = 0; focus_dist = 1; + projection = CAMERA_PROJECTION.perspective; + fov = 60; view_near = 1; view_far = 32000; @@ -39,8 +48,21 @@ function __3dCamera() constructor { } static setMatrix = function() { - projMat.setRaw(matrix_build_projection_perspective_fov(fov, view_aspect, view_near, view_far)); - viewMat.setRaw(matrix_build_lookat(position.x, position.y, position.z, focus.x, focus.y, focus.z, up.x, up.y, up.z)); + if(projection == CAMERA_PROJECTION.perspective) + projMat.setRaw(matrix_build_projection_perspective_fov(fov, view_aspect, view_near, view_far)); + else + projMat.setRaw(matrix_build_projection_ortho(view_w, view_h, view_near, view_far)); + + if(useFocus) + viewMat.setRaw(matrix_build_lookat(position.x, position.y, position.z, focus.x, focus.y, focus.z, up.x, up.y, up.z)); + else { + var _for = rotation.Rotate(new BBMOD_Vec3( 1.0, 0.0, 0.0)); + var _up = rotation.Rotate(new BBMOD_Vec3( 0.0, 0.0, -1.0)); + + viewMat.setRaw(matrix_build_lookat(position.x, position.y, position.z, + position.x + _for.X, position.y + _for.Y, position.z + _for.Z, + _up.X, _up.Y, _up.Z)); + } return self; } diff --git a/scripts/d3d_camera_object/d3d_camera_object.gml b/scripts/d3d_camera_object/d3d_camera_object.gml index f7a87f28f..03ec738ca 100644 --- a/scripts/d3d_camera_object/d3d_camera_object.gml +++ b/scripts/d3d_camera_object/d3d_camera_object.gml @@ -6,24 +6,24 @@ function __3dCamera_object() : __3dObject() constructor { len = 0.5; //cameraLength vertex = [ - [ len, -ivw, ivh ], [ len, ivw, ivh ], - [ len, ivw, ivh ], [ len, ivw, -ivh ], - [ len, ivw, -ivh ], [ len, -ivw, -ivh ], - [ len, -ivw, -ivh ], [ len, -ivw, ivh ], + [ -len, -ivw, ivh ], [ -len, ivw, ivh ], + [ -len, ivw, ivh ], [ -len, ivw, -ivh ], + [ -len, ivw, -ivh ], [ -len, -ivw, -ivh ], + [ -len, -ivw, -ivh ], [ -len, -ivw, ivh ], - [ -len, -ovw, ovh ], [ -len, ovw, ovh ], - [ -len, ovw, ovh ], [ -len, ovw, -ovh ], - [ -len, ovw, -ovh ], [ -len, -ovw, -ovh ], - [ -len, -ovw, -ovh ], [ -len, -ovw, ovh ], - - [ len, -ivw, ivh ], [ -len, -ovw, ovh ], - [ len, ivw, ivh ], [ -len, ovw, ovh ], - [ len, ivw, -ivh ], [ -len, ovw, -ovh ], - [ len, -ivw, -ivh ], [ -len, -ovw, -ovh ], + [ len, -ovw, ovh ], [ len, ovw, ovh ], + [ len, ovw, ovh ], [ len, ovw, -ovh ], + [ len, ovw, -ovh ], [ len, -ovw, -ovh ], + [ len, -ovw, -ovh ], [ len, -ovw, ovh ], + + [ -len, -ivw, ivh ], [ len, -ovw, ovh ], + [ -len, ivw, ivh ], [ len, ovw, ovh ], + [ -len, ivw, -ivh ], [ len, ovw, -ovh ], + [ -len, -ivw, -ivh ], [ len, -ovw, -ovh ], - [ -len, -ovw * 0.5, ovh + 0.2 ], [ -len, ovw * 0.5, ovh + 0.2 ], - [ -len, 0, ovh + 0.6 ], [ -len, ovw * 0.5, ovh + 0.2 ], - [ -len, -ovw * 0.5, ovh + 0.2 ], [ -len, 0, ovh + 0.6 ], + [ len, -ovw * 0.5, ovh + 0.2 ], [ len, ovw * 0.5, ovh + 0.2 ], + [ len, 0, ovh + 0.6 ], [ len, ovw * 0.5, ovh + 0.2 ], + [ len, -ovw * 0.5, ovh + 0.2 ], [ len, 0, ovh + 0.6 ], ]; VF = global.VF_POS_COL; @@ -33,6 +33,12 @@ function __3dCamera_object() : __3dObject() constructor { position.set(-5, -5, 5); rotation.set(0, 30, 135); scale.set(1, room_width / room_height, 1); + + static submitSel = function(params = {}) { + shader_set(sh_d3d_wireframe); + submitVertex(params); + shader_reset(); + } } function calculate_3d_position(camFx, camFy, camFz, camAx, camAy, camDist) { diff --git a/scripts/d3d_light/d3d_light.gml b/scripts/d3d_light/d3d_light.gml index fe6f5f276..f19766da1 100644 --- a/scripts/d3d_light/d3d_light.gml +++ b/scripts/d3d_light/d3d_light.gml @@ -1,39 +1,10 @@ function __3dLight() : __3dObject() constructor { UI_vertex = []; - for( var i = 0; i <= 32; i++ ) - UI_vertex[i] = [ 0, lengthdir_x(0.5, i / 32 * 360), lengthdir_y(0.5, i / 32 * 360), c_yellow, 0.8 ]; + for( var i = 0; i <= 32; i++ ) UI_vertex[i] = [ 0, lengthdir_x(0.5, i / 32 * 360), lengthdir_y(0.5, i / 32 * 360), c_yellow, 0.8 ]; VB_UI = build(noone, UI_vertex); color = c_white; intensity = 1; - static presubmit = function(params = {}) { - var _rot = new __rot3(0, 0, 0).lookAt(position, params.camera.position); - - var rot = matrix_build(0, 0, 0, - _rot.x, _rot.y, _rot.z, - 1, 1, 1); - var sca = matrix_build(0, 0, 0, - 0, 0, 0, - 0.6, 0.6, 0.6); - var pos = matrix_build(position.x, position.y, position.z, - 0, 0, 0, - 1, 1, 1); - - matrix_stack_clear(); - matrix_stack_push(pos); - matrix_stack_push(rot); - - matrix_set(matrix_world, matrix_stack_top()); - vertex_submit(VB_UI, pr_linestrip, -1); - - matrix_stack_push(sca); - matrix_set(matrix_world, matrix_stack_top()); - vertex_submit(VB_UI, pr_linestrip, -1); - - matrix_stack_clear(); - matrix_set(matrix_world, matrix_build_identity()); - } - - static shine = function(params = {}) {} + static submit = function(params = {}, shader = noone) {} } \ No newline at end of file diff --git a/scripts/d3d_light_directional/d3d_light_directional.gml b/scripts/d3d_light_directional/d3d_light_directional.gml index f843494ae..51d2f375c 100644 --- a/scripts/d3d_light_directional/d3d_light_directional.gml +++ b/scripts/d3d_light_directional/d3d_light_directional.gml @@ -1,30 +1,46 @@ function __3dLightDirectional() : __3dLight() constructor { - vertex = [ - [ 1, 0, 0, c_yellow, 0.8 ], [ 3, 0, 0, c_yellow, 0.8 ] - ]; - VF = global.VF_POS_COL; + vertex = [ [ 1, 0, 0, c_yellow, 0.8 ], [ 3, 0, 0, c_yellow, 0.8 ] ]; + VF = global.VF_POS_COL; render_type = pr_linelist; - VB = build(); + VB = build(); - color = c_white; + color = c_white; intensity = 1; - position.set(1, 0, 0); + position.set(4, 0, 0); - static submit = function(params = {}, shader = noone) { shine(params); } - static submitUI = function(params = {}, shader = noone) { shine(params); submitVertex(params, shader); } static submitSel = function(params = {}) { shader_set(sh_d3d_wireframe); - presubmit(params); + preSubmitVertex(params); shader_reset(); } - static shine = function(params = {}) { - shader_set(sh_d3d_default); + static submitShader = function(params = {}) { params.addLightDirectional(self); } + + static preSubmitVertex = function(params = {}) { + var _rot = new __rot3(0, 0, 0).lookAt(position, params.camera.position); - shader_set_f("light_dir_direction", position.x, position.y, position.z); - shader_set_f("light_dir_color", colToVec4(color)); - shader_set_f("light_dir_intensity", intensity); + var rot = matrix_build(0, 0, 0, + _rot.x, _rot.y, _rot.z, + 1, 1, 1); + var sca = matrix_build(0, 0, 0, + 0, 0, 0, + 0.6, 0.6, 0.6); + var pos = matrix_build(position.x, position.y, position.z, + 0, 0, 0, + 1, 1, 1); - shader_reset(); + matrix_stack_clear(); + matrix_stack_push(pos); + matrix_stack_push(rot); + + matrix_set(matrix_world, matrix_stack_top()); + vertex_submit(VB_UI, pr_linestrip, -1); + + matrix_stack_push(sca); + matrix_set(matrix_world, matrix_stack_top()); + vertex_submit(VB_UI, pr_linestrip, -1); + + matrix_stack_clear(); + matrix_set(matrix_world, matrix_build_identity()); } } \ No newline at end of file diff --git a/scripts/d3d_light_point/d3d_light_point.gml b/scripts/d3d_light_point/d3d_light_point.gml new file mode 100644 index 000000000..51cb3c7c6 --- /dev/null +++ b/scripts/d3d_light_point/d3d_light_point.gml @@ -0,0 +1,50 @@ +function __3dLightPoint() : __3dLight() constructor { + color = c_white; + intensity = 1; + radius = 10; + + static submitSel = function(params = {}) { + shader_set(sh_d3d_wireframe); + preSubmitVertex(params); + shader_reset(); + } + + static submitShader = function(params = {}) { params.addLightPoint(self); } + + static preSubmitVertex = function(params = {}) { + var _rot = new __rot3(0, 0, 0).lookAt(position, params.camera.position); + + var rot = matrix_build(0, 0, 0, + _rot.x, _rot.y, _rot.z, + 1, 1, 1); + var sca = matrix_build(0, 0, 0, + 0, 0, 0, + 0.6, 0.6, 0.6); + var ran = matrix_build(0, 0, 0, + 0, 0, 0, + radius * 2, radius * 2, radius * 2); + var pos = matrix_build(position.x, position.y, position.z, + 0, 0, 0, + 1, 1, 1); + + matrix_stack_clear(); + matrix_stack_push(pos); + matrix_stack_push(rot); + + matrix_set(matrix_world, matrix_stack_top()); + vertex_submit(VB_UI, pr_linestrip, -1); + + matrix_stack_push(sca); + matrix_set(matrix_world, matrix_stack_top()); + vertex_submit(VB_UI, pr_linestrip, -1); + matrix_stack_pop(); + + matrix_stack_push(ran); + matrix_set(matrix_world, matrix_stack_top()); + vertex_submit(VB_UI, pr_linestrip, -1); + matrix_stack_pop(); + + matrix_stack_clear(); + matrix_set(matrix_world, matrix_build_identity()); + } +} \ No newline at end of file diff --git a/scripts/d3d_light_point/d3d_light_point.yy b/scripts/d3d_light_point/d3d_light_point.yy new file mode 100644 index 000000000..f2e76ee07 --- /dev/null +++ b/scripts/d3d_light_point/d3d_light_point.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "d3d_light_point", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "3d", + "path": "folders/functions/3d.yy", + }, +} \ No newline at end of file diff --git a/scripts/d3d_object/d3d_object.gml b/scripts/d3d_object/d3d_object.gml index 5453d7bd7..2ec09f9ce 100644 --- a/scripts/d3d_object/d3d_object.gml +++ b/scripts/d3d_object/d3d_object.gml @@ -26,7 +26,7 @@ function __3dObject() constructor { rotation = new BBMOD_Quaternion(); scale = new __vec3(1, 1, 1); - static build = function(_buffer = VB, _vertex = vertex, _normal = normals) { + static build = function(_buffer = VB, _vertex = vertex, _normal = normals) { #region if(_buffer != noone) vertex_delete_buffer(_buffer); _buffer = vertex_create_buffer(); @@ -57,16 +57,18 @@ function __3dObject() constructor { vertex_end(_buffer); return _buffer; - } + } #endregion - static presubmit = function(params = {}) {} - static postsubmit = function(params = {}) {} + static preSubmitVertex = function(params = {}) {} + static postSubmitVertex = function(params = {}) {} + + static submitShader = function(params = {}, shader = noone) {} static submit = function(params = {}, shader = noone) { submitVertex(params, shader); } static submitUI = function(params = {}, shader = noone) { submitVertex(params, shader); } static submitSel = function(params = {}) { submitVertex(params, sh_d3d_silhouette); } - static submitVertex = function(params = {}, shader = noone) { + static submitVertex = function(params = {}, shader = noone) { #region if(shader != noone) shader_set(shader); else if(custom_shader != noone) @@ -78,7 +80,7 @@ function __3dObject() constructor { } } - presubmit(params); + preSubmitVertex(params); if(VB != noone) { var pos = matrix_build(position.x, position.y, position.z, @@ -101,12 +103,8 @@ function __3dObject() constructor { matrix_set(matrix_world, matrix_build_identity()); } - postsubmit(params); + postSubmitVertex(params); shader_reset(); - } -} - -function __3dObjectParameters(camera) constructor { - self.camera = camera; + } #endregion } \ No newline at end of file diff --git a/scripts/d3d_plane/d3d_plane.gml b/scripts/d3d_plane/d3d_plane.gml index d05baf677..f37f8e549 100644 --- a/scripts/d3d_plane/d3d_plane.gml +++ b/scripts/d3d_plane/d3d_plane.gml @@ -15,7 +15,7 @@ function __plane(origin, normal) constructor { #region functions function d3d_intersect_ray_plane(ray, plane) { - print($"Intersect {ray}\n\tto {plane}"); + //print($"Intersect {ray}\n\tto {plane}"); var det = plane.normal.dot(ray.direction); if(det == 0) return new __vec3(); diff --git a/scripts/d3d_scene/d3d_scene.gml b/scripts/d3d_scene/d3d_scene.gml new file mode 100644 index 000000000..9afbc0a4c --- /dev/null +++ b/scripts/d3d_scene/d3d_scene.gml @@ -0,0 +1,67 @@ +function __3dScene(camera) constructor { + self.camera = camera; + name = "New scene"; + + lightAmbient = c_black; + lightDir_count = 0; + lightDir_direction = []; + lightDir_color = []; + lightDir_intensity = []; + + lightPnt_count = 0; + lightPnt_position = []; + lightPnt_color = []; + lightPnt_intensity = []; + lightPnt_radius = []; + + static reset = function() { + lightDir_count = 0; + lightDir_direction = []; + lightDir_color = []; + lightDir_intensity = []; + + lightPnt_count = 0; + lightPnt_position = []; + lightPnt_color = []; + lightPnt_intensity = []; + lightPnt_radius = []; + } + + static apply = function() { + shader_set(sh_d3d_default); + shader_set_f("light_ambient", colToVec4(lightAmbient)); + + shader_set_i("light_dir_count", lightDir_count); + shader_set_f("light_dir_direction", lightDir_direction); + shader_set_f("light_dir_color", lightDir_color); + shader_set_f("light_dir_intensity", lightDir_intensity); + + shader_set_i("light_pnt_count", lightPnt_count); + shader_set_f("light_pnt_position", lightPnt_position); + shader_set_f("light_pnt_color", lightPnt_color); + shader_set_f("light_pnt_intensity", lightPnt_intensity); + shader_set_f("light_pnt_radius", lightPnt_radius); + + //print($"Scene {name} submit {lightPnt_position} point lights"); + shader_reset(); + } + + static addLightDirectional = function(light) { + array_append(lightDir_direction, [ light.position.x, light.position.y, light.position.z ]); + array_append(lightDir_color, colToVec4(light.color)); + array_append(lightDir_intensity, [ light.intensity ]); + lightDir_count++; + + return self; + } + + static addLightPoint = function(light) { + array_append(lightPnt_position, [ light.position.x, light.position.y, light.position.z ]); + array_append(lightPnt_color, colToVec4(light.color)); + array_append(lightPnt_intensity, [ light.intensity ]); + array_append(lightPnt_radius, [ light.radius ]); + lightPnt_count++; + + return self; + } +} \ No newline at end of file diff --git a/scripts/d3d_scene/d3d_scene.yy b/scripts/d3d_scene/d3d_scene.yy new file mode 100644 index 000000000..093e696ca --- /dev/null +++ b/scripts/d3d_scene/d3d_scene.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "d3d_scene", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "3d", + "path": "folders/functions/3d.yy", + }, +} \ No newline at end of file diff --git a/scripts/event_recorder/event_recorder.gml b/scripts/event_recorder/event_recorder.gml index 50f410e93..139cb3fb1 100644 --- a/scripts/event_recorder/event_recorder.gml +++ b/scripts/event_recorder/event_recorder.gml @@ -26,6 +26,7 @@ enum ACTION_TYPE { collection_loaded, struct_modify, + custom, } enum DS_TYPE { @@ -39,6 +40,8 @@ function Action(_type, _object, _data) constructor { data = _data; extra_data = 0; + clear_action = noone; + static undo = function() { var _n; @@ -104,6 +107,9 @@ function Action(_type, _object, _data) constructor { obj.deserialize(data); data = _data; break; + case ACTION_TYPE.custom : + data = obj(data); + break; } } @@ -171,6 +177,9 @@ function Action(_type, _object, _data) constructor { obj.deserialize(data); data = _data; break; + case ACTION_TYPE.custom : + data = obj(data); + break; } } @@ -225,9 +234,17 @@ function Action(_type, _object, _data) constructor { case ACTION_TYPE.struct_modify : ss = $"modify {struct_try_get(obj, "name", "value")}"; break; + case ACTION_TYPE.custom : + ss = struct_try_get(data, "tooltip", "action"); + break; } return ss; } + + static destroy = function() { + if(clear_action == noone) return; + clear_action(data); + } } function recordAction(_type, _object, _data = -1) { @@ -237,7 +254,12 @@ function recordAction(_type, _object, _data = -1) { var act = new Action(_type, _object, _data); array_push(o_main.action_last_frame, act); - ds_stack_clear(REDO_STACK); + + while(!ds_stack_empty(REDO_STACK)) { + var actions = ds_stack_pop(REDO_STACK); + for( var i = 0, n = array_length(actions); i < n; i++ ) + actions[i].destroy(); + } return act; } diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index 6569ad5b3..6d245f628 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -101,10 +101,10 @@ globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER; - VERSION = 11505; + VERSION = 11506; SAVE_VERSION = 11500; - VERSION_STRING = "1.15.0.5"; - BUILD_NUMBER = 11505; + VERSION_STRING = "1.15.0.6"; + BUILD_NUMBER = 11506; globalvar APPEND_MAP; APPEND_MAP = ds_map_create(); diff --git a/scripts/node_3d_camera/node_3d_camera.gml b/scripts/node_3d_camera/node_3d_camera.gml new file mode 100644 index 000000000..bc1991088 --- /dev/null +++ b/scripts/node_3d_camera/node_3d_camera.gml @@ -0,0 +1,138 @@ +function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) constructor { + name = "3D Camera"; + object = new __3dCamera_object(); + camera = new __3dCamera(); + camera.useFocus = false; + + scene = new __3dScene(camera); + scene.name = "Camera"; + + inputs[| input_d3d_index + 0] = nodeValue("FOV", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 60) + .setDisplay(VALUE_DISPLAY.slider, [ 10, 90, 1 ]); + + inputs[| input_d3d_index + 1] = nodeValue("Clipping Distance", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 1, 32000 ]) + .setDisplay(VALUE_DISPLAY.vector); + + inputs[| input_d3d_index + 2] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF ) + .setDisplay(VALUE_DISPLAY.vector); + + inputs[| input_d3d_index + 3] = nodeValue("Projection", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 ) + .setDisplay(VALUE_DISPLAY.enum_button, [ "Perspective", "Orthographic" ]); + + inputs[| input_d3d_index + 4] = nodeValue("Scene", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Scene, noone ) + .setVisible(true, true); + + inputs[| input_d3d_index + 5] = nodeValue("Ambient Light", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black ); + + inputs[| input_d3d_index + 6] = nodeValue("Show Background", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false ); + + inputs[| input_d3d_index + 7] = nodeValue("Backface Culling", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) + .setDisplay(VALUE_DISPLAY.enum_button, [ "None", "CW", "CCW" ]); + + inputs[| input_d3d_index + 8] = nodeValue("Orthographic Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) + .setDisplay(VALUE_DISPLAY.slider, [ 0.01, 4, 0.01 ]); + + outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); + + input_display_list = [ input_d3d_index + 4, + ["Output", false], input_d3d_index + 2, + ["Transform", false], 0, 1, + ["Camera", false], input_d3d_index + 3, input_d3d_index + 0, input_d3d_index + 1, input_d3d_index + 8, + ["Render", false], input_d3d_index + 5, input_d3d_index + 6, input_d3d_index + 7, + ]; + + static step = function() { + var _proj = inputs[| input_d3d_index + 3].getValue(); + + inputs[| input_d3d_index + 8].setVisible(_proj == 1); + } + + static update = function(frame = PROJECT.animator.current_frame) { + setTransform(); + + var _pos = inputs[| 0].getValue(); + var _rot = inputs[| 1].getValue(); + + var _fov = inputs[| input_d3d_index + 0].getValue(); + var _clip = inputs[| input_d3d_index + 1].getValue(); + var _dim = inputs[| input_d3d_index + 2].getValue(); + var _proj = inputs[| input_d3d_index + 3].getValue(); + var _scne = inputs[| input_d3d_index + 4].getValue(); + var _ambt = inputs[| input_d3d_index + 5].getValue(); + var _dbg = inputs[| input_d3d_index + 6].getValue(); + var _back = inputs[| input_d3d_index + 7].getValue(); + var _orts = inputs[| input_d3d_index + 8].getValue(); + + if(_scne == noone) return; + + camera.position.set(_pos[0], _pos[1], _pos[2]); + camera.rotation.set(_rot[0], _rot[1], _rot[2], _rot[3]); + camera.projection = _proj; + + camera.setViewFov(_fov, _clip[0], _clip[1]); + if(_proj == 0) camera.setViewSize(_dim[0], _dim[1]); + else if(_proj == 1) camera.setViewSize(_dim[0] / _orts, _dim[1] / _orts); + + scene.lightAmbient = _ambt; + + var _outSurf = outputs[| 0].getValue(); + _outSurf = surface_verify(_outSurf, _dim[0], _dim[1]); + outputs[| 0].setValue(_outSurf); + + camera.setMatrix(); + + surface_set_target(_outSurf); + if(_dbg) draw_clear(_ambt); + else DRAW_CLEAR + + gpu_set_zwriteenable(true); + gpu_set_ztestenable(true); + gpu_set_cullmode(_back); + + var cam = camera_get_active(); + camera.applyCamera(cam); + + scene.reset(); + _scne.submitShader(scene); + scene.apply(); + + _scne.submit(scene); //////////////// SUBMIT //////////////// + + surface_reset_target(); + + gpu_set_cullmode(cull_noculling); + } + + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { + + } + + static submitShader = function(params = {}, shader = noone) { + object.submitShader(params, shader); + + var _scne = inputs[| input_d3d_index + 4].getValue(); + if(_scne == noone) return; + _scne.submitShader(params, shader); + } + + static submitUI = function(params = {}, shader = noone) { + object.submitUI(params, shader); + + var _scne = inputs[| input_d3d_index + 4].getValue(); + if(_scne == noone) return; + _scne.submitUI(params, shader); + } + + static submit = function(params = {}, shader = noone) { + object.submit(params, shader); + + var _scne = inputs[| input_d3d_index + 4].getValue(); + if(_scne == noone) return; + _scne.submit(params, shader); + } + + static submitSel = function(params = {}, shader = noone) { + object.submitSel(params, shader); + } + +} \ No newline at end of file diff --git a/scripts/__node_3d_camera/__node_3d_camera.yy b/scripts/node_3d_camera/node_3d_camera.yy similarity index 85% rename from scripts/__node_3d_camera/__node_3d_camera.yy rename to scripts/node_3d_camera/node_3d_camera.yy index a7474e304..d3bc922bf 100644 --- a/scripts/__node_3d_camera/__node_3d_camera.yy +++ b/scripts/node_3d_camera/node_3d_camera.yy @@ -1,7 +1,7 @@ { "resourceType": "GMScript", "resourceVersion": "1.0", - "name": "__node_3d_camera", + "name": "node_3d_camera", "isCompatibility": false, "isDnD": false, "parent": { diff --git a/scripts/__node_3d_camera/node_counter.yy b/scripts/node_3d_camera/node_counter.yy similarity index 100% rename from scripts/__node_3d_camera/node_counter.yy rename to scripts/node_3d_camera/node_counter.yy diff --git a/scripts/node_3d_light_point/node_3d_light_point.gml b/scripts/node_3d_light_point/node_3d_light_point.gml new file mode 100644 index 000000000..1c77c422b --- /dev/null +++ b/scripts/node_3d_light_point/node_3d_light_point.gml @@ -0,0 +1,19 @@ +function Node_3D_Light_Point(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _group) constructor { + name = "Point Light"; + object = new __3dLightPoint(); + + inputs[| input_light_index + 0] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4) + + input_display_list = [ + ["Transform", false], 0, + __d3d_input_list_light, input_light_index, + ] + + static update = function(frame = PROJECT.animator.current_frame) { + setTransform(); + setLight(); + + var _rad = inputs[| input_light_index + 0].getValue(); + object.radius = _rad; + } +} \ No newline at end of file diff --git a/scripts/node_3d_light_point/node_3d_light_point.yy b/scripts/node_3d_light_point/node_3d_light_point.yy new file mode 100644 index 000000000..9d5e0c487 --- /dev/null +++ b/scripts/node_3d_light_point/node_3d_light_point.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "node_3d_light_point", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "d3d light", + "path": "folders/nodes/data/3D/d3d light.yy", + }, +} \ No newline at end of file diff --git a/scripts/node_3d_light_point/node_counter.yy b/scripts/node_3d_light_point/node_counter.yy new file mode 100644 index 000000000..10832a0b0 --- /dev/null +++ b/scripts/node_3d_light_point/node_counter.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "variable", + "path": "folders/nodes/data/variable.yy", + }, + "resourceVersion": "1.0", + "name": "node_counter", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/scripts/node_3d_scene/node_3d_scene.gml b/scripts/node_3d_scene/node_3d_scene.gml index 3a531022e..0f1dd9af4 100644 --- a/scripts/node_3d_scene/node_3d_scene.gml +++ b/scripts/node_3d_scene/node_3d_scene.gml @@ -8,6 +8,8 @@ function Node_3D_Scene(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constru setIsDynamicInput(1); + object_lists = []; + static createNewInput = function() { var index = ds_list_size(inputs); inputs[| index] = nodeValue("Object", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Mesh, noone ) @@ -40,36 +42,26 @@ function Node_3D_Scene(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constru refreshDynamicInput(); } - static submitSel = function(params = {}) { - for( var i = input_fix_len, n = ds_list_size(inputs); i < n; i += data_length ) { - var _obj = inputs[| i].getValue(); - if(_obj == noone) continue; - - _obj.submitSel(params); - } - } - - static submitUI = function(params = {}, shader = noone) { - for( var i = input_fix_len, n = ds_list_size(inputs); i < n; i += data_length ) { - var _obj = inputs[| i].getValue(); - if(_obj == noone) continue; - - _obj.submitUI(params, shader); - } - } - - static submit = function(params = {}, shader = noone) { - for( var i = input_fix_len, n = ds_list_size(inputs); i < n; i += data_length ) { - var _obj = inputs[| i].getValue(); - if(_obj == noone) continue; - - _obj.submit(params, shader); - } - } - static update = function(frame = PROJECT.animator.current_frame) { + object_lists = []; + for( var i = input_fix_len, n = ds_list_size(inputs); i < n; i += data_length ) { + var _obj = inputs[| i].getValue(); + if(_obj == noone) continue; + + array_push(object_lists, _obj); + } } + static _submit = function(callback, params = {}, shader = noone) { + for( var i = 0, n = array_length(object_lists); i < n; i++ ) + callback(object_lists[i], params, shader); + } + + static submitShader = function(params = {}) { _submit(function(_obj, params) { _obj.submitShader(params); }, params); } + static submitSel = function(params = {}) { _submit(function(_obj, params) { _obj.submitSel(params); }, params); } + static submitUI = function(params = {}, shader = noone) { _submit(function(_obj, params, shader) { _obj.submitUI(params, shader); }, params); } + static submit = function(params = {}, shader = noone) { _submit(function(_obj, params, shader) { _obj.submit(params, shader); }, params); } + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {} } \ No newline at end of file diff --git a/scripts/node_canvas/node_canvas.gml b/scripts/node_canvas/node_canvas.gml index 4f671f597..a46bdaa39 100644 --- a/scripts/node_canvas/node_canvas.gml +++ b/scripts/node_canvas/node_canvas.gml @@ -44,8 +44,9 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor attribute_surface_depth(); - canvas_surface = surface_create_empty(1, 1); - drawing_surface = surface_create_empty(1, 1); + canvas_surface = surface_create_empty(1, 1); + drawing_surface = surface_create_empty(1, 1); + _drawing_surface = surface_create_empty(1, 1); canvas_buffer = buffer_create(1 * 1 * 4, buffer_fixed, 2); surface_w = 1; surface_h = 1; @@ -82,30 +83,21 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor draw_stack = ds_list_create(); - function apply_draw_surface() { - var _alp = inputs[| 11].getValue(); + function storeAction() { + var action = recordAction(ACTION_TYPE.custom, function(data) { + is_selected = false; + + var _canvas = surface_clone(canvas_surface); + + if(is_surface(data.surface)) + canvas_surface = surface_clone(data.surface); + surface_store_buffer(); + surface_free(data.surface); + + return { surface: _canvas, tooltip: data.tooltip } + }, { surface: surface_clone(canvas_surface), tooltip: "Modify canvas" }); - BLEND_ALPHA; - if(isUsingTool("Eraser")) - gpu_set_blendmode(bm_subtract); - draw_surface_ext_safe(drawing_surface, 0, 0, 1, 1, 0, c_white, _alp); - - surface_clear(drawing_surface); - BLEND_NORMAL; - - surface_store_buffer(); - } - - function surface_store_buffer() { - buffer_delete(canvas_buffer); - - surface_w = surface_get_width(canvas_surface); - surface_h = surface_get_height(canvas_surface); - canvas_buffer = buffer_create(surface_w * surface_h * 4, buffer_fixed, 4); - buffer_get_surface(canvas_buffer, canvas_surface, 0); - - triggerRender(); - apply_surface(); + action.clear_action = function(data) { surface_free_safe(data.surface); }; } function apply_surface() { @@ -124,6 +116,35 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor surface_clear(drawing_surface); } + function surface_store_buffer() { + buffer_delete(canvas_buffer); + + surface_w = surface_get_width(canvas_surface); + surface_h = surface_get_height(canvas_surface); + canvas_buffer = buffer_create(surface_w * surface_h * 4, buffer_fixed, 4); + buffer_get_surface(canvas_buffer, canvas_surface, 0); + + triggerRender(); + apply_surface(); + } + + function apply_draw_surface() { + var _alp = inputs[| 11].getValue(); + + storeAction(); + + surface_set_target(canvas_surface); + if(isUsingTool("Eraser")) gpu_set_blendmode(bm_subtract); + else BLEND_ALPHA + draw_surface_ext_safe(drawing_surface, 0, 0, 1, 1, 0, c_white, _alp); + surface_reset_target(); + + surface_clear(drawing_surface); + BLEND_NORMAL; + + surface_store_buffer(); + } + function draw_point_size(_x, _y, _siz, _brush) { #region if(!is_surface(_brush)) { if(_siz <= 1) @@ -401,13 +422,23 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor var _prev = inputs[| 5].getValue(); var _brush = inputs[| 6].getValue(); + if(key_mod_press(ALT)) return; + if(!surface_exists(canvas_surface)) surface_store_buffer(); var _surf_w = surface_get_width(canvas_surface); var _surf_h = surface_get_height(canvas_surface); - if(!isUsingTool("Selection") && is_surface(selection_surface)) { + #region drawing surface review + _drawing_surface = surface_verify(_drawing_surface, _surf_w, _surf_h); + surface_set_target(_drawing_surface); + DRAW_CLEAR + draw_surface_safe(drawing_surface); + surface_reset_target(); + #endregion + + if(!isUsingTool("Selection") && is_surface(selection_surface)) { #region var pos_x = selection_position[0]; var pos_y = selection_position[1]; @@ -419,15 +450,14 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor surface_store_buffer(); surface_free(selection_surface); - } + } #endregion - surface_set_target(canvas_surface); draw_set_color(_col); if(!isUsingTool("Selection")) gpu_set_colorwriteenable(tool_attribute.channel[0], tool_attribute.channel[1], tool_attribute.channel[2], tool_attribute.channel[3]); - if(isUsingTool("Selection")) { + if(isUsingTool("Selection")) { #region if(is_selected) { if(!is_surface(selection_surface)) { is_selected = false; @@ -507,7 +537,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor draw_surface(selection_mask, 0, 0); BLEND_NORMAL surface_reset_target(); - + + storeAction(); surface_set_target(canvas_surface); gpu_set_blendmode(bm_subtract); draw_surface(selection_surface, sel_x0, sel_y0); @@ -529,7 +560,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor } } } - } else if(isUsingTool("Pencil") || isUsingTool("Eraser")) { + #endregion + } else if(isUsingTool("Pencil") || isUsingTool("Eraser")) { #region if(key_mod_press(SHIFT) && key_mod_press(CTRL)) { var aa = point_direction(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y); var dd = point_distance(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y); @@ -550,9 +582,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor mouse_holding = true; if(key_mod_press(SHIFT)) { surface_set_shader(drawing_surface, noone, true, BLEND.alpha); - //print($"===== DRAW LINE {mouse_pre_draw_x}, {mouse_pre_draw_y}, {mouse_cur_x}, {mouse_cur_y} ====="); draw_line_size(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, _siz, _brush); - //print($"===== DRAW LINE END ====="); surface_reset_shader(); mouse_holding = false; @@ -584,8 +614,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor mouse_pre_x = mouse_cur_x; mouse_pre_y = mouse_cur_y; - - } else if(isUsingTool("Rectangle") || isUsingTool("Ellipse")) { + #endregion + } else if(isUsingTool("Rectangle") || isUsingTool("Ellipse")) { #region if(mouse_holding && key_mod_press(SHIFT)) { var ww = mouse_cur_x - mouse_pre_x; var hh = mouse_cur_y - mouse_pre_y; @@ -617,33 +647,33 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor mouse_holding = false; } } - } else if(isUsingTool("Fill") || (DRAGGING && DRAGGING.type == "Color")) { - if(point_in_rectangle(mouse_cur_x, mouse_cur_y, 0, 0, _surf_w - 1, _surf_h - 1)) { - var fill = DRAGGING? mouse_release(mb_left) : mouse_press(mb_left); - - if(fill) { - if(DRAGGING) draw_set_color(DRAGGING.data); - switch(_fill_type) { - case 0 : - flood_fill_scanline(mouse_cur_x, mouse_cur_y, canvas_surface, _thr, false); - break; - case 1 : - flood_fill_scanline(mouse_cur_x, mouse_cur_y, canvas_surface, _thr, true); - break; - case 2 : - canvas_fill(mouse_cur_x, mouse_cur_y, canvas_surface, _thr); - break; - } - surface_store_buffer(); - } + #endregion + } else if(isUsingTool("Fill") || (DRAGGING && DRAGGING.type == "Color")) { #region + var fill = DRAGGING? mouse_release(mb_left) : mouse_press(mb_left); + + if(fill && point_in_rectangle(mouse_cur_x, mouse_cur_y, 0, 0, _surf_w - 1, _surf_h - 1)) { + storeAction(); + surface_set_target(canvas_surface); + if(DRAGGING) draw_set_color(DRAGGING.data); + switch(_fill_type) { + case 0 : + flood_fill_scanline(mouse_cur_x, mouse_cur_y, canvas_surface, _thr, false); + break; + case 1 : + flood_fill_scanline(mouse_cur_x, mouse_cur_y, canvas_surface, _thr, true); + break; + case 2 : + canvas_fill(mouse_cur_x, mouse_cur_y, canvas_surface, _thr); + break; + } + surface_store_buffer(); + surface_reset_target(); } + #endregion } draw_set_alpha(1); gpu_set_colorwriteenable(true, true, true, true); - surface_reset_target(); - - if(key_mod_press(ALT)) return; #region preview var _bg = inputs[| 8].getValue(); @@ -658,7 +688,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor _preview_draw_surface = surface_verify(_preview_draw_surface, surface_get_width(__s), surface_get_height(__s)); surface_set_shader(preview_draw_surface, noone,, BLEND.alpha); - draw_surface_safe(drawing_surface, 0, 0); + draw_surface_safe(_drawing_surface, 0, 0); draw_set_color(_col); if(isUsingTool("Selection")) { @@ -690,7 +720,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor } surface_reset_shader(); - if(!isNotUsingTool()) { + if(isUsingTool()) { if(isUsingTool("Selection")) { if(is_selected) { var pos_x = _x + selection_position[0] * _s; diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index 1c9a8f61e..1da1a94e6 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -1,34 +1,30 @@ global.loop_nodes = [ "Node_Iterate", "Node_Iterate_Each" ]; function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x, _y) constructor { - active = true; - renderActive = true; + #region ---- main & active ---- + active = true; + renderActive = true; - node_id = UUID_generate(); + node_id = UUID_generate(); - group = _group; - destroy_when_upgroup = false; - ds_list_add(PANEL_GRAPH.getNodeList(_group), self); + group = _group; + destroy_when_upgroup = false; + ds_list_add(PANEL_GRAPH.getNodeList(_group), self); - active_index = -1; - active_range = [ 0, PROJECT.animator.frames_total - 1 ]; + active_index = -1; + active_range = [ 0, PROJECT.animator.frames_total - 1 ]; + #endregion - color = c_white; - icon = noone; - bg_spr = THEME.node_bg; - bg_sel_spr = THEME.node_active; - anim_priority = ds_map_size(PROJECT.nodeMap); - - static resetInternalName = function() { + static resetInternalName = function() { #region var str = string_replace_all(name, " ", "_"); str = string_replace_all(str, "/", ""); str = string_replace_all(str, "-", ""); internalName = str + string(irandom_range(10000, 99999)); PROJECT.nodeNameMap[? internalName] = self; - } + } #endregion - if(!LOADING && !APPENDING) { + if(!LOADING && !APPENDING) { #region recordAction(ACTION_TYPE.node_added, self); PROJECT.nodeMap[? node_id] = self; PROJECT.modified = true; @@ -40,108 +36,144 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x resetInternalName(); display_name = name; //__txt_node_name(instanceof(self), name); }); - } + } #endregion - name = ""; - display_name = ""; - internalName = ""; + #region ---- display ---- + color = c_white; + icon = noone; + bg_spr = THEME.node_bg; + bg_sel_spr = THEME.node_active; - tooltip = ""; - x = _x; - y = _y; + name = ""; + display_name = ""; + internalName = ""; - w = 128; - h = 128; - min_h = 0; - draw_padding = 8; - auto_height = true; + tooltip = ""; + x = _x; + y = _y; - draw_name = true; - draggable = true; + w = 128; + h = 128; + min_h = 0; + draw_padding = 4; + auto_height = true; + + display_parameter = {}; + + draw_name = true; + draggable = true; + + draw_graph_culled = false; + + badgePreview = 0; + badgeInspect = 0; + + active_draw_index = -1; + + draw_droppable = false; + #endregion - inputs = ds_list_create(); - outputs = ds_list_create(); - inputMap = ds_map_create(); - outputMap = ds_map_create(); + #region ---- junctions ---- + inputs = ds_list_create(); + outputs = ds_list_create(); + inputMap = ds_map_create(); + outputMap = ds_map_create(); - input_display_list = -1; - output_display_list = -1; - inspector_display_list = -1; - is_dynamic_output = false; + input_display_list = -1; + output_display_list = -1; + inspector_display_list = -1; + is_dynamic_output = false; + + inspectInput1 = nodeValue("Toggle execution", self, JUNCTION_CONNECT.input, VALUE_TYPE.action, false).setVisible(true, true); + inspectInput2 = nodeValue("Toggle execution", self, JUNCTION_CONNECT.input, VALUE_TYPE.action, false).setVisible(true, true); + + insp1UpdateTooltip = __txtx("panel_inspector_execute", "Execute node"); + insp1UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ]; - attributes = {}; - attributeEditors = []; + insp2UpdateTooltip = __txtx("panel_inspector_execute", "Execute node"); + insp2UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ]; - inspectInput1 = nodeValue("Toggle execution", self, JUNCTION_CONNECT.input, VALUE_TYPE.action, false).setVisible(true, true); - inspectInput2 = nodeValue("Toggle execution", self, JUNCTION_CONNECT.input, VALUE_TYPE.action, false).setVisible(true, true); + updateAction = nodeValue("Update", self, JUNCTION_CONNECT.input, VALUE_TYPE.action, false).setVisible(true, true); + + is_dynamic_input = false; + input_display_len = 0; + input_fix_len = 0; + data_length = 1; + #endregion - updateAction = nodeValue("Update", self, JUNCTION_CONNECT.input, VALUE_TYPE.action, false).setVisible(true, true); + #region --- attributes ---- + attributes = {}; + attributeEditors = []; + #endregion - show_input_name = false; - show_output_name = false; + #region ---- preview ---- + show_input_name = false; + show_output_name = false; - inspecting = false; - previewing = 0; + inspecting = false; + previewing = 0; - preview_surface = noone; - preview_amount = 0; - previewable = true; - preview_speed = 0; - preview_index = 0; - preview_channel = 0; - preview_alpha = 1; - preview_x = 0; - preview_y = 0; + preview_surface = noone; + preview_amount = 0; + previewable = true; + preview_speed = 0; + preview_index = 0; + preview_channel = 0; + preview_alpha = 1; + preview_x = 0; + preview_y = 0; - preview_surface_prev = noone; - preview_trans = 1; - preview_drop_x = 0; - preview_drop_y = 0; + preview_mx = 0; + preview_my = 0; + #endregion - preview_mx = 0; - preview_my = 0; + #region ---- rendering ---- + rendered = false; + update_on_frame = false; + render_time = 0; + auto_render_time = true; + updated = false; - rendered = false; - update_on_frame = false; - render_time = 0; - auto_render_time = true; - updated = false; + use_cache = false; + clearCacheOnChange = true; + cached_output = []; + cache_result = []; + temp_surface = []; + #endregion - use_cache = false; - clearCacheOnChange = true; - cached_output = []; - cache_result = []; - temp_surface = []; + #region ---- timeline ---- + anim_priority = ds_map_size(PROJECT.nodeMap); + + anim_show = true; + dopesheet_color = COLORS.panel_animation_dope_blend_default; + dopesheet_y = 0; + #endregion - tools = -1; + #region ---- notification ---- + value_validation = array_create(3); + + error_noti_update = noone; + error_update_enabled = false; + manual_updated = false; + manual_deletable = true; + #endregion + + #region ---- tools ---- + tools = -1; + isTool = false; + tool_settings = []; + tool_attribute = {}; + #endregion + + #region ---- 3d ---- + is_3D = false; + #endregion on_dragdrop_file = -1; - anim_show = true; - dopesheet_color = COLORS.panel_animation_dope_blend_default; - dopesheet_y = 0; - - value_validation = array_create(3); - - error_noti_update = noone; - error_update_enabled = false; - manual_updated = false; - manual_deletable = true; - - isTool = false; - tool_settings = []; - tool_attribute = {}; - - is_dynamic_input = false; - input_display_len = 0; - input_fix_len = 0; - data_length = 1; - - is_3D = false; - static createNewInput = noone; - static initTooltip = function() { + static initTooltip = function() { #region var type_self/*:string*/ = instanceof(self); if(!struct_has(global.NODE_GUIDE, type_self)) return; @@ -160,10 +192,10 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x outputs[| i].name = _ots[i].name; outputs[| i].tooltip = _ots[i].tooltip; } - } + } #endregion run_in(1, initTooltip); - static resetDefault = function() { + static resetDefault = function() { #region var folder = instanceof(self); if(!ds_map_exists(global.PRESETS_MAP, folder)) return; @@ -177,11 +209,11 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x } doUpdate(); - } + } #endregion if(!APPENDING && !LOADING) run_in(1, method(self, resetDefault)); - static getInputJunctionIndex = function(index) { + static getInputJunctionIndex = function(index) { #region if(input_display_list == -1) return index; @@ -189,15 +221,15 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x if(is_array(jun_list_arr)) return noone; if(is_struct(jun_list_arr)) return noone; return jun_list_arr; - } + } #endregion - static getOutputJunctionIndex = function(index) { + static getOutputJunctionIndex = function(index) { #region if(output_display_list == -1) return index; return output_display_list[index]; - } + } #endregion - static setHeight = function() { + static setHeight = function() { #region var _hi = ui(32); var _ho = ui(32); @@ -210,26 +242,26 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x } h = max(min_h, (preview_surface && previewable)? 128 : 0, _hi, _ho); - } + } #endregion onSetDisplayName = noone; - static setDisplayName = function(_name) { + static setDisplayName = function(_name) { #region display_name = _name; internalName = string_replace_all(display_name, " ", "_"); refreshNodeMap(); if(onSetDisplayName != noone) onSetDisplayName(); - } + } #endregion - static setIsDynamicInput = function(_data_length = 1) { + static setIsDynamicInput = function(_data_length = 1) { #region is_dynamic_input = true; input_display_len = input_display_list == -1? 0 : array_length(input_display_list); input_fix_len = ds_list_size(inputs); data_length = _data_length; - } + } #endregion - static getOutput = function(junc = noone) { + static getOutput = function(junc = noone) { #region for( var i = 0; i < ds_list_size(outputs); i++ ) { if(!outputs[| i].visible) continue; if(junc != noone && !junc.isConnectable(outputs[| i], true)) continue; @@ -237,9 +269,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x return outputs[| i]; } return noone; - } + } #endregion - static getInput = function(junc = noone) { + static getInput = function(junc = noone) { #region for( var i = 0; i < ds_list_size(inputs); i++ ) { if(!inputs[| i].visible) continue; if(inputs[| i].value_from != noone) continue; @@ -248,42 +280,40 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x return inputs[| i]; } return noone; - } + } #endregion - static getFullName = function() { + static getFullName = function() { #region return display_name == ""? name : "[" + name + "] " + display_name; - } + } #endregion - static addInput = function(junctionFrom) { + static addInput = function(junctionFrom) { #region var targ = getInput(junctionFrom); if(targ == noone) return; targ.setFrom(junctionFrom); - } + } #endregion - static isAnimated = function() { + static isAnimated = function() { #region for(var i = 0; i < ds_list_size(inputs); i++) { if(inputs[| i].isAnimated()) return true; } return false; - } + } #endregion - static isInLoop = function() { + static isInLoop = function() { #region return array_exists(global.loop_nodes, instanceof(group)); - } + } #endregion - static move = function(_x, _y) { + static move = function(_x, _y) { #region if(x == _x && y == _y) return; x = _x; y = _y; if(!LOADING) PROJECT.modified = true; - } - - insp1UpdateTooltip = __txtx("panel_inspector_execute", "Execute node"); - insp1UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ]; + } #endregion + #region ++++ inspector update ++++ static inspector1Update = function() { if(error_update_enabled && error_noti_update != noone) noti_remove(error_noti_update); @@ -294,14 +324,12 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x static onInspector1Update = noone; static hasInspector1Update = function() { return onInspector1Update != noone; } - insp2UpdateTooltip = __txtx("panel_inspector_execute", "Execute node"); - insp2UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ]; - static inspector2Update = function() { onInspector2Update(); } static onInspector2Update = noone; static hasInspector2Update = function() { return onInspector2Update != noone; } + #endregion - static stepBegin = function() { + static stepBegin = function() { #region if(use_cache) cacheArrayCheck(); var willUpdate = false; @@ -322,14 +350,13 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x if(hasInspector1Update()) inspectInput1.name = insp1UpdateTooltip; if(hasInspector2Update()) inspectInput2.name = insp2UpdateTooltip; - } + } #endregion + static doStepBegin = function() {} - static triggerCheck = function() { - _triggerCheck(); - } + static triggerCheck = function() { _triggerCheck(); } - static _triggerCheck = function() { + static _triggerCheck = function() { #region for( var i = 0; i < ds_list_size(inputs); i++ ) { if(inputs[| i].type != VALUE_TYPE.trigger) continue; if(!is_instanceof(inputs[| i].editWidget, buttonClass)) continue; @@ -356,13 +383,13 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x inspectInput2.setValue(false); } } - } + } #endregion static step = function() {} static focusStep = function() {} static inspectorStep = function() {} - static doUpdate = function() { + static doUpdate = function() { #region if(SAFE_MODE) return; if(NODE_EXTRACT) return; @@ -406,19 +433,19 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x if(trigger) onInspector2Update(); } LOG_BLOCK_END(); - } + } #endregion - static valueUpdate = function(index) { + static valueUpdate = function(index) { #region if(error_update_enabled && error_noti_update == noone) error_noti_update = noti_error(getFullName() + " node require manual execution.",, self); onValueUpdate(index); - } + } #endregion static onValueUpdate = function(index = 0) {} static onValueFromUpdate = function(index) {} - static triggerRender = function() { + static triggerRender = function() { #region LOG_BLOCK_START(); LOG_IF(global.FLAG.render, $"Trigger render for {internalName}"); @@ -436,12 +463,12 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x } LOG_BLOCK_END(); - } + } #endregion static resetRender = function() { setRenderStatus(false); } static isRenderActive = function() { return renderActive || (PREF_MAP[? "render_all_export"] && PROJECT.animator.rendering); } - static isRenderable = function(log = false) { //Check if every input is ready (updated) + static isRenderable = function(log = false) { #region //Check if every input is ready (updated) if(!active) return false; if(!isRenderActive()) return false; @@ -462,11 +489,11 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x } return true; - } + } #endregion static getNextNodesRaw = function() { return getNextNodes(); } - static getNextNodes = function() { + static getNextNodes = function() { #region var nodes = []; var nodeNames = []; @@ -495,43 +522,42 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x LOG_BLOCK_END(); LOG_BLOCK_END(); return nodes; - } + } #endregion - static isTerminal = function() { + static isTerminal = function() { #region for( var i = 0; i < ds_list_size(outputs); i++ ) { var _to = outputs[| i].getJunctionTo(); if(array_length(_to)) return false; } return true; - } + } #endregion static onInspect = function() {} - static setRenderStatus = function(result) { + static setRenderStatus = function(result) { #region LOG_LINE_IF(global.FLAG.render, $"Set render status for {internalName} : {result}"); rendered = result; - } + } #endregion - static pointIn = function(_x, _y, _mx, _my, _s) { + static pointIn = function(_x, _y, _mx, _my, _s) { #region var xx = x * _s + _x; var yy = y * _s + _y; return point_in_rectangle(_mx, _my, xx, yy, xx + w * _s, yy + h * _s); - } + } #endregion - draw_graph_culled = false; - static cullCheck = function(_x, _y, _s, minx, miny, maxx, maxy) { + static cullCheck = function(_x, _y, _s, minx, miny, maxx, maxy) { #region var x0 = x * _s + _x; var y0 = y * _s + _y; var x1 = (x + w) * _s + _x; var y1 = (y + h) * _s + _y; draw_graph_culled = !rectangle_in_rectangle(minx, miny, maxx, maxy, x0, y0, x1, y1); - } + } #endregion - static preDraw = function(_x, _y, _s) { + static preDraw = function(_x, _y, _s) { #region var xx = x * _s + _x; var yy = y * _s + _y; var jun; @@ -576,25 +602,36 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x jun.y = _in; _in += 24 * _s * jun.isVisible(); } - } + } #endregion - static drawNodeBase = function(xx, yy, _s) { + static drawNodeBase = function(xx, yy, _s) { #region if(draw_graph_culled) return; if(!active) return; var aa = 0.25 + 0.5 * renderActive; draw_sprite_stretched_ext(bg_spr, 0, xx, yy, w * _s, h * _s, color, aa); - } + } #endregion - static drawGetBbox = function(xx, yy, _s) { - var x0 = xx + draw_padding * _s; - var x1 = xx + (w - draw_padding) * _s; - var y0 = yy + 20 * draw_name + draw_padding * _s; - var y1 = yy + (h - draw_padding) * _s; + static drawGetBbox = function(xx, yy, _s) { #region + var pad_label = draw_name && display_parameter.avoid_label; + + var _w = w - draw_padding * 2; + var _h = h - draw_padding * 2 - 20 * pad_label; + + _w *= display_parameter.preview_scale / 100 * _s; + _h *= display_parameter.preview_scale / 100 * _s; + + var _xc = xx + w * _s / 2; + var _yc = yy + (h * _s + 20 * pad_label) / 2; + + var x0 = _xc - _w / 2; + var x1 = _xc + _w / 2; + var y0 = _yc - _h / 2; + var y1 = _yc + _h / 2; return BBOX().fromPoints(x0, y0, x1, y1); - } + } #endregion - static drawNodeName = function(xx, yy, _s) { + static drawNodeName = function(xx, yy, _s) { #region if(draw_graph_culled) return; if(!active) return; @@ -626,9 +663,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x draw_text_cut(xx + ui(8), yy + ui(10), _name, w * _s - ui(8), ts); draw_set_alpha(1); - } + } #endregion - static drawJunctions = function(_x, _y, _mx, _my, _s) { + static drawJunctions = function(_x, _y, _mx, _my, _s) { #region if(!active) return; var hover = noone; var amo = input_display_list == -1? ds_list_size(inputs) : array_length(input_display_list); @@ -658,9 +695,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x hover = inspectInput2; return hover; - } + } #endregion - static drawJunctionNames = function(_x, _y, _mx, _my, _s) { + static drawJunctionNames = function(_x, _y, _mx, _my, _s) { #region if(draw_graph_culled) return; if(!active) return; var amo = input_display_list == -1? ds_list_size(inputs) : array_length(input_display_list); @@ -707,9 +744,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x inspectInput2.drawNameBG(_s); inspectInput2.drawName(_s, _mx, _my); } - } + } #endregion - static drawConnections = function(_x, _y, _s, mx, my, _active, aa = 1, minx = undefined, miny = undefined, maxx = undefined, maxy = undefined) { + static drawConnections = function(_x, _y, _s, mx, my, _active, aa = 1, minx = undefined, miny = undefined, maxx = undefined, maxy = undefined) { #region if(!active) return; var hovering = noone; @@ -765,15 +802,15 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x } return hovering; - } + } #endregion - static getGraphPreviewSurface = function() { + static getGraphPreviewSurface = function() { #region var _node = outputs[| preview_channel]; if(_node.type != VALUE_TYPE.surface) return noone; return _node.getValue(); - } + } #endregion - static drawPreview = function(xx, yy, _s) { + static drawPreview = function(xx, yy, _s) { #region if(draw_graph_culled) return; if(!active) return; @@ -798,46 +835,13 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x preview_surface = is_surface(surf)? surf : noone; if(preview_surface == noone) return; - var pw = surface_get_width(preview_surface); - var ph = surface_get_height(preview_surface); - var ps = min((w * _s - 8) / pw, (h * _s - 8) / ph); - var px = xx + w * _s / 2 - pw * ps / 2; - var py = yy + h * _s / 2 - ph * ps / 2; - var aa = 0.5 + 0.5 * renderActive; + var bbox = drawGetBbox(xx, yy, _s); + var aa = 0.5 + 0.5 * renderActive; - if(preview_trans == 1) { - draw_surface_ext_safe(preview_surface, px, py, ps, ps, 0, c_white, aa); - return; - } - - if(preview_trans < 1 && is_surface(preview_surface_prev)) { - preview_trans = lerp_float(preview_trans, 1, 8); - var _pw = surface_get_width(preview_surface_prev); - var _ph = surface_get_height(preview_surface_prev); - var _ps = min((w * _s - 8) / _pw, (h * _s - 8) / _ph); - var _px = xx + w * _s / 2 - _pw * _ps / 2; - var _py = yy + h * _s / 2 - _ph * _ps / 2; - - draw_surface_ext_safe(preview_surface_prev, _px, _py, _ps, _ps, 0, c_white, aa); - - shader_set(sh_trans_node_prev_drop); - shader_set_f("dimension", _pw, _ph); - shader_set_f("position", (preview_drop_x - px) / (_pw * _ps), (preview_drop_y - py) / (_ph * _ps)); - shader_set_f("prog", preview_trans); - draw_surface_ext_safe(preview_surface, px, py, ps, ps, 0, c_white, aa); - shader_reset(); - } else if(is_surface(preview_surface_prev)) - surface_free(preview_surface_prev); - } + draw_surface_bbox(preview_surface, bbox, c_white, aa); + } #endregion - static previewDropAnimation = function() { - preview_surface_prev = surface_clone(preview_surface); - preview_trans = 0; - preview_drop_x = preview_mx; - preview_drop_y = preview_my; - } - - static getNodeDimension = function(showFormat = true) { + static getNodeDimension = function(showFormat = true) { #region if(!is_surface(preview_surface)) { if(ds_list_size(outputs)) return "[" + array_shape(outputs[| 0].getValue()) + "]"; @@ -864,9 +868,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x txt += "]"; return txt; - } + } #endregion - static drawDimension = function(xx, yy, _s) { + static drawDimension = function(xx, yy, _s) { #region if(draw_graph_culled) return; if(!active) return; if(_s * w < 64) return; @@ -875,7 +879,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x var tx = xx + w * _s / 2; var ty = yy + (h + 4) * _s - 2; - if(PANEL_GRAPH.show_dimension) { + if(display_parameter.show_dimension) { var txt = string(getNodeDimension(_s > 0.65)); draw_text(round(tx), round(ty), txt); ty += string_height(txt) - 2; @@ -883,7 +887,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x draw_set_font(f_p3); - if(PANEL_GRAPH.show_compute) { + if(display_parameter.show_compute) { var rt, unit; if(render_time < 1000) { rt = round(render_time / 10) * 10; @@ -900,11 +904,12 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x } draw_text(round(tx), round(ty), string(rt) + " " + unit); } - } + } #endregion - static drawNode = function(_x, _y, _mx, _my, _s) { + static drawNode = function(_x, _y, _mx, _my, _s, display_parameter) { #region if(draw_graph_culled) return; if(!active) return; + self.display_parameter = display_parameter; var xx = x * _s + _x; var yy = y * _s + _y; @@ -936,7 +941,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x draw_droppable = false; return drawJunctions(xx, yy, _mx, _my, _s); - } + } #endregion static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) {} @@ -944,9 +949,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x static onDrawHover = function(_x, _y, _mx, _my, _s) {} - badgePreview = 0; - badgeInspect = 0; - static drawBadge = function(_x, _y, _s) { + static drawBadge = function(_x, _y, _s) { #region if(!active) return; var xx = x * _s + _x + w * _s; var yy = y * _s + _y; @@ -971,12 +974,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x inspecting = false; previewing = 0; - } + } #endregion - active_draw_index = -1; - static drawActive = function(_x, _y, _s, ind = 0) { - active_draw_index = ind; - } + static drawActive = function(_x, _y, _s, ind = 0) { active_draw_index = ind; } static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {} @@ -985,7 +985,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x static enable = function() { active = true; } static disable = function() { active = false; } - static destroy = function(_merge = false) { + static destroy = function(_merge = false) { #region if(!active) return; disable(); @@ -1024,15 +1024,15 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x outputs[| i].destroy(); onDestroy(); - } + } #endregion - static restore = function() { + static restore = function() { #region if(active) return; enable(); ds_list_add(group == noone? PROJECT.nodes : group.getNodeList(), self); - } + } #endregion - static onValidate = function() { + static onValidate = function() { #region value_validation[VALIDATION.pass] = 0; value_validation[VALIDATION.warning] = 0; value_validation[VALIDATION.error] = 0; @@ -1042,23 +1042,23 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x if(jun.value_validation) value_validation[jun.value_validation]++; } - } + } #endregion static onDestroy = function() {} - static clearInputCache = function() { + static clearInputCache = function() { #region for( var i = 0; i < ds_list_size(inputs); i++ ) inputs[| i].cache_value[0] = false; - } + } #endregion - static cacheArrayCheck = function() { + static cacheArrayCheck = function() { #region if(array_length(cached_output) != PROJECT.animator.frames_total) array_resize(cached_output, PROJECT.animator.frames_total); if(array_length(cache_result) != PROJECT.animator.frames_total) array_resize(cache_result, PROJECT.animator.frames_total); - } + } #endregion - static cacheCurrentFrame = function(_frame) { + static cacheCurrentFrame = function(_frame) { #region cacheArrayCheck(); if(PROJECT.animator.current_frame < 0) return; if(PROJECT.animator.current_frame >= array_length(cached_output)) return; @@ -1069,9 +1069,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x array_safe_set(cache_result, PROJECT.animator.current_frame, true); return cached_output[PROJECT.animator.current_frame]; - } + } #endregion - static cacheExist = function(frame = PROJECT.animator.current_frame) { + static cacheExist = function(frame = PROJECT.animator.current_frame) { #region if(frame < 0) return false; if(frame >= array_length(cached_output)) return false; @@ -1080,25 +1080,26 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x var s = array_safe_get(cached_output, frame); return is_array(s) || surface_exists(s); - } + } #endregion - static getCacheFrame = function(frame = PROJECT.animator.current_frame) { + static getCacheFrame = function(frame = PROJECT.animator.current_frame) { #region if(frame < 0) return false; if(!cacheExist(frame)) return noone; var surf = array_safe_get(cached_output, frame); return surf; - } + } #endregion - static recoverCache = function(frame = PROJECT.animator.current_frame) { + static recoverCache = function(frame = PROJECT.animator.current_frame) { #region if(!cacheExist(frame)) return false; var _s = cached_output[PROJECT.animator.current_frame]; outputs[| 0].setValue(_s); return true; - } - static clearCache = function() { + } #endregion + + static clearCache = function() { #region clearInputCache(); if(!clearCacheOnChange) return; @@ -1114,13 +1115,11 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x cached_output[i] = 0; cache_result[i] = false; } - } + } #endregion - static clearCacheForward = function() { - _clearCacheForward(); - } + static clearCacheForward = function() { _clearCacheForward(); } - static _clearCacheForward = function() { + static _clearCacheForward = function() { #region if(!isRenderActive()) return; clearCache(); @@ -1131,14 +1130,14 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x //for( var i = 0; i < ds_list_size(outputs); i++ ) //for( var j = 0; j < ds_list_size(outputs[| i].value_to); j++ ) // outputs[| i].value_to[| j].node._clearCacheForward(); - } + } #endregion - static clearInputCache = function() { + static clearInputCache = function() { #region for( var i = 0; i < ds_list_size(inputs); i++ ) inputs[| i].resetCache(); - } + } #endregion - static checkConnectGroup = function(_type = "group") { + static checkConnectGroup = function(_type = "group") { #region var _y = y; var nodes = []; @@ -1189,13 +1188,11 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x } return nodes; - } + } #endregion - static isNotUsingTool = function() { - return PANEL_PREVIEW.tool_current == noone; - } + static isNotUsingTool = function() { return PANEL_PREVIEW.tool_current == noone; } - static isUsingTool = function(index, subtool = noone) { + static isUsingTool = function(index = undefined, subtool = noone) { #region if(tools == -1) return false; @@ -1203,6 +1200,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x if(_tool == noone) return false; + if(index == undefined) + return true; + if(is_real(index) && _tool != tools[index]) return false; @@ -1213,9 +1213,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x return true; return _tool.selecting == subtool; - } + } #endregion - static clone = function(target = PANEL_GRAPH.getCurrentContext()) { + static clone = function(target = PANEL_GRAPH.getCurrentContext()) { #region CLONING = true; var _type = instanceof(self); var _node = nodeBuild(_type, x, y, target); @@ -1240,35 +1240,33 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x onClone(_node, target); return _node; - } + } #endregion static onClone = function(_NewNode, target = PANEL_GRAPH.getCurrentContext()) {} - draw_droppable = false; - static droppable = function(dragObj) { + static droppable = function(dragObj) { #region for( var i = 0; i < ds_list_size(inputs); i++ ) { if(dragObj.type == inputs[| i].drop_key) return true; } return false; - } + } #endregion - static onDrop = function(dragObj) { + static onDrop = function(dragObj) { #region for( var i = 0; i < ds_list_size(inputs); i++ ) { if(dragObj.type == inputs[| i].drop_key) { inputs[| i].setValue(dragObj.data); - previewDropAnimation(); return; } } - } + } #endregion - static getPreviewValue = function() { + static getPreviewValue = function() { #region if(preview_channel > ds_list_size(outputs)) return noone; return outputs[| preview_channel]; - } + } #endregion - static getPreviewBoundingBox = function() { + static getPreviewBoundingBox = function() { #region var _node = getPreviewValue(); if(_node == undefined) return noone; if(_node.type != VALUE_TYPE.surface) return noone; @@ -1279,13 +1277,11 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x if(!is_surface(_surf)) return noone; return BBOX().fromWH(preview_x, preview_y, surface_get_width(_surf), surface_get_height(_surf)); - } + } #endregion - static getTool = function() { - return self; - } + static getTool = function() { return self; } - static setTool = function(tool) { + static setTool = function(tool) { #region if(!tool) { isTool = false; return; @@ -1295,7 +1291,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x group.nodes[| i].isTool = false; isTool = true; - } + } #endregion #region[#88ffe916] === Save Load === static serialize = function(scale = false, preset = false) { @@ -1523,7 +1519,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x static resetAnimation = function() {} - static cleanUp = function() { + static cleanUp = function() { #region for( var i = 0; i < ds_list_size(inputs); i++ ) inputs[| i].cleanUp(); for( var i = 0; i < ds_list_size(outputs); i++ ) @@ -1539,12 +1535,12 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x surface_free(temp_surface[i]); onCleanUp(); - } + } #endregion static onCleanUp = function() {} // helper function - static attrDepth = function() { + static attrDepth = function() { #region if(struct_has(attributes, "color_depth")) { var form = attributes.color_depth; if(inputs[| 0].type == VALUE_TYPE.surface) @@ -1558,5 +1554,5 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x if(!is_surface(_s)) return surface_rgba8unorm; return surface_get_format(_s); - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_keyframe/node_keyframe.gml b/scripts/node_keyframe/node_keyframe.gml index 2cfc25598..29b826f8e 100644 --- a/scripts/node_keyframe/node_keyframe.gml +++ b/scripts/node_keyframe/node_keyframe.gml @@ -193,8 +193,17 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { if(prop.on_end == KEYFRAME_END.wrap) { var from = values[| ds_list_size(values) - 1]; var to = values[| 0]; - var prog = PROJECT.animator.frames_total - from.time + _time; - var totl = PROJECT.animator.frames_total - from.time + to.time; + + var fTime = from.time; + var tTime = to.time; + + //if(from > PROJECT.animator.frames_total) { + // fTime = fTime % PROJECT.animator.frames_total; + // tTime = tTime - PROJECT.animator.frames_total; + //} + + var prog = PROJECT.animator.frames_total - fTime + _time; + var totl = PROJECT.animator.frames_total - fTime + tTime; var rat = prog / totl; var _lrp = interpolate(from, to, rat); diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index f4c01725d..96da629f8 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -350,13 +350,15 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { ///**/ addNodeObject(threeD, "Depth 3D", s_node_stack, "Node_3D_Depth", [1, Node_3D_Depth],, "Create 3D looking image from depth map.").setVersion(1447); ds_list_add(threeD, "3D"); - addNodeObject(threeD, "3D Scene", s_node_3d_cube, "Node_3D_Scene", [1, Node_3D_Scene]); + addNodeObject(threeD, "3D Scene", s_node_3d_cube, "Node_3D_Scene", [1, Node_3D_Scene]); + addNodeObject(threeD, "3D Camera", s_node_3d_cube, "Node_3D_Camera", [1, Node_3D_Camera]); ds_list_add(threeD, "Mesh"); - addNodeObject(threeD, "3D Cube", s_node_3d_cube, "Node_3D_Mesh_Cube", [1, Node_3D_Mesh_Cube]); + addNodeObject(threeD, "3D Cube", s_node_3d_cube, "Node_3D_Mesh_Cube", [1, Node_3D_Mesh_Cube]); ds_list_add(threeD, "Light"); addNodeObject(threeD, "Directional Light", s_node_3d_cube, "Node_3D_Light_Directional", [1, Node_3D_Light_Directional]); + addNodeObject(threeD, "Point Light", s_node_3d_cube, "Node_3D_Light_Point", [1, Node_3D_Light_Point]); ds_list_add(threeD, "Legacy"); addNodeObject(threeD, "3D Object", s_node_3d_obj, "Node_3D_Obj", [0, Node_create_3D_Obj],, "Load .obj file from your computer as a 3D object."); diff --git a/scripts/panel_animation/panel_animation.gml b/scripts/panel_animation/panel_animation.gml index bb67fc109..fb5417ed4 100644 --- a/scripts/panel_animation/panel_animation.gml +++ b/scripts/panel_animation/panel_animation.gml @@ -10,12 +10,14 @@ function Panel_Animation() : PanelContent() constructor { context_str = "Animation"; icon = THEME.panel_animation; - timeline_h = ui(28); - min_w = ui(40); - min_h = ui(48); - tool_width = ui(224); + #region ---- dimension ---- + timeline_h = ui(28); + min_w = ui(40); + min_h = ui(48); + tool_width = ui(224); + #endregion - static initSize = function() { + static initSize = function() { #region timeline_w = w - tool_width - ui(80); timeline_surface = surface_create_valid(timeline_w, timeline_h); timeline_mask = surface_create_valid(timeline_w, timeline_h); @@ -24,79 +26,99 @@ function Panel_Animation() : PanelContent() constructor { dope_sheet_h = h - timeline_h - ui(20); dope_sheet_surface = surface_create_valid(dope_sheet_w, 1); dope_sheet_mask = surface_create_valid(dope_sheet_w, 1); - } + } #endregion initSize(); - dope_sheet_y = 0; - dope_sheet_y_to = 0; - dope_sheet_y_max = 0; - is_scrolling = false; + #region ---- position ---- + dope_sheet_y = 0; + dope_sheet_y_to = 0; + dope_sheet_y_max = 0; + is_scrolling = false; - dopesheet_dragging = noone; - dopesheet_drag_mx = 0; + dopesheet_dragging = noone; + dopesheet_drag_mx = 0; - dope_sheet_node_padding = ui(2); + dope_sheet_node_padding = ui(2); + #endregion ds_name_surface = surface_create_valid(tool_width - ui(16), 1); - timeline_scubbing = false; - timeline_scub_st = 0; - timeline_scale = 20; - timeline_separate = 5; - timeline_sep_line = 1; - _scrub_frame = -1; + #region ---- timeline ---- + timeline_scubbing = false; + timeline_scub_st = 0; + timeline_scale = 20; + timeline_separate = 5; + timeline_sep_line = 1; + _scrub_frame = -1; - timeline_shift = 0; - timeline_shift_to = 0; - timeline_dragging = false; - timeline_drag_sx = 0; - timeline_drag_sy = 0; - timeline_drag_mx = 0; - timeline_drag_my = 0; - timeline_draggable = true; + timeline_shift = 0; + timeline_shift_to = 0; + timeline_dragging = false; + timeline_drag_sx = 0; + timeline_drag_sy = 0; + timeline_drag_mx = 0; + timeline_drag_my = 0; + timeline_draggable = true; - timeline_stretch = 0; - timeline_stretch_sx = 0; - timeline_stretch_mx = 0; + timeline_stretch = 0; + timeline_stretch_sx = 0; + timeline_stretch_mx = 0; - timeline_show_time = -1; - timeline_preview = noone; + timeline_show_time = -1; + timeline_preview = noone; + #endregion - keyframe_dragging = noone; - keyframe_drag_type = -1; - keyframe_dragout = false; - keyframe_drag_mx = 0; - keyframe_drag_my = 0; - keyframe_selecting = []; + #region ---- keyframes ---- + keyframe_dragging = noone; + keyframe_drag_type = -1; + keyframe_dragout = false; + keyframe_drag_mx = 0; + keyframe_drag_my = 0; + keyframe_selecting = []; - keyframe_boxable = true; - keyframe_boxing = false; - keyframe_box_sx = -1; - keyframe_box_sy = -1; + keyframe_boxable = true; + keyframe_boxing = false; + keyframe_box_sx = -1; + keyframe_box_sy = -1; + #endregion - value_hovering = noone; - value_focusing = noone; + #region ---- values ---- + value_hovering = noone; + value_focusing = noone; + #endregion - show_node_outside_context = true; - node_ordering = noone; - node_name_type = 0; + #region ---- display ---- + show_node_outside_context = true; + #endregion - stagger_mode = 0; - stagger_index = 0; + #region ---- nodes ---- + node_ordering = noone; + node_name_type = 0; + #endregion + + #region ---- stagger ---- + stagger_mode = 0; + stagger_index = 0; + #endregion + + #region ---- tools ---- + tool_width_drag = false; + tool_width_start = 0; + tool_width_mx = 0; + #endregion anim_properties = ds_list_create(); - tool_width_drag = false; - tool_width_start = 0; - tool_width_mx = 0; - on_end_dragging_anim = noone; onion_dragging = noone; prev_cache = array_create(PROJECT.animator.frames_total); - control_buttons = [ + copy_clipboard = ds_list_create(); + + #region ++++ control_buttons ++++ + control_buttons = [ [ function() { return __txt("Stop"); }, function() { return 4; }, function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; }, @@ -129,7 +151,9 @@ function Panel_Animation() : PanelContent() constructor { function() { PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); } ], ]; + #endregion + #region ++++ hotkeys ++++ addHotkey("", "Play/Pause", vk_space, MOD_KEY.none, function() { if(PROJECT.animator.is_playing) PROJECT.animator.pause() else PROJECT.animator.play(); }); addHotkey("", "Resume/Pause", vk_space, MOD_KEY.shift, function() { if(PROJECT.animator.is_playing) PROJECT.animator.pause() else PROJECT.animator.resume(); }); @@ -146,17 +170,18 @@ function Panel_Animation() : PanelContent() constructor { addHotkey("Animation", "Duplicate", "D", MOD_KEY.ctrl, function() { PANEL_ANIMATION.doDuplicate(); }); addHotkey("Animation", "Copy", "C", MOD_KEY.ctrl, function() { PANEL_ANIMATION.doCopy(); }); addHotkey("Animation", "Paste", "V", MOD_KEY.ctrl, function() { PANEL_ANIMATION.doPaste(PANEL_ANIMATION.value_focusing); }); + #endregion - function deleteKeys() { + function deleteKeys() { #region for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) { var k = keyframe_selecting[i]; k.anim.removeKey(k); } keyframe_selecting = []; updatePropertyList(); - } + } #endregion - function alignKeys(halign = fa_left) { + function alignKeys(halign = fa_left) { #region if(array_empty(keyframe_selecting)) return; var tt = 0; @@ -184,9 +209,9 @@ function Panel_Animation() : PanelContent() constructor { var k = keyframe_selecting[i]; k.anim.setKeyTime(k, tt); } - } + } #endregion - function arrangeKeys() { + function arrangeKeys() { #region var l = []; for( var i = 0; i < ds_list_size(anim_properties); i++ ) { var node = anim_properties[| i]; @@ -216,9 +241,9 @@ function Panel_Animation() : PanelContent() constructor { } keyframe_selecting = l; - } + } #endregion - function staggerKeys(_index, _stag) { + function staggerKeys(_index, _stag) { #region var t = keyframe_selecting[_index].time; for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) { var k = keyframe_selecting[i]; @@ -226,8 +251,9 @@ function Panel_Animation() : PanelContent() constructor { k.anim.setKeyTime(k, _t); } - } + } #endregion + #region ++++ keyframe_menu ++++ keyframe_menu = [ menuItem(__txtx("panel_animation_lock_y", "Lock/Unlock Y easing"), function() { for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) { @@ -318,10 +344,11 @@ function Panel_Animation() : PanelContent() constructor { keyframe_menu_empty = [ menuItem(__txt("Paste"), function() { doPaste(value_focusing); }, THEME.paste, [ "Animation", "Paste" ]), ]; + #endregion function onFocusBegin() { PANEL_ANIMATION = self; } - function onResize() { + function onResize() { #region initSize(); if(w - tool_width > 1) { @@ -344,9 +371,9 @@ function Panel_Animation() : PanelContent() constructor { ds_name_surface = surface_verify(ds_name_surface, tool_width - ui(0), dope_sheet_h); } resetTimelineMask(); - } + } #endregion - function resetTimelineMask() { + function resetTimelineMask() { #region if(!surface_exists(timeline_mask)) timeline_mask = surface_create_valid(timeline_w, timeline_h); @@ -368,10 +395,10 @@ function Panel_Animation() : PanelContent() constructor { gpu_set_blendmode(bm_normal); surface_reset_target(); } - } + } #endregion resetTimelineMask(); - function updatePropertyNode(pr, _node) { + function updatePropertyNode(pr, _node) { #region var is_anim = false; for(var j = 0; j < ds_list_size(_node.inputs); j++) { var jun = _node.inputs[| j]; @@ -380,9 +407,9 @@ function Panel_Animation() : PanelContent() constructor { if(!is_anim) return; ds_priority_add(pr, _node, _node.anim_priority); - } + } #endregion - function updatePropertyList() { + function updatePropertyList() { #region ds_list_destroy(anim_properties); var amo = ds_map_size(PROJECT.nodeMap); var k = ds_map_find_first(PROJECT.nodeMap); @@ -400,9 +427,9 @@ function Panel_Animation() : PanelContent() constructor { anim_properties = ds_priority_to_list(pr); ds_priority_destroy(pr); - } + } #endregion - function drawTimeline() { //draw summary + function drawTimeline() { #region //draw summary var bar_x = tool_width + ui(16); var bar_y = h - timeline_h - ui(10); var bar_w = timeline_w; @@ -577,9 +604,9 @@ function Panel_Animation() : PanelContent() constructor { surface_reset_target(); draw_surface_safe(timeline_surface, bar_x, bar_y); - } + } #endregion - function drawDopesheetLine(animator, key_y, msx, msy, _gy_val_min = 999999, _gy_val_max = -999999) { + function drawDopesheetLine(animator, key_y, msx, msy, _gy_val_min = 999999, _gy_val_max = -999999) { #region var bar_total_w = PROJECT.animator.frames_total * ui(timeline_scale); var bar_show_w = timeline_shift + bar_total_w; var hovering = noone; @@ -719,9 +746,9 @@ function Panel_Animation() : PanelContent() constructor { } } } - } + } #endregion - function drawDopesheetGraph(prop, key_y, msx, msy) { + function drawDopesheetGraph(prop, key_y, msx, msy) { #region var bar_total_w = PROJECT.animator.frames_total * ui(timeline_scale); var bar_show_w = timeline_shift + bar_total_w; var _gy_top = key_y + ui(16); @@ -787,9 +814,9 @@ function Panel_Animation() : PanelContent() constructor { drawDopesheetLine(prop.animators[i], key_y, msx, msy, _min, _max); } else drawDopesheetLine(prop.animator, key_y, msx, msy); - } + } #endregion - function drawDopesheetAnimatorKeysBG(animator, msx, msy) { + function drawDopesheetAnimatorKeysBG(animator, msx, msy) { #region var prop_dope_y = animator.dopesheet_y; var key_hover = noone; var key_list = animator.values; @@ -845,9 +872,9 @@ function Panel_Animation() : PanelContent() constructor { } return key_hover; - } + } #endregion - function drawDopesheetAnimatorKeys(_node, animator, msx, msy) { + function drawDopesheetAnimatorKeys(_node, animator, msx, msy) { #region var prop_y = animator.dopesheet_y; var key_hover = noone; var node_y = _node.dopesheet_y + dope_sheet_node_padding; @@ -917,10 +944,9 @@ function Panel_Animation() : PanelContent() constructor { } return key_hover; - } + } #endregion -#region label - function drawDopesheetLabelAnimator(_node, animator, msx, msy) { + function drawDopesheetLabelAnimator(_node, animator, msx, msy) { #region var aa = _node.group == PANEL_GRAPH.getCurrentContext()? 1 : 0.9; var tx = tool_width; var ty = animator.dopesheet_y - 1; @@ -1018,9 +1044,9 @@ function Panel_Animation() : PanelContent() constructor { draw_set_alpha(aa); draw_text_add(ui(32), ty - 2, animator.getName()); draw_set_alpha(1); - } + } #endregion - function drawDopesheetLabel() { + function drawDopesheetLabel() { #region surface_set_target(ds_name_surface); draw_clear_alpha(COLORS.panel_bg_clear, 0); var msx = mx - ui(8); @@ -1133,10 +1159,9 @@ function Panel_Animation() : PanelContent() constructor { } surface_reset_target(); - } -#endregion + } #endregion - function drawDopesheet() { + function drawDopesheet() { #region var bar_x = tool_width + ui(16); var bar_y = h - timeline_h - ui(10); var bar_w = timeline_w; @@ -1700,9 +1725,9 @@ function Panel_Animation() : PanelContent() constructor { draw_surface_safe(dope_sheet_surface, bar_x, ui(8)); draw_sprite_stretched(THEME.ui_panel_bg_cover, 1, bar_x, ui(8), bar_w, dope_sheet_h); - } + } #endregion - function drawAnimationControl() { + function drawAnimationControl() { #region var bx = ui(8); var by = h - ui(40); var mini = w < ui(348); @@ -1812,9 +1837,9 @@ function Panel_Animation() : PanelContent() constructor { txt = __txt("Onion skin"); if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(24), [mx, my], pFOCUS, pHOVER, txt, THEME.onion_skin,, PROJECT.onion_skin.enabled? c_white : COLORS._main_icon) == 2) PROJECT.onion_skin.enabled = !PROJECT.onion_skin.enabled; - } + } #endregion - function drawContent(panel) { + function drawContent(panel) { #region draw_clear_alpha(COLORS.panel_bg_clear, 0); if(!PROJECT.active) return; @@ -1851,9 +1876,9 @@ function Panel_Animation() : PanelContent() constructor { TOOLTIP = __txt("Frame") + " " + string(timeline_show_time + 1) + "/" + string(PROJECT.animator.frames_total); timeline_show_time = -1; } - } + } #endregion - function doDuplicate() { + function doDuplicate() { #region if(array_empty(keyframe_selecting)) return; var clones = []; @@ -1868,16 +1893,15 @@ function Panel_Animation() : PanelContent() constructor { keyframe_drag_type = KEYFRAME_DRAG_TYPE.move; keyframe_drag_mx = mx; keyframe_drag_my = my; - } + } #endregion - copy_clipboard = ds_list_create(); - function doCopy() { + function doCopy() { #region ds_list_clear(copy_clipboard); for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) ds_list_add(copy_clipboard, keyframe_selecting[i]); - } + } #endregion - function doPaste(val = noone) { + function doPaste(val = noone) { #region if(ds_list_empty(copy_clipboard)) return; var shf = 0; @@ -1915,5 +1939,5 @@ function Panel_Animation() : PanelContent() constructor { for( var i = 0; i < ds_list_size(copy_clipboard); i++ ) copy_clipboard[| i].cloneAnimator(shf, (multiVal || val == noone)? noone : val.animator); } - } + } #endregion } diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index 4058b4873..48cf741ab 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -11,94 +11,111 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { } setProject(project); - scale = [ 0.01, 0.02, 0.05, 0.10, 0.15, 0.20, 0.25, 0.33, 0.5, 0.65, 0.8, 1, 1.2, 1.35, 1.5, 2.0]; - graph_s = 1; - graph_s_to = graph_s; + #region ---- display ---- + display_parameter = { + show_grid : true, + show_dimension : true, + show_compute : true, + + avoid_label : false, + preview_scale : 100, + } + #endregion - graph_dragging_key = false; - graph_zooming_key = false; + #region ---- position ---- + scale = [ 0.01, 0.02, 0.05, 0.10, 0.15, 0.20, 0.25, 0.33, 0.5, 0.65, 0.8, 1, 1.2, 1.35, 1.5, 2.0]; + graph_s = 1; + graph_s_to = graph_s; + + graph_dragging_key = false; + graph_zooming_key = false; + + graph_draggable= true; + graph_dragging = false; + graph_drag_mx = 0; + graph_drag_my = 0; + graph_drag_sx = 0; + graph_drag_sy = 0; + + graph_zooming = false; + graph_zoom_mx = 0; + graph_zoom_my = 0; + graph_zoom_m = 0; + graph_zoom_s = 0; + + drag_key = mb_middle; + drag_locking = false; + #endregion - graph_draggable= true; - graph_dragging = false; - graph_drag_mx = 0; - graph_drag_my = 0; - graph_drag_sx = 0; - graph_drag_sy = 0; + #region ---- mouse ---- + mouse_graph_x = 0; + mouse_graph_y = 0; + mouse_grid_x = 0; + mouse_grid_y = 0; + mouse_on_graph = false; + #endregion - graph_zooming = false; - graph_zoom_mx = 0; - graph_zoom_my = 0; - graph_zoom_m = 0; - graph_zoom_s = 0; + #region ---- nodes ---- + node_context = ds_list_create(); - drag_key = mb_middle; - drag_locking = false; + node_dragging = noone; + node_drag_mx = 0; + node_drag_my = 0; + node_drag_sx = 0; + node_drag_sy = 0; + node_drag_ox = 0; + node_drag_oy = 0; - mouse_graph_x = 0; - mouse_graph_y = 0; - mouse_grid_x = 0; - mouse_grid_y = 0; - mouse_on_graph = false; + selection_block = 0; + nodes_select_list = ds_list_create(); + nodes_select_drag = false; + nodes_select_mx = 0; + nodes_select_my = 0; - node_context = ds_list_create(); + nodes_junction_d = noone; + nodes_junction_dx = 0; + nodes_junction_dy = 0; - node_dragging = noone; - node_drag_mx = 0; - node_drag_my = 0; - node_drag_sx = 0; - node_drag_sy = 0; - node_drag_ox = 0; - node_drag_oy = 0; + node_hovering = noone; + node_hover = noone; + node_focus = noone; + + junction_hovering = noone; + add_node_draw_junc = false; + add_node_draw_x_fix = 0; + add_node_draw_y_fix = 0; + add_node_draw_x = 0; + add_node_draw_y = 0; + + connection_aa = 2; + connection_surface = surface_create(1, 1); - selection_block = 0; - nodes_select_list = ds_list_create(); - nodes_select_drag = false; - nodes_select_mx = 0; - nodes_select_my = 0; + value_focus = noone; + value_dragging = noone; + value_draggings = []; + #endregion - nodes_junction_d = noone; - nodes_junction_dx = 0; - nodes_junction_dy = 0; + #region ---- minimap ---- + minimap_show = false; + minimap_w = ui(160); + minimap_h = ui(160); + minimap_surface = -1; - node_hovering = noone; - node_hover = noone; - node_focus = noone; + minimap_panning = false; + minimap_dragging = false; + minimap_drag_sx = 0; + minimap_drag_sy = 0; + minimap_drag_mx = 0; + minimap_drag_my = 0; + #endregion - junction_hovering = noone; - add_node_draw_junc = false; - add_node_draw_x_fix = 0; - add_node_draw_y_fix = 0; - add_node_draw_x = 0; - add_node_draw_y = 0; - - value_focus = noone; - value_dragging = noone; - value_draggings = []; - - minimap_show = false; - minimap_w = ui(160); - minimap_h = ui(160); - minimap_surface = -1; - - minimap_panning = false; - minimap_dragging = false; - minimap_drag_sx = 0; - minimap_drag_sy = 0; - minimap_drag_mx = 0; - minimap_drag_my = 0; - - context_framing = false; - context_frame_progress = 0; - context_frame_direct = 0; - context_frame_sx = 0; context_frame_ex = 0; - context_frame_sy = 0; context_frame_ey = 0; - - show_grid = true; - show_dimension = true; - show_compute = true; - - connection_aa = 2; - connection_surface = surface_create(1, 1); + #region ---- context frame ---- + context_framing = false; + context_frame_progress = 0; + context_frame_direct = 0; + context_frame_sx = 0; context_frame_ex = 0; + context_frame_sy = 0; context_frame_ey = 0; + #endregion toolbar_height = ui(40); @@ -182,7 +199,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { function() { return 0; }, function() { return __txtx("graph_visibility_title", "Visibility settings"); }, function(param) { - var gs = dialogCall(o_dialog_graph_view, param.x, param.y); + var gs = dialogCall(o_dialog_graph_view, param.x, param.y, { display_parameter }); gs.anchor = ANCHOR.bottom | ANCHOR.left; } ], @@ -209,7 +226,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { } }); - addHotkey("Graph", "Toggle grid", "G", MOD_KEY.none, function() { PANEL_GRAPH.show_grid = !PANEL_GRAPH.show_grid; }); + addHotkey("Graph", "Toggle grid", "G", MOD_KEY.none, function() { display_parameter.show_grid = !display_parameter.show_grid; }); addHotkey("Graph", "Toggle preview", "H", MOD_KEY.none, function() { PANEL_GRAPH.setTriggerPreview(); }); addHotkey("Graph", "Toggle render", "R", MOD_KEY.none, function() { PANEL_GRAPH.setTriggerRender(); }); @@ -530,7 +547,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { } #endregion function drawGrid() { #region - if(!show_grid) return; + if(!display_parameter.show_grid) return; var gls = project.graphGrid.size; if(graph_s <= 0.15) gls *= 10; @@ -577,7 +594,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { #region draw frame for(var i = 0; i < ds_list_size(nodes_list); i++) { if(instanceof(nodes_list[| i]) != "Node_Frame") continue; - nodes_list[| i].drawNode(gr_x, gr_y, mx, my, graph_s); + nodes_list[| i].drawNode(gr_x, gr_y, mx, my, graph_s, display_parameter); } #endregion printIf(log, "Frame draw time: " + string(current_time - t)); t = current_time; @@ -881,7 +898,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { for(var i = 0; i < ds_list_size(nodes_list); i++) { var _node = nodes_list[| i]; if(instanceof(_node) == "Node_Frame") continue; - var val = _node.drawNode(gr_x, gr_y, mx, my, graph_s); + var val = _node.drawNode(gr_x, gr_y, mx, my, graph_s, display_parameter); if(val) { if(key_mod_press(SHIFT)) diff --git a/scripts/panel_menu/panel_menu.gml b/scripts/panel_menu/panel_menu.gml index 2f424fe52..70fcbb4dc 100644 --- a/scripts/panel_menu/panel_menu.gml +++ b/scripts/panel_menu/panel_menu.gml @@ -7,6 +7,8 @@ function Panel_Menu() : PanelContent() constructor { noti_icon_show = 0; noti_icon_time = 0; + version_name_copy = 0; + if(PREF_MAP[? "panel_menu_right_control"]) action_buttons = ["exit", "maximize", "minimize", "fullscreen"]; else @@ -572,8 +574,12 @@ function Panel_Menu() : PanelContent() constructor { var txt = "v. " + string(VERSION_STRING); if(STEAM_ENABLED) txt += " Steam"; + version_name_copy = lerp_float(version_name_copy, 0, 10); + var tc = merge_color(COLORS._main_text_sub, COLORS._main_value_positive, min(1, version_name_copy)); + var sc = merge_color(c_white, COLORS._main_value_positive, min(1, version_name_copy)); + if(hori) { - draw_set_text(f_p0, fa_center, fa_center, COLORS._main_text_sub); + draw_set_text(f_p0, fa_center, fa_center, tc); var ww = string_width(txt) + ui(12); if(h > ui(76)) { @@ -590,25 +596,34 @@ function Panel_Menu() : PanelContent() constructor { } if(pHOVER && point_in_rectangle(mx, my, _x0, _y0, _x1, _y1)) { - draw_sprite_stretched(THEME.button_hide_fill, 1, _x0, _y0, _x1 - _x0, _y1 - _y0); + draw_sprite_stretched_ext(THEME.button_hide_fill, 1, _x0, _y0, _x1 - _x0, _y1 - _y0, sc, 1); - if(mouse_press(mb_left, pFOCUS)) { + if(mouse_press(mb_left, pFOCUS)) dialogCall(o_dialog_release_note); + if(mouse_press(mb_right, pFOCUS)) { + clipboard_set_text(VERSION_STRING); + version_name_copy = 3; } } + draw_text((_x0 + _x1) / 2, (_y0 + _y1) / 2, txt); } else { var x1 = ui(40); var y1 = h - ui(20); - draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_sub); + draw_set_text(f_p0, fa_left, fa_center, tc); var ww = string_width(txt) + ui(12); if(pHOVER && point_in_rectangle(mx, my, x1, y1 - ui(16), x1 + ww, y1 + ui(16))) { - draw_sprite_stretched(THEME.button_hide_fill, 1, x1, y1 - ui(16), ww, ui(32)); + draw_sprite_stretched_ext(THEME.button_hide_fill, 1, x1, y1 - ui(16), ww, ui(32), sc, 1); if(mouse_press(mb_left, pFOCUS)) dialogCall(o_dialog_release_note); + if(mouse_press(mb_right, pFOCUS)) { + clipboard_set_text(VERSION_STRING); + version_name_copy = 3; + } } + draw_text(x1 + ui(6), y1, txt); } #endregion diff --git a/scripts/panel_preview/panel_preview.gml b/scripts/panel_preview/panel_preview.gml index 5363ad767..385a1c391 100644 --- a/scripts/panel_preview/panel_preview.gml +++ b/scripts/panel_preview/panel_preview.gml @@ -101,8 +101,16 @@ function Panel_Preview() : PanelContent() constructor { d3_zoom_speed = 0.2; d3_pan_speed = 2; - d3_preview_params = new __3dObjectParameters(d3_view_camera); - d3_light_ambient = $303030; + d3_scene = new __3dScene(d3_view_camera); + d3_scene.lightAmbient = $202020; + + d3_scene_light0 = new __3dLightDirectional(); + d3_scene_light0.position.set(-1, -2, 3); + d3_scene_light0.color = $303030; + + d3_scene_light1 = new __3dLightDirectional(); + d3_scene_light1.position.set(1, 2, 3); + d3_scene_light1.color = $404040; #endregion tb_framerate = new textBox(TEXTBOX_INPUT.number, function(val) { preview_rate = real(val); }); @@ -360,6 +368,72 @@ function Panel_Preview() : PanelContent() constructor { canvas_hover = point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height); } #endregion + function dragCanvas3D() { #region + if(d3_camPanning) { + if(!MOUSE_WRAPPING) { + var dx = mx - d3_camPan_mx; + var dy = my - d3_camPan_my; + + d3_view_camera.focus_angle_x += dx * 0.2 * d3_pan_speed; + d3_view_camera.focus_angle_y += dy * 0.1 * d3_pan_speed; + } + + d3_camPan_mx = mx; + d3_camPan_my = my; + setMouseWrap(); + + if(mouse_release(canvas_drag_key)) + d3_camPanning = false; + } + + if(canvas_zooming) { + if(!MOUSE_WRAPPING) { + var dy = -(my - canvas_zoom_m) / 200; + d3_view_camera.focus_dist = clamp(d3_view_camera.focus_dist + dy, 1, 1000); + } + + canvas_zoom_m = my; + setMouseWrap(); + + if(mouse_release(canvas_drag_key)) + canvas_zooming = false; + } + + if(pFOCUS && pHOVER && canvas_hover) { + var _doDragging = false; + var _doZooming = false; + + if(mouse_press(mb_middle)) { + _doDragging = true; + canvas_drag_key = mb_middle; + } else if(mouse_press(mb_left) && canvas_dragging_key) { + _doDragging = true; + canvas_drag_key = mb_left; + } else if(mouse_press(mb_left) && canvas_zooming_key) { + _doZooming = true; + canvas_drag_key = mb_left; + } + + if(_doDragging) { + d3_camPanning = true; + d3_camPan_mx = mx; + d3_camPan_my = my; + } + + if(_doZooming) { + canvas_zooming = true; + canvas_zoom_m = my; + } + + if(mouse_wheel_up()) d3_view_camera.focus_dist = max( 1, d3_view_camera.focus_dist * (1 - d3_zoom_speed)); + if(mouse_wheel_down()) d3_view_camera.focus_dist = min(1000, d3_view_camera.focus_dist * (1 + d3_zoom_speed)); + } + + canvas_dragging_key = false; + canvas_zooming_key = false; + canvas_hover = point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height); + } #endregion + function fullView() { #region var node = getNodePreview(); if(node == noone) { @@ -625,11 +699,7 @@ function Panel_Preview() : PanelContent() constructor { var _prev_node = getNodePreview(); _prev_node.previewing = 1; - #region draw - d3_view_camera.setViewSize(w, h); - d3_surface = surface_verify(d3_surface, w, h); - d3_outline_surface = surface_verify(d3_outline_surface, w, h); - + #region view var cam = camera_get_active(); var _pos, targ; @@ -647,7 +717,13 @@ function Panel_Preview() : PanelContent() constructor { d3_view_camera.focus.set(targ); } + d3_view_camera.setViewSize(w, h); d3_view_camera.setMatrix(); + #endregion + + #region draw + d3_surface = surface_verify(d3_surface, w, h); + d3_outline_surface = surface_verify(d3_outline_surface, w, h); surface_set_target(d3_surface); draw_clear(COLORS.panel_3d_bg); @@ -661,7 +737,7 @@ function Panel_Preview() : PanelContent() constructor { var _tx = round(d3_view_camera.focus.x); var _ty = round(d3_view_camera.focus.y); - var _scale = _dist; + var _scale = _dist * 2; while(_scale > 32) _scale /= 2; shader_set_f("scale", _scale); @@ -670,65 +746,35 @@ function Panel_Preview() : PanelContent() constructor { shader_reset(); gpu_set_zwriteenable(true); - shader_set(sh_d3d_default); - shader_set_f("light_ambient", colToVec4(d3_light_ambient)); - - shader_set_f("light_dir_direction", 1, 2, 3); - shader_set_f("light_dir_color", colToVec4(c_white)); - shader_set_f("light_dir_intensity", 0.5); - shader_reset(); + d3_scene.reset(); + d3_scene.addLightDirectional(d3_scene_light0); + d3_scene.addLightDirectional(d3_scene_light1); + _prev_node.submitShader(d3_scene); + d3_scene.apply(); - _prev_node.submitUI(d3_preview_params); + _prev_node.submitUI(d3_scene); //////////////// SUBMIT //////////////// surface_reset_target(); draw_surface(d3_surface, 0, 0); - - #region outline - var inspect_node = PANEL_INSPECTOR.inspecting; - if(inspect_node) { - surface_set_target(d3_outline_surface); - draw_clear(c_black); - - d3_view_camera.applyCamera(cam); - - gpu_set_ztestenable(false); - inspect_node.submitSel(d3_preview_params); - surface_reset_target(); - - shader_set(sh_d3d_outline); - shader_set_dim("dimension", d3_outline_surface); - shader_set_color("outlineColor", COLORS._main_accent); - draw_surface(d3_outline_surface, 0, 0); - shader_reset(); - } - #endregion #endregion - - #region camera - if(pHOVER) { - if(mouse_wheel_up()) d3_view_camera.focus_dist = max( 1, d3_view_camera.focus_dist * (1 - d3_zoom_speed)); - if(mouse_wheel_down()) d3_view_camera.focus_dist = min(1000, d3_view_camera.focus_dist * (1 + d3_zoom_speed)); - } - - if(d3_camPanning) { - if(!MOUSE_WRAPPING) { - var dx = mx - d3_camPan_mx; - var dy = my - d3_camPan_my; - - d3_view_camera.focus_angle_x += dx * 0.2 * d3_pan_speed; - d3_view_camera.focus_angle_y += dy * 0.1 * d3_pan_speed; - } - - d3_camPan_mx = mx; - d3_camPan_my = my; - setMouseWrap(); - - if(mouse_release(mb_middle)) - d3_camPanning = false; - } else if(mouse_press(mb_middle, pFOCUS)) { - d3_camPanning = true; - d3_camPan_mx = mx; - d3_camPan_my = my; + + #region outline + var inspect_node = PANEL_INSPECTOR.inspecting; + if(inspect_node && inspect_node.is_3D) { + surface_set_target(d3_outline_surface); + draw_clear(c_black); + + d3_view_camera.applyCamera(cam); + + gpu_set_ztestenable(false); + inspect_node.submitSel(d3_scene); + surface_reset_target(); + + shader_set(sh_d3d_outline); + shader_set_dim("dimension", d3_outline_surface); + shader_set_color("outlineColor", COLORS._main_accent); + draw_surface(d3_outline_surface, 0, 0); + shader_reset(); } #endregion } #endregion @@ -882,7 +928,7 @@ function Panel_Preview() : PanelContent() constructor { overlayHover &= point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height); overlayHover &= !key_mod_press(CTRL); - if(d3_active) _node.drawOverlay3D(overlayHover, d3_preview_params, _mx, _my, _snx, _sny, { w, h }); + if(_node.is_3D) _node.drawOverlay3D(overlayHover, d3_scene, _mx, _my, _snx, _sny, { w, h }); else _node.drawOverlay(overlayHover, cx, cy, canvas_s, _mx, _my, _snx, _sny, { w, h }); var _tool = tool_hovering; @@ -1162,6 +1208,7 @@ function Panel_Preview() : PanelContent() constructor { draw_clear(canvas_bg); if(d3_active) { + dragCanvas3D(); draw3D(); } else { diff --git a/scripts/slider/slider.gml b/scripts/slider/slider.gml index 3e417a10f..312f9f30b 100644 --- a/scripts/slider/slider.gml +++ b/scripts/slider/slider.gml @@ -38,7 +38,7 @@ function slider(_min, _max, _step, _onModify = noone, _onRelease = noone) : widg return draw(params.x, params.y, params.w, params.h, params.data, params.m); } - static draw = function(_x, _y, _w, _h, _data, _m, tb_w = 64, halign = fa_left, valign = fa_top) { + static draw = function(_x, _y, _w, _h, _data, _m, tb_w = 50, halign = fa_left, valign = fa_top) { x = _x; y = _y; w = _w; diff --git a/scripts/widget/widget.gml b/scripts/widget/widget.gml index 6fdc49b3c..57af91dc3 100644 --- a/scripts/widget/widget.gml +++ b/scripts/widget/widget.gml @@ -75,7 +75,7 @@ function widget() constructor { static draw = function() {} } -function widgetParam(x, y, w, h, data, extra_data, m, rx = 0, ry = 0) constructor { +function widgetParam(x, y, w, h, data, extra_data = 0, m = mouse_ui, rx = 0, ry = 0) constructor { self.x = x; self.y = y; diff --git a/shaders/sh_d3d_default/sh_d3d_default.fsh b/shaders/sh_d3d_default/sh_d3d_default.fsh index 7505e7084..bb15c8db9 100644 --- a/shaders/sh_d3d_default/sh_d3d_default.fsh +++ b/shaders/sh_d3d_default/sh_d3d_default.fsh @@ -7,27 +7,58 @@ varying vec3 v_vNormal; varying vec3 v_worldPosition; -uniform vec4 light_ambient; -uniform vec3 light_dir_direction; -uniform vec4 light_dir_color; -uniform float light_dir_intensity; +#region ---- light ---- + uniform vec4 light_ambient; + + #define LIGHT_DIR_LIMIT 16 + uniform int light_dir_count; + uniform vec3 light_dir_direction[LIGHT_DIR_LIMIT]; + uniform vec4 light_dir_color[LIGHT_DIR_LIMIT]; + uniform float light_dir_intensity[LIGHT_DIR_LIMIT]; + + #define LIGHT_PNT_LIMIT 16 + uniform int light_pnt_count; + uniform vec3 light_pnt_position[LIGHT_PNT_LIMIT]; + uniform vec4 light_pnt_color[LIGHT_PNT_LIMIT]; + uniform float light_pnt_intensity[LIGHT_PNT_LIMIT]; + uniform float light_pnt_radius[LIGHT_PNT_LIMIT]; +#endregion void main() { vec4 final_color = texture2D( gm_BaseTexture, v_vTexcoord ); final_color *= v_vColour; + gl_FragColor = vec4(0.); - ///////////////// LIGHT ///////////////// + #region ++++ light ++++ + vec3 light_effect = light_ambient.rgb; + + for(int i = 0; i < light_dir_count; i++) { + float light_dir_strength = dot(normalize(v_vNormal), normalize(light_dir_direction[i])); + if(light_dir_strength < 0.) + continue; + + light_dir_strength = max(light_dir_strength * light_dir_intensity[i], 0.); + light_effect += light_dir_color[i].rgb * light_dir_strength; + } + + for(int i = 0; i < light_pnt_count; i++) { + float light_pnt_strength = dot(normalize(v_vNormal), normalize(light_pnt_position[i] - v_worldPosition)); + if(light_pnt_strength < 0.) + continue; + + float light_distance = distance(light_pnt_position[i], v_worldPosition); + if(light_distance > light_pnt_radius[i]) + continue; + + float light_attenuation = 1. - pow(light_distance / light_pnt_radius[i], 2.); + + light_pnt_strength = max(light_pnt_strength * light_pnt_intensity[i] * light_attenuation, 0.); + light_effect += light_pnt_color[i].rgb * light_pnt_strength; + } - vec3 light_effect = light_ambient.rgb * light_ambient.a; - - float light_dir_strength = dot(normalize(v_vNormal), normalize(light_dir_direction)); - light_dir_strength = max(light_dir_strength * light_dir_intensity, 0.); - light_effect += light_dir_color.rgb * light_dir_color.a * light_dir_strength; - - light_effect = max(light_effect, 0.); - final_color.rgb *= light_effect; - - ///////////////// FINAL ///////////////// + light_effect = max(light_effect, 0.); + final_color.rgb *= light_effect; + #endregion gl_FragColor = final_color; } diff --git a/shaders/sh_d3d_default/sh_d3d_default.vsh b/shaders/sh_d3d_default/sh_d3d_default.vsh index a61299944..50ac57604 100644 --- a/shaders/sh_d3d_default/sh_d3d_default.vsh +++ b/shaders/sh_d3d_default/sh_d3d_default.vsh @@ -17,9 +17,9 @@ void main() vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0); gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos; - v_worldPosition = (gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos).xyz; - v_vColour = in_Colour; - v_vTexcoord = in_TextureCoord; + v_worldPosition = (gm_Matrices[MATRIX_WORLD] * object_space_pos).xyz; + v_vColour = in_Colour; + v_vTexcoord = in_TextureCoord; vec3 worldNormal = normalize(gm_Matrices[MATRIX_WORLD] * vec4(in_Normal, 0.)).xyz; v_vNormal = worldNormal;