From a386dfc77160241fd04439a056f6d41f2c19dadd Mon Sep 17 00:00:00 2001 From: Tanasart Date: Wed, 29 Jan 2025 08:22:38 +0700 Subject: [PATCH] [Plot Path] Add 3d parametric. --- datafiles/data/Nodes/Internal.zip | Bin 9100058 -> 9100058 bytes scripts/node_line/node_line.gml | 16 ++- scripts/node_path_plot/node_path_plot.gml | 156 ++++++++++++---------- 3 files changed, 100 insertions(+), 72 deletions(-) diff --git a/datafiles/data/Nodes/Internal.zip b/datafiles/data/Nodes/Internal.zip index 7a7f80570f5cb9136b29ad82dc49ed68ae07d2cc..ab61a8b0ee1d9de8c46c80a8b71c024b076c14dc 100644 GIT binary patch delta 1371 zcmZA0TWl0n7zc24TbHgbt$>OVMcb~>Ra!3k z?+i2H5+3j*y*%(lq9hVxTpl!LyDc%M`qak6wm!&!zz@c0+p!3YOKLpJcDOZjT)>&E$UE@287Uv^$24F zn$Y}}-W>6qXbP!cqk2GfMs&Ya-4VS)!r6$vQo>IWeU*g2BYL@nlkJ@Nc1Md>ZHwwY zX>~;PN(m>T&LYkS)Xz~pPue`BL_#>mc129jb*mK;x?*~%1pllNP;*mQpuUSad-L3Y z%KsfX>el~S+HpHa6|_66c=5oQfkB^YySJl;mkj#+ZCgEAi|1uNnLn7YqlLx-f-2snS!<%DYpjlTO1l zLYZK4Aq^(`r;R(=o>SbmXU149fiF6!y8kr1>c<(wC#_#*j4Jop8n+WvVZWJu&nwLA zBE#Vl)2l{jondL+PTAi3mR_AT*2-QCK~+6xEOd_ue%5Gu&G?)_=DGOXu^aNM_&jZC z>U7G=m+C^wYLxI>%Bqu4F=jPL*f(Z{BwU%`#P?%Xp;R}=to0Jg)6R2_YU)_pDv&n! zuaQtV&i383wbZR@CF~lv)=Bts*w)m=aqHiI9G<4BKgO*hc_vlOgj4a7n(CXdmdP`z zF1ZyiS1;}S%g(-;*<|l!Yv8=RtUJASi-g9wy(trtX56mNlGa}dUg27wT_x3`gtKx_ z!rmgC^9j3EM!4`sP`=pfL-qyt|BhG4>Rc@6U Xv72QPgQki`?b827l6yz(i=lr2IerBv delta 1371 zcmZA0TWl0n7zc25TbEr~S}t5R_kJ*@mxtNEiF&_)C5Q`9mh5|f; z#VAA(LMX-(EX6WBixQM#IaZ(yD^ZRLtU@JLV-42gIXsUlRAU`#P>VX$Ba8;DM+6(t zh^DXgrl@De>3a2BOb@DqQ9U44M^vwna6YQ9knnv}Un${UR4?`iwDp4_W4!IgB>-nu+JZ8+3Lxe_gMCm{eyY^GCAvNt8=KF z5RRKZ)8D4k3$&3o(PnC~dnLwGkG>&|!GULw5`{SsUPW=SJ z*!dzYVXtIcfN%_2Z;b={{TIc0wu=FmoSxh1p$X zI8tJI)zFkPEUn+uw)c^xKTjEJWiN)1s+uR3fMPmBYE%{Y^nXxo= zCT$f+bt!E%Ncbad)k>%sw(2Du8@9p{ej4S(x5HMERJVt%^%BZ6&U21x>Qu%mls5OT zmQXap_Wg{t*sW?L>>IJxN%(5O*3{(@>%V^-o~Eh4Myz6aCRO#QQ}L3T>K?V0$TO*~ zxD_u~C+&h8&c4~%RM!ow_oBS4yIpp(gocE@F&k25!mi7a);~#J;g@c^QmVO0XXSyU zy+t|~llFEQ;lf)X`C@Lo*SAB~rBy*b%qg=yo)fH)t<&+nU-n=&Y7m 0) for( var i = 0; i < lineLen; i++ ) { @@ -430,6 +433,9 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons _nx = p.x; _ny = p.y; + _wmin = min(_wmin, wght); + _wmax = max(_wmax, wght); + if(_total < _pathEnd) { //Do not wiggle the last point. var _d = point_direction(_ox, _oy, _nx, _ny); _nx += lengthdir_x(random1D(_sed + _sedIndex, -_wig, _wig), _d + 90); _sedIndex++; @@ -482,6 +488,8 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons array_resize(lines, _lineAmo); array_resize(line_data, _lineAmo); + if(_wmax == _wmin) { _wmin = 0; _wmax = 1; } + if(_pbbox) _surfDim = [ max(1, maxx - minx + _ppadd[0] + _ppadd[2]), max(1, maxy - miny + _ppadd[1] + _ppadd[3]) ]; break; @@ -618,11 +626,12 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons widthMap[? widProg] = eval_curve_x(_widc, widProg, 0.1); _nw *= widthMap[? widProg]; - if(_wg2wid) _nw *= p0.weight / 2; + var _ww = lerp_invert(p0.weight, _wmin, _wmax); + if(_wg2wid) _nw *= _ww / 2; _nc = _col_base; _nc = colorMultiply(_nc, _color.eval(_colP? prog : prgc)); - _nc = colorMultiply(_nc, _wg2clr.eval((p0.weight - _wg2clrR[0]) / _wg2clrRng)); + _nc = colorMultiply(_nc, _wg2clr.eval((_ww - _wg2clrR[0]) / _wg2clrRng)); if(_cap) { if(j == 1) { @@ -747,12 +756,13 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons var _dir = j? point_direction(_ox, _oy, _nx, _ny) : 0; var widProg = value_snap_real(_widap? prog : prgc, 0.01); + var _ww = lerp_invert(p0.weight, _wmin, _wmax); _nw = random_range(_wid[0], _wid[1]); if(!ds_map_exists(widthMap, widProg)) widthMap[? widProg] = eval_curve_x(_widc, widProg, 0.1); _nw *= widthMap[? widProg]; - _nw *= p0.weight; + _nw *= _ww; if(_cap) { if(j == 1) { diff --git a/scripts/node_path_plot/node_path_plot.gml b/scripts/node_path_plot/node_path_plot.gml index d5cad6a0f..46854e355 100644 --- a/scripts/node_path_plot/node_path_plot.gml +++ b/scripts/node_path_plot/node_path_plot.gml @@ -27,12 +27,17 @@ function Node_Path_Plot(_x, _y, _group = noone) : Node(_x, _y, _group) construct newInput(10, nodeValue_Text("w(x)", self, "")); + newInput(11, nodeValue_Text("z(x)", self, "")); + + newInput(12, nodeValue_Bool("3D", self, false)); + newOutput(0, nodeValue_Output("Path", self, VALUE_TYPE.pathnode, self)); input_display_list = [ - [ "Variable", false], 5, 7, 8, 0, - [ "Equation", false], 1, 2, 3, 4, 6, - [ "Weight", false, 9], 10, + [ "Variable", false], 5, 7, 8, 0, + [ "Equation", false], 1, 2, 3, 4, 6, + [ "Weight", false, 9], 10, + [ "3D", false, 12], 11, ] boundary = new BoundingBox( 0, 0, 1, 1 ); @@ -41,18 +46,18 @@ function Node_Path_Plot(_x, _y, _group = noone) : Node(_x, _y, _group) construct curr_sca = 0; curr_coor = 0; curr_eqa = 0; - curr_eq0 = 0; - curr_eq1 = 0; curr_orig = 0; curr_ran = 0; curr_iran = 0; curr_shf = 0; + curr_d3d = 0; curr_usew = 0; curr_wgfn = 0; fn0 = 0; fn1 = 0; + fn2 = 0; _a = new __vec2P(); _param = { x:0, y:0, t:0, r:0, O:0 }; @@ -68,7 +73,8 @@ function Node_Path_Plot(_x, _y, _group = noone) : Node(_x, _y, _group) construct static getBoundary = function() /*=>*/ {return boundary}; static getPointRatio = function(_rat, ind = 0, out = undefined) { - if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; } + if(out == undefined) out = curr_d3d? new __vec3P() : new __vec2P(); + else { out.x = 0; out.y = 0; out.z = 0; } _rat = curr_ran[0] + (_rat * (curr_ran[1] - curr_ran[0])); @@ -106,6 +112,11 @@ function Node_Path_Plot(_x, _y, _group = noone) : Node(_x, _y, _group) construct _param.t = _rat * curr_iran[1] + curr_shf[1]; out.y = fn1.eval(_param); + if(curr_d3d) { + _param.t = _rat; + out.z = fn2.eval(_param); + } + if(curr_usew) { _param.t = _rat; out.weight = fnw.eval(_param); @@ -149,6 +160,11 @@ function Node_Path_Plot(_x, _y, _group = noone) : Node(_x, _y, _group) construct _param.t = _rat * curr_iran[1] + curr_shf[1]; _ay = fn1.eval(_param); + if(curr_d3d) { + _param.t = _rat; + out.z = fn2.eval(_param); + } + if(curr_usew) { _param.t = _rat; out.weight = fnw.eval(_param); @@ -169,62 +185,6 @@ function Node_Path_Plot(_x, _y, _group = noone) : Node(_x, _y, _group) construct static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(ind), ind, out); } - static step = function() { - var _coor = getInputData(1); - var _eqa = getInputData(2); - - inputs[2].editWidget.data_list = _coor? eq_type_pol : eq_type_car; - inputs[4].setVisible(_eqa == 2); - - switch(_coor) { - case 0 : - switch(_eqa) { - case 0 : - inputs[ 3].name = "f(x) = "; - inputs[ 6].name = "x range"; - inputs[10].name = "w(x) = "; - break; - - case 1 : - inputs[ 3].name = "f(y) = "; - inputs[ 6].name = "y range"; - inputs[10].name = "w(y) = "; - break; - - case 2 : - inputs[ 3].name = "x(t) = "; - inputs[ 4].name = "y(t) = "; - inputs[ 6].name = "t range"; - inputs[10].name = "w(t) = "; - break; - } - break; - - case 1 : - switch(_eqa) { - case 0 : - inputs[ 3].name = "f(r) = "; - inputs[ 6].name = "r range"; - inputs[10].name = "w(r) = "; - break; - - case 1 : - inputs[ 3].name = "f(O) = "; - inputs[ 6].name = "O range"; - inputs[10].name = "w(O) = "; - break; - - case 2 : - inputs[ 3].name = "r(t) = "; - inputs[ 4].name = "O(t) = "; - inputs[ 6].name = "t range"; - inputs[10].name = "w(t) = "; - break; - } - break; - } - } - static updateBoundary = function() { boundary = new BoundingBox( 0, 0, 1, 1 ); length = 0; @@ -246,22 +206,80 @@ function Node_Path_Plot(_x, _y, _group = noone) : Node(_x, _y, _group) construct curr_sca = getInputData(0); curr_coor = getInputData(1); curr_eqa = getInputData(2); - curr_eq0 = getInputData(3); - curr_eq1 = getInputData(4); curr_orig = getInputData(5); curr_ran = getInputData(6); curr_iran = getInputData(7); curr_shf = getInputData(8); - - curr_usew = getInputData( 9); + curr_usew = getInputData(9); curr_wgfn = getInputData(10); + curr_d3d = getInputData(12); - fn0 = evaluateFunctionList(curr_eq0); - fn1 = evaluateFunctionList(curr_eq1); + var _eq0 = getInputData(3); + var _eq1 = getInputData(4); + var _eq2 = getInputData(11); + + fn0 = evaluateFunctionList(_eq0); + fn1 = evaluateFunctionList(_eq1); + fn2 = evaluateFunctionList(_eq2); fnw = evaluateFunctionList(curr_wgfn); + _a = curr_d3d? new __vec3P() : new __vec2P(); + updateBoundary(); - outputs[0].setValue(self); + outputs[0].setValue(self); + + #region display + inputs[ 2].editWidget.data_list = curr_coor? eq_type_pol : eq_type_car; + inputs[ 4].setVisible(curr_eqa == 2); + + switch(curr_coor) { + case 0 : + switch(curr_eqa) { + case 0 : + inputs[ 3].name = "f(x) = "; + inputs[ 6].name = "x range"; + inputs[10].name = "w(x) = "; + break; + + case 1 : + inputs[ 3].name = "f(y) = "; + inputs[ 6].name = "y range"; + inputs[10].name = "w(y) = "; + break; + + case 2 : + inputs[ 3].name = "x(t) = "; + inputs[ 4].name = "y(t) = "; + inputs[ 6].name = "t range"; + inputs[10].name = "w(t) = "; + break; + } + break; + + case 1 : + switch(_eqa) { + case 0 : + inputs[ 3].name = "f(r) = "; + inputs[ 6].name = "r range"; + inputs[10].name = "w(r) = "; + break; + + case 1 : + inputs[ 3].name = "f(O) = "; + inputs[ 6].name = "O range"; + inputs[10].name = "w(O) = "; + break; + + case 2 : + inputs[ 3].name = "r(t) = "; + inputs[ 4].name = "O(t) = "; + inputs[ 6].name = "t range"; + inputs[10].name = "w(t) = "; + break; + } + break; + } + #endregion } static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {