diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 95e17c879..eb53a3b2f 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -21,6 +21,11 @@ {"name":"widget","order":9,"path":"folders/dialog/widget.yy",}, {"name":"font","order":7,"path":"folders/font.yy",}, {"name":"functions","order":6,"path":"folders/functions.yy",}, + {"name":"camera","order":7,"path":"folders/functions/3d/camera.yy",}, + {"name":"gizmo","order":11,"path":"folders/functions/3d/gizmo.yy",}, + {"name":"light","order":6,"path":"folders/functions/3d/light.yy",}, + {"name":"mesh","order":8,"path":"folders/functions/3d/mesh.yy",}, + {"name":"util","order":5,"path":"folders/functions/3d/util.yy",}, {"name":"action","order":40,"path":"folders/functions/action.yy",}, {"name":"animation","order":19,"path":"folders/functions/animation.yy",}, {"name":"async","order":36,"path":"folders/functions/async.yy",}, @@ -186,10 +191,6 @@ {"name":"biterator","order":2,"path":"folders/VCT/biterator.yy",}, {"name":"widget","order":3,"path":"folders/VCT/widget.yy",}, {"name":"widgets","order":5,"path":"folders/widgets.yy",}, - {"name":"util","order":17,"path":"folders/functions/3d/util.yy",}, - {"name":"light","order":18,"path":"folders/functions/3d/light.yy",}, - {"name":"camera","order":19,"path":"folders/functions/3d/camera.yy",}, - {"name":"mesh","order":20,"path":"folders/functions/3d/mesh.yy",}, ], "ResourceOrderSettings": [ {"name":"s_node_corner","order":16,"path":"sprites/s_node_corner/s_node_corner.yy",}, @@ -290,7 +291,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":"d3d_scene","order":4,"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",}, @@ -588,6 +589,7 @@ {"name":"sh_warp_4points_pers","order":10,"path":"shaders/sh_warp_4points_pers/sh_warp_4points_pers.yy",}, {"name":"node_mirror","order":3,"path":"scripts/node_mirror/node_mirror.yy",}, {"name":"node_corner","order":6,"path":"scripts/node_corner/node_corner.yy",}, + {"name":"__vertex_function","order":1,"path":"scripts/__vertex_function/__vertex_function.yy",}, {"name":"node_path_anchor","order":13,"path":"scripts/node_path_anchor/node_path_anchor.yy",}, {"name":"s_node_path_wave","order":7,"path":"sprites/s_node_path_wave/s_node_path_wave.yy",}, {"name":"string_function","order":6,"path":"scripts/string_function/string_function.yy",}, @@ -1121,7 +1123,7 @@ {"name":"s_node_atlas","order":5,"path":"sprites/s_node_atlas/s_node_atlas.yy",}, {"name":"node_fluid_add","order":4,"path":"scripts/node_fluid_add/node_fluid_add.yy",}, {"name":"BBMOD_Quaternion","order":3,"path":"scripts/BBMOD_Quaternion/BBMOD_Quaternion.yy",}, - {"name":"d3d_group","order":21,"path":"scripts/d3d_group/d3d_group.yy",}, + {"name":"d3d_group","order":9,"path":"scripts/d3d_group/d3d_group.yy",}, {"name":"o_dialog_output_visibility","order":2,"path":"objects/o_dialog_output_visibility/o_dialog_output_visibility.yy",}, {"name":"node_normal","order":1,"path":"scripts/node_normal/node_normal.yy",}, {"name":"s_node_glow","order":24,"path":"sprites/s_node_glow/s_node_glow.yy",}, @@ -1250,7 +1252,7 @@ {"name":"__view_get","order":1,"path":"scripts/__view_get/__view_get.yy",}, {"name":"s_node_texture_map","order":38,"path":"sprites/s_node_texture_map/s_node_texture_map.yy",}, {"name":"fd_rectangle_create","order":7,"path":"scripts/fd_rectangle_create/fd_rectangle_create.yy",}, - {"name":"d3d_gizmo","order":4,"path":"scripts/d3d_gizmo/d3d_gizmo.yy",}, + {"name":"d3d_gizmo","order":3,"path":"scripts/d3d_gizmo/d3d_gizmo.yy",}, {"name":"s_node_level_selector","order":29,"path":"sprites/s_node_level_selector/s_node_level_selector.yy",}, {"name":"random_function","order":3,"path":"scripts/random_function/random_function.yy",}, {"name":"s_node_input","order":6,"path":"sprites/s_node_input/s_node_input.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 8c36836dd..ddd6a94f9 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -42,6 +42,11 @@ {"resourceType":"GMFolder","resourceVersion":"1.0","name":"font","folderPath":"folders/font.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"functions","folderPath":"folders/functions.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"3d","folderPath":"folders/functions/3d.yy",}, + {"resourceType":"GMFolder","resourceVersion":"1.0","name":"camera","folderPath":"folders/functions/3d/camera.yy",}, + {"resourceType":"GMFolder","resourceVersion":"1.0","name":"gizmo","folderPath":"folders/functions/3d/gizmo.yy",}, + {"resourceType":"GMFolder","resourceVersion":"1.0","name":"light","folderPath":"folders/functions/3d/light.yy",}, + {"resourceType":"GMFolder","resourceVersion":"1.0","name":"mesh","folderPath":"folders/functions/3d/mesh.yy",}, + {"resourceType":"GMFolder","resourceVersion":"1.0","name":"util","folderPath":"folders/functions/3d/util.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"action","folderPath":"folders/functions/action.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"animation","folderPath":"folders/functions/animation.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"async","folderPath":"folders/functions/async.yy",}, @@ -224,10 +229,6 @@ {"resourceType":"GMFolder","resourceVersion":"1.0","name":"biterator","folderPath":"folders/VCT/biterator.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"widget","folderPath":"folders/VCT/widget.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"widgets","folderPath":"folders/widgets.yy",}, - {"resourceType":"GMFolder","resourceVersion":"1.0","name":"util","folderPath":"folders/functions/3d/util.yy",}, - {"resourceType":"GMFolder","resourceVersion":"1.0","name":"light","folderPath":"folders/functions/3d/light.yy",}, - {"resourceType":"GMFolder","resourceVersion":"1.0","name":"camera","folderPath":"folders/functions/3d/camera.yy",}, - {"resourceType":"GMFolder","resourceVersion":"1.0","name":"mesh","folderPath":"folders/functions/3d/mesh.yy",}, ], "IncludedFiles": [ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":-1,"filePath":"datafiles",}, @@ -524,6 +525,7 @@ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"graphics x2.ai","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/tool",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_3d_tool_rotate.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/tool",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_3d_tool_scale.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/tool",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_3d_tool_transform_object.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/tool",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_3d_tool_transform.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/tool",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_bone_tool_add.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/tool",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_bone_tool_detach.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/tool",}, @@ -1152,6 +1154,7 @@ {"id":{"name":"s_node_random","path":"sprites/s_node_random/s_node_random.yy",},}, {"id":{"name":"sh_3d_extrude_filler","path":"shaders/sh_3d_extrude_filler/sh_3d_extrude_filler.yy",},}, {"id":{"name":"s_window_exit","path":"sprites/s_window_exit/s_window_exit.yy",},}, + {"id":{"name":"d3d_gizmo_sphere","path":"scripts/d3d_gizmo_sphere/d3d_gizmo_sphere.yy",},}, {"id":{"name":"s_node_color_remove","path":"sprites/s_node_color_remove/s_node_color_remove.yy",},}, {"id":{"name":"sh_average","path":"shaders/sh_average/sh_average.yy",},}, {"id":{"name":"sh_warp_4points_pers","path":"shaders/sh_warp_4points_pers/sh_warp_4points_pers.yy",},}, diff --git a/datafiles/data/themes/default.zip b/datafiles/data/themes/default.zip index bc8470e43..a5bda4cf4 100644 Binary files a/datafiles/data/themes/default.zip and b/datafiles/data/themes/default.zip differ diff --git a/scripts/BBMOD_Quaternion/BBMOD_Quaternion.gml b/scripts/BBMOD_Quaternion/BBMOD_Quaternion.gml index 88176b17b..05a3102c7 100644 --- a/scripts/BBMOD_Quaternion/BBMOD_Quaternion.gml +++ b/scripts/BBMOD_Quaternion/BBMOD_Quaternion.gml @@ -240,9 +240,9 @@ function BBMOD_Quaternion(_x=0.0, _y=0.0, _z=0.0, _w=1.0) constructor /// @return {Struct.BBMOD_Quaternion} Returns `self`. static FromLookRotation = function (_forward, _up) { gml_pragma("forceinline"); - - _forward = _forward.Clone(); - _up = _up.Clone(); + + _forward = new BBMOD_Vec3(_forward); + _up = new BBMOD_Vec3(_up); if (!_forward.Orthonormalize(_up)) { @@ -268,9 +268,9 @@ function BBMOD_Quaternion(_x=0.0, _y=0.0, _z=0.0, _w=1.0) constructor gml_pragma("forceinline"); W = sqrt(1 + rotMatrix[0] + rotMatrix[5] + rotMatrix[10]) / 2; - X = (rotMatrix[9] - rotMatrix[6]) / (4 * W); - Y = (rotMatrix[2] - rotMatrix[8]) / (4 * W); - Z = (rotMatrix[4] - rotMatrix[1]) / (4 * W); + X = (rotMatrix[9] - rotMatrix[6]) / (4 * W); + Y = (rotMatrix[2] - rotMatrix[8]) / (4 * W); + Z = (rotMatrix[4] - rotMatrix[1]) / (4 * W); return self; } @@ -427,10 +427,19 @@ function BBMOD_Quaternion(_x=0.0, _y=0.0, _z=0.0, _w=1.0) constructor /// @return {Struct.BBMOD_Vec3} The created vector. static Rotate = function (_v) { gml_pragma("forceinline"); + + var _tovec = is_instanceof(_v, __vec3); + if(_tovec) _v = new BBMOD_Vec3(_v.x, _v.y, _v.z); + var _q = Normalize(); var _V = new BBMOD_Quaternion(_v.X, _v.Y, _v.Z, 0.0); var _rot = _q.Mul(_V).Mul(_q.Conjugate()); - return new BBMOD_Vec3(_rot.X, _rot.Y, _rot.Z); + + var res; + if(_tovec) res = new __vec3(_rot.X, _rot.Y, _rot.Z); + else res = new BBMOD_Vec3(_rot.X, _rot.Y, _rot.Z); + + return res; }; /// @func Scale(_s) diff --git a/scripts/BBMOD_Vec3/BBMOD_Vec3.gml b/scripts/BBMOD_Vec3/BBMOD_Vec3.gml index 807716181..7d874ac69 100644 --- a/scripts/BBMOD_Vec3/BBMOD_Vec3.gml +++ b/scripts/BBMOD_Vec3/BBMOD_Vec3.gml @@ -26,16 +26,24 @@ /// /// @see BBMOD_Vec2 /// @see BBMOD_Vec4 -function BBMOD_Vec3(_x=0.0, _y=_x, _z=_x) constructor -{ - /// @var {Real} The first component of the vector. - X = _x; - - /// @var {Real} The second component of the vector. - Y = _y; - - /// @var {Real} The third component of the vector. - Z = _z; +function BBMOD_Vec3(_x=0.0, _y=_x, _z=_x) constructor { + if(is_instanceof(_x, __vec3)) { + X = _x.x; + Y = _x.y; + Z = _x.z; + } else if(is_instanceof(_x, BBMOD_Vec3)) { + X = _x.X; + Y = _x.Y; + Z = _x.Z; + } else if(is_array(_x)) { + X = _x[0]; + Y = _x[1]; + Z = _x[2]; + } else { + X = _x; + Y = _y; + Z = _z; + } /// @func Abs() /// diff --git a/scripts/__node_3d/__node_3d.gml b/scripts/__node_3d/__node_3d.gml index 72ebdcd26..1cdeb8bd2 100644 --- a/scripts/__node_3d/__node_3d.gml +++ b/scripts/__node_3d/__node_3d.gml @@ -7,7 +7,7 @@ function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constr static processData = function(_outSurf, _data, _output_index, _array_index) {} static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {} - static getPreviewObject = function() { + static getPreviewObject = function() { #region if(ds_list_empty(outputs)) return []; switch(outputs[| preview_channel].type) { case VALUE_TYPE.d3Mesh : @@ -23,7 +23,7 @@ function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constr _obj = array_safe_get(_obj, preview_index, noone); return [ _obj ]; - } + } #endregion static getPreviewObjectOutline = function() { return getPreviewObject() } } \ 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 697733fc3..80edb0397 100644 --- a/scripts/__node_3d_light/__node_3d_light.gml +++ b/scripts/__node_3d_light/__node_3d_light.gml @@ -4,20 +4,20 @@ function Node_3D_Light(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) if(!LOADING && !APPENDING) inputs[| 0].setValue([ 0, 0, 1 ]); - inputs[| input_d3d_index + 0] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white); + inputs[| in_d3d + 0] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white); - inputs[| input_d3d_index + 1] = nodeValue("Intensity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) + inputs[| in_d3d + 1] = nodeValue("Intensity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) .setDisplay(VALUE_DISPLAY.slider, [ 0, 1, 0.01 ]); - input_light_index = ds_list_size(inputs); + in_light = ds_list_size(inputs); outputs[| 0] = nodeValue("Light", self, JUNCTION_CONNECT.output, VALUE_TYPE.d3Light, noone); - #macro __d3d_input_list_light ["Light", false], input_d3d_index + 0, input_d3d_index + 1 + #macro __d3d_input_list_light ["Light", false], in_d3d + 0, in_d3d + 1 static setLight = function(light, _data) { - var _col = _data[input_d3d_index + 0]; - var _int = _data[input_d3d_index + 1]; + var _col = _data[in_d3d + 0]; + var _int = _data[in_d3d + 1]; light.color = _col; light.intensity = _int; diff --git a/scripts/__node_3d_mesh/__node_3d_mesh.gml b/scripts/__node_3d_mesh/__node_3d_mesh.gml index 3fc2fce3d..74c4bbe39 100644 --- a/scripts/__node_3d_mesh/__node_3d_mesh.gml +++ b/scripts/__node_3d_mesh/__node_3d_mesh.gml @@ -1,7 +1,7 @@ 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); + in_mesh = ds_list_size(inputs); outputs[| 0] = nodeValue("Mesh", self, JUNCTION_CONNECT.output, VALUE_TYPE.d3Mesh, noone); diff --git a/scripts/__node_3d_object/__node_3d_object.gml b/scripts/__node_3d_object/__node_3d_object.gml index b804c0d29..8d630f6d2 100644 --- a/scripts/__node_3d_object/__node_3d_object.gml +++ b/scripts/__node_3d_object/__node_3d_object.gml @@ -14,7 +14,7 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr inputs[| 2] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1, 1 ]) .setDisplay(VALUE_DISPLAY.vector); - input_d3d_index = ds_list_size(inputs); + in_d3d = ds_list_size(inputs); #macro __d3d_input_list_transform ["Transform", false], 0, 1, 2 @@ -34,63 +34,96 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr drag_original = 0; axis_hover = noone; - - tools = [ - new NodeTool( "Transform", THEME.tools_3d_transform ), - new NodeTool( "Rotate", THEME.tools_3d_rotate ), - new NodeTool( "Scale", THEME.tools_3d_scale ), - ]; #endregion - static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) { #region - var _pos = inputs[| 0].getValue(,,, true); - var _rot = inputs[| 1].getValue(,,, true); - var _sca = inputs[| 2].getValue(,,, true); + #region ---- tools ---- + tool_pos = new NodeTool( "Transform", THEME.tools_3d_transform ); + tool_rot = new NodeTool( "Rotate", THEME.tools_3d_rotate ); + tool_sca = new NodeTool( "Scale", THEME.tools_3d_scale ); + tools = [ tool_pos, tool_rot, tool_sca ]; - var _camera = params.camera; - var _camPos = _camera.position; - var _camTar = _camera.focus; - var _camDis = _camera.focus_dist; - var _camAx = _camera.focus_angle_x; - var _camAy = _camera.focus_angle_y; + tool_axis_edit = new scrollBox([ "local", "global" ], function(val) { tool_attribute.context = val; }); + tool_axis_edit.font = f_p2; + tool_axis_edit.arrow_spr = THEME.arrow; + tool_axis_edit.arrow_ind = 3; + tool_attribute.context = 0; + tool_settings = [ + [ "Axis", tool_axis_edit, "context", tool_attribute ], + ]; - var _qview = new BBMOD_Quaternion().FromEuler(_camAy, -_camAx, 0); + static getToolSettings = function() { + if(isUsingTool("Transform") || isUsingTool("Rotate")) + return tool_settings; + return []; + } + #endregion + + static drawGizmoPosition = function(index, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel) { #region + #region ---- main ---- + var _pos = inputs[| index].getValue(,,, true); + var _qrot = object == noone? new BBMOD_Quaternion() : object.rotation; + var _qinv = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), 90); - var _vpos = new __vec3( _pos[0], _pos[1], _pos[2] ); - var _posView = _camera.worldPointToViewPoint(_vpos); + var _camera = params.camera; + var _qview = new BBMOD_Quaternion().FromEuler(_camera.focus_angle_y, -_camera.focus_angle_x, 0); - var cx = _posView.x; - var cy = _posView.y; + var _axis = tool_attribute.context; - var _hover = noone; - var _hoverDist = 10; - var th; + var _hover = noone; + var _hoverDist = 10; + var th; + + var _posView = _camera.worldPointToViewPoint(_vpos); + + var cx = _posView.x; + var cy = _posView.y; - if(isUsingTool(0)) { #region move var ga = []; var size = 64; var hs = size / 2; var sq = 8; - + #endregion + + #region display ga[0] = new BBMOD_Vec3(-size, 0, 0); ga[1] = new BBMOD_Vec3(0, 0, size); ga[2] = new BBMOD_Vec3(0, -size, 0); ga[3] = [ new BBMOD_Vec3(-hs + sq, 0, hs - sq), - new BBMOD_Vec3(-hs - sq, 0, hs - sq), - new BBMOD_Vec3(-hs - sq, 0, hs + sq), - new BBMOD_Vec3(-hs + sq, 0, hs + sq), ]; + new BBMOD_Vec3(-hs - sq, 0, hs - sq), + new BBMOD_Vec3(-hs - sq, 0, hs + sq), + new BBMOD_Vec3(-hs + sq, 0, hs + sq), ]; ga[4] = [ new BBMOD_Vec3( 0, -hs + sq, hs - sq), - new BBMOD_Vec3( 0, -hs - sq, hs - sq), - new BBMOD_Vec3( 0, -hs - sq, hs + sq), - new BBMOD_Vec3( 0, -hs + sq, hs + sq), ]; + new BBMOD_Vec3( 0, -hs - sq, hs - sq), + new BBMOD_Vec3( 0, -hs - sq, hs + sq), + new BBMOD_Vec3( 0, -hs + sq, hs + sq), ]; ga[5] = [ new BBMOD_Vec3(-hs + sq, -hs - sq, 0), - new BBMOD_Vec3(-hs - sq, -hs - sq, 0), - new BBMOD_Vec3(-hs - sq, -hs + sq, 0), - new BBMOD_Vec3(-hs + sq, -hs + sq, 0), ]; + new BBMOD_Vec3(-hs - sq, -hs - sq, 0), + new BBMOD_Vec3(-hs - sq, -hs + sq, 0), + new BBMOD_Vec3(-hs + sq, -hs + sq, 0), ]; + ga[0] = new BBMOD_Vec3(-size, 0, 0); + ga[1] = new BBMOD_Vec3(0, -size, 0); + ga[2] = new BBMOD_Vec3(0, 0, -size); + + ga[3] = [ new BBMOD_Vec3(-hs + sq, -hs - sq, 0), + new BBMOD_Vec3(-hs - sq, -hs - sq, 0), + new BBMOD_Vec3(-hs - sq, -hs + sq, 0), + new BBMOD_Vec3(-hs + sq, -hs + sq, 0), ]; + ga[4] = [ new BBMOD_Vec3( 0, -hs + sq, -hs - sq), + new BBMOD_Vec3( 0, -hs - sq, -hs - sq), + new BBMOD_Vec3( 0, -hs - sq, -hs + sq), + new BBMOD_Vec3( 0, -hs + sq, -hs + sq), ]; + ga[5] = [ new BBMOD_Vec3(-hs + sq, 0, -hs - sq), + new BBMOD_Vec3(-hs - sq, 0, -hs - sq), + new BBMOD_Vec3(-hs - sq, 0, -hs + sq), + new BBMOD_Vec3(-hs + sq, 0, -hs + sq), ]; + for( var i = 0; i < 3; i++ ) { - ga[i] = _qview.Rotate(ga[i]); + if(_axis == 0) + ga[i] = _qview.Rotate(_qinv.Rotate(_qrot.Rotate(ga[i]))); + else if(_axis == 1) + ga[i] = _qview.Rotate(_qinv.Rotate(ga[i])); th = 2 + (axis_hover == i || drag_axis == i); if(drag_axis != noone && drag_axis != i) @@ -110,8 +143,12 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr } for( var i = 3; i < 6; i++ ) { - for( var j = 0; j < 4; j++ ) - ga[i][j] = _qview.Rotate(ga[i][j]); + for( var j = 0; j < 4; j++ ) { + if(_axis == 0) + ga[i][j] = _qview.Rotate(_qinv.Rotate(_qrot.Rotate(ga[i][j]))); + else if(_axis == 1) + ga[i][j] = _qview.Rotate(_qinv.Rotate(ga[i][j])); + } th = 1; @@ -149,82 +186,116 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr } axis_hover = _hover; - - if(drag_axis != noone) { - if(!MOUSE_WRAPPING) { - drag_mx += _mx - drag_px; - drag_my += _my - drag_py; + #endregion display + + if(drag_axis != noone) { #region editing + if(!MOUSE_WRAPPING) { + drag_mx += _mx - drag_px; + drag_my += _my - drag_py; - var _mmx = drag_mx - drag_cx; - var _mmy = drag_my - drag_cy; - var mAdj, nor; + var mAdj, nor, prj; - var ray = _camera.viewPointToWorldRay(_mx, _my); + var ray = _camera.viewPointToWorldRay(drag_mx, drag_my); - if(drag_axis < 3) { - switch(drag_axis) { - case 0 : nor = new __vec3(0, 0, 1); break; - case 1 : nor = new __vec3(1, 0, 0); break; - case 2 : nor = new __vec3(0, 1, 0); break; - } - - var pln = new __plane(drag_original, nor); - mAdj = d3d_intersect_ray_plane(ray, pln); - - if(drag_prev != undefined) { - var _diff = mAdj.subtract(drag_prev); - _pos[drag_axis] += _diff.getIndex(drag_axis); - - if(inputs[| 0].setValue(_pos)) - UNDO_HOLDING = true; - } - } else { - switch(drag_axis) { - case 3 : nor = new __vec3(0, 0, 1); break; - case 4 : nor = new __vec3(1, 0, 0); break; - case 5 : nor = new __vec3(0, 1, 0); break; - } - - var pln = new __plane(drag_original, nor); - mAdj = d3d_intersect_ray_plane(ray, pln); - - if(drag_prev != undefined) { - var _diff = mAdj.subtract(drag_prev); - _pos[0] += _diff.x; - _pos[1] += _diff.y; - _pos[2] += _diff.z; - - if(inputs[| 0].setValue(_pos)) - UNDO_HOLDING = true; - } + if(drag_axis < 3) { + switch(drag_axis) { + case 0 : nor = new __vec3(0, 1, 0); prj = new __vec3(1, 0, 0); break; + case 1 : nor = new __vec3(0, 0, 1); prj = new __vec3(0, 1, 0); break; + case 2 : nor = new __vec3(1, 0, 0); prj = new __vec3(0, 0, 1); break; + } + + if(_axis == 0) { + nor = _qrot.Rotate(nor); + prj = _qrot.Rotate(prj); + } + + var pln = new __plane(drag_original, nor); + mAdj = d3d_intersect_ray_plane(ray, pln); + + if(drag_prev != undefined) { + var _diff = mAdj.subtract(drag_prev); + var _dist = _diff.dot(prj); + + for( var i = 0; i < 3; i++ ) + _pos[i] += prj.getIndex(i) * _dist; + + if(inputs[| index].setValue(_pos)) + UNDO_HOLDING = true; + } + } else { + switch(drag_axis) { + case 3 : nor = new __vec3(0, 0, 1); break; + case 4 : nor = new __vec3(1, 0, 0); break; + case 5 : nor = new __vec3(0, 1, 0); break; + } + + if(_axis == 0) + nor = _qrot.Rotate(nor); + + var pln = new __plane(drag_original, nor); + mAdj = d3d_intersect_ray_plane(ray, pln); + + if(drag_prev != undefined) { + var _diff = mAdj.subtract(drag_prev); + + for( var i = 0; i < 3; i++ ) + _pos[i] += _diff.getIndex(i); + + if(inputs[| index].setValue(_pos)) + UNDO_HOLDING = true; } - - drag_prev = mAdj; } - - setMouseWrap(); - drag_px = _mx; - drag_py = _my; + + drag_prev = mAdj; } + + setMouseWrap(); + drag_px = _mx; + drag_py = _my; + } #endregion - if(_hover != noone && mouse_press(mb_left, active)) { - drag_axis = _hover; - drag_prev = undefined; - drag_mx = _mx; - drag_my = _my; - drag_px = _mx; - drag_py = _my; - drag_cx = cx; - drag_cy = cy; + if(_hover != noone && mouse_press(mb_left, active)) { #region + drag_axis = _hover; + drag_prev = undefined; + drag_mx = _mx; + drag_my = _my; + drag_px = _mx; + drag_py = _my; + drag_cx = cx; + drag_cy = cy; - drag_original = new __vec3(_pos); - } - #endregion - } else if(isUsingTool(1)) { #region rotate - var size = 64; - var _qrot = object.rotation; + drag_original = new __vec3(_pos); + } #endregion + } #endregion + + static drawGizmoRotation = function(index, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel) { #region + #region ---- main ---- + var _rot = inputs[| index].getValue(,,, true); + var _qrot = object == noone? new BBMOD_Quaternion() : object.rotation; var _qinv = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), 90); - + + var _camera = params.camera; + var _qview = new BBMOD_Quaternion().FromEuler(_camera.focus_angle_y, -_camera.focus_angle_x, 0); + + var _axis = tool_attribute.context; + + var _hover = noone; + var _hoverDist = 10; + var th; + + var _posView = _camera.worldPointToViewPoint(_vpos); + + var cx = _posView.x; + var cy = _posView.y; + + var ga = []; + var size = 64; + var hs = size / 2; + var sq = 8; + #endregion + + #region display + var size = 64; for( var i = 0; i < 3; i++ ) { var op, np; @@ -242,7 +313,10 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr case 2 : np = new BBMOD_Vec3(lengthdir_x(size, ang), 0, lengthdir_y(size, ang)); break; } - np = _qview.Rotate(_qinv.Rotate(_qrot.Rotate(np))); + if(_axis == 0) + np = _qview.Rotate(_qinv.Rotate(_qrot.Rotate(np))); + else if(_axis == 1) + np = _qview.Rotate(_qinv.Rotate(np)); if(j && (op.Z > 0 && np.Z > 0 || drag_axis == i)) { draw_line_round(cx + op.X, cy + op.Y, cx + np.X, cy + np.Y, th); @@ -256,70 +330,96 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr op = np; } } - axis_hover = _hover; + #endregion - if(drag_axis != noone) { - var mAng = point_direction(cx, cy, _mx, _my); - var _n = BBMOD_VEC3_FORWARD; - - switch(drag_axis) { - case 0 : _n = new BBMOD_Vec3(-1, 0, 0); break; - case 1 : _n = new BBMOD_Vec3( 0, 0, -1); break; - case 2 : _n = new BBMOD_Vec3( 0, -1, 0); break; - } + if(drag_axis != noone) { #region + var mAng = point_direction(cx, cy, _mx, _my); + var _n = BBMOD_VEC3_FORWARD; + switch(drag_axis) { + case 0 : _n = new BBMOD_Vec3(-1, 0, 0); break; + case 1 : _n = new BBMOD_Vec3( 0, 0, -1); break; + case 2 : _n = new BBMOD_Vec3( 0, -1, 0); break; + } + + if(_axis == 0) _n = _qrot.Rotate(_n).Normalize(); - var _nv = _qview.Rotate(_qinv.Rotate(_n)); - draw_line_round(cx, cy, cx + _nv.X * 100, cy + _nv.Y * 100, 2); + var _nv = _qview.Rotate(_qinv.Rotate(_n)); + draw_line_round(cx, cy, cx + _nv.X * 100, cy + _nv.Y * 100, 2); - if(drag_prev != undefined) { - var _rd = (mAng - drag_prev) * (_nv.Z > 0? 1 : -1); + if(drag_prev != undefined) { + var _rd = (mAng - drag_prev) * (_nv.Z > 0? 1 : -1); - var _currR = new BBMOD_Quaternion().FromAxisAngle(_n, _rd); - var _mulp = _currR.Mul(_qrot); - var _Nrot = _mulp.ToArray(); + var _currR = new BBMOD_Quaternion().FromAxisAngle(_n, _rd); + var _mulp = _currR.Mul(_qrot); + var _Nrot = _mulp.ToArray(); - if(inputs[| 1].setValue(_Nrot)) - UNDO_HOLDING = true; - } - - draw_set_color(COLORS._main_accent); - draw_line_dashed(cx, cy, _mx, _my, 1, 4); - - drag_prev = mAng; + if(inputs[| index].setValue(_Nrot)) + UNDO_HOLDING = true; } + + draw_set_color(COLORS._main_accent); + draw_line_dashed(cx, cy, _mx, _my, 1, 4); + + drag_prev = mAng; + } #endregion - if(_hover != noone && mouse_press(mb_left, active)) { - drag_axis = _hover; - drag_prev = undefined; - } - #endregion - } else if(isUsingTool(2)) { #region scale + if(_hover != noone && mouse_press(mb_left, active)) { #region + drag_axis = _hover; + drag_prev = undefined; + } #endregion + } #endregion + + static drawGizmoScale = function(index, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel) { #region + #region ---- main ---- + var _sca = inputs[| index].getValue(,,, true); + var _qrot = object == noone? new BBMOD_Quaternion() : object.rotation; + var _qinv = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), 90); + + var _camera = params.camera; + var _qview = new BBMOD_Quaternion().FromEuler(_camera.focus_angle_y, -_camera.focus_angle_x, 0); + + var _axis = tool_attribute.context; + + var _hover = noone; + var _hoverDist = 10; + var th; + + var _posView = _camera.worldPointToViewPoint(_vpos); + + var cx = _posView.x; + var cy = _posView.y; + var ga = []; var size = 64; var hs = size / 2; var sq = 8; - var _qrot = object.rotation; - var _qinv = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), 90); + #endregion + + #region display + var ga = []; + var size = 64; + var hs = size / 2; + var sq = 8; ga[0] = new BBMOD_Vec3(-size, 0, 0); ga[1] = new BBMOD_Vec3(0, -size, 0); ga[2] = new BBMOD_Vec3(0, 0, -size); ga[3] = [ new BBMOD_Vec3(-hs + sq, -hs - sq, 0), - new BBMOD_Vec3(-hs - sq, -hs - sq, 0), - new BBMOD_Vec3(-hs - sq, -hs + sq, 0), - new BBMOD_Vec3(-hs + sq, -hs + sq, 0), ]; + new BBMOD_Vec3(-hs - sq, -hs - sq, 0), + new BBMOD_Vec3(-hs - sq, -hs + sq, 0), + new BBMOD_Vec3(-hs + sq, -hs + sq, 0), ]; ga[4] = [ new BBMOD_Vec3( 0, -hs + sq, -hs - sq), - new BBMOD_Vec3( 0, -hs - sq, -hs - sq), - new BBMOD_Vec3( 0, -hs - sq, -hs + sq), - new BBMOD_Vec3( 0, -hs + sq, -hs + sq), ]; + new BBMOD_Vec3( 0, -hs - sq, -hs - sq), + new BBMOD_Vec3( 0, -hs - sq, -hs + sq), + new BBMOD_Vec3( 0, -hs + sq, -hs + sq), ]; ga[5] = [ new BBMOD_Vec3(-hs + sq, 0, -hs - sq), - new BBMOD_Vec3(-hs - sq, 0, -hs - sq), - new BBMOD_Vec3(-hs - sq, 0, -hs + sq), - new BBMOD_Vec3(-hs + sq, 0, -hs + sq), ]; + new BBMOD_Vec3(-hs - sq, 0, -hs - sq), + new BBMOD_Vec3(-hs - sq, 0, -hs + sq), + new BBMOD_Vec3(-hs + sq, 0, -hs + sq), ]; for( var i = 0; i < 3; i++ ) { ga[i] = _qview.Rotate(_qinv.Rotate(_qrot.Rotate(ga[i]))); @@ -342,8 +442,12 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr } for( var i = 3; i < 6; i++ ) { - for( var j = 0; j < 4; j++ ) - ga[i][j] = _qview.Rotate(_qinv.Rotate(_qrot.Rotate(ga[i][j]))); + for( var j = 0; j < 4; j++ ) { + if(_axis == 0) + ga[i][j] = _qview.Rotate(_qinv.Rotate(_qrot.Rotate(ga[i][j]))); + else + ga[i][j] = _qview.Rotate(_qinv.Rotate(ga[i][j])); + } th = 1; @@ -381,78 +485,96 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr } axis_hover = _hover; + #endregion - if(drag_axis != noone) { - if(!MOUSE_WRAPPING) { - drag_mx += _mx - drag_px; - drag_my += _my - drag_py; + if(drag_axis != noone) { #region editing + if(!MOUSE_WRAPPING) { + drag_mx += _mx - drag_px; + drag_my += _my - drag_py; - var _mmx = drag_mx - drag_cx; - var _mmy = drag_my - drag_cy; - var mAdj, nor; + var mAdj, nor; - var ray = _camera.viewPointToWorldRay(_mx, _my); + var ray = _camera.viewPointToWorldRay(drag_mx, drag_my); - if(drag_axis < 3) { - switch(drag_axis) { - case 0 : nor = new __vec3(0, 0, 1); break; - case 1 : nor = new __vec3(1, 0, 0); break; - case 2 : nor = new __vec3(0, 1, 0); break; - } - - var pln = new __plane(drag_original, nor); - mAdj = d3d_intersect_ray_plane(ray, pln); - - if(drag_prev != undefined) { - var _diff = mAdj.subtract(drag_prev); - _sca[drag_axis] += _diff.getIndex(drag_axis); - - if(inputs[| 2].setValue(_sca)) - UNDO_HOLDING = true; - } - } else { - switch(drag_axis) { - case 3 : nor = new __vec3(0, 0, 1); break; - case 4 : nor = new __vec3(1, 0, 0); break; - case 5 : nor = new __vec3(0, 1, 0); break; - } - - var pln = new __plane(drag_original, nor); - mAdj = d3d_intersect_ray_plane(ray, pln); - - if(drag_prev != undefined) { - var _diff = mAdj.subtract(drag_prev); - _sca[0] += _diff.x; - _sca[1] += _diff.y; - _sca[2] += _diff.z; - - if(inputs[| 2].setValue(_sca)) - UNDO_HOLDING = true; - } + if(drag_axis < 3) { + switch(drag_axis) { + case 0 : nor = new __vec3(0, 1, 0); prj = new __vec3(1, 0, 0); break; + case 1 : nor = new __vec3(0, 0, 1); prj = new __vec3(0, 1, 0); break; + case 2 : nor = new __vec3(1, 0, 0); prj = new __vec3(0, 0, 1); break; + } + + nor = _qrot.Rotate(nor); + prj = _qrot.Rotate(prj); + + var pln = new __plane(drag_original, nor); + mAdj = d3d_intersect_ray_plane(ray, pln); + + if(drag_prev != undefined) { + var _diff = mAdj.subtract(drag_prev); + var _dist = _diff.dot(prj); + + for( var i = 0; i < 3; i++ ) + _sca[i] += prj.getIndex(i) * _dist; + + if(inputs[| index].setValue(_sca)) + UNDO_HOLDING = true; + } + } else { + switch(drag_axis) { + case 3 : nor = new __vec3(0, 0, 1); break; + case 4 : nor = new __vec3(1, 0, 0); break; + case 5 : nor = new __vec3(0, 1, 0); break; + } + + nor = _qrot.Rotate(nor); + + var pln = new __plane(drag_original, nor); + mAdj = d3d_intersect_ray_plane(ray, pln); + + if(drag_prev != undefined) { + var _diff = mAdj.subtract(drag_prev); + + for( var i = 0; i < 3; i++ ) + _sca[i] += _diff.getIndex(i); + + if(inputs[| index].setValue(_sca)) + UNDO_HOLDING = true; } - - drag_prev = mAdj; } - - setMouseWrap(); - drag_px = _mx; - drag_py = _my; + + drag_prev = mAdj; } + + setMouseWrap(); + drag_px = _mx; + drag_py = _my; + } #endregion - if(_hover != noone && mouse_press(mb_left, active)) { - drag_axis = _hover; - drag_prev = undefined; - drag_mx = _mx; - drag_my = _my; - drag_px = _mx; - drag_py = _my; - drag_cx = cx; - drag_cy = cy; + if(_hover != noone && mouse_press(mb_left, active)) { #region + drag_axis = _hover; + drag_prev = undefined; + drag_mx = _mx; + drag_my = _my; + drag_px = _mx; + drag_py = _my; + drag_cx = cx; + drag_cy = cy; - drag_original = new __vec3(_sca); - } - #endregion - } + drag_original = new __vec3(_sca); + } #endregion + } #endregion + + static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) { #region + var object = getPreviewObject(); + if(array_empty(object)) return; + object = object[0]; + + var _pos = inputs[| 0].getValue(,,, true); + var _vpos = new __vec3( _pos[0], _pos[1], _pos[2] ); + + if(isUsingTool("Transform")) drawGizmoPosition(0, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel); + else if(isUsingTool("Rotate")) drawGizmoRotation(1, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel); + else if(isUsingTool("Scale")) drawGizmoScale(2, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel); if(drag_axis != noone && mouse_release(mb_left)) { drag_axis = noone; diff --git a/scripts/d3d_camera/d3d_camera.gml b/scripts/d3d_camera/d3d_camera.gml index fe864ac6a..8a5f76414 100644 --- a/scripts/d3d_camera/d3d_camera.gml +++ b/scripts/d3d_camera/d3d_camera.gml @@ -27,15 +27,15 @@ function __3dCamera() constructor { viewMat = new __mat4(); projMat = new __mat4(); - static getUp = function() { - var upVector = new __vec3(0, 0, 0); + static getUp = function(_x = 1, _y = 1, _z = 1) { + var upVector = new __vec3(0, 0, -1); var hRad = degtorad(focus_angle_x); var vRad = degtorad(focus_angle_y); - upVector.x = -sin(hRad) * sin(vRad); - upVector.y = cos(hRad) * -sin(vRad); - upVector.z = cos(vRad); + upVector.x = -sin(hRad) * sin(vRad) * _x; + upVector.y = cos(hRad) * -sin(vRad) * _y; + upVector.z = cos(vRad) * _z; return upVector._normalize(); } @@ -91,6 +91,11 @@ function __3dCamera() constructor { return self; } + static setCameraLookRotate = function() { + var _fPos = calculate_3d_position(focus.x, focus.y, focus.z, focus_angle_x, focus_angle_y, focus_dist); + position.set(_fPos); + } + static worldPointToViewPoint = function(vec3) { var _vec4 = new __vec4().set(vec3, 1); var _view = viewMat.transpose().multiplyVector(_vec4); diff --git a/scripts/d3d_gizmo_sphere/d3d_gizmo_sphere.gml b/scripts/d3d_gizmo_sphere/d3d_gizmo_sphere.gml new file mode 100644 index 000000000..3a50760fb --- /dev/null +++ b/scripts/d3d_gizmo_sphere/d3d_gizmo_sphere.gml @@ -0,0 +1,30 @@ +function __3dGizmoSphere(radius = 0.5, color = c_white, alpha = 1) : __3dObject() constructor { + vertex = array_create(33 * 3); + + var _i = 0; + for( var i = 0; i <= 32; i++ ) { + var a0 = (i + 0) / 32 * 360; + var a1 = (i + 1) / 32 * 360; + var x0 = lengthdir_x(radius, a0); + var y0 = lengthdir_y(radius, a0); + var x1 = lengthdir_x(radius, a1); + var y1 = lengthdir_y(radius, a1); + + vertex[_i++] = [ 0, x0, y0, color, alpha ]; + vertex[_i++] = [ 0, x1, y1, color, alpha ]; + vertex[_i++] = [ x0, 0, y0, color, alpha ]; + vertex[_i++] = [ x1, 0, y1, color, alpha ]; + vertex[_i++] = [ x0, y0, 0, color, alpha ]; + vertex[_i++] = [ x1, y1, 0, color, alpha ]; + } + + VF = global.VF_POS_COL; + render_type = pr_linelist; + VB = build(); + + static submitSel = function(params = {}) { + shader_set(sh_d3d_wireframe); + submitVertex(params); + shader_reset(); + } +} \ No newline at end of file diff --git a/scripts/d3d_gizmo_sphere/d3d_gizmo_sphere.yy b/scripts/d3d_gizmo_sphere/d3d_gizmo_sphere.yy new file mode 100644 index 000000000..d66683c54 --- /dev/null +++ b/scripts/d3d_gizmo_sphere/d3d_gizmo_sphere.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "d3d_gizmo_sphere", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "gizmo", + "path": "folders/functions/3d/gizmo.yy", + }, +} \ No newline at end of file diff --git a/scripts/d3d_vec3/d3d_vec3.gml b/scripts/d3d_vec3/d3d_vec3.gml index c48c64218..dcfba0466 100644 --- a/scripts/d3d_vec3/d3d_vec3.gml +++ b/scripts/d3d_vec3/d3d_vec3.gml @@ -30,7 +30,12 @@ function __vec3(_x = 0, _y = 0, _z = 0) constructor { z = _z; return self; } set(_x, _y, _z); - + + static isZero = function() { + gml_pragma("forceinline"); + return x == 0 && y == 0 && z == 0; + } + static setIndex = function(index, value) { gml_pragma("forceinline"); switch(index) { diff --git a/scripts/nodeValue_drawer/nodeValue_drawer.gml b/scripts/nodeValue_drawer/nodeValue_drawer.gml index 3d1fc3f35..68c309920 100644 --- a/scripts/nodeValue_drawer/nodeValue_drawer.gml +++ b/scripts/nodeValue_drawer/nodeValue_drawer.gml @@ -157,7 +157,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc draw_line(bx - ui(20), by - lhf, bx - ui(20), by + lhf); bx -= ui(26 + 12); - if(buttonInstant(THEME.button_hide, bx - ui(12), by - ui(12), ui(24), ui(24), _m, _focus, _hover, __txtx("panel_animation_looping_mode", "Looping mode") + " " + ON_END_NAME[jun.on_end], THEME.prop_on_end, jun.on_end) == 2) + if(buttonInstant(THEME.button_hide, bx - ui(12), by - ui(12), ui(24), ui(24), _m, _focus, _hover, __txtx("panel_animation_looping_mode", "Looping mode") + " " + global.junctionEndName[jun.on_end], THEME.prop_on_end, jun.on_end) == 2) jun.on_end = safe_mod(jun.on_end + 1, sprite_get_number(THEME.prop_on_end)); } #endregion diff --git a/scripts/node_3d_camera/node_3d_camera.gml b/scripts/node_3d_camera/node_3d_camera.gml index 7859ec258..5a8735e79 100644 --- a/scripts/node_3d_camera/node_3d_camera.gml +++ b/scripts/node_3d_camera/node_3d_camera.gml @@ -2,73 +2,197 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) name = "3D Camera"; object = new __3dCamera_object(); camera = new __3dCamera(); - camera.useFocus = false; + lookat = new __3dGizmoSphere(0.5, c_ltgray, 1); scene = new __3dScene(camera); scene.name = "Camera"; - inputs[| input_d3d_index + 0] = nodeValue("FOV", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 60) + inputs[| in_d3d + 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 ]) + inputs[| in_d3d + 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 ) + inputs[| in_d3d + 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 ) + inputs[| in_d3d + 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 ) + inputs[| in_d3d + 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[| in_d3d + 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[| in_d3d + 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) + inputs[| in_d3d + 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) + inputs[| in_d3d + 8] = nodeValue("Orthographic Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) .setDisplay(VALUE_DISPLAY.slider, [ 0.01, 4, 0.01 ]); + inputs[| in_d3d + 9] = nodeValue("Postioning Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) + .setDisplay(VALUE_DISPLAY.enum_scroll, [ "Position + Rotation", "Position + Lookat", "Lookat + Rotation" ]); + + inputs[| in_d3d + 10] = nodeValue("Lookat Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ]) + .setDisplay(VALUE_DISPLAY.vector); + + inputs[| in_d3d + 11] = nodeValue("Roll", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) + .setDisplay(VALUE_DISPLAY.rotation); + + inputs[| in_d3d + 12] = nodeValue("Horizontal Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) + .setDisplay(VALUE_DISPLAY.rotation); + + inputs[| in_d3d + 13] = nodeValue("Vertical Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 45) + .setDisplay(VALUE_DISPLAY.slider, [0, 90, 1]); + + inputs[| in_d3d + 14] = nodeValue("Distance", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4); + 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, + input_display_list = [ in_d3d + 4, + ["Output", false], in_d3d + 2, + ["Transform", false], in_d3d + 9, 0, 1, in_d3d + 10, in_d3d + 11, in_d3d + 12, in_d3d + 13, in_d3d + 14, + ["Camera", false], in_d3d + 3, in_d3d + 0, in_d3d + 1, in_d3d + 8, + ["Render", false], in_d3d + 5, in_d3d + 6, in_d3d + 7, ]; - static step = function() { - var _proj = inputs[| input_d3d_index + 3].getValue(); + tool_lookat = new NodeTool( "Move Target", THEME.tools_3d_transform_object ); + + static getToolSettings = function() { #region + var _posm = inputs[| in_d3d + 9].getValue(); - inputs[| input_d3d_index + 0].setVisible(_proj == 0); - inputs[| input_d3d_index + 8].setVisible(_proj == 1); + switch(_posm) { + case 0 : return tool_settings; + case 1 : + case 2 : return []; + } + + return []; + } #endregion + + static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) { #region + var object = getPreviewObject(); + if(array_empty(object)) return; + object = object[0]; + + var _pos = inputs[| 0].getValue(,,, true); + var _vpos = new __vec3( _pos[0], _pos[1], _pos[2] ); + + if(isUsingTool("Transform")) drawGizmoPosition(0, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel); + else if(isUsingTool("Rotate")) drawGizmoRotation(1, object, _vpos, active, params, _mx, _my, _snx, _sny, _panel); + else if(isUsingTool("Move Target")) { + var _lkpos = inputs[| in_d3d + 10].getValue(,,, true); + var _lkvpos = new __vec3( _lkpos[0], _lkpos[1], _lkpos[2] ); + + drawGizmoPosition(in_d3d + 10, noone, _lkvpos, active, params, _mx, _my, _snx, _sny, _panel); + } + + if(drag_axis != noone && mouse_release(mb_left)) { + drag_axis = noone; + UNDO_HOLDING = false; + } + } #endregion + + static onValueUpdate = function(index) { + if(index == in_d3d + 9) PANEL_PREVIEW.tool_current = noone; } + + static step = function() { #region + var _proj = inputs[| in_d3d + 3].getValue(); + var _posm = inputs[| in_d3d + 9].getValue(); + + inputs[| in_d3d + 0].setVisible(_proj == 0); + inputs[| in_d3d + 8].setVisible(_proj == 1); + + inputs[| 0].setVisible(_posm == 0 || _posm == 1); + inputs[| 1].setVisible(_posm == 0); + inputs[| in_d3d + 10].setVisible(_posm == 1 || _posm == 2); + inputs[| in_d3d + 11].setVisible(_posm == 1); + inputs[| in_d3d + 12].setVisible(_posm == 2); + inputs[| in_d3d + 13].setVisible(_posm == 2); + inputs[| in_d3d + 14].setVisible(_posm == 2); + + switch(_posm) { + case 0 : + tools = [ tool_pos, tool_rot ]; + break; + case 1 : + tools = [ tool_pos, tool_lookat ]; + tool_attribute.context = 1; + break; + case 2 : + tools = [ tool_lookat ]; + tool_attribute.context = 1; + break; + } + } #endregion static processData = function(_output, _data, _output_index, _array_index = 0) { #region var _pos = _data[0]; var _rot = _data[1]; - var _fov = _data[input_d3d_index + 0]; - var _clip = _data[input_d3d_index + 1]; - var _dim = _data[input_d3d_index + 2]; - var _proj = _data[input_d3d_index + 3]; - var _scne = _data[input_d3d_index + 4]; - var _ambt = _data[input_d3d_index + 5]; - var _dbg = _data[input_d3d_index + 6]; - var _back = _data[input_d3d_index + 7]; - var _orts = _data[input_d3d_index + 8]; + var _fov = _data[in_d3d + 0]; + var _clip = _data[in_d3d + 1]; + var _dim = _data[in_d3d + 2]; + var _proj = _data[in_d3d + 3]; + var _scne = _data[in_d3d + 4]; + var _ambt = _data[in_d3d + 5]; + var _dbg = _data[in_d3d + 6]; + var _back = _data[in_d3d + 7]; + var _orts = _data[in_d3d + 8]; + + var _posm = _data[in_d3d + 9]; + var _look = _data[in_d3d + 10]; + var _roll = _data[in_d3d + 11]; + var _hAng = _data[in_d3d + 12]; + var _vAng = _data[in_d3d + 13]; + var _dist = _data[in_d3d + 14]; + + var _qi1 = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(0, 1, 0), 90); + var _qi2 = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), -90); + var _qi3 = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), 90); + + switch(_posm) { + case 0 : + camera.useFocus = false; + camera.position.set(_pos); + camera.rotation.set(_rot[0], _rot[1], _rot[2], _rot[3]); + break; + case 1 : + camera.useFocus = true; + camera.position.set(_pos); + camera.focus.set(_look); + camera.up.set(0, 0, -1); + + var _for = camera.focus.subtract(camera.position); + if(!_for.isZero()) + camera.rotation = new BBMOD_Quaternion().FromLookRotation(_for, camera.up).Mul(_qi1).Mul(_qi2); + + lookat.position.set(_look); + break; + case 2 : + camera.useFocus = true; + camera.focus.set(_look); + camera.setFocusAngle(_hAng, _vAng, _dist); + camera.setCameraLookRotate(); + camera.up = camera.getUp(); + + var _for = camera.focus.subtract(camera.position); + if(!_for.isZero()) + camera.rotation = new BBMOD_Quaternion().FromLookRotation(_for, camera.up).Mul(_qi1).Mul(_qi3); + + lookat.position.set(_look); + break; + } + + object.position.set(camera.position); + object.rotation = camera.rotation.Clone(); - setTransform(object, _data); 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(1 / _orts, _dim[0] / _dim[1] / _orts); @@ -106,12 +230,21 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) } - static getPreviewObject = function() { - var _scene = array_safe_get(all_inputs, input_d3d_index + 4, []); - _scene = array_safe_get(_scene, preview_index); + static getPreviewObject = function() { #region + var _posm = inputs[| in_d3d + 9].getValue(); + + var _scene = array_safe_get(all_inputs, in_d3d + 4, []); + if(is_array(_scene)) + _scene = array_safe_get(_scene, preview_index, noone); + + switch(_posm) { + case 0 : return [ object, _scene ]; + case 1 : return [ object, lookat, _scene ]; + case 2 : return [ object, lookat, _scene ]; + } return [ object, _scene ]; - } + } #endregion - static getPreviewObjectOutline = function() { return [ object ]; } + static getPreviewObjectOutline = function() { return isUsingTool("Move Target")? [ lookat ] : [ object ]; } } \ No newline at end of file diff --git a/scripts/node_3d_light_point/node_3d_light_point.gml b/scripts/node_3d_light_point/node_3d_light_point.gml index b4673e5cc..dc1f62636 100644 --- a/scripts/node_3d_light_point/node_3d_light_point.gml +++ b/scripts/node_3d_light_point/node_3d_light_point.gml @@ -1,11 +1,11 @@ function Node_3D_Light_Point(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _group) constructor { name = "Point Light"; - inputs[| input_light_index + 0] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4) + inputs[| in_light + 0] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4) input_display_list = [ ["Transform", false], 0, - __d3d_input_list_light, input_light_index, + __d3d_input_list_light, in_light, ] static processData = function(_output, _data, _output_index, _array_index = 0) { @@ -14,7 +14,7 @@ function Node_3D_Light_Point(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _gr setTransform(object, _data); setLight(object, _data); - var _rad = inputs[| input_light_index + 0].getValue(); + var _rad = inputs[| in_light + 0].getValue(); object.radius = _rad; return object; diff --git a/scripts/node_3d_mesh_cube/node_3d_mesh_cube.gml b/scripts/node_3d_mesh_cube/node_3d_mesh_cube.gml index 8fc39dcbe..203b12b8a 100644 --- a/scripts/node_3d_mesh_cube/node_3d_mesh_cube.gml +++ b/scripts/node_3d_mesh_cube/node_3d_mesh_cube.gml @@ -1,47 +1,47 @@ function Node_3D_Mesh_Cube(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group) constructor { name = "3D Cube"; - inputs[| input_mesh_index + 0] = nodeValue("Texture per side", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false ); + inputs[| in_mesh + 0] = nodeValue("Texture per side", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false ); - inputs[| input_mesh_index + 1] = nodeValue("Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); + inputs[| in_mesh + 1] = nodeValue("Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); - inputs[| input_mesh_index + 2] = nodeValue("Texture 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); + inputs[| in_mesh + 2] = nodeValue("Texture 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); - inputs[| input_mesh_index + 3] = nodeValue("Texture 3", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); + inputs[| in_mesh + 3] = nodeValue("Texture 3", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); - inputs[| input_mesh_index + 4] = nodeValue("Texture 4", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); + inputs[| in_mesh + 4] = nodeValue("Texture 4", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); - inputs[| input_mesh_index + 5] = nodeValue("Texture 5", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); + inputs[| in_mesh + 5] = nodeValue("Texture 5", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); - inputs[| input_mesh_index + 6] = nodeValue("Texture 6", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); + inputs[| in_mesh + 6] = nodeValue("Texture 6", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); input_display_list = [ __d3d_input_list_mesh, __d3d_input_list_transform, - ["Texture", false], input_mesh_index + 0, input_mesh_index + 1, input_mesh_index + 2, input_mesh_index + 3, - input_mesh_index + 4, input_mesh_index + 5, input_mesh_index + 6, + ["Texture", false], in_mesh + 0, in_mesh + 1, in_mesh + 2, in_mesh + 3, + in_mesh + 4, in_mesh + 5, in_mesh + 6, ] static step = function() { #region - var _tex_side = inputs[| input_mesh_index + 0].getValue(); + var _tex_side = inputs[| in_mesh + 0].getValue(); - inputs[| input_mesh_index + 1].name = _tex_side? "Texture 1" : "Texture"; - inputs[| input_mesh_index + 1].setVisible(true, true); - inputs[| input_mesh_index + 2].setVisible(_tex_side, _tex_side); - inputs[| input_mesh_index + 3].setVisible(_tex_side, _tex_side); - inputs[| input_mesh_index + 4].setVisible(_tex_side, _tex_side); - inputs[| input_mesh_index + 5].setVisible(_tex_side, _tex_side); - inputs[| input_mesh_index + 6].setVisible(_tex_side, _tex_side); + inputs[| in_mesh + 1].name = _tex_side? "Texture 1" : "Texture"; + inputs[| in_mesh + 1].setVisible(true, true); + inputs[| in_mesh + 2].setVisible(_tex_side, _tex_side); + inputs[| in_mesh + 3].setVisible(_tex_side, _tex_side); + inputs[| in_mesh + 4].setVisible(_tex_side, _tex_side); + inputs[| in_mesh + 5].setVisible(_tex_side, _tex_side); + inputs[| in_mesh + 6].setVisible(_tex_side, _tex_side); } #endregion static processData = function(_output, _data, _output_index, _array_index = 0) { #region - var _tex_side = _data[input_mesh_index + 0]; - var _tex_1 = _data[input_mesh_index + 1]; - var _tex_2 = _data[input_mesh_index + 2]; - var _tex_3 = _data[input_mesh_index + 3]; - var _tex_4 = _data[input_mesh_index + 4]; - var _tex_5 = _data[input_mesh_index + 5]; - var _tex_6 = _data[input_mesh_index + 6]; + var _tex_side = _data[in_mesh + 0]; + var _tex_1 = _data[in_mesh + 1]; + var _tex_2 = _data[in_mesh + 2]; + var _tex_3 = _data[in_mesh + 3]; + var _tex_4 = _data[in_mesh + 4]; + var _tex_5 = _data[in_mesh + 5]; + var _tex_6 = _data[in_mesh + 6]; var object; if(_tex_side) { @@ -59,5 +59,5 @@ function Node_3D_Mesh_Cube(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group return object; } #endregion - static getPreviewValues = function() { return array_safe_get(all_inputs, input_mesh_index + 1, noone); } + static getPreviewValues = function() { return array_safe_get(all_inputs, in_mesh + 1, noone); } } \ No newline at end of file diff --git a/scripts/node_canvas/node_canvas.gml b/scripts/node_canvas/node_canvas.gml index f278e9af9..2e74c4e61 100644 --- a/scripts/node_canvas/node_canvas.gml +++ b/scripts/node_canvas/node_canvas.gml @@ -66,7 +66,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor selection_mx = 0; selection_my = 0; - tool_channel_edit = new checkBoxGroup(THEME.tools_canvas_channel, function(ind, val) { tool_attribute.channel[ind] = val; }); + tool_channel_edit = new checkBoxGroup(THEME.tools_canvas_channel, function(ind, val) { tool_attribute.channel[ind] = val; }); tool_attribute.channel = [ true, true, true, true ]; tool_settings = [ [ "Channel", tool_channel_edit, "channel", tool_attribute ], diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index c883fdb94..13d15efe3 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -371,7 +371,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x if(hasInspector1Update()) { var trig = inspectInput1.getValue(); if(trig) { - inspectInput1.editWidget.onClick(); + onInspector1Update(); inspectInput1.setValue(false); } } @@ -379,7 +379,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x if(hasInspector2Update()) { var trig = inspectInput2.getValue(); if(trig) { - inspectInput2.editWidget.onClick(); + onInspector2Update(); inspectInput2.setValue(false); } } @@ -1277,6 +1277,8 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x static getTool = function() { return self; } + static getToolSettings = function() { return tool_settings; } + static setTool = function(tool) { #region if(!tool) { isTool = false; diff --git a/scripts/node_keyframe/node_keyframe.gml b/scripts/node_keyframe/node_keyframe.gml index 29b826f8e..5f0172ec1 100644 --- a/scripts/node_keyframe/node_keyframe.gml +++ b/scripts/node_keyframe/node_keyframe.gml @@ -1,30 +1,33 @@ enum CURVE_TYPE { - none, + linear, bezier, cut, } function valueKey(_time, _value, _anim = noone, _in = 0, _ot = 0) constructor { - time = _time; - ratio = time / (PROJECT.animator.frames_total - 1); - value = _value; - anim = _anim; + #region ---- main ---- + time = _time; + ratio = time / (PROJECT.animator.frames_total - 1); + value = _value; + anim = _anim; - ease_y_lock = true; - ease_in = is_array(_in)? _in : [_in, 1]; - ease_out = is_array(_ot)? _ot : [_ot, 0]; + ease_y_lock = true; + ease_in = is_array(_in)? _in : [_in, 1]; + ease_out = is_array(_ot)? _ot : [_ot, 0]; + + var _int = anim? anim.prop.key_inter : CURVE_TYPE.linear; + ease_in_type = _int; + ease_out_type = _int; - ease_in_type = CURVE_TYPE.none; - ease_out_type = CURVE_TYPE.none; + dopesheet_x = 0; + #endregion - dopesheet_x = 0; - - static setTime = function(time) { + static setTime = function(time) { #region self.time = time; ratio = time / (PROJECT.animator.frames_total - 1); - } + } #endregion - static clone = function(target = noone) { + static clone = function(target = noone) { #region var key = new valueKey(time, value, target); key.ease_in = ease_in; key.ease_out = ease_out; @@ -32,9 +35,9 @@ function valueKey(_time, _value, _anim = noone, _in = 0, _ot = 0) constructor { key.ease_out_type = ease_out_type; return key; - } + } #endregion - static cloneAnimator = function(shift = 0, anim = noone, removeDup = true) { + static cloneAnimator = function(shift = 0, anim = noone, removeDup = true) { #region if(anim != noone) { //check value compat between animator if(value_bit(self.anim.prop.type) & value_bit(anim.prop.type) == 0) { noti_warning("Type incompatible"); @@ -58,26 +61,28 @@ function valueKey(_time, _value, _anim = noone, _in = 0, _ot = 0) constructor { anim.setKeyTime(key, time + shift, removeDup); return key; - } + } #endregion } function valueAnimator(_val, _prop, _sep_axis = false) constructor { - suffix = ""; - values = ds_list_create(); - sep_axis = _sep_axis; - if(_prop.type != VALUE_TYPE.trigger) - ds_list_add(values, new valueKey(0, _val, self)); - //print(_prop.name + ": " + string(_val)); + #region ---- main ---- + suffix = ""; + values = ds_list_create(); + sep_axis = _sep_axis; + + index = 0; + prop = _prop; + dopesheet_y = 0; + + if(_prop.type != VALUE_TYPE.trigger) + ds_list_add(values, new valueKey(0, _val, self)); + #endregion - index = 0; - prop = _prop; - dopesheet_y = 0; - - static interpolate = function(from, to, rat) { + static interpolate = function(from, to, rat) { #region if(prop.type == VALUE_TYPE.boolean) return 0; - if(to.ease_in_type == CURVE_TYPE.none && from.ease_out_type == CURVE_TYPE.none) + if(to.ease_in_type == CURVE_TYPE.linear && from.ease_out_type == CURVE_TYPE.linear) return rat; if(to.ease_in_type == CURVE_TYPE.cut) return 0; @@ -93,9 +98,9 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { var bz = [0, eox, eoy, 1. - eix, eiy, 1]; return eval_curve_segment_x(bz, rat); - } + } #endregion - static lerpValue = function(from, to, _lrp) { + static lerpValue = function(from, to, _lrp) { #region var _f = from.value; var _t = to.value; @@ -138,11 +143,11 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { return processType(_f); return processType(lerp(_f, _t, _lrp)); - } + } #endregion static getName = function() { return prop.name + suffix; } - static getValue = function(_time = PROJECT.animator.current_frame) { + static getValue = function(_time = PROJECT.animator.current_frame) { #region if(prop.type == VALUE_TYPE.trigger) { if(ds_list_size(values) == 0) return false; @@ -239,14 +244,14 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { } return processType(values[| ds_list_size(values) - 1].value); //Last frame - } + } #endregion - static processTypeDefault = function() { + static processTypeDefault = function() { #region if(!sep_axis && typeArray(prop.display_type)) return []; return 0; - } - - static processType = function(_val) { + } #endregion + + static processType = function(_val) { #region if(!sep_axis && typeArray(prop.display_type) && is_array(_val)) { for(var i = 0; i < array_length(_val); i++) _val[i] = processValue(_val[i]); @@ -254,9 +259,9 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { return _val; } return processValue(_val); - } + } #endregion - static processValue = function(_val) { + static processValue = function(_val) { #region if(is_array(_val)) return _val; if(is_struct(_val)) return _val; if(is_undefined(_val)) return 0; @@ -275,9 +280,9 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { } return _val; - } + } #endregion - static setKeyTime = function(_key, _time, _replace = true) { + static setKeyTime = function(_key, _time, _replace = true) { #region if(!ds_list_exist(values, _key)) return 0; if(!LOADING) PROJECT.modified = true; @@ -303,9 +308,9 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { ds_list_add(values, _key); return 1; - } + } #endregion - static setValue = function(_val = 0, _record = true, _time = PROJECT.animator.current_frame, ease_in = 0, ease_out = 0) { + static setValue = function(_val = 0, _record = true, _time = PROJECT.animator.current_frame, ease_in = 0, ease_out = 0) { #region if(prop.type == VALUE_TYPE.trigger) { if(!prop.is_anim) { values[| 0] = new valueKey(0, _val, self); @@ -370,16 +375,16 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { if(_record) recordAction(ACTION_TYPE.list_insert, values, [ k, ds_list_size(values), "add " + string(prop.name) + " keyframe" ]); ds_list_add(values, k); return true; - } + } #endregion - static removeKey = function(key) { + static removeKey = function(key) { #region if(ds_list_size(values) > 1) ds_list_remove(values, key); else prop.is_anim = false; - } + } #endregion - static serialize = function(scale = false) { + static serialize = function(scale = false) { #region var _data = []; for(var i = 0; i < ds_list_size(values); i++) { @@ -417,9 +422,9 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { } return _data; - } + } #endregion - static deserialize = function(_data, scale = false) { + static deserialize = function(_data, scale = false) { #region ds_list_clear(values); if(prop.type == VALUE_TYPE.gradient && PROJECT.version < 1340 && !CLONING) { //backward compat: Gradient @@ -482,9 +487,9 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor { vk.ease_y_lock = ease_y_lock; ds_list_add(values, vk); } - } + } #endregion - static cleanUp = function() { + static cleanUp = function() { #region ds_list_destroy(values); - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_processor/node_processor.gml b/scripts/node_processor/node_processor.gml index 2b2100a03..7cd8f7999 100644 --- a/scripts/node_processor/node_processor.gml +++ b/scripts/node_processor/node_processor.gml @@ -64,7 +64,8 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct } static preProcess = function(outIndex) { - var _out = outputs[| outIndex].getValue(); + var _out = outputs[| outIndex].getValue(); + all_inputs = array_create(ds_list_size(inputs)); if(process_amount == 0) { #region render single data if(outputs[| outIndex].type == VALUE_TYPE.d3object) //passing 3D vertex call @@ -101,6 +102,7 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct return inputs_data[0] } + all_inputs = inputs_data; var data = processData(_out, inputs_data, outIndex, 0); /// Process data return data; } #endregion @@ -117,7 +119,6 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct array_resize(_out, process_amount); var _data = array_create(ds_list_size(inputs)); - all_inputs = array_create(ds_list_size(inputs)); for(var i = 0; i < ds_list_size(inputs); i++) all_inputs[i] = array_create(process_amount); diff --git a/scripts/node_render_sprite_sheet/node_render_sprite_sheet.gml b/scripts/node_render_sprite_sheet/node_render_sprite_sheet.gml index fdf2034c0..7ae6d9e33 100644 --- a/scripts/node_render_sprite_sheet/node_render_sprite_sheet.gml +++ b/scripts/node_render_sprite_sheet/node_render_sprite_sheet.gml @@ -103,6 +103,8 @@ function Node_Render_Sprite_Sheet(_x, _y, _group = noone) : Node(_x, _y, _group) amo = _ed - _st; for(var i = 0; i < array_length(inpt); i++) { + _atl[i] = []; + if(!is_surface(inpt[i])) continue; var sw = surface_get_width(inpt[i]); var sh = surface_get_height(inpt[i]); @@ -133,8 +135,6 @@ function Node_Render_Sprite_Sheet(_x, _y, _group = noone) : Node(_x, _y, _group) surface_reset_target(); refreshSurface = true; - - _atl[i] = []; } if(!arr) _surf = array_safe_get(_surf, 0); diff --git a/scripts/node_trigger_bool/node_trigger_bool.gml b/scripts/node_trigger_bool/node_trigger_bool.gml index 7a594867a..a5d2f43bc 100644 --- a/scripts/node_trigger_bool/node_trigger_bool.gml +++ b/scripts/node_trigger_bool/node_trigger_bool.gml @@ -35,7 +35,7 @@ function Node_Trigger_Bool(_x, _y, _group = noone) : Node(_x, _y, _group) constr switch(con) { case 0 : doTrigger = val; break; case 1 : doTrigger = !prevVal && val; break; - case 2 : doTrigger = prevVal && !val; break; + case 2 : doTrigger = prevVal && !val; break; case 3 : doTrigger = prevVal != val; break; } diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 373540e7a..6d9efdb38 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -1,3 +1,13 @@ +#region ---- global names ---- + global.junctionEndName = [ "Hold", "Loop", "Ping pong", "Wrap" ]; + + global.displaySuffix_Range = [ "min", "max" ]; + global.displaySuffix_Area = [ "x", "y", "w", "h" ]; + global.displaySuffix_Padding = [ "right", "top", "left", "bottom" ]; + global.displaySuffix_VecRange = [ "x min", "x max", "y min", "y max" ]; + global.displaySuffix_Axis = [ "x", "y", "z", "w"]; +#endregion + enum JUNCTION_CONNECT { input, output @@ -93,7 +103,25 @@ enum VALUE_DISPLAY { d3vertex, } -function value_color(i) { +enum KEYFRAME_END { + hold, + loop, + ping, + wrap, +} + +enum VALIDATION { + pass, + warning, + error +} + +enum VALUE_UNIT { + constant, + reference +} + +function value_color(i) { #region static JUNCTION_COLORS = [ $6691ff, //int $78e4ff, //float @@ -129,9 +157,9 @@ function value_color(i) { if(i == 99) return $5dde8f; return JUNCTION_COLORS[safe_mod(max(0, i), array_length(JUNCTION_COLORS))]; -} +} #endregion -function value_bit(i) { +function value_bit(i) { #region switch(i) { case VALUE_TYPE.integer : return 1 << 0 | 1 << 1; case VALUE_TYPE.float : return 1 << 2 | 1 << 1; @@ -172,9 +200,9 @@ function value_bit(i) { case VALUE_TYPE.any : return ~0 & ~(1 << 32); } return 0; -} +} #endregion -function value_type_directional(f, t) { +function value_type_directional(f, t) { #region if(f == VALUE_TYPE.surface && t == VALUE_TYPE.integer) return true; if(f == VALUE_TYPE.surface && t == VALUE_TYPE.float) return true; @@ -194,9 +222,9 @@ function value_type_directional(f, t) { if(f == VALUE_TYPE.mesh && t == VALUE_TYPE.struct ) return true; return false; -} +} #endregion -function typeArray(_type) { +function typeArray(_type) { #region switch(_type) { case VALUE_DISPLAY.range : case VALUE_DISPLAY.vector_range : @@ -220,26 +248,26 @@ function typeArray(_type) { return 1; } return 0; -} +} #endregion -function typeArrayDynamic(_type) { +function typeArrayDynamic(_type) { #region switch(_type) { case VALUE_DISPLAY.curve : case VALUE_DISPLAY.palette : return true; } return false; -} +} #endregion -function typeCompatible(fromType, toType, directional_cast = true) { +function typeCompatible(fromType, toType, directional_cast = true) { #region if(value_bit(fromType) & value_bit(toType) != 0) return true; if(!directional_cast) return false; return value_type_directional(fromType, toType); -} +} #endregion -function typeIncompatible(from, to) { +function typeIncompatible(from, to) { #region if(from.type == VALUE_TYPE.surface && (to.type == VALUE_TYPE.integer || to.type == VALUE_TYPE.float)) { switch(to.display_type) { case VALUE_DISPLAY.area : @@ -253,30 +281,9 @@ function typeIncompatible(from, to) { } return false; -} +} #endregion -enum KEYFRAME_END { - hold, - loop, - ping, - wrap, -} - -globalvar ON_END_NAME; -ON_END_NAME = [ "Hold", "Loop", "Ping pong", "Wrap" ]; - -enum VALIDATION { - pass, - warning, - error -} - -enum VALUE_UNIT { - constant, - reference -} - -function isGraphable(prop) { +function isGraphable(prop) { #region if(prop.type == VALUE_TYPE.integer || prop.type == VALUE_TYPE.float) { if(prop.display_type == VALUE_DISPLAY.puppet_control) return false; @@ -286,9 +293,9 @@ function isGraphable(prop) { return true; return false; -} +} #endregion -function nodeValueUnit(value) constructor { +function nodeValueUnit(value) constructor { #region self.value = value; mode = VALUE_UNIT.constant; @@ -302,7 +309,7 @@ function nodeValueUnit(value) constructor { triggerButton.icon_blend = COLORS._main_icon_light; triggerButton.icon = THEME.unit_ref; - static setMode = function(type) { + static setMode = function(type) { #region if(type == "constant" && mode == VALUE_UNIT.constant) return; if(type == "relative" && mode == VALUE_UNIT.reference) return; @@ -310,34 +317,34 @@ function nodeValueUnit(value) constructor { value.cache_value[0] = false; value.unitConvert(mode); value.node.doUpdate(); - } + } #endregion - static draw = function(_x, _y, _w, _h, _m) { + static draw = function(_x, _y, _w, _h, _m) { #region triggerButton.icon_index = mode; triggerButton.tooltip = (mode? "Fraction" : "Pixel") + " unit"; triggerButton.draw(_x, _y, _w, _h, _m, THEME.button_hide); - } + } #endregion - static invApply = function(value, index = 0) { + static invApply = function(value, index = 0) { #region if(mode == VALUE_UNIT.constant) return value; if(reference == noone) return value; return convertUnit(value, VALUE_UNIT.reference, index); - } + } #endregion - static apply = function(value, index = 0) { + static apply = function(value, index = 0) { #region if(mode == VALUE_UNIT.constant) return value; if(reference == noone) return value; return convertUnit(value, VALUE_UNIT.constant, index); - } + } #endregion - static convertUnit = function(value, unitTo, index = 0) { + static convertUnit = function(value, unitTo, index = 0) { #region var disp = self.value.display_type; var base = reference(index); var inv = unitTo == VALUE_UNIT.reference; @@ -369,123 +376,148 @@ function nodeValueUnit(value) constructor { } return value; - } -} + } #endregion +} #endregion -global.displaySuffix_Range = [ "min", "max" ]; -global.displaySuffix_Area = [ "x", "y", "w", "h" ]; -global.displaySuffix_Padding = [ "right", "top", "left", "bottom" ]; -global.displaySuffix_VecRange = [ "x min", "x max", "y min", "y max" ]; -global.displaySuffix_Axis = [ "x", "y", "z", "w"]; - -function nodeValue(_name, _node, _connect, _type, _value, _tooltip = "") { - return new NodeValue(_name, _node, _connect, _type, _value, _tooltip); -} +function nodeValue(_name, _node, _connect, _type, _value, _tooltip = "") { return new NodeValue(_name, _node, _connect, _type, _value, _tooltip); } function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constructor { - node = _node; - x = node.x; - y = node.y; - index = _connect == JUNCTION_CONNECT.input? ds_list_size(node.inputs) : ds_list_size(node.outputs); - type = _type; - forward = true; + #region ---- main ---- + node = _node; + x = node.x; + y = node.y; + index = _connect == JUNCTION_CONNECT.input? ds_list_size(node.inputs) : ds_list_size(node.outputs); + type = _type; + forward = true; + + _initName = _name; + name = __txt_junction_name(instanceof(node), type, index, _name); + name = _name; - _initName = _name; - name = __txt_junction_name(instanceof(node), type, index, _name); - name = _name; + static updateName = function() { + internalName = string_lower(string_replace_all(name, " ", "_")); + } updateName(); + + if(struct_has(node, "inputMap")) { + if(_connect == JUNCTION_CONNECT.input) node.inputMap[? internalName] = self; + else if(_connect == JUNCTION_CONNECT.output) node.outputMap[? internalName] = self; + } + + tooltip = _tooltip; + editWidget = noone; + #endregion - static updateName = function() { - internalName = string_lower(string_replace_all(name, " ", "_")); - } updateName(); + #region ---- connection ---- + connect_type = _connect; + value_from = noone; + value_to = ds_list_create(); + value_to_arr = []; + accept_array = true; + array_depth = 0; + auto_connect = true; + setFrom_condition = -1; + #endregion - if(struct_has(node, "inputMap")) { - if(_connect == JUNCTION_CONNECT.input) node.inputMap[? internalName] = self; - else if(_connect == JUNCTION_CONNECT.output) node.outputMap[? internalName] = self; - } + #region ---- animation ---- + key_inter = CURVE_TYPE.linear; + + is_anim = false; + sep_axis = false; + sepable = is_array(_value) && array_length(_value) > 1; + animator = new valueAnimator(_value, self, false); + animators = []; + if(is_array(_value)) + for( var i = 0, n = array_length(_value); i < n; i++ ) { + animators[i] = new valueAnimator(_value[i], self, true); + animators[i].index = i; + } + + on_end = KEYFRAME_END.hold; + loop_range = -1; + #endregion - tooltip = _tooltip; - editWidget = noone; + #region ---- value ---- + def_val = _value; + unit = new nodeValueUnit(self); + extra_data = {}; + dyna_depo = ds_list_create(); + + is_changed = true; + cache_value = [ false, false, undefined ]; + cache_array = [ false, false ]; + use_cache = true; + + process_array = true; + validateValue = true; + + fullUpdate = false; + #endregion - connect_type = _connect; - value_from = noone; - value_to = ds_list_create(); - value_to_arr = []; - accept_array = true; - array_depth = 0; - auto_connect = true; - setFrom_condition = -1; + #region ---- draw ---- + draw_line_shift_x = 0; + draw_line_shift_y = 0; + draw_line_thick = 1; + draw_line_shift_hover = false; + drawLineIndex = 1; + draw_line_vb = noone; + + junction_drawing = [ THEME.node_junctions_single, type ]; + + drag_type = 0; + drag_mx = 0; + drag_my = 0; + drag_sx = 0; + drag_sy = 0; + #endregion - is_anim = false; - sep_axis = false; - sepable = is_array(_value) && array_length(_value) > 1; - animator = new valueAnimator(_value, self, false); - animators = []; - if(is_array(_value)) - for( var i = 0, n = array_length(_value); i < n; i++ ) { - animators[i] = new valueAnimator(_value[i], self, true); - animators[i].index = i; - } + #region ---- timeline ---- + show_graph = false; + graph_h = ui(64); + #endregion - def_val = _value; - on_end = KEYFRAME_END.hold; - loop_range = -1; + #region ---- inspector ---- + visible = _connect == JUNCTION_CONNECT.output || _type == VALUE_TYPE.surface || _type == VALUE_TYPE.path; + show_in_inspector = true; - unit = new nodeValueUnit(self); - extra_data = {}; - dyna_depo = ds_list_create(); + display_type = VALUE_DISPLAY._default; + if(_type == VALUE_TYPE.curve) display_type = VALUE_DISPLAY.curve; + else if(_type == VALUE_TYPE.d3vertex) display_type = VALUE_DISPLAY.d3vertex; - draw_line_shift_x = 0; - draw_line_shift_y = 0; - draw_line_thick = 1; - draw_line_shift_hover = false; - drawLineIndex = 1; - draw_line_vb = noone; + display_data = -1; + display_attribute = noone; + #endregion - show_graph = false; - graph_h = ui(64); + #region ---- graph ---- + value_validation = VALIDATION.pass; + error_notification = noone; + + extract_node = ""; + #endregion - visible = _connect == JUNCTION_CONNECT.output || _type == VALUE_TYPE.surface || _type == VALUE_TYPE.path; - show_in_inspector = true; + #region ---- expression ---- + expUse = false; + expression = ""; + expTree = noone; - display_type = VALUE_DISPLAY._default; - if(_type == VALUE_TYPE.curve) display_type = VALUE_DISPLAY.curve; - else if(_type == VALUE_TYPE.d3vertex) display_type = VALUE_DISPLAY.d3vertex; + express_edit = new textArea(TEXTBOX_INPUT.text, function(str) { + expression = str; + expressionUpdate(); + }); + express_edit.autocomplete_server = pxl_autocomplete_server; + express_edit.function_guide_server = pxl_function_guide_server; + express_edit.parser_server = pxl_document_parser; + express_edit.format = TEXT_AREA_FORMAT.code; + express_edit.font = f_code; + express_edit.boxColor = COLORS._main_value_positive; + express_edit.align = fa_left; + #endregion - display_data = -1; - display_attribute = noone; + #region ---- serialization ---- + con_node = -1; + con_index = -1; + #endregion - value_validation = VALIDATION.pass; - error_notification = noone; - - extract_node = ""; - - is_changed = true; - cache_value = [ false, false, undefined ]; - cache_array = [ false, false ]; - use_cache = true; - - expUse = false; - expression = ""; - expTree = noone; - - express_edit = new textArea(TEXTBOX_INPUT.text, function(str) { - expression = str; - expressionUpdate(); - }); - express_edit.autocomplete_server = pxl_autocomplete_server; - express_edit.function_guide_server = pxl_function_guide_server; - express_edit.parser_server = pxl_document_parser; - express_edit.format = TEXT_AREA_FORMAT.code; - express_edit.font = f_code; - express_edit.boxColor = COLORS._main_value_positive; - express_edit.align = fa_left; - - process_array = true; - validateValue = true; - - fullUpdate = false; - - static setDefault = function(vals) { + static setDefault = function(vals) { #region if(LOADING || APPENDING) return self; ds_list_clear(animator.values); @@ -493,19 +525,19 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru ds_list_add(animator.values, new valueKey(vals[i][0], vals[i][1], animator)); return self; - } + } #endregion static resetValue = function() { setValue(def_val); } - static setUnitRef = function(ref, mode = VALUE_UNIT.constant) { + static setUnitRef = function(ref, mode = VALUE_UNIT.constant) { #region unit.reference = ref; unit.mode = mode; cache_value[0] = false; return self; - } + } #endregion - static setVisible = function(inspector) { + static setVisible = function(inspector) { #region if(connect_type == JUNCTION_CONNECT.input) { show_in_inspector = inspector; visible = argument_count > 1? argument[1] : visible; @@ -513,59 +545,59 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru visible = inspector; return self; - } + } #endregion - static setDisplay = function(_type = VALUE_DISPLAY._default, _data = -1, _attr = noone) { + static setDisplay = function(_type = VALUE_DISPLAY._default, _data = -1, _attr = noone) { #region display_type = _type; display_data = _data; display_attribute = _attr; resetDisplay(); return self; - } + } #endregion - static rejectArray = function() { + static rejectArray = function() { #region accept_array = false; return self; - } + } #endregion - static uncache = function() { + static uncache = function() { #region use_cache = false; return self; - } + } #endregion - static setArrayDepth = function(aDepth) { + static setArrayDepth = function(aDepth) { #region array_depth = aDepth; return self; - } + } #endregion - static rejectConnect = function() { + static rejectConnect = function() { #region auto_connect = false; return self; - } + } #endregion - static rejectArrayProcess = function() { + static rejectArrayProcess = function() { #region process_array = false; return self; - } + } #endregion - static nonForward = function() { + static nonForward = function() { #region forward = false; return self; - } + } #endregion - static nonValidate = function() { + static nonValidate = function() { #region validateValue = false; return self; - } + } #endregion - static isAnimable = function() { + static isAnimable = function() { #region //if(type == VALUE_TYPE.gradient) return false; if(display_type == VALUE_DISPLAY.text_array) return false; return true; - } + } #endregion - static setDropKey = function() { + static setDropKey = function() { #region switch(type) { case VALUE_TYPE.integer : drop_key = "Number"; break; case VALUE_TYPE.float : drop_key = "Number"; break; @@ -585,17 +617,17 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru default: drop_key = "None"; } - } + } #endregion setDropKey(); - static resetDisplay = function() { + static resetDisplay = function() { #region editWidget = noone; switch(display_type) { - case VALUE_DISPLAY.button : + case VALUE_DISPLAY.button : #region editWidget = button(display_data[0]); editWidget.text = display_data[1]; visible = false; - return; + return; #endregion } switch(type) { @@ -603,8 +635,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru case VALUE_TYPE.integer : var _txt = TEXTBOX_INPUT.number; - switch(display_type) { - case VALUE_DISPLAY._default : + switch(display_type) { + case VALUE_DISPLAY._default : #region editWidget = new textBox(_txt, function(val) { return setValueDirect(val); } ); @@ -613,8 +645,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(display_data != -1) editWidget.slide_speed = display_data; extract_node = "Node_Number"; - break; - case VALUE_DISPLAY.range : + break; #endregion + case VALUE_DISPLAY.range : #region editWidget = new rangeBox(_txt, function(index, val) { //var _val = animator.getValue(); //_val[index] = val; @@ -627,8 +659,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru animators[i].suffix = " " + array_safe_get(global.displaySuffix_Range, i); extract_node = "Node_Number"; - break; - case VALUE_DISPLAY.vector : + break; #endregion + case VALUE_DISPLAY.vector : #region var val = animator.getValue(); if(array_length(val) <= 4) { editWidget = new vectorBox(array_length(animator.getValue()), function(index, val) { @@ -650,8 +682,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru for( var i = 0, n = array_length(animators); i < n; i++ ) animators[i].suffix = " " + string(array_safe_get(global.displaySuffix_Axis, i)); - break; - case VALUE_DISPLAY.vector_range : + break; #endregion + case VALUE_DISPLAY.vector_range : #region var val = animator.getValue(); editWidget = new vectorRangeBox(array_length(val), _txt, function(index, val) { @@ -672,15 +704,15 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru for( var i = 0, n = array_length(animators); i < n; i++ ) animators[i].suffix = " " + string(array_safe_get(global.displaySuffix_VecRange, i)); - break; - case VALUE_DISPLAY.rotation : + break; #endregion + case VALUE_DISPLAY.rotation : #region editWidget = new rotator(function(val) { return setValueDirect(val); }, display_data ); extract_node = "Node_Number"; - break; - case VALUE_DISPLAY.rotation_range : + break; #endregion + case VALUE_DISPLAY.rotation_range : #region editWidget = new rotatorRange(function(index, val) { //var _val = animator.getValue(); //_val[index] = round(val); @@ -691,16 +723,16 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru animators[i].suffix = " " + array_safe_get(global.displaySuffix_Range, i); extract_node = "Node_Vector2"; - break; - case VALUE_DISPLAY.slider : + break; #endregion + case VALUE_DISPLAY.slider : #region editWidget = new slider(display_data[0], display_data[1], display_data[2], function(val) { return setValueDirect(toNumber(val)); } ); if(type == VALUE_TYPE.integer) editWidget.setSlideSpeed(1); extract_node = "Node_Number"; - break; - case VALUE_DISPLAY.slider_range : + break; #endregion + case VALUE_DISPLAY.slider_range : #region editWidget = new sliderRange(display_data[0], display_data[1], display_data[2], function(index, val) { //var _val = animator.getValue(); //_val[index] = val; @@ -712,8 +744,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru animators[i].suffix = " " + array_safe_get(global.displaySuffix_Range, i); extract_node = "Node_Vector2"; - break; - case VALUE_DISPLAY.area : + break; #endregion + case VALUE_DISPLAY.area : #region editWidget = new areaBox(function(index, val) { return setValueDirect(val, index); }, unit); @@ -725,8 +757,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru extra_data.area_type = AREA_MODE.area; extract_node = "Node_Area"; - break; - case VALUE_DISPLAY.padding : + break; #endregion + case VALUE_DISPLAY.padding : #region editWidget = new paddingBox(function(index, val) { //var _val = animator.getValue(); //_val[index] = val; @@ -738,8 +770,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru animators[i].suffix = " " + array_safe_get(global.displaySuffix_Padding, i); extract_node = "Node_Vector4"; - break; - case VALUE_DISPLAY.corner : + break; #endregion + case VALUE_DISPLAY.corner : #region editWidget = new cornerBox(function(index, val) { return setValueDirect(val, index); }, unit); @@ -749,8 +781,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru animators[i].suffix = " " + array_safe_get(global.displaySuffix_Padding, i); extract_node = "Node_Vector4"; - break; - case VALUE_DISPLAY.puppet_control : + break; #endregion + case VALUE_DISPLAY.puppet_control : #region editWidget = new controlPointBox(function(index, val) { //var _val = animator.getValue(); //_val[index] = val; @@ -758,8 +790,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru }); extract_node = ""; - break; - case VALUE_DISPLAY.enum_scroll : + break; #endregion + case VALUE_DISPLAY.enum_scroll : #region editWidget = new scrollBox(display_data, function(val) { if(val == -1) return; return setValueDirect(toNumber(val)); @@ -769,17 +801,19 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } rejectConnect(); + key_inter = CURVE_TYPE.cut; extract_node = ""; - break; - case VALUE_DISPLAY.enum_button : + break; #endregion + case VALUE_DISPLAY.enum_button : #region editWidget = new buttonGroup(display_data, function(val) { return setValueDirect(val); } ); rejectConnect(); + key_inter = CURVE_TYPE.cut; extract_node = ""; - break; - case VALUE_DISPLAY.kernel : + break; #endregion + case VALUE_DISPLAY.kernel : #region editWidget = new matrixGrid(_txt, function(index, val) { var _val = animator.getValue(); _val[index] = val; @@ -792,8 +826,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru animators[i].suffix = " " + string(i); extract_node = ""; - break; - case VALUE_DISPLAY.transform : + break; #endregion + case VALUE_DISPLAY.transform : #region editWidget = new transformBox(function(index, val) { var _val = animator.getValue(); _val[index] = val; @@ -801,25 +835,27 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru }); extract_node = "Node_Transform_Array"; - break; - case VALUE_DISPLAY.toggle : + break; #endregion + case VALUE_DISPLAY.toggle : #region editWidget = new toggleGroup(display_data, function(val) { return setValueDirect(val); } ); rejectConnect(); + key_inter = CURVE_TYPE.cut; extract_node = ""; - break; + break; #endregion } break; - case VALUE_TYPE.boolean : + case VALUE_TYPE.boolean : #region editWidget = new checkBox(function() { return setValueDirect(!animator.getValue()); } ); + key_inter = CURVE_TYPE.cut; extract_node = "Node_Boolean"; - break; - case VALUE_TYPE.color : + break; #endregion + case VALUE_TYPE.color : #region switch(display_type) { case VALUE_DISPLAY._default : editWidget = new buttonColor(function(color) { @@ -837,15 +873,15 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru extract_node = "Node_Palette"; break; } - break; - case VALUE_TYPE.gradient : + break; #endregion + case VALUE_TYPE.gradient : #region editWidget = new buttonGradient(function(gradient) { return setValueDirect(gradient); } ); extract_node = "Node_Gradient_Out"; - break; - case VALUE_TYPE.path : + break; #endregion + case VALUE_TYPE.path : #region switch(display_type) { case VALUE_DISPLAY.path_array : editWidget = new pathArrayBox(node, display_data, function(path) { setValueDirect(path); } ); @@ -885,14 +921,14 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru ); break; } - break; - case VALUE_TYPE.curve : + break; #endregion + case VALUE_TYPE.curve : #region display_type = VALUE_DISPLAY.curve; editWidget = new curveBox(function(_modified) { return setValueDirect(_modified); }); - break; - case VALUE_TYPE.text : + break; #endregion + case VALUE_TYPE.text : #region switch(display_type) { case VALUE_DISPLAY._default : editWidget = new textArea(TEXTBOX_INPUT.text, function(str) { @@ -918,29 +954,34 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru }); break; } - break; - case VALUE_TYPE.surface : + break; #endregion + case VALUE_TYPE.surface : #region editWidget = new surfaceBox(function(ind) { return setValueDirect(ind); }, display_data ); show_in_inspector = true; extract_node = "Node_Canvas"; - break; - case VALUE_TYPE.pathnode : + break; #endregion + case VALUE_TYPE.pathnode : #region extract_node = "Node_Path"; - break; + break; #endregion + } + + for( var i = 0, n = ds_list_size(animator.values); i < n; i++ ) { + animator.values[| i].ease_in_type = key_inter; + animator.values[| i].ease_out_type = key_inter; } setDropKey(); - } + } #endregion resetDisplay(); - static expressionUpdate = function() { + static expressionUpdate = function() { #region expTree = evaluateFunctionList(expression); node.triggerRender(); - } + } #endregion - static onValidate = function() { + static onValidate = function() { #region if(!validateValue) return; var _val = value_validation, str = ""; value_validation = VALIDATION.pass; @@ -990,9 +1031,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru #endregion return self; - } + } #endregion - static valueProcess = function(value, nodeFrom, applyUnit = true, arrIndex = 0) { + static valueProcess = function(value, nodeFrom, applyUnit = true, arrIndex = 0) { #region var typeFrom = nodeFrom.type; var display = nodeFrom.display_type; @@ -1080,18 +1121,15 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru return DEF_SURFACE; return value; - } + } #endregion - static resetCache = function() { - cache_value[0] = false; - } + static resetCache = function() { cache_value[0] = false; } - #region[#eb004b20] === GetValue === - static getValueCached = function(_time = PROJECT.animator.current_frame, applyUnit = true, arrIndex = 0) { + static getValueCached = function(_time = PROJECT.animator.current_frame, applyUnit = true, arrIndex = 0) { #region return getValue(_time, applyUnit, arrIndex, true); - } + } #endregion - static getValue = function(_time = PROJECT.animator.current_frame, applyUnit = true, arrIndex = 0, useCache = false) { + static getValue = function(_time = PROJECT.animator.current_frame, applyUnit = true, arrIndex = 0, useCache = false) { #region if(type == VALUE_TYPE.trigger) useCache = false; @@ -1121,9 +1159,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru cache_value[2] = val; return val; - } + } #endregion - static __getAnimValue = function(_time = PROJECT.animator.current_frame) { + static __getAnimValue = function(_time = PROJECT.animator.current_frame) { #region if(sep_axis) { var val = []; for( var i = 0, n = array_length(animators); i < n; i++ ) @@ -1131,9 +1169,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru return val; } else return animator.getValue(_time); - } + } #endregion - static _getValue = function(_time = PROJECT.animator.current_frame, applyUnit = true, arrIndex = 0) { + static _getValue = function(_time = PROJECT.animator.current_frame, applyUnit = true, arrIndex = 0) { #region var _val = getValueRecursive(_time); var val = _val[0]; var nod = _val[1]; @@ -1182,9 +1220,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru val = valueProcess(val, nod, applyUnit, arrIndex); return val; - } + } #endregion - static getValueRecursive = function(_time = PROJECT.animator.current_frame) { + static getValueRecursive = function(_time = PROJECT.animator.current_frame) { #region var val = [ -1, self ]; if(type == VALUE_TYPE.trigger && connect_type == JUNCTION_CONNECT.output) //trigger even will not propagate from input to output, need to be done manually @@ -1225,15 +1263,14 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } return val; - } - #endregion + } #endregion - static setAnim = function(anim) { + static setAnim = function(anim) { #region is_anim = anim; PANEL_ANIMATION.updatePropertyList(); - } + } #endregion - static __anim = function() { + static __anim = function() { #region if(node.update_on_frame) return true; if(expUse) { if(!is_struct(expTree)) return false; @@ -1246,14 +1283,14 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } return is_anim; - } + } #endregion - static isAnimated = function() { + static isAnimated = function() { #region if(value_from == noone) return __anim(); else return value_from.isAnimated() || value_from.__anim(); - } + } #endregion - static showValue = function() { + static showValue = function() { #region var useCache = true; if(display_type == VALUE_DISPLAY.area) useCache = false; @@ -1266,9 +1303,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(array_length(v) >= 100) return $"[{array_length(v)}]"; } return val; - } + } #endregion - static isArray = function(val = undefined) { + static isArray = function(val = undefined) { #region if(val == undefined) { if(cache_array[0]) return cache_array[1]; @@ -1299,9 +1336,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru cache_array[1] = is_array(ar); return cache_array[1]; - } + } #endregion - static arrayLength = function(val = undefined) { + static arrayLength = function(val = undefined) { #region if(val == undefined) val = getValue(); @@ -1316,18 +1353,17 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru ar = ar[0]; return array_length(ar); - } + } #endregion - #region[#8fde5d16] === SetValue === - static setValue = function(val = 0, record = true, time = PROJECT.animator.current_frame, _update = true) { + static setValue = function(val = 0, record = true, time = PROJECT.animator.current_frame, _update = true) { #region //if(type == VALUE_TYPE.d3vertex && !is_array(val)) // print(val); val = unit.invApply(val); return setValueDirect(val, noone, record, time, _update); - } + } #endregion - static setValueDirect = function(val = 0, index = noone, record = true, time = PROJECT.animator.current_frame, _update = true) { + static setValueDirect = function(val = 0, index = noone, record = true, time = PROJECT.animator.current_frame, _update = true) { #region var updated = false; if(sep_axis) { @@ -1365,10 +1401,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru onValidate(); return updated; - } - #endregion + } #endregion - static isConnectable = function(_valueFrom, checkRecur = true, log = false) { + static isConnectable = function(_valueFrom, checkRecur = true, log = false) { #region if(_valueFrom == -1 || _valueFrom == undefined || _valueFrom == noone) { if(log) noti_warning("LOAD: Cannot set node connection from " + string(_valueFrom) + " to " + string(name) + " of node " + string(node.name) + ".",, node); @@ -1423,9 +1458,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } return true; - } + } #endregion - static setFrom = function(_valueFrom, _update = true, checkRecur = true, log = false) { + static setFrom = function(_valueFrom, _update = true, checkRecur = true, log = false) { #region if(_valueFrom == noone) return removeFrom(); @@ -1462,9 +1497,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(!LOADING) PROJECT.modified = true; return true; - } + } #endregion - static removeFrom = function(_remove_list = true) { + static removeFrom = function(_remove_list = true) { #region recordAction(ACTION_TYPE.junction_disconnect, self, value_from); if(_remove_list && value_from != noone) ds_list_remove(value_from.value_to, self); @@ -1475,14 +1510,14 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru node.clearCacheForward(); return false; - } + } #endregion - static getShowString = function() { + static getShowString = function() { #region var val = showValue(); return string_real(val); - } + } #endregion - static setString = function(str) { + static setString = function(str) { #region var _o = animator.getValue(); if(string_pos(",", str) > 0) { @@ -1517,16 +1552,16 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru setValue(toNumber(str)); } } - } + } #endregion - static checkConnection = function(_remove_list = true) { + static checkConnection = function(_remove_list = true) { #region if(value_from == noone) return; if(value_from.node.active) return; removeFrom(_remove_list); - } + } #endregion - static searchNodeBackward = function(_node) { + static searchNodeBackward = function(_node) { #region if(node == _node) return true; for(var i = 0; i < ds_list_size(node.inputs); i++) { var _in = node.inputs[| i].value_from; @@ -1534,21 +1569,16 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru return true; } return false; - } + } #endregion - static unitConvert = function(mode) { + static unitConvert = function(mode) { #region var _v = animator.values; for( var i = 0; i < ds_list_size(_v); i++ ) _v[| i].value = unit.convertUnit(_v[| i].value, mode); - } + } #endregion - drag_type = 0; - drag_mx = 0; - drag_my = 0; - drag_sx = 0; - drag_sy = 0; - static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region if(type != VALUE_TYPE.integer && type != VALUE_TYPE.float) return -1; if(value_from != noone) return -1; if(expUse) return -1; @@ -1577,10 +1607,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } return -1; - } + } #endregion - junction_drawing = [ THEME.node_junctions_single, type ]; - static drawJunction = function(_s, _mx, _my, sca = 1) { + static drawJunction = function(_s, _mx, _my, sca = 1) { #region if(!isVisible()) return false; var ss = max(0.25, _s / 2); @@ -1608,9 +1637,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru draw_sprite_ext(junction_drawing[0], junction_drawing[1], x, y, ss, ss, 0, c_white, 1); return is_hover; - } + } #endregion - static drawNameBG = function(_s) { + static drawNameBG = function(_s) { #region if(!isVisible()) return false; draw_set_text(f_p1, fa_left, fa_center); @@ -1628,8 +1657,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru var tx = x + 12 * _s; draw_sprite_stretched_ext(THEME.node_junction_name_bg, 0, tx - 16, y - th / 2, tw, th, c_white, 0.5); } - } - static drawName = function(_s, _mx, _my) { + } #endregion + + static drawName = function(_s, _mx, _my) { #region if(!isVisible()) return false; var _hover = PANEL_GRAPH.pHOVER && point_in_circle(_mx, _my, x, y, 10 * _s); @@ -1649,9 +1679,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru draw_set_halign(fa_left); draw_text(tx, y, name); } - } + } #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(value_from == noone) return noone; if(!value_from.node.active) return noone; if(!isVisible()) return noone; @@ -1779,9 +1809,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } return hovering; - } + } #endregion - static drawConnectionMouse = function(_mx, _my, ss, target) { + static drawConnectionMouse = function(_mx, _my, ss, target) { #region var drawCorner = type == VALUE_TYPE.action; if(target != noone) drawCorner |= target.type == VALUE_TYPE.action; @@ -1836,9 +1866,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } break; } - } - - static isVisible = function() { + } #endregion + + static isVisible = function() { #region if(!node.active) return false; @@ -1853,9 +1883,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru return array_exists(node.input_display_list, index); } return visible; - } + } #endregion - static extractNode = function(_type = extract_node) { + static extractNode = function(_type = extract_node) { #region if(_type == "") return noone; var ext = nodeBuild(_type, node.x, node.y); @@ -1907,9 +1937,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru ext.doUpdate(); PANEL_ANIMATION.updatePropertyList(); - } + } #endregion - static getJunctionTo = function() { + static getJunctionTo = function() { #region var to = []; for(var j = 0; j < ds_list_size(value_to); j++) { @@ -1921,9 +1951,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } return to; - } + } #endregion - static dragValue = function() { + static dragValue = function() { #region if(drop_key == "None") return; DRAGGING = { @@ -1938,10 +1968,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(connect_type == JUNCTION_CONNECT.input) DRAGGING.from = self; - } + } #endregion - #region[#88ffe916] === Save Load === - static serialize = function(scale = false, preset = false) { + static serialize = function(scale = false, preset = false) { #region var _map = {}; _map.visible = visible; @@ -1971,12 +2000,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru _map.data = extra_data; return _map; - } + } #endregion - con_node = -1; - con_index = -1; - - static applyDeserialize = function(_map, scale = false, preset = false) { + static applyDeserialize = function(_map, scale = false, preset = false) { #region if(_map == undefined) return; if(_map == noone) return; if(!is_struct(_map)) return; @@ -2020,9 +2046,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(APPENDING) def_val = getValue(0); onValidate(); - } + } #endregion - static connect = function(log = false) { + static connect = function(log = false) { #region if(con_node == -1 || con_index == -1) return true; @@ -2056,19 +2082,18 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru log_warning("LOAD", $"[Connect] Connection conflict {node.name} to {_nd.name} : Output not exist.", node); return false; - } - #endregion + } #endregion - static destroy = function() { + static destroy = function() { #region if(error_notification != noone) { noti_remove(error_notification); error_notification = noone; } - } + } #endregion - static cleanUp = function() { + static cleanUp = function() { #region ds_list_destroy(value_to); animator.cleanUp(); delete animator; - } + } #endregion } \ No newline at end of file diff --git a/scripts/panel_animation/panel_animation.gml b/scripts/panel_animation/panel_animation.gml index fb5417ed4..4933d28f6 100644 --- a/scripts/panel_animation/panel_animation.gml +++ b/scripts/panel_animation/panel_animation.gml @@ -264,7 +264,7 @@ function Panel_Animation() : PanelContent() constructor { [ [THEME.timeline_ease, 0], function() { for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) { var k = keyframe_selecting[i]; - k.ease_in_type = CURVE_TYPE.none; + k.ease_in_type = CURVE_TYPE.linear; k.ease_in = [0, 1]; } }, __txtx("panel_animation_ease_linear", "Linear") ], @@ -301,7 +301,7 @@ function Panel_Animation() : PanelContent() constructor { [ [THEME.timeline_ease, 0], function() { for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) { var k = keyframe_selecting[i]; - k.ease_out_type = CURVE_TYPE.none; + k.ease_out_type = CURVE_TYPE.linear; k.ease_out = [0, 0]; } }, __txtx("panel_animation_ease_linear", "Linear") ], @@ -637,7 +637,7 @@ function Panel_Animation() : PanelContent() constructor { var key_next = animator.values[| k + 1]; var dx = key_next.time - key.time; - if(key.ease_out_type == CURVE_TYPE.none && key_next.ease_in_type == CURVE_TYPE.none) { //linear draw + if(key.ease_out_type == CURVE_TYPE.linear && key_next.ease_in_type == CURVE_TYPE.linear) { //linear draw nx = (key_next.time + 1) * ui(timeline_scale) + timeline_shift; if(valArray) { for( var ki = 0; ki < array_length(key.value); ki++ ) { @@ -1011,7 +1011,7 @@ function Panel_Animation() : PanelContent() constructor { tx = tool_width - ui(20 + 16 * 4.5); if(pHOVER && point_in_circle(msx, msy, tx, ty, ui(6))) { draw_sprite_ui_uniform(THEME.prop_on_end, animator.prop.on_end, tx, ty, 1, COLORS._main_icon_on_inner, 1); - TOOLTIP = __txtx("panel_animation_looping_mode", "Looping mode") + ": " + ON_END_NAME[animator.prop.on_end]; + TOOLTIP = __txtx("panel_animation_looping_mode", "Looping mode") + ": " + global.junctionEndName[animator.prop.on_end]; if(mouse_release(mb_left, pFOCUS)) animator.prop.on_end = safe_mod(animator.prop.on_end + 1, sprite_get_number(THEME.prop_on_end)); @@ -1099,7 +1099,7 @@ function Panel_Animation() : PanelContent() constructor { draw_sprite_ui_uniform(THEME.arrow, _node.anim_show? 3 : 0, ui(10), _node_y, 1, COLORS._main_icon, 0.75); draw_set_font(f_p3); - var nodeName = "[" + _node.name + "] "; + var nodeName = $"[{_node.name}] "; var tw = string_width(nodeName); draw_set_color(node_ordering == _node? COLORS._main_text_accent : COLORS._main_text); @@ -1199,7 +1199,8 @@ function Panel_Animation() : PanelContent() constructor { var s_bar_y = scr_y + scr_prog_s; if(is_scrolling) { - dope_sheet_y_to = clamp((my - scr_y - scr_scale_s / 2) / (scr_s - scr_scale_s), 0, 1) * -dope_sheet_y_max; + if(scr_s - scr_scale_s != 0) + dope_sheet_y_to = clamp((my - scr_y - scr_scale_s / 2) / (scr_s - scr_scale_s), 0, 1) * -dope_sheet_y_max; if(mouse_release(mb_left)) is_scrolling = false; } @@ -1399,7 +1400,7 @@ function Panel_Animation() : PanelContent() constructor { case KEYFRAME_DRAG_TYPE.ease_in : for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) { var k = keyframe_selecting[i]; - k.ease_in_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.none; + k.ease_in_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.linear; k.ease_in[0] = dx; if(!k.ease_y_lock) @@ -1410,7 +1411,7 @@ function Panel_Animation() : PanelContent() constructor { case KEYFRAME_DRAG_TYPE.ease_out : for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) { var k = keyframe_selecting[i]; - k.ease_out_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.none; + k.ease_out_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.linear; k.ease_out[0] = dx; if(!k.ease_y_lock) @@ -1420,8 +1421,8 @@ function Panel_Animation() : PanelContent() constructor { case KEYFRAME_DRAG_TYPE.ease_both : for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) { var k = keyframe_selecting[i]; - k.ease_in_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.none; - k.ease_out_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.none; + k.ease_in_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.linear; + k.ease_out_type = keyframe_dragout? CURVE_TYPE.bezier : CURVE_TYPE.linear; k.ease_in[0] = dx; if(!k.ease_y_lock) diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index d3eccec88..a0d5f69f5 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -17,7 +17,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { show_dimension : true, show_compute : true, - avoid_label : false, + avoid_label : true, preview_scale : 100, } #endregion diff --git a/scripts/panel_preview/panel_preview.gml b/scripts/panel_preview/panel_preview.gml index 103ffa95e..e5f571e5e 100644 --- a/scripts/panel_preview/panel_preview.gml +++ b/scripts/panel_preview/panel_preview.gml @@ -72,7 +72,7 @@ function Panel_Preview() : PanelContent() constructor { tileMode = 0; - bg_color = COLORS.panel_3d_bg; + bg_color = COLORS.panel_bg_clear; #endregion #region ---- tool ---- @@ -877,7 +877,7 @@ function Panel_Preview() : PanelContent() constructor { } preview_x_max = 0; - var _xx = (_node.tools != -1) * ui(40); + var _xx = tool_side_drawing * ui(40); var xx = _xx + preview_x + ui(8); var yy = h - toolbar_height - prev_size - ui(8); if(my > yy) mouse_on_preview = false; @@ -979,84 +979,88 @@ function Panel_Preview() : PanelContent() constructor { var _tool = tool_hovering; tool_hovering = noone; - if(_node.tools != -1) { - var aa = d3_active? 0.5 : 1; - draw_sprite_stretched_ext(THEME.tool_side, 1, 0, ui(32), tool_width, h - toolbar_height - ui(32), c_white, aa); + if(_node.tools == -1) { + tool_current = noone; + return; + } + + var aa = d3_active? 0.5 : 1; + draw_sprite_stretched_ext(THEME.tool_side, 1, 0, ui(32), tool_width, h - toolbar_height - ui(32), c_white, aa); - var xx = ui(1) + tool_width / 2; - var yy = ui(34) + tool_size / 2; - var pd = 2; + var xx = ui(1) + tool_width / 2; + var yy = ui(34) + tool_size / 2; + var pd = 2; - for(var i = 0; i < array_length(_node.tools); i++) { - var tool = _node.tools[i]; - var _x0 = xx - tool_size / 2; - var _y0 = yy - tool_size / 2; - var _x1 = xx + tool_size / 2; - var _y1 = yy + tool_size / 2; + for(var i = 0; i < array_length(_node.tools); i++) { #region iterate each tools + var tool = _node.tools[i]; + var _x0 = xx - tool_size / 2; + var _y0 = yy - tool_size / 2; + var _x1 = xx + tool_size / 2; + var _y1 = yy + tool_size / 2; - if(point_in_rectangle(_mx, _my, _x0, _y0 + 1, _x1, _y1 - 1)) { - tool_hovering = tool; - } + if(point_in_rectangle(_mx, _my, _x0, _y0 + 1, _x1, _y1 - 1)) { + tool_hovering = tool; + } - if(tool.subtools > 0 && _tool == tool) { - var s_ww = tool_size * tool.subtools; - var s_hh = tool_size; - draw_sprite_stretched(THEME.menu_bg, 0, _x0 - pd, _y0 - pd, s_ww + pd * 2, s_hh + pd * 2); + if(tool.subtools > 0 && _tool == tool) { #region subtools + var s_ww = tool_size * tool.subtools; + var s_hh = tool_size; + draw_sprite_stretched(THEME.menu_bg, 0, _x0 - pd, _y0 - pd, s_ww + pd * 2, s_hh + pd * 2); - var stool = tool.spr; + var stool = tool.spr; - for( var j = 0; j < array_length(stool); j++ ) { - var _sxx = xx + j * tool_size; - var _syy = yy; + for( var j = 0; j < array_length(stool); j++ ) { + var _sxx = xx + j * tool_size; + var _syy = yy; - var _sx0 = _sxx - tool_size / 2; - var _sy0 = _syy - tool_size / 2; - var _sx1 = _sxx + tool_size / 2; - var _sy1 = _syy + tool_size / 2; + var _sx0 = _sxx - tool_size / 2; + var _sy0 = _syy - tool_size / 2; + var _sx1 = _sxx + tool_size / 2; + var _sy1 = _syy + tool_size / 2; - if(point_in_rectangle(_mx, _my, _sx0, _sy0 + 1, _sx1, _sy1 - 1)) { - TOOLTIP = tool.getName(j); - draw_sprite_stretched(THEME.button_hide, 1, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2); + if(point_in_rectangle(_mx, _my, _sx0, _sy0 + 1, _sx1, _sy1 - 1)) { + TOOLTIP = tool.getName(j); + draw_sprite_stretched(THEME.button_hide, 1, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2); - if(mouse_press(mb_left, pFOCUS)) - tool.toggle(j); - } - - if(tool_current == tool && tool.selecting == j) { - draw_sprite_stretched_ext(THEME.button_hide, 2, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS.panel_preview_grid, 1); - draw_sprite_stretched_ext(THEME.button_hide, 3, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS._main_accent, 1); - } - - draw_sprite_colored(stool[j], 0, _sxx, _syy); - } - - if(point_in_rectangle(_mx, _my, _x0, _y0 + 1, _x0 + s_ww, _y1 - 1)) - tool_hovering = tool; - } else { - if(tool_hovering == tool) { - draw_sprite_stretched(THEME.button_hide, 1, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2); - TOOLTIP = tool.getName(); - if(mouse_press(mb_left, pFOCUS)) - tool.toggle(); + tool.toggle(j); + } + + if(tool_current == tool && tool.selecting == j) { + draw_sprite_stretched_ext(THEME.button_hide, 2, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS.panel_preview_grid, 1); + draw_sprite_stretched_ext(THEME.button_hide, 3, _sx0 + pd, _sy0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS._main_accent, 1); } - if(pFOCUS && WIDGET_CURRENT == noone && keyboard_check_pressed(ord(string(i + 1)))) + draw_sprite_colored(stool[j], 0, _sxx, _syy); + } + + if(point_in_rectangle(_mx, _my, _x0, _y0 + 1, _x0 + s_ww, _y1 - 1)) + tool_hovering = tool; + #endregion + } else { #region single tools + if(tool_hovering == tool) { + draw_sprite_stretched(THEME.button_hide, 1, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2); + TOOLTIP = tool.getName(); + + if(mouse_press(mb_left, pFOCUS)) tool.toggle(); + } + + if(pFOCUS && WIDGET_CURRENT == noone && keyboard_check_pressed(ord(string(i + 1)))) + tool.toggle(); - if(tool_current == tool) { - draw_sprite_stretched_ext(THEME.button_hide, 2, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS.panel_preview_grid, 1); - draw_sprite_stretched_ext(THEME.button_hide, 3, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS._main_accent, 1); - } - - if(tool.subtools > 0) draw_sprite_colored(tool.spr[tool.selecting], 0, xx, yy); - else draw_sprite_colored(tool.spr, 0, xx, yy); + if(tool_current == tool) { + draw_sprite_stretched_ext(THEME.button_hide, 2, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS.panel_preview_grid, 1); + draw_sprite_stretched_ext(THEME.button_hide, 3, _x0 + pd, _y0 + pd, tool_size - pd * 2, tool_size - pd * 2, COLORS._main_accent, 1); } - yy += tool_size; + if(tool.subtools > 0) draw_sprite_colored(tool.spr[tool.selecting], 0, xx, yy); + else draw_sprite_colored(tool.spr, 0, xx, yy); + #endregion } - } else - tool_current = noone; + + yy += tool_size; + } #endregion } #endregion function drawToolBar(_node) { #region @@ -1072,8 +1076,8 @@ function Panel_Preview() : PanelContent() constructor { if(!_node) return; - if(tool_current != noone) { //tool settings - var settings = _node.tool_settings; + if(tool_current != noone) { #region tool settings + var settings = _node.getToolSettings(); var len = array_length(settings); for( var i = 0, n = array_length(tool_current.settings); i < n; i++ ) settings[len + i] = tool_current.settings[i]; @@ -1098,20 +1102,16 @@ function Panel_Preview() : PanelContent() constructor { tol_max_w += string_width(nme) + ui(8); wdg.setFocusHover(pFOCUS, pHOVER); + switch(instanceof(wdg)) { - case "textBox" : - wdg.draw(tolx, toly, tolw, tolh, atr[$ key], [ mx, my ]); - break; - case "checkBoxGroup" : - tolw = tolh * wdg.size; - wdg.draw(tolx, toly, atr[$ key], [ mx, my ], tolh); - break; - case "checkBox" : - tolw = tolh; - wdg.draw(tolx, toly, atr[$ key], [ mx, my ], tolh); - break; + case "checkBoxGroup" : tolw = tolh * wdg.size; break; + case "checkBox" : tolw = tolh; break; + case "scrollBox" : tolw = ui(96); break; } + var params = new widgetParam(tolx, toly, tolw, tolh, atr[$ key],, [ mx, my ]) + wdg.drawParam(params); + tolx += tolw + ui(16); tol_max_w += tolw + ui(16); } @@ -1121,7 +1121,8 @@ function Panel_Preview() : PanelContent() constructor { if(mouse_wheel_up()) tool_x_to = clamp(tool_x_to + ui(64) * SCROLL_SPEED, -tol_max_w, 0); if(mouse_wheel_down()) tool_x_to = clamp(tool_x_to - ui(64) * SCROLL_SPEED, -tol_max_w, 0); } - } else { //color sampler + #endregion + } else { #region color sampler var cx = ui(10); var cy = ui(10); var cw = ui(32); @@ -1145,6 +1146,7 @@ function Panel_Preview() : PanelContent() constructor { draw_set_color(COLORS._main_text_sub); draw_text(tx, cy + ch / 2, "(" + string(color_get_alpha(sample_color)) + ")"); } + #endregion } var tbx = toolbar_height / 2; diff --git a/scripts/scrollBox/scrollBox.gml b/scripts/scrollBox/scrollBox.gml index b776dbec3..0cca4faba 100644 --- a/scripts/scrollBox/scrollBox.gml +++ b/scripts/scrollBox/scrollBox.gml @@ -5,6 +5,10 @@ function scrollBox(_data, _onModify, update_hover = true) : widget() constructor data = []; curr_text = 0; + font = f_p0; + arrow_spr = THEME.scroll_box_arrow; + arrow_ind = 0; + open = false; open_rx = 0; open_ry = 0; @@ -78,15 +82,17 @@ function scrollBox(_data, _onModify, update_hover = true) : widget() constructor if(mouse_press(mb_left)) deactivate(); } - draw_set_text(f_p0, align, fa_center, COLORS._main_text); + var _arw = sprite_get_width(arrow_spr) + ui(8); + + draw_set_text(font, align, fa_center, COLORS._main_text); draw_set_alpha(0.5 + 0.5 * interactable); if(align == fa_center) - draw_text(_x + w / 2, _y + _h / 2 - ui(2), _text); + draw_text(_x + (w - _arw) / 2, _y + _h / 2 - ui(2), _text); else if(align == fa_left) draw_text(_x + ui(8), _y + _h / 2 - ui(2), _text); draw_set_alpha(1); - draw_sprite_ui_uniform(THEME.scroll_box_arrow, 0, _x + w - 20, _y + _h / 2, 1, COLORS._main_icon, 0.5 + 0.5 * interactable); + draw_sprite_ui_uniform(arrow_spr, arrow_ind, _x + w - _arw / 2, _y + _h / 2, 1, COLORS._main_icon, 0.5 + 0.5 * interactable); if(WIDGET_CURRENT == self) draw_sprite_stretched_ext(THEME.widget_selecting, 0, _x - ui(3), _y - ui(3), _w + ui(6), _h + ui(6), COLORS._main_accent, 1);