From 4ed768574a7aa01fcc73eb8ac46cddb256899a81 Mon Sep 17 00:00:00 2001 From: FedFod Date: Wed, 7 Apr 2021 18:01:23 +0200 Subject: [PATCH 01/36] Added: Mesh class, meshes initialization draft --- README.md | 4 +- meshwarp/Mesh.js | 56 ++++++++++++++++++++++++ meshwarp/Utilities.js | 48 +++++++++++++++++++++ meshwarp/meshwarp.js | 42 +++++++++++++++--- meshwarp/meshwarp.maxpat | 92 ++++++++++++++++++++++------------------ 5 files changed, 193 insertions(+), 49 deletions(-) create mode 100644 meshwarp/Mesh.js create mode 100644 meshwarp/Utilities.js diff --git a/README.md b/README.md index 8f9068d..78f400a 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# meshwarp \ No newline at end of file +# meshwarp + +Federico's Branch \ No newline at end of file diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js new file mode 100644 index 0000000..a0e5cd0 --- /dev/null +++ b/meshwarp/Mesh.js @@ -0,0 +1,56 @@ +function Mesh() +{ + this.mesh = new JitterObject("jit.gl.mesh"); + this.mesh.draw_mode = "points"; + this.mesh.color = WHITE; + this.mesh.point_size = 10; + + this.ID = 0; // ID of the mesh + + this.positionMat = new JitterMatrix(3, "float32", [10, 10]); + + this.initMesh = function(dim_x, dim_y, drawto, ID) + { + this.ID = ID; + this.mesh.drawto = drawto; + this.setMeshDim(dim_x, dim_y); + this.initPositionMat(); + postln(this.mesh.drawto) + postln(this.mesh.vertex_matrix.dim); + } + + this.setMeshDim = function(dim_x, dim_y) + { + if (dim_x && dim_y) { + this.positionMat.dim = [dim_x, dim_y]; + } + else { + this.positioMat.dim = [4,4]; + } + } + + this.initPositionMat = function() + { + postln("Initializing vertex matrix for mesh"); + postln(this.positionMat.dim) + + // Set values for position matrix + for(var i=0; i= max ? max : num; +} + +// - - - + +function map(value, low1, high1, low2, high2) { + return low2 + (high2 - low2) * (value - low1) / (high1 - low1); +} + +// - - - + +function random(min, max) { + if(typeof max != 'undefined') { + return Math.random() * (max - min) + min; + } else { + return Math.random() * min; + } +} + +// - - - + +if (!Math.sign) { + Math.sign = function(x) { + return ((x > 0) - (x < 0)) || +x; + } +} diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index 0f89358..8d3232a 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -1,14 +1,40 @@ autowatch = 1; +include("Mesh.js"); +include("Utilities.js"); + +// number of meshes +var meshesNumber = 2; +declareattribute("meshesNumber", null, null, 1); + +var windowRatio = 1; +declareattribute("windowRatio"); + +var meshes = []; + +var mousePosScreen = []; + +function initMeshes() +{ + for (var i=0; i 0 ? cur_drawto : vg.curctx)); } + postln(drawto) } implicit_callback.local = 1; \ No newline at end of file diff --git a/meshwarp/meshwarp.maxpat b/meshwarp/meshwarp.maxpat index 79ffabe..c0234a9 100644 --- a/meshwarp/meshwarp.maxpat +++ b/meshwarp/meshwarp.maxpat @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 390.0, 79.0, 961.0, 661.0 ], + "rect" : [ 817.0, 234.0, 586.0, 661.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -39,6 +39,30 @@ "subpatcher_template" : "", "assistshowspatchername" : 0, "boxes" : [ { + "box" : { + "id" : "obj-10", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "jit_gl_texture", "" ], + "patching_rect" : [ 117.404759526252747, 312.0, 177.0, 22.0 ], + "text" : "jit.gl.camera theWorld @ortho 2" + } + + } +, { + "box" : { + "id" : "obj-8", + "maxclass" : "message", + "numinlets" : 2, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 182.642860054969788, 84.0, 66.0, 22.0 ], + "text" : "initMeshes" + } + + } +, { "box" : { "id" : "obj-9", "maxclass" : "toggle", @@ -57,7 +81,7 @@ "numinlets" : 2, "numoutlets" : 2, "outlettype" : [ "", "" ], - "patching_rect" : [ 245.833330988883972, 232.738093018531799, 155.0, 22.0 ], + "patching_rect" : [ 337.642860054969788, 207.738093018531799, 155.0, 22.0 ], "text" : "substitute drawto setdrawto" } @@ -69,22 +93,10 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 249.404759526252747, 65.476189851760864, 61.0, 22.0 ], + "patching_rect" : [ 233.404759526252747, 125.595236897468567, 61.0, 22.0 ], "text" : "getdrawto" } - } -, { - "box" : { - "id" : "obj-4", - "maxclass" : "toggle", - "numinlets" : 1, - "numoutlets" : 1, - "outlettype" : [ "int" ], - "parameter_enable" : 0, - "patching_rect" : [ 87.642860054969788, 23.119050145149231, 24.0, 24.0 ] - } - } , { "box" : { @@ -93,8 +105,8 @@ "numinlets" : 1, "numoutlets" : 3, "outlettype" : [ "jit_matrix", "bang", "" ], - "patching_rect" : [ 108.642860054969788, 171.119050145149231, 205.0, 22.0 ], - "text" : "jit.world" + "patching_rect" : [ 108.642860054969788, 171.119050145149231, 248.0, 22.0 ], + "text" : "jit.world theWorld @floating 1 @size 160 120" } } @@ -102,7 +114,7 @@ "box" : { "id" : "obj-1", "maxclass" : "newobj", - "numinlets" : 3, + "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], "patcher" : { @@ -116,7 +128,7 @@ } , "classnamespace" : "box", - "rect" : [ 182.0, 178.0, 640.0, 480.0 ], + "rect" : [ 746.0, 555.0, 640.0, 483.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -144,14 +156,16 @@ "style" : "", "subpatcher_template" : "", "assistshowspatchername" : 0, + "visible" : 1, "boxes" : [ { "box" : { + "embedstate" : [ [ "meshesNumber", 1 ] ], "id" : "obj-8", "maxclass" : "newobj", "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 119.0, 202.0, 88.0, 22.0 ], + "patching_rect" : [ 107.0, 195.0, 88.0, 22.0 ], "saved_object_attributes" : { "filename" : "meshwarp.js", "parameter_enable" : 0 @@ -160,19 +174,6 @@ "text" : "js meshwarp.js" } - } -, { - "box" : { - "comment" : "", - "id" : "obj-7", - "index" : 2, - "maxclass" : "inlet", - "numinlets" : 0, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 201.0, 64.0, 30.0, 30.0 ] - } - } , { "box" : { @@ -189,7 +190,7 @@ "box" : { "comment" : "", "id" : "obj-5", - "index" : 3, + "index" : 2, "maxclass" : "inlet", "numinlets" : 0, "numoutlets" : 1, @@ -206,7 +207,7 @@ "maxclass" : "inlet", "numinlets" : 0, "numoutlets" : 1, - "outlettype" : [ "int" ], + "outlettype" : [ "" ], "patching_rect" : [ 107.0, 64.0, 30.0, 30.0 ] } @@ -241,6 +242,13 @@ "source" : [ "obj-4", 0 ] } + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-5", 0 ] + } + } , { "patchline" : { @@ -281,22 +289,22 @@ } , { "patchline" : { - "destination" : [ "obj-1", 0 ], - "source" : [ "obj-4", 0 ] + "destination" : [ "obj-2", 0 ], + "source" : [ "obj-6", 0 ] } } , { "patchline" : { - "destination" : [ "obj-2", 0 ], - "source" : [ "obj-6", 0 ] + "destination" : [ "obj-1", 0 ], + "source" : [ "obj-7", 0 ] } } , { "patchline" : { - "destination" : [ "obj-1", 0 ], - "source" : [ "obj-7", 0 ] + "destination" : [ "obj-1", 1 ], + "source" : [ "obj-8", 0 ] } } @@ -310,7 +318,7 @@ ], "dependency_cache" : [ { "name" : "meshwarp.js", - "bootpath" : "~/Desktop/meshwarp", + "bootpath" : "D:/MyData/Lavori/Cycling74/MaxMapper_with_Rob/meshwarp", "patcherrelativepath" : ".", "type" : "TEXT", "implicit" : 1 From 7c7ac7b54db263271e767495e40bc1a570f30507 Mon Sep 17 00:00:00 2001 From: FedFod Date: Wed, 7 Apr 2021 19:03:33 +0200 Subject: [PATCH 02/36] Added: node and videoplane --- meshwarp/Mesh.js | 11 ++++++---- meshwarp/Utilities.js | 1 + meshwarp/meshwarp.js | 47 +++++++++++++++++++++++++++++++++++----- meshwarp/meshwarp.maxpat | 26 ++++++---------------- 4 files changed, 56 insertions(+), 29 deletions(-) diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index a0e5cd0..e5b1e4f 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -15,8 +15,7 @@ function Mesh() this.mesh.drawto = drawto; this.setMeshDim(dim_x, dim_y); this.initPositionMat(); - postln(this.mesh.drawto) - postln(this.mesh.vertex_matrix.dim); + postln("mesh draws to: " + this.mesh.drawto) } this.setMeshDim = function(dim_x, dim_y) @@ -31,8 +30,7 @@ function Mesh() this.initPositionMat = function() { - postln("Initializing vertex matrix for mesh"); - postln(this.positionMat.dim) + postln("Initializing vertex matrix for mesh with ID " + this.ID); // Set values for position matrix for(var i=0; i Date: Wed, 7 Apr 2021 21:34:50 +0200 Subject: [PATCH 03/36] Fixed: window size with node --- meshwarp/Mesh.js | 55 ++++++++++++++++++++++++++++++---------- meshwarp/Utilities.js | 9 +++++++ meshwarp/meshwarp.js | 44 ++++++++++++++++++++++---------- meshwarp/meshwarp.maxpat | 47 +++++++++++++++++++++++++++++++--- 4 files changed, 125 insertions(+), 30 deletions(-) diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index e5b1e4f..9780952 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -1,21 +1,38 @@ -function Mesh() -{ - this.mesh = new JitterObject("jit.gl.mesh"); - this.mesh.draw_mode = "points"; - this.mesh.color = WHITE; - this.mesh.point_size = 10; - +function Mesh() { this.ID = 0; // ID of the mesh + this.meshPoints = new JitterObject("jit.gl.mesh"); + this.meshGrid = new JitterObject("jit.gl.mesh"); this.positionMat = new JitterMatrix(3, "float32", [10, 10]); - this.initMesh = function(dim_x, dim_y, drawto, ID) - { + this.initMesh = function(dim_x, dim_y, drawto, ID) { + this.meshPoints = new JitterObject("jit.gl.mesh"); + this.meshPoints.draw_mode = "points"; + this.meshPoints.depth_enable = 0; + this.meshPoints.layer = 10; + this.meshPoints.color = WHITE; + this.meshPoints.point_size = 10; + + this.meshGrid = new JitterObject("jit.gl.mesh"); + this.meshGrid.draw_mode = "tri_grid"; + this.meshGrid.depth_enable = 0; + this.meshGrid.layer = 9; + this.meshGrid.color = randomColor(); + + this.positionMat = new JitterMatrix(3, "float32", [10, 10]); + this.ID = ID; - this.mesh.drawto = drawto; + this.meshPoints.drawto = drawto; + this.meshGrid.drawto = drawto; this.setMeshDim(dim_x, dim_y); this.initPositionMat(); - postln("mesh draws to: " + this.mesh.drawto) + postln("mesh draws to: " + this.meshPoints.drawto) + } + + this.freeMesh = function() { + this.positionMat.freepeer(); + this.meshPoints.freepeer(); + this.meshGrid.freepeer(); } this.setMeshDim = function(dim_x, dim_y) @@ -47,13 +64,25 @@ function Mesh() } // assign vertex mat to mesh - this.mesh.vertex_matrix(this.positionMat.name); + this.meshPoints.vertex_matrix(this.positionMat.name); + this.meshGrid.vertex_matrix(this.positionMat.name); } //------------------------------------------- - this.checkIfDragged = function() + this.checkIfVertexDragged = function(mouseArray) { + for (var i=0; i Date: Thu, 8 Apr 2021 14:46:01 +0200 Subject: [PATCH 04/36] added: simple mouse-into-mesh check --- meshwarp/GraphicElements.js | 22 ++++++++++++++ meshwarp/Mesh.js | 52 +++++++++++++++++++++++++-------- meshwarp/Utilities.js | 13 +++++++++ meshwarp/meshwarp.js | 58 ++++++++++++++++++++++--------------- meshwarp/meshwarp.maxpat | 6 ++-- 5 files changed, 112 insertions(+), 39 deletions(-) create mode 100644 meshwarp/GraphicElements.js diff --git a/meshwarp/GraphicElements.js b/meshwarp/GraphicElements.js new file mode 100644 index 0000000..537f734 --- /dev/null +++ b/meshwarp/GraphicElements.js @@ -0,0 +1,22 @@ +function GraphicElements() { + this.sketch = new JitterObject("jit.gl.sketch"); + this.sketch.depth_enable = 0; + this.sketch.layer = FRONT; + this.sketch.color = RED; + + this.setDrawto = function(drawto) { + this.sketch.drawto = drawto; + postln(this.sketch.drawto) + } + + this.initGraphicElements = function() { + this.setDrawto(nodeCTX.name); + } + + this.drawCircle = function(coordsWorld) { + this.sketch.reset(); + this.sketch.moveto(coordsWorld); + this.sketch.framecircle(0.05); + postln("draw") + } +} \ No newline at end of file diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index 9780952..cc6f415 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -5,18 +5,21 @@ function Mesh() { this.meshGrid = new JitterObject("jit.gl.mesh"); this.positionMat = new JitterMatrix(3, "float32", [10, 10]); + this.maxPos = [-1000, -1000]; + this.minPos = [1000, 1000]; + this.initMesh = function(dim_x, dim_y, drawto, ID) { this.meshPoints = new JitterObject("jit.gl.mesh"); this.meshPoints.draw_mode = "points"; this.meshPoints.depth_enable = 0; - this.meshPoints.layer = 10; + this.meshPoints.layer = FRONT; this.meshPoints.color = WHITE; this.meshPoints.point_size = 10; this.meshGrid = new JitterObject("jit.gl.mesh"); this.meshGrid.draw_mode = "tri_grid"; this.meshGrid.depth_enable = 0; - this.meshGrid.layer = 9; + this.meshGrid.layer = BACKGROUND; this.meshGrid.color = randomColor(); this.positionMat = new JitterMatrix(3, "float32", [10, 10]); @@ -35,6 +38,16 @@ function Mesh() { this.meshGrid.freepeer(); } + this.getMaxMinPositionMat = function() + { + gJit3m.matrixcalc(this.positionMat, this.positionMat); + this.minPos = gJit3m.min.slice(0, 2); + this.maxPos = gJit3m.max.slice(0, 2); + + postln("min pos values (x, y): "+this.minPos); + postln("max pos values (x, y): "+this.maxPos); + } + this.setMeshDim = function(dim_x, dim_y) { if (dim_x && dim_y) { @@ -55,8 +68,8 @@ function Mesh() { for(var j=0; j= this.minPos[0] && mouseWorld[0] <= this.maxPos[0]) { - for (var j=0; j Date: Thu, 8 Apr 2021 15:57:49 +0200 Subject: [PATCH 05/36] added: possibility to move single vertices with mouse --- meshwarp/GraphicElements.js | 5 +++- meshwarp/Mesh.js | 54 +++++++++++++++++++++++-------------- meshwarp/Utilities.js | 1 + meshwarp/meshwarp.js | 36 ++++++++++++++++++++++--- meshwarp/meshwarp.maxpat | 5 ++-- 5 files changed, 75 insertions(+), 26 deletions(-) diff --git a/meshwarp/GraphicElements.js b/meshwarp/GraphicElements.js index 537f734..d6c8713 100644 --- a/meshwarp/GraphicElements.js +++ b/meshwarp/GraphicElements.js @@ -17,6 +17,9 @@ function GraphicElements() { this.sketch.reset(); this.sketch.moveto(coordsWorld); this.sketch.framecircle(0.05); - postln("draw") + } + + this.reset = function() { + this.sketch.reset(); } } \ No newline at end of file diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index cc6f415..db6ecb2 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -33,9 +33,11 @@ function Mesh() { } this.freeMesh = function() { - this.positionMat.freepeer(); - this.meshPoints.freepeer(); - this.meshGrid.freepeer(); + if (this.positionMat) { + this.positionMat.freepeer(); + this.meshPoints.freepeer(); + this.meshGrid.freepeer(); + } } this.getMaxMinPositionMat = function() @@ -77,40 +79,52 @@ function Mesh() { } // assign vertex mat to mesh - this.meshPoints.vertex_matrix(this.positionMat.name); - this.meshGrid.vertex_matrix(this.positionMat.name); + this.assignPositionMatToMesh(); this.getMaxMinPositionMat(); } + this.setVertexPos = function(coordsWorld, cellIndex) { + this.positionMat.setcell2d(cellIndex[0], cellIndex[1], coordsWorld[0], coordsWorld[1], 0.0); + } + + this.assignPositionMatToMesh = function() { + this.meshPoints.vertex_matrix(this.positionMat.name); + this.meshGrid.vertex_matrix(this.positionMat.name); + } + //------------------------------------------- + this.moveVertex = function(coordsWorld, cellIndex) { + this.setVertexPos(coordsWorld, cellIndex); + this.assignPositionMatToMesh(); + } + this.checkIfMouseInsideMesh = function(mouseWorld) { if (mouseWorld[0] >= this.minPos[0] && mouseWorld[0] <= this.maxPos[0]) { - return 1; + return this.ID; } else { - return 0; + return -1; } } - this.checkIfVertexDragged = function(mouseWorld) + this.checkIfVertexIsClicked = function(mouseWorld) { - if (this.checkIfMouseInsideMesh(mouseWorld)) + for (var i=0; i Date: Thu, 8 Apr 2021 17:16:41 +0200 Subject: [PATCH 06/36] fixed: fixed minor things in mouse callback --- meshwarp/Mesh.js | 11 ++++++----- meshwarp/meshwarp.js | 42 ++++++++++++++++++++++------------------ meshwarp/meshwarp.maxpat | 1 - 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index db6ecb2..7b87eac 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -17,10 +17,12 @@ function Mesh() { this.meshPoints.point_size = 10; this.meshGrid = new JitterObject("jit.gl.mesh"); - this.meshGrid.draw_mode = "tri_grid"; + this.meshGrid.draw_mode = "quad_grid"; this.meshGrid.depth_enable = 0; this.meshGrid.layer = BACKGROUND; this.meshGrid.color = randomColor(); + this.meshGrid.poly_mode = [1, 1]; + this.meshGrid.line_width = 3; this.positionMat = new JitterMatrix(3, "float32", [10, 10]); @@ -100,8 +102,7 @@ function Mesh() { this.assignPositionMatToMesh(); } - this.checkIfMouseInsideMesh = function(mouseWorld) - { + this.checkIfMouseInsideMesh = function(mouseWorld) { if (mouseWorld[0] >= this.minPos[0] && mouseWorld[0] <= this.maxPos[0]) { return this.ID; @@ -110,8 +111,7 @@ function Mesh() { } } - this.checkIfVertexIsClicked = function(mouseWorld) - { + this.checkIfVertexIsClicked = function(mouseWorld) { for (var i=0; i 0) { + for (var mesh in gMeshes) { + gMeshes[mesh].freeMesh(); + } } } freeMeshes.local = 1; @@ -121,33 +124,34 @@ function swapcallback(event){ init(); // RE INIT everything when window size is modified (temporary) } break; - case "mouse": // get mouse array + case "mouse": // get mouse array when mouse is clicked or released gMousePosScreen = (event.args); var mouseClicked = gMousePosScreen[2]; //postln(gMousePosScreen); var mouseWorld = transformMouseFromScreenToWorld2D(gMousePosScreen); + // Iterate through meshes to check in which one the mouse is in + for (var mesh in gMeshes) { + gSelectionStruct.meshID = gMeshes[mesh].checkIfMouseInsideMesh(mouseWorld); // Get the ID of the mesh in which the mouse is in + if (gSelectionStruct.meshID != -1) { break; } // if we are in a mesh, then break the loop, no need to check further + } + + if (gSelectionStruct.meshID != -1) { // if we are in a mesh + gSelectionStruct.cellIndex = gMeshes[gSelectionStruct.meshID].checkIfVertexIsClicked(mouseWorld); // check if one vertex in the mesh is clicked + } + if (mouseClicked) { - if (gSelectionStruct.meshID == -1) { - // Iterate through meshes to check in which one the mouse is - for (var i=0; i Date: Thu, 8 Apr 2021 19:10:37 +0200 Subject: [PATCH 07/36] added: highlight vertex when mouse is close enough --- meshwarp/GraphicElements.js | 1 + meshwarp/Mesh.js | 12 +++++------- meshwarp/meshwarp.js | 38 ++++++++++++++++++++++--------------- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/meshwarp/GraphicElements.js b/meshwarp/GraphicElements.js index d6c8713..dfde837 100644 --- a/meshwarp/GraphicElements.js +++ b/meshwarp/GraphicElements.js @@ -3,6 +3,7 @@ function GraphicElements() { this.sketch.depth_enable = 0; this.sketch.layer = FRONT; this.sketch.color = RED; + this.sketch.line_width = 2; this.setDrawto = function(drawto) { this.sketch.drawto = drawto; diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index 7b87eac..ffe47ae 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -80,10 +80,8 @@ function Mesh() { } } - // assign vertex mat to mesh - this.assignPositionMatToMesh(); - - this.getMaxMinPositionMat(); + this.assignPositionMatToMesh(); // assign vertex mat to mesh + this.getMaxMinPositionMat(); // calculate what are the max and min position values in matrix } this.setVertexPos = function(coordsWorld, cellIndex) { @@ -100,6 +98,7 @@ function Mesh() { this.moveVertex = function(coordsWorld, cellIndex) { this.setVertexPos(coordsWorld, cellIndex); this.assignPositionMatToMesh(); + gGraphics.drawCircle(coordsWorld); } this.checkIfMouseInsideMesh = function(mouseWorld) { @@ -111,7 +110,7 @@ function Mesh() { } } - this.checkIfVertexIsClicked = function(mouseWorld) { + this.mouseIsCloseToVertex = function(mouseWorld) { for (var i=0; i Date: Fri, 9 Apr 2021 18:20:12 +0200 Subject: [PATCH 08/36] Implemented: PNPOLY algorithm for vertex picking --- meshwarp/GraphicElements.js | 4 +- meshwarp/Mesh.js | 85 ++++++++++++++++++++++++++++++------- meshwarp/Utilities.js | 18 +++++--- meshwarp/meshwarp.js | 20 ++++++--- meshwarp/meshwarp.maxpat | 23 +++++++++- 5 files changed, 120 insertions(+), 30 deletions(-) diff --git a/meshwarp/GraphicElements.js b/meshwarp/GraphicElements.js index dfde837..5b535b8 100644 --- a/meshwarp/GraphicElements.js +++ b/meshwarp/GraphicElements.js @@ -5,6 +5,8 @@ function GraphicElements() { this.sketch.color = RED; this.sketch.line_width = 2; + this.circleRadius = 0.03; + this.setDrawto = function(drawto) { this.sketch.drawto = drawto; postln(this.sketch.drawto) @@ -17,7 +19,7 @@ function GraphicElements() { this.drawCircle = function(coordsWorld) { this.sketch.reset(); this.sketch.moveto(coordsWorld); - this.sketch.framecircle(0.05); + this.sketch.framecircle(this.circleRadius); } this.reset = function() { diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index ffe47ae..802a814 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -3,12 +3,14 @@ function Mesh() { this.meshPoints = new JitterObject("jit.gl.mesh"); this.meshGrid = new JitterObject("jit.gl.mesh"); + this.meshFull = new JitterObject("jit.gl.mesh"); this.positionMat = new JitterMatrix(3, "float32", [10, 10]); + this.boundingMat = new JitterMatrix(3, "float32", 10); this.maxPos = [-1000, -1000]; this.minPos = [1000, 1000]; - this.initMesh = function(dim_x, dim_y, drawto, ID) { + this.initMesh = function(dimensions, drawto, ID) { this.meshPoints = new JitterObject("jit.gl.mesh"); this.meshPoints.draw_mode = "points"; this.meshPoints.depth_enable = 0; @@ -19,17 +21,25 @@ function Mesh() { this.meshGrid = new JitterObject("jit.gl.mesh"); this.meshGrid.draw_mode = "quad_grid"; this.meshGrid.depth_enable = 0; - this.meshGrid.layer = BACKGROUND; + this.meshGrid.layer = MIDDLE; this.meshGrid.color = randomColor(); this.meshGrid.poly_mode = [1, 1]; this.meshGrid.line_width = 3; + this.meshFull = new JitterObject("jit.gl.mesh"); + this.meshFull.draw_mode = "quad_grid"; + this.meshFull.depth_enable = 0; + this.meshFull.layer = BACKGROUND; + this.meshFull.color = GREY; + this.positionMat = new JitterMatrix(3, "float32", [10, 10]); + this.boundingMat = new JitterMatrix(3, "float32", 10); this.ID = ID; this.meshPoints.drawto = drawto; this.meshGrid.drawto = drawto; - this.setMeshDim(dim_x, dim_y); + this.meshFull.drawto = drawto; + this.setMeshDim(dimensions); this.initPositionMat(); postln("mesh draws to: " + this.meshPoints.drawto) } @@ -39,6 +49,7 @@ function Mesh() { this.positionMat.freepeer(); this.meshPoints.freepeer(); this.meshGrid.freepeer(); + this.meshFull.freepeer(); } } @@ -48,14 +59,15 @@ function Mesh() { this.minPos = gJit3m.min.slice(0, 2); this.maxPos = gJit3m.max.slice(0, 2); - postln("min pos values (x, y): "+this.minPos); - postln("max pos values (x, y): "+this.maxPos); + // postln("min pos values (x, y): "+this.minPos); + // postln("max pos values (x, y): "+this.maxPos); } - this.setMeshDim = function(dim_x, dim_y) + this.setMeshDim = function(dimensions) { - if (dim_x && dim_y) { - this.positionMat.dim = [dim_x, dim_y]; + if (dimensions[0] > 0 && dimensions[1] > 0) { + this.positionMat.dim = dimensions.slice(); + this.boundingMat.dim = dimensions[0]*2 + (dimensions[1] * 2) - 4; } else { this.positioMat.dim = [4,4]; @@ -82,6 +94,7 @@ function Mesh() { this.assignPositionMatToMesh(); // assign vertex mat to mesh this.getMaxMinPositionMat(); // calculate what are the max and min position values in matrix + this.calcBoundingPolygonMat(); } this.setVertexPos = function(coordsWorld, cellIndex) { @@ -91,6 +104,7 @@ function Mesh() { this.assignPositionMatToMesh = function() { this.meshPoints.vertex_matrix(this.positionMat.name); this.meshGrid.vertex_matrix(this.positionMat.name); + this.meshFull.vertex_matrix(this.positionMat.name); } //------------------------------------------- @@ -101,13 +115,54 @@ function Mesh() { gGraphics.drawCircle(coordsWorld); } + this.calcBoundingPolygonMat = function() { + // Get the bounding vertices that are on the edges of the polygon in clockwise order + var boundingArray = []; + + // TOP + for (var i=0; i < this.positionMat.dim[0]; i++) { + boundingArray.push(this.positionMat.getcell(i, 0)); + } + // RIGHT + for (var j=1; j < this.positionMat.dim[1]; j++) { + boundingArray.push(this.positionMat.getcell(this.positionMat.dim[0]-1, j)); + } + // BOTTOM + for (var k=this.positionMat.dim[0]-2; k >= 0; k--) { + boundingArray.push(this.positionMat.getcell(k, this.positionMat.dim[1]-1)); + } + // LEFT + for (var z=this.positionMat.dim[1]-2; z > 0; z--) { + boundingArray.push(this.positionMat.getcell(0, z)); + } + // Transfer those vertices from the array to the boundingMat matrix + for (var i=0; i= this.minPos[0] && mouseWorld[0] <= this.maxPos[0]) - { - return this.ID; - } else { - return -1; + // if (mouseWorld[0] >= this.minPos[0] && mouseWorld[0] <= this.maxPos[0]) + // { + // return this.ID; + // } else { + // return -1; + // } + var testx = mouseWorld[0]; var testy = mouseWorld[1]; + var nvert = this.boundingMat.dim; + var i, j, c = 0; + for (i=0, j = nvert-1; i < nvert; j = i++) { + var verty_i = this.boundingMat.getcell(i)[1]; + var verty_j = this.boundingMat.getcell(j)[1]; + var vertx_i = this.boundingMat.getcell(i)[0]; + var vertx_j = this.boundingMat.getcell(j)[0]; + if ( ((verty_i>testy) != (verty_j>testy)) && + ((testx < ( ((vertx_j-vertx_i) * (testy-verty_i)) / (verty_j-verty_i) + vertx_i)) ) ) { + c = !c; + } } + return c ? this.ID : -1; } this.mouseIsCloseToVertex = function(mouseWorld) { @@ -120,10 +175,10 @@ function Mesh() { if (distFromMouse <= 0.1) { gGraphics.drawCircle(currVertexPos); - return [i, j].splice(0); + return [i, j].slice(); } } } - return [-1, -1].splice(0); + return [-1, -1].slice(); } } \ No newline at end of file diff --git a/meshwarp/Utilities.js b/meshwarp/Utilities.js index 8a2f8cf..572f260 100644 --- a/meshwarp/Utilities.js +++ b/meshwarp/Utilities.js @@ -1,10 +1,16 @@ var WHITE = [1,1,1,1]; var BLACK = [0,0,0,1]; var RED = [1,0,0,1]; +var GREY = [0.5, 0.5, 0.5, 1.0]; var BACKGROUND = 9; var MIDDLE = 10; -var FRONT = 11; +var MIDDLE_1 = 11; +var FRONT = 12; + +function switchDrawModeMeshes(mode) { + +} function transformMouseFromScreenToWorld2D(mouseScreen) { var mouseXWorld = (((mouseScreen[0] / gWindowDim[0]) * 2.0) - 1.0) * gWindowRatio; @@ -19,13 +25,13 @@ transformMouseFromScreenToWorld2D.local = 1; function calcDist2D(vec1, vec2) { return Math.sqrt((vec1[0]-vec2[0])*(vec1[0]-vec2[0]) + (vec1[1]-vec2[1])*(vec1[1]-vec2[1])); } +calcDist2D.local = 1; // - - - Math.radians = function(degrees) { return degrees * Math.PI / 180; }; - // - - - function print() @@ -35,6 +41,7 @@ function print() } post(); } +print.local = 1; // - - - @@ -42,13 +49,13 @@ function clamp(num, min, max) { return num <= min ? min : num >= max ? max : num; } - +clamp.local = 1; // - - - function map(value, low1, high1, low2, high2) { return low2 + (high2 - low2) * (value - low1) / (high1 - low1); } - +map.local = 1; // - - - function random(min, max) { @@ -58,11 +65,12 @@ function random(min, max) { return Math.random() * min; } } +random.local = 1; function randomColor() { return [random(0, 1), random(0, 1), random(0, 1), 1]; } - +randomColor.local = 1; // - - - if (!Math.sign) { diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index ca32c73..d6746b5 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -8,6 +8,13 @@ include("GraphicElements.js"); var gMeshesNumber = 4; declareattribute("gMeshesNumber", null, null, 1); +var c=0; +postln((!c ? 1 : 0)) + +// Size of Meshes +var gMeshSize = [4, 8]; +declareattribute("gMeshSize", null, null, 1); + var gWindowDim = [0,0]; var gWindowRatio = 1; function setWindowRatio(ratio) { @@ -65,10 +72,10 @@ function freeMeshes() { freeMeshes.local = 1; function initMeshes() { + for (var i=0; i Date: Fri, 9 Apr 2021 20:33:33 +0200 Subject: [PATCH 09/36] Implemented: checking closest vertex when meshes overlap --- meshwarp/meshwarp.js | 40 +++++++++++++++++++++++++--------------- meshwarp/meshwarp.maxpat | 16 ++++++++++++++-- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index d6746b5..c794bcc 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -29,10 +29,12 @@ var gGraphics = new GraphicElements(); // a structure to contain infos relative to the clicked mesh and vertex var gSelectionStruct = { cellIndex: [-1, -1], - meshID: -1, + meshIDsToCheck: new Array(), + meshIDClicked: -1, reset: function() { this.cellIndex = [-1, -1]; - this.meshID = -1; + this.meshIDsToCheck = []; + this.meshIdClicked = -1; } }; @@ -41,7 +43,6 @@ var gMeshes = []; var gMousePosScreen = []; - // JIT_GL_NODE var nodeCTX = new JitterObject("jit.gl.node"); nodeCTX.name = "##mesherNodeCTX##"; @@ -136,37 +137,46 @@ function swapcallback(event){ var mouseWorld = transformMouseFromScreenToWorld2D(gMousePosScreen); if (mouseClicked) { - if (gSelectionStruct.cellIndex[0] != -1 && gSelectionStruct.meshID != -1) { // we are clicking on a vertex - gMeshes[gSelectionStruct.meshID].moveVertex(mouseWorld, gSelectionStruct.cellIndex.slice(0,2)); // move the vertex with the mouse + if (gSelectionStruct.cellIndex[0] != -1 && gSelectionStruct.meshIDClicked != -1) { // we are clicking on a vertex + gMeshes[gSelectionStruct.meshIDClicked].moveVertex(mouseWorld, gSelectionStruct.cellIndex.slice(0,2)); // move the vertex with the mouse } } else { // mouse is released - if (gSelectionStruct.meshID != -1) { - gMeshes[gSelectionStruct.meshID].getMaxMinPositionMat(); // recalculate the new max and min position values - gMeshes[gSelectionStruct.meshID].calcBoundingPolygonMat() // recalculate the bounding matrix + if (gSelectionStruct.meshIDClicked != -1) { + gMeshes[gSelectionStruct.meshIDClicked].getMaxMinPositionMat(); // recalculate the new max and min position values + gMeshes[gSelectionStruct.meshIDClicked].calcBoundingPolygonMat() // recalculate the bounding matrix gSelectionStruct.reset(); // reset the values in the selectionStruct } gGraphics.reset(); // delete the circle } - break; + case "mouseidle": // Check if mouse is close to vertices to highlight them gMousePosScreen = (event.args); var mouseWorld = transformMouseFromScreenToWorld2D(gMousePosScreen); + gSelectionStruct.reset(); // reset all the struct values + // Iterate through meshes to check in which one the mouse is in for (var mesh in gMeshes) { - gSelectionStruct.meshID = gMeshes[mesh].checkIfMouseInsideMesh(mouseWorld); // Get the ID of the mesh in which the mouse is in - if (gSelectionStruct.meshID != -1) { break; } // if we are in a mesh, then break the loop, no need to check further + var meshID = gMeshes[mesh].checkIfMouseInsideMesh(mouseWorld); // Get the ID of the mesh in which the mouse is in (if it's inside any) + if (meshID != -1) { + gSelectionStruct.meshIDsToCheck.push(meshID); // push in this array all the IDs of the meshes the mouse is in (it could be more than one when meshes overlap) + } } - if (gSelectionStruct.meshID != -1) { // if we are in a mesh - gSelectionStruct.cellIndex = gMeshes[gSelectionStruct.meshID].mouseIsCloseToVertex(mouseWorld); // check if one vertex in the mesh is clicked - if (gSelectionStruct.cellIndex[0] == -1) { // delete circle if mouse is far from vertex + // if we are on a mesh, let's check if the mouse is close to a vertex + for (var i=0; i Date: Fri, 9 Apr 2021 20:35:23 +0200 Subject: [PATCH 10/36] Implemented: checking closest vertex when meshes overlap --- meshwarp/meshwarp.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index c794bcc..ad16418 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -30,11 +30,11 @@ var gGraphics = new GraphicElements(); var gSelectionStruct = { cellIndex: [-1, -1], meshIDsToCheck: new Array(), - meshIDClicked: -1, + meshIDToClick: -1, reset: function() { this.cellIndex = [-1, -1]; - this.meshIDsToCheck = []; - this.meshIdClicked = -1; + this.meshIDsToCheck = []; // we need to check multiple meshes in case they overlap + this.meshIDToClick = -1; // the mesh we are going to operate on } }; @@ -137,13 +137,13 @@ function swapcallback(event){ var mouseWorld = transformMouseFromScreenToWorld2D(gMousePosScreen); if (mouseClicked) { - if (gSelectionStruct.cellIndex[0] != -1 && gSelectionStruct.meshIDClicked != -1) { // we are clicking on a vertex - gMeshes[gSelectionStruct.meshIDClicked].moveVertex(mouseWorld, gSelectionStruct.cellIndex.slice(0,2)); // move the vertex with the mouse + if (gSelectionStruct.cellIndex[0] != -1 && gSelectionStruct.meshIDToClick != -1) { // we are clicking on a vertex + gMeshes[gSelectionStruct.meshIDToClick].moveVertex(mouseWorld, gSelectionStruct.cellIndex.slice(0,2)); // move the vertex with the mouse } } else { // mouse is released - if (gSelectionStruct.meshIDClicked != -1) { - gMeshes[gSelectionStruct.meshIDClicked].getMaxMinPositionMat(); // recalculate the new max and min position values - gMeshes[gSelectionStruct.meshIDClicked].calcBoundingPolygonMat() // recalculate the bounding matrix + if (gSelectionStruct.meshIDToClick != -1) { + gMeshes[gSelectionStruct.meshIDToClick].getMaxMinPositionMat(); // recalculate the new max and min position values + gMeshes[gSelectionStruct.meshIDToClick].calcBoundingPolygonMat() // recalculate the bounding matrix gSelectionStruct.reset(); // reset the values in the selectionStruct } gGraphics.reset(); // delete the circle @@ -171,7 +171,7 @@ function swapcallback(event){ if (gSelectionStruct.cellIndex[0] == -1) { // if mouse is not close to vertex than delete highlight circle gGraphics.reset(); } else { - gSelectionStruct.meshIDClicked = gSelectionStruct.meshIDsToCheck[i]; // This is the mesh we are working with + gSelectionStruct.meshIDToClick = gSelectionStruct.meshIDsToCheck[i]; // This is the mesh we are working with break; // We just need to check a single mesh } } From 5a654a4f150c357016bb8153c9590ccc429bcb50 Mon Sep 17 00:00:00 2001 From: FedFod Date: Fri, 9 Apr 2021 21:07:08 +0200 Subject: [PATCH 11/36] added pad for boundaries to include mouse when coming from outside of the mesh --- meshwarp/Mesh.js | 17 +++++++++++++---- meshwarp/Utilities.js | 7 +++++++ meshwarp/meshwarp.js | 9 --------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index 802a814..01a67d0 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -118,22 +118,31 @@ function Mesh() { this.calcBoundingPolygonMat = function() { // Get the bounding vertices that are on the edges of the polygon in clockwise order var boundingArray = []; + var pad = 0.05; // pad so that the mesh is checked also when mouse is outside of it // TOP for (var i=0; i < this.positionMat.dim[0]; i++) { - boundingArray.push(this.positionMat.getcell(i, 0)); + var xVal = this.positionMat.getcell(i, 0)[0]; + var yVal = this.positionMat.getcell(i, 0)[1] - pad; + boundingArray.push([xVal, yVal]); } // RIGHT for (var j=1; j < this.positionMat.dim[1]; j++) { - boundingArray.push(this.positionMat.getcell(this.positionMat.dim[0]-1, j)); + var xVal = this.positionMat.getcell(this.positionMat.dim[0]-1, j)[0] + pad; + var yVal = this.positionMat.getcell(this.positionMat.dim[0]-1, j)[1]; + boundingArray.push([xVal, yVal]); } // BOTTOM for (var k=this.positionMat.dim[0]-2; k >= 0; k--) { - boundingArray.push(this.positionMat.getcell(k, this.positionMat.dim[1]-1)); + var xVal = this.positionMat.getcell(k, this.positionMat.dim[1]-1)[0]; + var yVal = this.positionMat.getcell(k, this.positionMat.dim[1]-1)[1] + pad; + boundingArray.push([xVal, yVal]); } // LEFT for (var z=this.positionMat.dim[1]-2; z > 0; z--) { - boundingArray.push(this.positionMat.getcell(0, z)); + var xVal = this.positionMat.getcell(0, z)[0] - pad; + var yVal = this.positionMat.getcell(0, z)[1]; + boundingArray.push([xVal, yVal]); } // Transfer those vertices from the array to the boundingMat matrix for (var i=0; i Date: Fri, 9 Apr 2021 21:11:56 +0200 Subject: [PATCH 12/36] added global variable gMinimumSelectionDist --- meshwarp/Mesh.js | 2 +- meshwarp/meshwarp.js | 2 +- meshwarp/meshwarp.maxpat | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index 01a67d0..f78ac38 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -182,7 +182,7 @@ function Mesh() { var currVertexPos = this.positionMat.getcell(i,j); var distFromMouse = calcDist2D(currVertexPos.slice(0,2), mouseWorld.slice(0,2)); - if (distFromMouse <= 0.1) { + if (distFromMouse <= gMinimumSelectionDist) { gGraphics.drawCircle(currVertexPos); return [i, j].slice(); } diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index f9950e6..cafa023 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -38,7 +38,7 @@ var gSelectionStruct = { // GLOBAL VARIABLES var gMeshes = []; var gMousePosScreen = []; - +var gMinimumSelectionDist = 0.06; // JIT_GL_NODE var nodeCTX = new JitterObject("jit.gl.node"); diff --git a/meshwarp/meshwarp.maxpat b/meshwarp/meshwarp.maxpat index fd4a592..20c53fe 100644 --- a/meshwarp/meshwarp.maxpat +++ b/meshwarp/meshwarp.maxpat @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 1034.0, 188.0, 525.0, 651.0 ], + "rect" : [ 1233.0, 207.0, 525.0, 651.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -184,7 +184,7 @@ "assistshowspatchername" : 0, "boxes" : [ { "box" : { - "embedstate" : [ [ "gMeshSize", 4, 8 ], [ "gMeshesNumber", 4 ] ], + "embedstate" : [ [ "gMeshesNumber", 4 ], [ "gMeshSize", 4, 8 ] ], "id" : "obj-8", "maxclass" : "newobj", "numinlets" : 1, From d9756e0928b9fff4455eb586a273bc5f4fe78997 Mon Sep 17 00:00:00 2001 From: FedFod Date: Mon, 12 Apr 2021 16:46:14 +0200 Subject: [PATCH 13/36] added constraints to vertices movement --- meshwarp/GraphicElements.js | 1 - meshwarp/Mesh.js | 105 ++++++++++++++++++++++++++++++------ meshwarp/Utilities.js | 25 +++++++++ meshwarp/meshwarp.js | 41 ++++++++------ meshwarp/meshwarp.maxpat | 21 +++++++- 5 files changed, 159 insertions(+), 34 deletions(-) diff --git a/meshwarp/GraphicElements.js b/meshwarp/GraphicElements.js index 5b535b8..b6989d6 100644 --- a/meshwarp/GraphicElements.js +++ b/meshwarp/GraphicElements.js @@ -9,7 +9,6 @@ function GraphicElements() { this.setDrawto = function(drawto) { this.sketch.drawto = drawto; - postln(this.sketch.drawto) } this.initGraphicElements = function() { diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index f78ac38..48cde01 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -6,6 +6,7 @@ function Mesh() { this.meshFull = new JitterObject("jit.gl.mesh"); this.positionMat = new JitterMatrix(3, "float32", [10, 10]); this.boundingMat = new JitterMatrix(3, "float32", 10); + this.adjacentCellsMat = new JitterMatrix(3, "float32", 8); this.maxPos = [-1000, -1000]; this.minPos = [1000, 1000]; @@ -34,12 +35,13 @@ function Mesh() { this.positionMat = new JitterMatrix(3, "float32", [10, 10]); this.boundingMat = new JitterMatrix(3, "float32", 10); + this.adjacentCellsMat = new JitterMatrix(3, "float32", 8); this.ID = ID; this.meshPoints.drawto = drawto; this.meshGrid.drawto = drawto; this.meshFull.drawto = drawto; - this.setMeshDim(dimensions); + this.setMeshDim(dimensions); // calculate and set matrices dimensions this.initPositionMat(); postln("mesh draws to: " + this.meshPoints.drawto) } @@ -47,6 +49,8 @@ function Mesh() { this.freeMesh = function() { if (this.positionMat) { this.positionMat.freepeer(); + this.boundingMat.freepeer(); + this.adjacentCellsMat.freepeer(); this.meshPoints.freepeer(); this.meshGrid.freepeer(); this.meshFull.freepeer(); @@ -109,10 +113,85 @@ function Mesh() { //------------------------------------------- + this.calcAdjacentCellsMat = function(cellIndex) { + var cell = []; + var leftX = clamp(cellIndex[0]-1, 0, this.positionMat.dim[0]-1); + var centerX = cellIndex[0]; + var rightX = clamp(cellIndex[0]+1, 0, this.positionMat.dim[0]-1); + var topY = clamp(cellIndex[1]+1, 0, this.positionMat.dim[1]-1); + var centerY = cellIndex[1]; + var bottomY = clamp(cellIndex[1]-1, 0, this.positionMat.dim[1]-1); + + cell = this.positionMat.getcell(leftX, topY).slice(); + if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { + cell[1] = 1; + } + if (cellIndex[0]-1 < 0) { + cell[0] = -gWindowRatio; + } + this.adjacentCellsMat.setcell1d(0, cell[0], cell[1], 0.0); // TOP LEFT + + cell = this.positionMat.getcell(centerX, topY).slice(); + if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { + cell[1] = 1; + } + if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { + cell[1] = 1; + } + this.adjacentCellsMat.setcell1d(1, cell[0], cell[1], 0.0); // TOP CENTER + + cell = this.positionMat.getcell(rightX, topY).slice(); + if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { + cell[1] = 1; + } + if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { + cell[0] = gWindowRatio; + } + this.adjacentCellsMat.setcell1d(2, cell[0], cell[1], 0.0); // TOP RIGHT + + cell = this.positionMat.getcell(rightX, centerY).slice(); + if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { + cell[0] = gWindowRatio; + } + this.adjacentCellsMat.setcell1d(3, cell[0], cell[1], 0.0); // RIGHT CENTER + + cell = this.positionMat.getcell(rightX, bottomY).slice(); + if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { + cell[0] = gWindowRatio; + } + if (cellIndex[1]-1 < 0) { + cell[1] = -1; + } + this.adjacentCellsMat.setcell1d(4, cell[0], cell[1], 0.0); // BOTTOM RIGHT + + cell = this.positionMat.getcell(centerX, bottomY).slice(); + if (cellIndex[1]-1 < 0) { + cell[1] = -1; + } + this.adjacentCellsMat.setcell1d(5, cell[0], cell[1], 0.0); // BOTTOM CENTER + + cell = this.positionMat.getcell(leftX, bottomY).slice(); + if (cellIndex[0]-1 < 0) { + cell[0] = -gWindowRatio; + } + if (cellIndex[1]-1 < 0) { + cell[1] = -1; + } + this.adjacentCellsMat.setcell1d(6, cell[0], cell[1], 0.0); // BOTTOM LEFT + + cell = this.positionMat.getcell(leftX, centerY).slice(); + if (cellIndex[0]-1 < 0) { + cell[0] = -gWindowRatio; + } + this.adjacentCellsMat.setcell1d(7, cell[0], cell[1], 0.0); // LEFT CENTER + } + this.moveVertex = function(coordsWorld, cellIndex) { - this.setVertexPos(coordsWorld, cellIndex); - this.assignPositionMatToMesh(); - gGraphics.drawCircle(coordsWorld); + if (isPointInsidePolygon(coordsWorld, this.adjacentCellsMat)) { + this.setVertexPos(coordsWorld, cellIndex); + this.assignPositionMatToMesh(); + gGraphics.drawCircle(coordsWorld); + } } this.calcBoundingPolygonMat = function() { @@ -158,22 +237,14 @@ function Mesh() { // } else { // return -1; // } - var testx = mouseWorld[0]; var testy = mouseWorld[1]; - var nvert = this.boundingMat.dim; - var i, j, c = 0; - for (i=0, j = nvert-1; i < nvert; j = i++) { - var verty_i = this.boundingMat.getcell(i)[1]; - var verty_j = this.boundingMat.getcell(j)[1]; - var vertx_i = this.boundingMat.getcell(i)[0]; - var vertx_j = this.boundingMat.getcell(j)[0]; - if ( ((verty_i>testy) != (verty_j>testy)) && - ((testx < ( ((vertx_j-vertx_i) * (testy-verty_i)) / (verty_j-verty_i) + vertx_i)) ) ) { - c = !c; - } + if (isPointInsidePolygon(mouseWorld, this.boundingMat)) { + return this.ID; + } else { + return -1; } - return c ? this.ID : -1; } + this.mouseIsCloseToVertex = function(mouseWorld) { for (var i=0; itesty) != (verty_j>testy)) && + ((testx < ( ((vertx_j-vertx_i) * (testy-verty_i)) / (verty_j-verty_i) + vertx_i)) ) ) { + c = !c; + } + } + } + return c ? 1 : 0; +} +isPointInsidePolygon.local = 1; +// - - - function transformMouseFromScreenToWorld2D(mouseScreen) { var mouseXWorld = (((mouseScreen[0] / gWindowDim[0]) * 2.0) - 1.0) * gWindowRatio; diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index cafa023..35013c8 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -12,7 +12,7 @@ declareattribute("gMeshesNumber", null, null, 1); var gMeshSize = [4, 8]; declareattribute("gMeshSize", null, null, 1); -var gWindowDim = [0,0]; +var gWindowDim = [512,512]; var gWindowRatio = 1; function setWindowRatio(ratio) { gWindowRatio = ratio; @@ -26,11 +26,13 @@ var gGraphics = new GraphicElements(); // a structure to contain infos relative to the clicked mesh and vertex var gSelectionStruct = { cellIndex: [-1, -1], - meshIDsToCheck: new Array(), + oldCellIndex: [-1, -1], + meshIDsToCheckArr: new Array(), meshIDToClick: -1, reset: function() { this.cellIndex = [-1, -1]; - this.meshIDsToCheck = []; // we need to check multiple meshes in case they overlap + //this.oldCellIndex = [-1, -1]; + this.meshIDsToCheckArr = []; // we need to check multiple meshes in case they overlap this.meshIDToClick = -1; // the mesh we are going to operate on } }; @@ -70,7 +72,8 @@ function freeMeshes() { freeMeshes.local = 1; function initMeshes() { - + postln("init meshes") + gMeshes = []; for (var i=0; i Date: Mon, 12 Apr 2021 17:27:16 +0200 Subject: [PATCH 14/36] added texture display demo --- meshwarp/Mesh.js | 60 ++++++++++++++++++++++++++++++-------------- meshwarp/meshwarp.js | 4 +-- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index 48cde01..fb5f2e4 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -7,6 +7,7 @@ function Mesh() { this.positionMat = new JitterMatrix(3, "float32", [10, 10]); this.boundingMat = new JitterMatrix(3, "float32", 10); this.adjacentCellsMat = new JitterMatrix(3, "float32", 8); + this.textureCoordMat = new JitterMatrix(2, "float32", [10, 10]); this.maxPos = [-1000, -1000]; this.minPos = [1000, 1000]; @@ -31,18 +32,22 @@ function Mesh() { this.meshFull.draw_mode = "quad_grid"; this.meshFull.depth_enable = 0; this.meshFull.layer = BACKGROUND; - this.meshFull.color = GREY; + this.meshFull.color = WHITE; this.positionMat = new JitterMatrix(3, "float32", [10, 10]); this.boundingMat = new JitterMatrix(3, "float32", 10); this.adjacentCellsMat = new JitterMatrix(3, "float32", 8); + this.textureCoordMat = new JitterMatrix(2, "float32", [10, 10]); this.ID = ID; this.meshPoints.drawto = drawto; this.meshGrid.drawto = drawto; this.meshFull.drawto = drawto; + this.setMeshDim(dimensions); // calculate and set matrices dimensions this.initPositionMat(); + this.initTextureCoordMat(); + this.assignTexture(); postln("mesh draws to: " + this.meshPoints.drawto) } @@ -57,24 +62,15 @@ function Mesh() { } } - this.getMaxMinPositionMat = function() - { - gJit3m.matrixcalc(this.positionMat, this.positionMat); - this.minPos = gJit3m.min.slice(0, 2); - this.maxPos = gJit3m.max.slice(0, 2); - - // postln("min pos values (x, y): "+this.minPos); - // postln("max pos values (x, y): "+this.maxPos); - } - this.setMeshDim = function(dimensions) { if (dimensions[0] > 0 && dimensions[1] > 0) { this.positionMat.dim = dimensions.slice(); this.boundingMat.dim = dimensions[0]*2 + (dimensions[1] * 2) - 4; + this.textureCoordMat.dim = dimensions.slice(); } else { - this.positioMat.dim = [4,4]; + this.positionMat.dim = [4,4]; } } @@ -97,20 +93,52 @@ function Mesh() { } this.assignPositionMatToMesh(); // assign vertex mat to mesh - this.getMaxMinPositionMat(); // calculate what are the max and min position values in matrix + //this.getMaxMinPositionMat(); // calculate what are the max and min position values in matrix this.calcBoundingPolygonMat(); } + // Initialize Texture Coordinates + this.initTextureCoordMat = function() { + print("Initializing Texture Coordinates: " + this.ID); + var xStartingPoint = (1.0/gMeshesNumber) * this.ID; + var xCoordTarget = xStartingPoint + (1.0/gMeshesNumber); // 0 a 1. +0.25 + + for (var i=0; i= this.minPos[0] && mouseWorld[0] <= this.maxPos[0]) - // { - // return this.ID; - // } else { - // return -1; - // } if (isPointInsidePolygon(mouseWorld, this.boundingMat)) { return this.ID; } else { diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index 35013c8..54a48b3 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -9,7 +9,7 @@ var gMeshesNumber = 4; declareattribute("gMeshesNumber", null, null, 1); // Size of Meshes -var gMeshSize = [4, 8]; +var gMeshSize = [8, 16]; declareattribute("gMeshSize", null, null, 1); var gWindowDim = [512,512]; @@ -135,8 +135,8 @@ function swapcallback(event){ gMeshes[gSelectionStruct.meshIDToClick].moveVertex(mouseWorld, gSelectionStruct.cellIndex.slice(0,2)); // move the vertex with the mouse } } else { // mouse is released + // if we moved some vertices if (gSelectionStruct.meshIDToClick != -1) { - gMeshes[gSelectionStruct.meshIDToClick].getMaxMinPositionMat(); // recalculate the new max and min position values gMeshes[gSelectionStruct.meshIDToClick].calcBoundingPolygonMat() // recalculate the bounding matrix gSelectionStruct.reset(); // reset the values in the selectionStruct } From 75f4928ebe81e77d800776f15d25015a6376f929 Mon Sep 17 00:00:00 2001 From: FedFod Date: Mon, 12 Apr 2021 18:14:20 +0200 Subject: [PATCH 15/36] added hide/show meshes --- meshwarp/Mesh.js | 9 ++- meshwarp/meshwarp.js | 115 ++++++++++++++++++++++----------------- meshwarp/meshwarp.maxpat | 52 +++++++++++++++++- 3 files changed, 124 insertions(+), 52 deletions(-) diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index fb5f2e4..f445491 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -51,6 +51,11 @@ function Mesh() { postln("mesh draws to: " + this.meshPoints.drawto) } + this.showMesh = function(show) { + this.meshGrid.enable = show; + this.meshPoints.enable = show; + } + this.freeMesh = function() { if (this.positionMat) { this.positionMat.freepeer(); @@ -215,7 +220,7 @@ function Mesh() { } this.moveVertex = function(coordsWorld, cellIndex) { - if (isPointInsidePolygon(coordsWorld, this.adjacentCellsMat)) { + if (isPointInsidePolygon(coordsWorld, this.adjacentCellsMat)) { this.setVertexPos(coordsWorld, cellIndex); this.assignPositionMatToMesh(); gGraphics.drawCircle(coordsWorld); @@ -225,7 +230,7 @@ function Mesh() { this.calcBoundingPolygonMat = function() { // Get the bounding vertices that are on the edges of the polygon in clockwise order var boundingArray = []; - var pad = 0.05; // pad so that the mesh is checked also when mouse is outside of it + var pad = 0.15; // pad so that the mesh is checked also when mouse is outside of it // TOP for (var i=0; i < this.positionMat.dim[0]; i++) { diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index 54a48b3..0fff8c4 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -9,14 +9,19 @@ var gMeshesNumber = 4; declareattribute("gMeshesNumber", null, null, 1); // Size of Meshes -var gMeshSize = [8, 16]; +var gMeshSize = [4, 8]; declareattribute("gMeshSize", null, null, 1); +// GLOBAL VARIABLES +var gMeshes = []; +var gMousePosScreen = []; +var gMinimumSelectionDist = 0.06; var gWindowDim = [512,512]; var gWindowRatio = 1; function setWindowRatio(ratio) { gWindowRatio = ratio; } +var gShowMeshes = 1; // OBJECTS USED GLOBALLY // jit.3m to find max and min @@ -37,11 +42,6 @@ var gSelectionStruct = { } }; -// GLOBAL VARIABLES -var gMeshes = []; -var gMousePosScreen = []; -var gMinimumSelectionDist = 0.06; - // JIT_GL_NODE var nodeCTX = new JitterObject("jit.gl.node"); nodeCTX.name = "##mesherNodeCTX##"; @@ -89,6 +89,16 @@ function init() { gGraphics.initGraphicElements(); } +function show_meshes(show) { + for (mesh in gMeshes) { + gMeshes[mesh].showMesh(show); + } + if (!show) { + gGraphics.reset(); + } + gShowMeshes = show; +} + // ROB //-------------------------------------------- @@ -124,57 +134,64 @@ function swapcallback(event){ init(); // RE INIT everything when window size is modified (temporary) } break; + case "mouse": // get mouse array when mouse is clicked or released - gMousePosScreen = (event.args); - var mouseClicked = gMousePosScreen[2]; - //postln(gMousePosScreen); - var mouseWorld = transformMouseFromScreenToWorld2D(gMousePosScreen); - - if (mouseClicked) { - if (gSelectionStruct.cellIndex[0] != -1 && gSelectionStruct.meshIDToClick != -1) { // we are clicking on a vertex - gMeshes[gSelectionStruct.meshIDToClick].moveVertex(mouseWorld, gSelectionStruct.cellIndex.slice(0,2)); // move the vertex with the mouse - } - } else { // mouse is released - // if we moved some vertices - if (gSelectionStruct.meshIDToClick != -1) { - gMeshes[gSelectionStruct.meshIDToClick].calcBoundingPolygonMat() // recalculate the bounding matrix - gSelectionStruct.reset(); // reset the values in the selectionStruct + if (gShowMeshes) { + gMousePosScreen = (event.args); + var mouseClicked = gMousePosScreen[2]; + //postln(gMousePosScreen); + var mouseWorld = transformMouseFromScreenToWorld2D(gMousePosScreen); + + if (mouseClicked) { + //print(gSelectionStruct.cellIndex) + if (gSelectionStruct.cellIndex[0] != -1 && gSelectionStruct.meshIDToClick != -1) { // we are clicking on a vertex + gMeshes[gSelectionStruct.meshIDToClick].moveVertex(mouseWorld, gSelectionStruct.cellIndex.slice(0,2)); // move the vertex with the mouse + } + } else { // mouse is released + // if we moved some vertices + if (gSelectionStruct.meshIDToClick != -1) { + gMeshes[gSelectionStruct.meshIDToClick].calcBoundingPolygonMat() // recalculate the bounding matrix + gSelectionStruct.reset(); // reset the values in the selectionStruct + } + gGraphics.reset(); // delete the circle } - gGraphics.reset(); // delete the circle } + break; case "mouseidle": // Check if mouse is close to vertices to highlight them - gMousePosScreen = (event.args); - var mouseWorld = transformMouseFromScreenToWorld2D(gMousePosScreen); - - gSelectionStruct.reset(); // reset all the struct values - // Iterate through meshes to check in which one the mouse is in - for (var mesh in gMeshes) { - var meshID = gMeshes[mesh].checkIfMouseInsideMesh(mouseWorld); // Get the ID of the mesh in which the mouse is in (if it's inside any) - if (meshID != -1) { - - gSelectionStruct.meshIDsToCheckArr.push(meshID); // push in this array all the IDs of the meshes the mouse is in (it could be more than one when meshes overlap) - } - } + if (gShowMeshes) { + gMousePosScreen = (event.args); + var mouseWorld = transformMouseFromScreenToWorld2D(gMousePosScreen); + + gSelectionStruct.reset(); // reset all the struct values + // Iterate through meshes to check in which one the mouse is in + for (var mesh in gMeshes) { + var meshID = gMeshes[mesh].checkIfMouseInsideMesh(mouseWorld); // Get the ID of the mesh in which the mouse is in (if it's inside any) + if (meshID != -1) { + + gSelectionStruct.meshIDsToCheckArr.push(meshID); // push in this array all the IDs of the meshes the mouse is in (it could be more than one when meshes overlap) + } + } - // if we are on a mesh, let's check if the mouse is close to a vertex - for (var i=0; i Date: Mon, 12 Apr 2021 22:12:53 -0400 Subject: [PATCH 16/36] get root ctx via new (8.2) JS enabled jit.proxy object we use the implicit-listener to get the current implicit context, then recursively get parent context until we find root via jit.proxy. the current version posts an error to the console when it tests the root context for a drawto attribute. this will be fixed in a future version --- meshwarp/meshwarp.js | 38 +++++++++++++++++------- meshwarp/meshwarp.maxpat | 63 ++-------------------------------------- 2 files changed, 30 insertions(+), 71 deletions(-) diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index 0fff8c4..d102a71 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -102,21 +102,37 @@ function show_meshes(show) { // ROB //-------------------------------------------- -var drawto = "theWorld"; // initialized for the moment +var implicitdrawto = ""; +var drawto = ""; var swaplisten = null; // The listener for the jit.world -function setdrawto(arg) { - if(arg === drawto || !arg) { +const is820 = (max.version >= 820); +var proxy = null; +if(is820) { + proxy = new JitterObject("jit.proxy"); +} + +function setdrawto(newdrawto) { + if(newdrawto == drawto || !newdrawto) { // bounce return; } - postln("setdrawto " + arg); - drawto=arg; + if(proxy) { + proxy.name = newdrawto; + //proxyattrs = proxy.send("getattributes"); + proxydrawto = proxy.send("getdrawto"); + if(proxydrawto !== null && proxydrawto !== undefined) { + // important! drawto is an array so get first element + return setdrawto(proxydrawto[0]); + } + } + postln("setdrawto " + newdrawto); + drawto = newdrawto; if(swaplisten) swaplisten.subjectname = ""; - swaplisten = new JitterListener(drawto,swapcallback); + swaplisten = new JitterListener(drawto, swapcallback); } @@ -208,10 +224,10 @@ postln("implicit tracker name: "+implicit_tracker.name) var implicit_lstnr = new JitterListener(implicit_tracker.name, implicit_callback); function implicit_callback(event) { - if(drawto !== implicit_tracker.drawto) { - setdrawto(implicit_tracker.drawto); - //outlet(0, "drawto", (cur_drawto.length > 0 ? cur_drawto : vg.curctx)); + if(implicitdrawto != implicit_tracker.drawto[0]) { + // important! drawto is an array so get first element + implicitdrawto = implicit_tracker.drawto[0]; + setdrawto(implicitdrawto); } - postln(drawto) } -implicit_callback.local = 1; \ No newline at end of file +implicit_callback.local = 1; diff --git a/meshwarp/meshwarp.maxpat b/meshwarp/meshwarp.maxpat index 7201a3c..40fbea0 100644 --- a/meshwarp/meshwarp.maxpat +++ b/meshwarp/meshwarp.maxpat @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 1052.0, 259.0, 528.0, 613.0 ], + "rect" : [ 550.0, 136.0, 528.0, 613.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -85,18 +85,6 @@ "text" : "fps 400, sync 0" } - } -, { - "box" : { - "bubble" : 1, - "id" : "obj-5", - "maxclass" : "comment", - "numinlets" : 1, - "numoutlets" : 0, - "patching_rect" : [ 291.642860054969788, 78.0, 170.0, 24.0 ], - "text" : "getdrawto initializes as well" - } - } , { "box" : { @@ -120,7 +108,7 @@ "numinlets" : 1, "numoutlets" : 2, "outlettype" : [ "", "" ], - "patching_rect" : [ 223.904759526252747, 207.738093018531799, 80.0, 36.0 ] + "patching_rect" : [ 223.904759526252747, 207.738093018531799, 80.0, 35.0 ] } } @@ -147,30 +135,6 @@ "patching_rect" : [ 38.690475821495056, 125.595236897468567, 24.0, 24.0 ] } - } -, { - "box" : { - "id" : "obj-7", - "maxclass" : "newobj", - "numinlets" : 2, - "numoutlets" : 2, - "outlettype" : [ "", "" ], - "patching_rect" : [ 337.642860054969788, 207.738093018531799, 155.0, 22.0 ], - "text" : "substitute drawto setdrawto" - } - - } -, { - "box" : { - "id" : "obj-6", - "maxclass" : "message", - "numinlets" : 2, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 223.904759526252747, 79.0, 61.0, 22.0 ], - "text" : "getdrawto" - } - } , { "box" : { @@ -385,13 +349,6 @@ "source" : [ "obj-2", 1 ] } - } -, { - "patchline" : { - "destination" : [ "obj-7", 0 ], - "source" : [ "obj-2", 2 ] - } - } , { "patchline" : { @@ -413,20 +370,6 @@ "source" : [ "obj-4", 0 ] } - } -, { - "patchline" : { - "destination" : [ "obj-2", 0 ], - "source" : [ "obj-6", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-1", 0 ], - "source" : [ "obj-7", 0 ] - } - } , { "patchline" : { @@ -445,7 +388,7 @@ ], "dependency_cache" : [ { "name" : "meshwarp.js", - "bootpath" : "D:/MyData/Lavori/Cycling74/MaxMapper_with_Rob/meshwarp", + "bootpath" : "~/dev/cycling/meshwarp/meshwarp", "patcherrelativepath" : ".", "type" : "TEXT", "implicit" : 1 From de4897fb3482208318fc417b02899000c6d61eb3 Mon Sep 17 00:00:00 2001 From: FedFod Date: Tue, 13 Apr 2021 16:18:23 +0200 Subject: [PATCH 17/36] added sketch screentoworld --- meshwarp/GraphicElements.js | 4 ++ meshwarp/meshwarp.js | 9 ++-- meshwarp/meshwarp.maxpat | 91 ++++++++++++++++++++++++++++++------- 3 files changed, 83 insertions(+), 21 deletions(-) diff --git a/meshwarp/GraphicElements.js b/meshwarp/GraphicElements.js index b6989d6..4b14814 100644 --- a/meshwarp/GraphicElements.js +++ b/meshwarp/GraphicElements.js @@ -7,6 +7,10 @@ function GraphicElements() { this.circleRadius = 0.03; + this.transformMouseToWorld = function(screenCoord) { + return this.sketch.screentoworld(screenCoord); + } + this.setDrawto = function(drawto) { this.sketch.drawto = drawto; } diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index 0fff8c4..bf1292a 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -81,7 +81,8 @@ function initMeshes() { } initMeshes.local = 1; -function init() { +function init(meshSizeX, meshSizeY) { + gMeshSize = [meshSizeX, meshSizeY]; nodeCTX.drawto = drawto; videoplane.drawto = drawto; freeMeshes(); @@ -140,7 +141,7 @@ function swapcallback(event){ gMousePosScreen = (event.args); var mouseClicked = gMousePosScreen[2]; //postln(gMousePosScreen); - var mouseWorld = transformMouseFromScreenToWorld2D(gMousePosScreen); + var mouseWorld = gGraphics.transformMouseToWorld(gMousePosScreen); // transformMouseFromScreenToWorld2D(gMousePosScreen); if (mouseClicked) { //print(gSelectionStruct.cellIndex) @@ -162,8 +163,8 @@ function swapcallback(event){ case "mouseidle": // Check if mouse is close to vertices to highlight them if (gShowMeshes) { gMousePosScreen = (event.args); - var mouseWorld = transformMouseFromScreenToWorld2D(gMousePosScreen); - + var mouseWorld = gGraphics.transformMouseToWorld(gMousePosScreen); //transformMouseFromScreenToWorld2D(gMousePosScreen); + gSelectionStruct.reset(); // reset all the struct values // Iterate through meshes to check in which one the mouse is in for (var mesh in gMeshes) { diff --git a/meshwarp/meshwarp.maxpat b/meshwarp/meshwarp.maxpat index 7201a3c..c49ff79 100644 --- a/meshwarp/meshwarp.maxpat +++ b/meshwarp/meshwarp.maxpat @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 1052.0, 259.0, 528.0, 613.0 ], + "rect" : [ 563.0, -1261.0, 545.0, 639.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -39,6 +39,42 @@ "subpatcher_template" : "", "assistshowspatchername" : 0, "boxes" : [ { + "box" : { + "id" : "obj-15", + "maxclass" : "number", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "", "bang" ], + "parameter_enable" : 0, + "patching_rect" : [ 306.690475821495056, 45.0, 50.0, 22.0 ] + } + + } +, { + "box" : { + "id" : "obj-13", + "maxclass" : "number", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "", "bang" ], + "parameter_enable" : 0, + "patching_rect" : [ 252.690475821495056, 45.0, 50.0, 22.0 ] + } + + } +, { + "box" : { + "id" : "obj-11", + "maxclass" : "newobj", + "numinlets" : 3, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 228.690475821495056, 79.0, 67.0, 22.0 ], + "text" : "pak init 2 2" + } + + } +, { "box" : { "id" : "obj-20", "maxclass" : "toggle", @@ -46,7 +82,7 @@ "numoutlets" : 1, "outlettype" : [ "int" ], "parameter_enable" : 0, - "patching_rect" : [ 67.0, 43.0, 24.0, 24.0 ] + "patching_rect" : [ 64.0, 87.0, 24.0, 24.0 ] } } @@ -57,7 +93,7 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 67.0, 79.0, 102.0, 22.0 ], + "patching_rect" : [ 64.0, 123.0, 102.0, 22.0 ], "text" : "show_meshes $1" } @@ -69,8 +105,8 @@ "numinlets" : 1, "numoutlets" : 2, "outlettype" : [ "jit_gl_texture", "" ], - "patching_rect" : [ 77.0, 391.0, 318.0, 22.0 ], - "text" : "jit.movie @output_texture 1 @texture_name TEST @vol 0" + "patching_rect" : [ 48.404759526252747, 436.0, 458.0, 22.0 ], + "text" : "jit.movie @output_texture 1 @texture_name TEST @vol 0 @moviefile chickens.mp4" } } @@ -81,7 +117,7 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 405.0, 135.0, 89.0, 22.0 ], + "patching_rect" : [ 402.0, 179.0, 89.0, 22.0 ], "text" : "fps 400, sync 0" } @@ -93,7 +129,7 @@ "maxclass" : "comment", "numinlets" : 1, "numoutlets" : 0, - "patching_rect" : [ 291.642860054969788, 78.0, 170.0, 24.0 ], + "patching_rect" : [ 288.642860054969788, 122.0, 170.0, 24.0 ], "text" : "getdrawto initializes as well" } @@ -105,7 +141,7 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 317.0, 135.0, 83.0, 22.0 ], + "patching_rect" : [ 314.0, 179.0, 83.0, 22.0 ], "text" : "fps 60, sync 1" } @@ -120,7 +156,7 @@ "numinlets" : 1, "numoutlets" : 2, "outlettype" : [ "", "" ], - "patching_rect" : [ 223.904759526252747, 207.738093018531799, 80.0, 36.0 ] + "patching_rect" : [ 272.642860054969788, 283.738093018531799, 80.0, 36.0 ] } } @@ -131,8 +167,8 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 182.642860054969788, 79.0, 29.5, 22.0 ], - "text" : "init" + "patching_rect" : [ 179.642860054969788, 79.0, 44.0, 22.0 ], + "text" : "init 4 8" } } @@ -144,7 +180,7 @@ "numoutlets" : 1, "outlettype" : [ "int" ], "parameter_enable" : 0, - "patching_rect" : [ 38.690475821495056, 125.595236897468567, 24.0, 24.0 ] + "patching_rect" : [ 35.690475821495056, 169.595236897468567, 24.0, 24.0 ] } } @@ -155,7 +191,7 @@ "numinlets" : 2, "numoutlets" : 2, "outlettype" : [ "", "" ], - "patching_rect" : [ 337.642860054969788, 207.738093018531799, 155.0, 22.0 ], + "patching_rect" : [ 306.642860054969788, 249.738093018531799, 155.0, 22.0 ], "text" : "substitute drawto setdrawto" } @@ -167,7 +203,7 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 223.904759526252747, 79.0, 61.0, 22.0 ], + "patching_rect" : [ 220.904759526252747, 123.0, 61.0, 22.0 ], "text" : "getdrawto" } @@ -179,7 +215,7 @@ "numinlets" : 1, "numoutlets" : 3, "outlettype" : [ "jit_matrix", "bang", "" ], - "patching_rect" : [ 108.642860054969788, 171.119050145149231, 353.0, 22.0 ], + "patching_rect" : [ 105.642860054969788, 215.119050145149231, 353.0, 22.0 ], "text" : "jit.world theWorld @floating 1 @size 160 120 @fps 400 @sync 0" } @@ -333,7 +369,7 @@ ] } , - "patching_rect" : [ 108.642860054969788, 129.119050145149231, 93.0, 22.0 ], + "patching_rect" : [ 105.642860054969788, 173.119050145149231, 93.0, 22.0 ], "saved_object_attributes" : { "description" : "", "digest" : "", @@ -353,7 +389,7 @@ "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 42.392860054969788, 272.119050000000016, 260.0, 22.0 ] + "patching_rect" : [ 35.690475821495056, 340.119050000000016, 260.0, 22.0 ] } } @@ -364,6 +400,20 @@ "source" : [ "obj-1", 0 ] } + } +, { + "patchline" : { + "destination" : [ "obj-1", 1 ], + "source" : [ "obj-11", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-11", 1 ], + "source" : [ "obj-13", 0 ] + } + } , { "patchline" : { @@ -371,6 +421,13 @@ "source" : [ "obj-14", 0 ] } + } +, { + "patchline" : { + "destination" : [ "obj-11", 2 ], + "source" : [ "obj-15", 0 ] + } + } , { "patchline" : { From b552d7fab22a70e0e08014f209ce4f7d8cdbfb85 Mon Sep 17 00:00:00 2001 From: FedFod Date: Tue, 13 Apr 2021 17:06:32 +0200 Subject: [PATCH 18/36] just updating my patch --- meshwarp/meshwarp.maxpat | 73 +++++----------------------------------- 1 file changed, 8 insertions(+), 65 deletions(-) diff --git a/meshwarp/meshwarp.maxpat b/meshwarp/meshwarp.maxpat index c49ff79..20c9522 100644 --- a/meshwarp/meshwarp.maxpat +++ b/meshwarp/meshwarp.maxpat @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 563.0, -1261.0, 545.0, 639.0 ], + "rect" : [ 959.0, 198.0, 543.0, 637.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -117,22 +117,10 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 402.0, 179.0, 89.0, 22.0 ], + "patching_rect" : [ 361.0, 184.595236897468567, 89.0, 22.0 ], "text" : "fps 400, sync 0" } - } -, { - "box" : { - "bubble" : 1, - "id" : "obj-5", - "maxclass" : "comment", - "numinlets" : 1, - "numoutlets" : 0, - "patching_rect" : [ 288.642860054969788, 122.0, 170.0, 24.0 ], - "text" : "getdrawto initializes as well" - } - } , { "box" : { @@ -141,7 +129,7 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 314.0, 179.0, 83.0, 22.0 ], + "patching_rect" : [ 273.0, 184.595236897468567, 83.0, 22.0 ], "text" : "fps 60, sync 1" } @@ -156,7 +144,7 @@ "numinlets" : 1, "numoutlets" : 2, "outlettype" : [ "", "" ], - "patching_rect" : [ 272.642860054969788, 283.738093018531799, 80.0, 36.0 ] + "patching_rect" : [ 247.142860054969788, 263.738093018531799, 80.0, 36.0 ] } } @@ -180,31 +168,7 @@ "numoutlets" : 1, "outlettype" : [ "int" ], "parameter_enable" : 0, - "patching_rect" : [ 35.690475821495056, 169.595236897468567, 24.0, 24.0 ] - } - - } -, { - "box" : { - "id" : "obj-7", - "maxclass" : "newobj", - "numinlets" : 2, - "numoutlets" : 2, - "outlettype" : [ "", "" ], - "patching_rect" : [ 306.642860054969788, 249.738093018531799, 155.0, 22.0 ], - "text" : "substitute drawto setdrawto" - } - - } -, { - "box" : { - "id" : "obj-6", - "maxclass" : "message", - "numinlets" : 2, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 220.904759526252747, 123.0, 61.0, 22.0 ], - "text" : "getdrawto" + "patching_rect" : [ 54.523813247680664, 173.119050145149231, 33.476186752319336, 33.476186752319336 ] } } @@ -215,8 +179,8 @@ "numinlets" : 1, "numoutlets" : 3, "outlettype" : [ "jit_matrix", "bang", "" ], - "patching_rect" : [ 105.642860054969788, 215.119050145149231, 353.0, 22.0 ], - "text" : "jit.world theWorld @floating 1 @size 160 120 @fps 400 @sync 0" + "patching_rect" : [ 105.642860054969788, 230.119050145149231, 302.0, 22.0 ], + "text" : "jit.world @floating 1 @size 160 120 @fps 400 @sync 0" } } @@ -389,7 +353,7 @@ "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 35.690475821495056, 340.119050000000016, 260.0, 22.0 ] + "patching_rect" : [ 35.690475821495056, 323.119050000000016, 260.0, 22.0 ] } } @@ -442,13 +406,6 @@ "source" : [ "obj-2", 1 ] } - } -, { - "patchline" : { - "destination" : [ "obj-7", 0 ], - "source" : [ "obj-2", 2 ] - } - } , { "patchline" : { @@ -470,20 +427,6 @@ "source" : [ "obj-4", 0 ] } - } -, { - "patchline" : { - "destination" : [ "obj-2", 0 ], - "source" : [ "obj-6", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-1", 0 ], - "source" : [ "obj-7", 0 ] - } - } , { "patchline" : { From fdc5b9a119dbbd1975b1ba3daa0c3b2c81b79cc6 Mon Sep 17 00:00:00 2001 From: FedFod Date: Wed, 14 Apr 2021 14:42:19 +0200 Subject: [PATCH 19/36] Added: resize of meshes (all together) --- meshwarp/Mesh.js | 21 ++++++-- meshwarp/meshwarp.js | 8 ++- meshwarp/meshwarp.maxpat | 111 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 135 insertions(+), 5 deletions(-) diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index f445491..06bae7f 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -6,8 +6,8 @@ function Mesh() { this.meshFull = new JitterObject("jit.gl.mesh"); this.positionMat = new JitterMatrix(3, "float32", [10, 10]); this.boundingMat = new JitterMatrix(3, "float32", 10); - this.adjacentCellsMat = new JitterMatrix(3, "float32", 8); this.textureCoordMat = new JitterMatrix(2, "float32", [10, 10]); + this.adjacentCellsMat = new JitterMatrix(3, "float32", 8); this.maxPos = [-1000, -1000]; this.minPos = [1000, 1000]; @@ -46,6 +46,7 @@ function Mesh() { this.setMeshDim(dimensions); // calculate and set matrices dimensions this.initPositionMat(); + this.calcBoundingPolygonMat(); this.initTextureCoordMat(); this.assignTexture(); postln("mesh draws to: " + this.meshPoints.drawto) @@ -79,6 +80,22 @@ function Mesh() { } } + this.resizeMesh = function(sizeX, sizeY) { + var tempMat = new JitterMatrix(3, "float32", [sizeX, sizeY]); + tempMat.interp = 1; + + tempMat.frommatrix(this.positionMat); + + this.setMeshDim([sizeX, sizeY]); + + this.positionMat.frommatrix(tempMat); + tempMat.freepeer(); + + this.assignPositionMatToMesh(); + this.initTextureCoordMat(); + this.calcBoundingPolygonMat(); + } + this.initPositionMat = function() { postln("Initializing vertex matrix for mesh with ID " + this.ID); @@ -99,12 +116,10 @@ function Mesh() { this.assignPositionMatToMesh(); // assign vertex mat to mesh //this.getMaxMinPositionMat(); // calculate what are the max and min position values in matrix - this.calcBoundingPolygonMat(); } // Initialize Texture Coordinates this.initTextureCoordMat = function() { - print("Initializing Texture Coordinates: " + this.ID); var xStartingPoint = (1.0/gMeshesNumber) * this.ID; var xCoordTarget = xStartingPoint + (1.0/gMeshesNumber); // 0 a 1. +0.25 diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index f53db9a..f874a36 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -90,6 +90,12 @@ function init(meshSizeX, meshSizeY) { gGraphics.initGraphicElements(); } +function resize_meshes(meshSizeX, meshSizeY) { + for (mesh in gMeshes) { + gMeshes[mesh].resizeMesh(meshSizeX, meshSizeY); + } +} + function show_meshes(show) { for (mesh in gMeshes) { gMeshes[mesh].showMesh(show); @@ -148,7 +154,7 @@ function swapcallback(event){ setWindowRatio(nodeCTX.dim[0] / nodeCTX.dim[1]); gWindowDim = nodeCTX.dim.slice(); postln("window Dimensions: "+gWindowDim); - init(); // RE INIT everything when window size is modified (temporary) + init(g); // RE INIT everything when window size is modified (temporary) } break; diff --git a/meshwarp/meshwarp.maxpat b/meshwarp/meshwarp.maxpat index 20c9522..d07dbdf 100644 --- a/meshwarp/meshwarp.maxpat +++ b/meshwarp/meshwarp.maxpat @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 959.0, 198.0, 543.0, 637.0 ], + "rect" : [ 908.0, 247.0, 900.0, 749.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -39,6 +39,78 @@ "subpatcher_template" : "", "assistshowspatchername" : 0, "boxes" : [ { + "box" : { + "id" : "obj-24", + "maxclass" : "button", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "bang" ], + "parameter_enable" : 0, + "patching_rect" : [ 190.0, 471.0, 24.0, 24.0 ] + } + + } +, { + "box" : { + "id" : "obj-22", + "maxclass" : "jit.pwindow", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "jit_matrix", "" ], + "patching_rect" : [ 40.0, 492.0, 118.0, 94.0 ], + "sync" : 1 + } + + } +, { + "box" : { + "id" : "obj-19", + "maxclass" : "jit.pwindow", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "jit_matrix", "" ], + "patching_rect" : [ 190.0, 573.0, 166.0, 152.0 ], + "sync" : 1 + } + + } +, { + "box" : { + "id" : "obj-12", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "jit_matrix", "" ], + "patching_rect" : [ 190.0, 540.0, 191.0, 22.0 ], + "text" : "jit.matrix 3 float32 10 10 @interp 1" + } + + } +, { + "box" : { + "id" : "obj-7", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "jit_matrix", "" ], + "patching_rect" : [ 190.0, 507.0, 119.0, 22.0 ], + "text" : "jit.noise 3 float32 4 8" + } + + } +, { + "box" : { + "id" : "obj-6", + "maxclass" : "message", + "numinlets" : 2, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 258.5, 136.0, 123.0, 22.0 ], + "text" : "resize_meshes 10 10" + } + + } +, { "box" : { "id" : "obj-15", "maxclass" : "number", @@ -371,6 +443,13 @@ "source" : [ "obj-11", 0 ] } + } +, { + "patchline" : { + "destination" : [ "obj-19", 0 ], + "source" : [ "obj-12", 0 ] + } + } , { "patchline" : { @@ -413,6 +492,13 @@ "source" : [ "obj-20", 0 ] } + } +, { + "patchline" : { + "destination" : [ "obj-7", 0 ], + "source" : [ "obj-24", 0 ] + } + } , { "patchline" : { @@ -427,6 +513,29 @@ "source" : [ "obj-4", 0 ] } + } +, { + "patchline" : { + "destination" : [ "obj-1", 1 ], + "source" : [ "obj-6", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-12", 0 ], + "order" : 0, + "source" : [ "obj-7", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-22", 0 ], + "order" : 1, + "source" : [ "obj-7", 0 ] + } + } , { "patchline" : { From 49ffc48398802bfa934d774850e118b82e0b3bb4 Mon Sep 17 00:00:00 2001 From: FedFod Date: Wed, 14 Apr 2021 16:03:33 +0200 Subject: [PATCH 20/36] Fixed: 2x2 picking bug --- meshwarp/meshwarp.js | 60 ++--- meshwarp/meshwarp.maxhelp | 471 ++++++++++++++++++++++++++++++++++++++ meshwarp/meshwarp.maxpat | 85 +++++-- 3 files changed, 575 insertions(+), 41 deletions(-) create mode 100644 meshwarp/meshwarp.maxhelp diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index f874a36..2a4566b 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -4,14 +4,6 @@ include("Mesh.js"); include("Utilities.js"); include("GraphicElements.js"); -// number of meshes -var gMeshesNumber = 4; -declareattribute("gMeshesNumber", null, null, 1); - -// Size of Meshes -var gMeshSize = [4, 8]; -declareattribute("gMeshSize", null, null, 1); - // GLOBAL VARIABLES var gMeshes = []; var gMousePosScreen = []; @@ -20,8 +12,14 @@ var gWindowDim = [512,512]; var gWindowRatio = 1; function setWindowRatio(ratio) { gWindowRatio = ratio; -} +} +setWindowRatio.local = 1; var gShowMeshes = 1; +var gMeshesNumber = 4; +declareattribute("gMeshesNumber", null, null, 1); +var gMeshSize = [4, 8]; +declareattribute("gMeshSize", null, null, 1); + // OBJECTS USED GLOBALLY // jit.3m to find max and min @@ -90,6 +88,10 @@ function init(meshSizeX, meshSizeY) { gGraphics.initGraphicElements(); } +function meshes(numberMeshes) { + +} + function resize_meshes(meshSizeX, meshSizeY) { for (mesh in gMeshes) { gMeshes[mesh].resizeMesh(meshSizeX, meshSizeY); @@ -164,7 +166,7 @@ function swapcallback(event){ var mouseClicked = gMousePosScreen[2]; //postln(gMousePosScreen); var mouseWorld = gGraphics.transformMouseToWorld(gMousePosScreen); // transformMouseFromScreenToWorld2D(gMousePosScreen); - + if (mouseClicked) { //print(gSelectionStruct.cellIndex) if (gSelectionStruct.cellIndex[0] != -1 && gSelectionStruct.meshIDToClick != -1) { // we are clicking on a vertex @@ -188,32 +190,36 @@ function swapcallback(event){ var mouseWorld = gGraphics.transformMouseToWorld(gMousePosScreen); //transformMouseFromScreenToWorld2D(gMousePosScreen); gSelectionStruct.reset(); // reset all the struct values + // Iterate through meshes to check in which one the mouse is in for (var mesh in gMeshes) { var meshID = gMeshes[mesh].checkIfMouseInsideMesh(mouseWorld); // Get the ID of the mesh in which the mouse is in (if it's inside any) if (meshID != -1) { - gSelectionStruct.meshIDsToCheckArr.push(meshID); // push in this array all the IDs of the meshes the mouse is in (it could be more than one when meshes overlap) } } - // if we are on a mesh, let's check if the mouse is close to a vertex - for (var i=0; i Date: Wed, 14 Apr 2021 16:28:47 +0200 Subject: [PATCH 21/36] Added: resize single mesh option --- meshwarp/meshwarp.js | 10 +- meshwarp/meshwarp.maxpat | 248 +++++++++++++++++++++++++++++++-------- 2 files changed, 211 insertions(+), 47 deletions(-) diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index 2a4566b..93da688 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -89,7 +89,9 @@ function init(meshSizeX, meshSizeY) { } function meshes(numberMeshes) { - + gMeshesNumber = numberMeshes; + freeMeshes(); + initMeshes(); } function resize_meshes(meshSizeX, meshSizeY) { @@ -98,6 +100,12 @@ function resize_meshes(meshSizeX, meshSizeY) { } } +function resize_mesh(index, meshSizeX, meshSizeY) { + if (index < gMeshes.length && index >= 0) { + gMeshes[index].resizeMesh(meshSizeX, meshSizeY); + } +} + function show_meshes(show) { for (mesh in gMeshes) { gMeshes[mesh].showMesh(show); diff --git a/meshwarp/meshwarp.maxpat b/meshwarp/meshwarp.maxpat index 34ab1e5..c5dac8f 100644 --- a/meshwarp/meshwarp.maxpat +++ b/meshwarp/meshwarp.maxpat @@ -39,6 +39,137 @@ "subpatcher_template" : "", "assistshowspatchername" : 0, "boxes" : [ { + "box" : { + "id" : "obj-42", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 605.0, 161.0, 113.0, 20.0 ], + "text" : "Resize single mesh" + } + + } +, { + "box" : { + "id" : "obj-40", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 605.0, 46.0, 106.0, 20.0 ], + "presentation_linecount" : 4, + "text" : "Resize all meshes" + } + + } +, { + "box" : { + "id" : "obj-39", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 657.0, 189.0, 37.0, 20.0 ], + "text" : "index" + } + + } +, { + "box" : { + "id" : "obj-37", + "maxclass" : "number", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "", "bang" ], + "parameter_enable" : 0, + "patching_rect" : [ 767.25, 211.0, 50.0, 22.0 ] + } + + } +, { + "box" : { + "id" : "obj-33", + "maxclass" : "number", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "", "bang" ], + "parameter_enable" : 0, + "patching_rect" : [ 711.25, 211.0, 50.0, 22.0 ] + } + + } +, { + "box" : { + "id" : "obj-34", + "maxclass" : "number", + "minimum" : 0, + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "", "bang" ], + "parameter_enable" : 0, + "patching_rect" : [ 657.0, 211.0, 50.0, 22.0 ] + } + + } +, { + "box" : { + "id" : "obj-35", + "maxclass" : "button", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "bang" ], + "parameter_enable" : 0, + "patching_rect" : [ 607.75, 211.0, 24.0, 24.0 ] + } + + } +, { + "box" : { + "id" : "obj-36", + "maxclass" : "newobj", + "numinlets" : 4, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 607.75, 247.0, 166.75, 22.0 ], + "text" : "pack resize_mesh i i i" + } + + } +, { + "box" : { + "id" : "obj-32", + "maxclass" : "button", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "bang" ], + "parameter_enable" : 0, + "patching_rect" : [ 260.142860054969788, 89.0, 24.0, 24.0 ] + } + + } +, { + "box" : { + "id" : "obj-30", + "maxclass" : "number", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "", "bang" ], + "parameter_enable" : 0, + "patching_rect" : [ 132.190475821495056, 35.0, 50.0, 22.0 ] + } + + } +, { + "box" : { + "id" : "obj-28", + "maxclass" : "message", + "numinlets" : 2, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 132.190475821495056, 68.0, 67.0, 22.0 ], + "text" : "meshes $1" + } + + } +, { "box" : { "id" : "obj-25", "maxclass" : "number", @@ -46,7 +177,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 554.5, 79.0, 50.0, 22.0 ] + "patching_rect" : [ 724.5, 81.0, 50.0, 22.0 ] } } @@ -58,7 +189,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 490.5, 79.0, 50.0, 22.0 ] + "patching_rect" : [ 660.5, 81.0, 50.0, 22.0 ] } } @@ -70,7 +201,7 @@ "numoutlets" : 1, "outlettype" : [ "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 435.0, 79.0, 24.0, 24.0 ] + "patching_rect" : [ 605.0, 81.0, 24.0, 24.0 ] } } @@ -81,7 +212,7 @@ "numinlets" : 3, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 435.0, 115.0, 130.0, 22.0 ], + "patching_rect" : [ 605.0, 117.0, 130.0, 22.0 ], "text" : "pack resize_meshes i i" } @@ -154,7 +285,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 306.690475821495056, 45.0, 50.0, 22.0 ] + "patching_rect" : [ 354.690475821495056, 89.0, 50.0, 22.0 ] } } @@ -166,7 +297,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 252.690475821495056, 45.0, 50.0, 22.0 ] + "patching_rect" : [ 296.690475821495056, 89.0, 50.0, 22.0 ] } } @@ -177,8 +308,8 @@ "numinlets" : 3, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 228.690475821495056, 79.0, 67.0, 22.0 ], - "text" : "pak init 2 2" + "patching_rect" : [ 269.690475821495056, 123.0, 73.0, 22.0 ], + "text" : "pack init 2 2" } } @@ -263,7 +394,7 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 179.642860054969788, 79.0, 44.0, 22.0 ], + "patching_rect" : [ 196.642860054969788, 123.0, 44.0, 22.0 ], "text" : "init 4 8" } @@ -296,7 +427,7 @@ "box" : { "id" : "obj-1", "maxclass" : "newobj", - "numinlets" : 2, + "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "" ], "patcher" : { @@ -340,7 +471,7 @@ "assistshowspatchername" : 0, "boxes" : [ { "box" : { - "embedstate" : [ [ "gMeshesNumber", 4 ], [ "gMeshSize", 4, 8 ] ], + "embedstate" : [ [ "gMeshesNumber", 3 ], [ "gMeshSize", 4, 8 ] ], "id" : "obj-8", "maxclass" : "newobj", "numinlets" : 1, @@ -355,41 +486,17 @@ "text" : "js meshwarp.js" } - } -, { - "box" : { - "id" : "obj-6", - "maxclass" : "comment", - "numinlets" : 1, - "numoutlets" : 0, - "patching_rect" : [ 99.0, 36.0, 77.0, 20.0 ], - "text" : "from jit.world" - } - } , { "box" : { "comment" : "", "id" : "obj-5", - "index" : 2, - "maxclass" : "inlet", - "numinlets" : 0, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 299.0, 64.0, 30.0, 30.0 ] - } - - } -, { - "box" : { - "comment" : "", - "id" : "obj-4", "index" : 1, "maxclass" : "inlet", "numinlets" : 0, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 107.0, 64.0, 30.0, 30.0 ] + "patching_rect" : [ 107.0, 66.0, 30.0, 30.0 ] } } @@ -418,13 +525,6 @@ } ], "lines" : [ { - "patchline" : { - "destination" : [ "obj-8", 0 ], - "source" : [ "obj-4", 0 ] - } - - } -, { "patchline" : { "destination" : [ "obj-8", 0 ], "source" : [ "obj-5", 0 ] @@ -475,7 +575,7 @@ } , { "patchline" : { - "destination" : [ "obj-1", 1 ], + "destination" : [ "obj-1", 0 ], "source" : [ "obj-11", 0 ] } @@ -556,6 +656,13 @@ "source" : [ "obj-25", 0 ] } + } +, { + "patchline" : { + "destination" : [ "obj-1", 0 ], + "source" : [ "obj-28", 0 ] + } + } , { "patchline" : { @@ -563,6 +670,55 @@ "source" : [ "obj-3", 0 ] } + } +, { + "patchline" : { + "destination" : [ "obj-28", 0 ], + "source" : [ "obj-30", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-11", 0 ], + "source" : [ "obj-32", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-36", 2 ], + "source" : [ "obj-33", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-36", 1 ], + "source" : [ "obj-34", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-36", 0 ], + "source" : [ "obj-35", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-1", 0 ], + "source" : [ "obj-36", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-36", 3 ], + "source" : [ "obj-37", 0 ] + } + } , { "patchline" : { @@ -573,7 +729,7 @@ } , { "patchline" : { - "destination" : [ "obj-1", 1 ], + "destination" : [ "obj-1", 0 ], "source" : [ "obj-5", 0 ] } @@ -596,7 +752,7 @@ } , { "patchline" : { - "destination" : [ "obj-1", 1 ], + "destination" : [ "obj-1", 0 ], "source" : [ "obj-8", 0 ] } From 3d724f4bb35d3532b9beeb205b91eb9415b7b8a2 Mon Sep 17 00:00:00 2001 From: FedFod Date: Wed, 14 Apr 2021 18:36:08 +0200 Subject: [PATCH 22/36] Working on: adding NURBS. Organizing code in multiple files. --- meshwarp/Canvas.js | 21 ++++++++++++ meshwarp/Mesh.js | 27 ++++++++------- meshwarp/Nurbs.js | 64 ++++++++++++++++++++++++++++++++++++ meshwarp/PrivateFunctions.js | 36 ++++++++++++++++++++ meshwarp/meshwarp.js | 32 +++++++----------- meshwarp/meshwarp.maxpat | 12 +++++++ 6 files changed, 161 insertions(+), 31 deletions(-) create mode 100644 meshwarp/Canvas.js create mode 100644 meshwarp/Nurbs.js create mode 100644 meshwarp/PrivateFunctions.js diff --git a/meshwarp/Canvas.js b/meshwarp/Canvas.js new file mode 100644 index 0000000..2a14548 --- /dev/null +++ b/meshwarp/Canvas.js @@ -0,0 +1,21 @@ +function Canvas() { + this.ID = -1; + + this.initCanvas = function(ID) { + this.ID = ID; + } + + this.initTextureCoordMat = function(texcoordMatrix) { + var xStartingPoint = (1.0/gMeshesNumber) * this.ID; + var xCoordTarget = xStartingPoint + (1.0/gMeshesNumber); // 0 a 1. +0.25 + + for (var i=0; i 0 && dimensions[1] > 0) { @@ -113,9 +122,6 @@ function Mesh() { this.positionMat.setcell2d(i, j, xVal, yVal, 0.0); } } - - this.assignPositionMatToMesh(); // assign vertex mat to mesh - //this.getMaxMinPositionMat(); // calculate what are the max and min position values in matrix } // Initialize Texture Coordinates @@ -131,7 +137,6 @@ function Mesh() { this.textureCoordMat.setcell2d(i,j, xCoord, j/(this.textureCoordMat.dim[1]-1)); } } - this.assignTextureCoordMatToMesh(); } this.setVertexPos = function(coordsWorld, cellIndex) { diff --git a/meshwarp/Nurbs.js b/meshwarp/Nurbs.js new file mode 100644 index 0000000..870db20 --- /dev/null +++ b/meshwarp/Nurbs.js @@ -0,0 +1,64 @@ +function Nurbs() { + this.ID = -1; + + this.nurbs = new JitterObject("jit.gl.nurbs"); + this.controlMat = new JitterMatrix(2, "float32", [10, 10]); + + this.initNurbs = function(dimensions, drawto, ID) { + this.nurbs = new JitterObject("jit.gl.nurbs"); + this.nurbs.dim = [40, 40]; + this.nurbs.depth_enable = 0; + this.nurbs.layer = BACKGROUND; + this.nurbs.color = WHITE; + this.nurbs.ctlshow = 1; + + this.controlMat = new JitterMatrix(2, "float32", [10, 10]); + + this.ID = ID; + this.nurbs.drawto = drawto; + this.setNurbsControlDim(dimensions); + this.initControlMat(); + this.assignControlMatToNurbs(); + + } + + this.freeNurbs = function() { + if (this.controlMat) { + this.nurbs.freepeer(); + this.controlMat.freepeer(); + } + } + + this.setNurbsControlDim = function(dimensions) { + if (dimensions[0] > 0 && dimensions[1] > 0) { + this.controlMat.dim = dimensions.slice(); + } + else { + this.controlMat.dim = [4,4]; + } + } + + this.initControlMat = function() + { + postln("Initializing control matrix for NURBS with ID " + this.ID); + + // Set values for position matrix + for(var i=0; i 0) { + for (var mesh in gMeshes) { + gMeshes[mesh].freeMesh(); + } + } +} +freeMeshes.local = 1; + +function freeNurbs() { + if (gNurbs.length > 0) { + for (var nurbs in gNurbs) { + gNurbs[nurbs].freeNurbs(); + } + } +} +freeNurbs.local = 1; + +function initMeshes() { + postln("init meshes") + gMeshes = []; + for (var i=0; i 0) { - for (var mesh in gMeshes) { - gMeshes[mesh].freeMesh(); - } - } -} -freeMeshes.local = 1; - -function initMeshes() { - postln("init meshes") - gMeshes = []; - for (var i=0; i= 0) { gMeshes[index].resizeMesh(meshSizeX, meshSizeY); diff --git a/meshwarp/meshwarp.maxpat b/meshwarp/meshwarp.maxpat index c5dac8f..bf77851 100644 --- a/meshwarp/meshwarp.maxpat +++ b/meshwarp/meshwarp.maxpat @@ -39,6 +39,18 @@ "subpatcher_template" : "", "assistshowspatchername" : 0, "boxes" : [ { + "box" : { + "id" : "obj-43", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "jit_matrix", "" ], + "patching_rect" : [ 626.5, 419.0, 63.0, 22.0 ], + "text" : "jit.gl.nurbs" + } + + } +, { "box" : { "id" : "obj-42", "maxclass" : "comment", From dcfc69c31ea7147b1b122dde33fae35af69690c2 Mon Sep 17 00:00:00 2001 From: FedFod Date: Wed, 14 Apr 2021 22:30:14 +0200 Subject: [PATCH 23/36] Added: texture to NURBS There is the problem that we cannot set texture coordinates for the NURBS, so the image is repeated on each mesh. --- meshwarp/Canvas.js | 29 +++++++++++++++---- meshwarp/Mesh.js | 62 +++++++++------------------------------- meshwarp/Nurbs.js | 29 ++++++------------- meshwarp/meshwarp.js | 8 +++--- meshwarp/meshwarp.maxpat | 23 ++++----------- 5 files changed, 53 insertions(+), 98 deletions(-) diff --git a/meshwarp/Canvas.js b/meshwarp/Canvas.js index 2a14548..722bf4a 100644 --- a/meshwarp/Canvas.js +++ b/meshwarp/Canvas.js @@ -1,9 +1,5 @@ -function Canvas() { - this.ID = -1; - - this.initCanvas = function(ID) { - this.ID = ID; - } +function Canvas(ID) { + this.ID = ID; this.initTextureCoordMat = function(texcoordMatrix) { var xStartingPoint = (1.0/gMeshesNumber) * this.ID; @@ -18,4 +14,25 @@ function Canvas() { } } } + + this.initPositionMat = function(positionMat) + { + // Set values for position matrix + for(var i=0; i Date: Thu, 15 Apr 2021 17:27:44 +0200 Subject: [PATCH 24/36] Implemented: Nurbs (but wrong texturecoords) --- meshwarp/Canvas.js | 183 +++++++++++++++++++++++++++++++++-- meshwarp/Mesh.js | 180 ++-------------------------------- meshwarp/Nurbs.js | 33 +++---- meshwarp/PrivateFunctions.js | 23 ++++- meshwarp/meshwarp.js | 34 ++++--- meshwarp/meshwarp.maxpat | 136 ++++++-------------------- 6 files changed, 269 insertions(+), 320 deletions(-) diff --git a/meshwarp/Canvas.js b/meshwarp/Canvas.js index 722bf4a..91494fa 100644 --- a/meshwarp/Canvas.js +++ b/meshwarp/Canvas.js @@ -1,5 +1,9 @@ -function Canvas(ID) { - this.ID = ID; +function Canvas() { + this.ID = null; + + this.positionMat = new JitterMatrix(3, "float32", [10, 10]); + this.boundingMat = new JitterMatrix(3, "float32", 10); + this.adjacentCellsMat = new JitterMatrix(3, "float32", 8); this.initTextureCoordMat = function(texcoordMatrix) { var xStartingPoint = (1.0/gMeshesNumber) * this.ID; @@ -15,19 +19,19 @@ function Canvas(ID) { } } - this.initPositionMat = function(positionMat) + this.initPositionMat = function() { // Set values for position matrix - for(var i=0; i= 0; k--) { + var xVal = this.positionMat.getcell(k, this.positionMat.dim[1]-1)[0]; + var yVal = this.positionMat.getcell(k, this.positionMat.dim[1]-1)[1] + pad; + boundingArray.push([xVal, yVal]); + } + // LEFT + for (var z=this.positionMat.dim[1]-2; z > 0; z--) { + var xVal = this.positionMat.getcell(0, z)[0] - pad; + var yVal = this.positionMat.getcell(0, z)[1]; + boundingArray.push([xVal, yVal]); + } + // Transfer those vertices from the array to the boundingMat matrix + for (var i=0; i this.positionMat.dim[1]-1) { + cell[1] = 1; + } + if (cellIndex[0]-1 < 0) { + cell[0] = -gWindowRatio; + } + this.adjacentCellsMat.setcell1d(0, cell[0], cell[1], 0.0); // TOP LEFT + + cell = this.positionMat.getcell(centerX, topY).slice(); + if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { + cell[1] = 1; + } + if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { + cell[1] = 1; + } + this.adjacentCellsMat.setcell1d(1, cell[0], cell[1], 0.0); // TOP CENTER + + cell = this.positionMat.getcell(rightX, topY).slice(); + if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { + cell[1] = 1; + } + if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { + cell[0] = gWindowRatio; + } + this.adjacentCellsMat.setcell1d(2, cell[0], cell[1], 0.0); // TOP RIGHT + + cell = this.positionMat.getcell(rightX, centerY).slice(); + if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { + cell[0] = gWindowRatio; + } + this.adjacentCellsMat.setcell1d(3, cell[0], cell[1], 0.0); // RIGHT CENTER + + cell = this.positionMat.getcell(rightX, bottomY).slice(); + if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { + cell[0] = gWindowRatio; + } + if (cellIndex[1]-1 < 0) { + cell[1] = -1; + } + this.adjacentCellsMat.setcell1d(4, cell[0], cell[1], 0.0); // BOTTOM RIGHT + + cell = this.positionMat.getcell(centerX, bottomY).slice(); + if (cellIndex[1]-1 < 0) { + cell[1] = -1; + } + this.adjacentCellsMat.setcell1d(5, cell[0], cell[1], 0.0); // BOTTOM CENTER + + cell = this.positionMat.getcell(leftX, bottomY).slice(); + if (cellIndex[0]-1 < 0) { + cell[0] = -gWindowRatio; + } + if (cellIndex[1]-1 < 0) { + cell[1] = -1; + } + this.adjacentCellsMat.setcell1d(6, cell[0], cell[1], 0.0); // BOTTOM LEFT + + cell = this.positionMat.getcell(leftX, centerY).slice(); + if (cellIndex[0]-1 < 0) { + cell[0] = -gWindowRatio; + } + this.adjacentCellsMat.setcell1d(7, cell[0], cell[1], 0.0); // LEFT CENTER + } + } \ No newline at end of file diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index 384010c..1ede633 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -1,22 +1,13 @@ function Mesh() { - this.ID = -1; // ID of the mesh + Canvas.call(this); // inherit from Canvas class this.meshPoints = null; this.meshGrid = null; this.meshFull = null; - this.positionMat = null; - this.boundingMat = null; - this.textureCoordMat = null; - this.adjacentCellsMat = null; - - this.canvas = null; - this.maxPos = [-1000, -1000]; - this.minPos = [1000, 1000]; + this.textureCoordMat = null; this.initMesh = function(dimensions, drawto, ID) { - this.canvas = new Canvas(ID); - this.meshPoints = new JitterObject("jit.gl.mesh"); this.meshPoints.draw_mode = "points"; this.meshPoints.depth_enable = 0; @@ -38,9 +29,6 @@ function Mesh() { this.meshFull.layer = BACKGROUND; this.meshFull.color = WHITE; - this.positionMat = new JitterMatrix(3, "float32", [10, 10]); - this.boundingMat = new JitterMatrix(3, "float32", 10); - this.adjacentCellsMat = new JitterMatrix(3, "float32", 8); this.textureCoordMat = new JitterMatrix(2, "float32", [10, 10]); this.ID = ID; @@ -49,14 +37,14 @@ function Mesh() { this.meshFull.drawto = drawto; this.setMeshDim(dimensions); // calculate and set matrices dimensions - this.canvas.initPositionMat(this.positionMat); + this.initPositionMat(); this.assignPositionMatToMesh(); // assign vertex mat to mesh this.calcBoundingPolygonMat(); - this.canvas.initTextureCoordMat(this.textureCoordMat); + this.initTextureCoordMat(this.textureCoordMat); this.assignTextureCoordMatToMesh(); - this.canvas.assignTexture(this.meshFull); + this.assignTexture(this.meshFull); postln("mesh draws to: " + this.meshPoints.drawto) } @@ -66,6 +54,7 @@ function Mesh() { this.positionMat.freepeer(); this.boundingMat.freepeer(); this.adjacentCellsMat.freepeer(); + this.textureCoordMat.freepeer(); this.meshPoints.freepeer(); this.meshGrid.freepeer(); this.meshFull.freepeer(); @@ -86,6 +75,8 @@ function Mesh() { } else { this.positionMat.dim = [4,4]; + this.boundingMat.dim = 4*2 + (4 * 2) - 4; + this.textureCoordMat.dim = [4, 4]; } } @@ -101,23 +92,12 @@ function Mesh() { tempMat.freepeer(); this.assignPositionMatToMesh(); - this.canvas.initTextureCoordMat(this.textureCoordMat); + this.initTextureCoordMat(this.textureCoordMat); this.assignTextureCoordMatToMesh(); this.calcBoundingPolygonMat(); } - this.setVertexPos = function(coordsWorld, cellIndex) { - this.positionMat.setcell2d(cellIndex[0], cellIndex[1], coordsWorld[0], coordsWorld[1], 0.0); - } - - this.getMaxMinPositionMat = function() - { - gJit3m.matrixcalc(this.positionMat, this.positionMat); - this.minPos = gJit3m.min.slice(0, 2); - this.maxPos = gJit3m.max.slice(0, 2); - } - this.assignPositionMatToMesh = function() { this.meshPoints.vertex_matrix(this.positionMat.name); this.meshGrid.vertex_matrix(this.positionMat.name); @@ -130,146 +110,6 @@ function Mesh() { //------------------------------------------- - this.calcAdjacentCellsMat = function(cellIndex) { - var cell = []; - var leftX = clamp(cellIndex[0]-1, 0, this.positionMat.dim[0]-1); - var centerX = cellIndex[0]; - var rightX = clamp(cellIndex[0]+1, 0, this.positionMat.dim[0]-1); - var topY = clamp(cellIndex[1]+1, 0, this.positionMat.dim[1]-1); - var centerY = cellIndex[1]; - var bottomY = clamp(cellIndex[1]-1, 0, this.positionMat.dim[1]-1); - - cell = this.positionMat.getcell(leftX, topY).slice(); - if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { - cell[1] = 1; - } - if (cellIndex[0]-1 < 0) { - cell[0] = -gWindowRatio; - } - this.adjacentCellsMat.setcell1d(0, cell[0], cell[1], 0.0); // TOP LEFT - - cell = this.positionMat.getcell(centerX, topY).slice(); - if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { - cell[1] = 1; - } - if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { - cell[1] = 1; - } - this.adjacentCellsMat.setcell1d(1, cell[0], cell[1], 0.0); // TOP CENTER - - cell = this.positionMat.getcell(rightX, topY).slice(); - if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { - cell[1] = 1; - } - if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { - cell[0] = gWindowRatio; - } - this.adjacentCellsMat.setcell1d(2, cell[0], cell[1], 0.0); // TOP RIGHT - - cell = this.positionMat.getcell(rightX, centerY).slice(); - if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { - cell[0] = gWindowRatio; - } - this.adjacentCellsMat.setcell1d(3, cell[0], cell[1], 0.0); // RIGHT CENTER - - cell = this.positionMat.getcell(rightX, bottomY).slice(); - if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { - cell[0] = gWindowRatio; - } - if (cellIndex[1]-1 < 0) { - cell[1] = -1; - } - this.adjacentCellsMat.setcell1d(4, cell[0], cell[1], 0.0); // BOTTOM RIGHT - - cell = this.positionMat.getcell(centerX, bottomY).slice(); - if (cellIndex[1]-1 < 0) { - cell[1] = -1; - } - this.adjacentCellsMat.setcell1d(5, cell[0], cell[1], 0.0); // BOTTOM CENTER - - cell = this.positionMat.getcell(leftX, bottomY).slice(); - if (cellIndex[0]-1 < 0) { - cell[0] = -gWindowRatio; - } - if (cellIndex[1]-1 < 0) { - cell[1] = -1; - } - this.adjacentCellsMat.setcell1d(6, cell[0], cell[1], 0.0); // BOTTOM LEFT - - cell = this.positionMat.getcell(leftX, centerY).slice(); - if (cellIndex[0]-1 < 0) { - cell[0] = -gWindowRatio; - } - this.adjacentCellsMat.setcell1d(7, cell[0], cell[1], 0.0); // LEFT CENTER - } - - this.moveVertex = function(coordsWorld, cellIndex) { - if (isPointInsidePolygon(coordsWorld, this.adjacentCellsMat)) { - this.setVertexPos(coordsWorld, cellIndex); - this.assignPositionMatToMesh(); - gGraphics.drawCircle(coordsWorld); - } - } - this.calcBoundingPolygonMat = function() { - // Get the bounding vertices that are on the edges of the polygon in clockwise order - var boundingArray = []; - var pad = 0.15; // pad so that the mesh is checked also when mouse is outside of it +} - // TOP - for (var i=0; i < this.positionMat.dim[0]; i++) { - var xVal = this.positionMat.getcell(i, 0)[0]; - var yVal = this.positionMat.getcell(i, 0)[1] - pad; - boundingArray.push([xVal, yVal]); - } - // RIGHT - for (var j=1; j < this.positionMat.dim[1]; j++) { - var xVal = this.positionMat.getcell(this.positionMat.dim[0]-1, j)[0] + pad; - var yVal = this.positionMat.getcell(this.positionMat.dim[0]-1, j)[1]; - boundingArray.push([xVal, yVal]); - } - // BOTTOM - for (var k=this.positionMat.dim[0]-2; k >= 0; k--) { - var xVal = this.positionMat.getcell(k, this.positionMat.dim[1]-1)[0]; - var yVal = this.positionMat.getcell(k, this.positionMat.dim[1]-1)[1] + pad; - boundingArray.push([xVal, yVal]); - } - // LEFT - for (var z=this.positionMat.dim[1]-2; z > 0; z--) { - var xVal = this.positionMat.getcell(0, z)[0] - pad; - var yVal = this.positionMat.getcell(0, z)[1]; - boundingArray.push([xVal, yVal]); - } - // Transfer those vertices from the array to the boundingMat matrix - for (var i=0; i 0 && dimensions[1] > 0) { - this.controlMat.dim = dimensions.slice(); + this.positionMat.dim = dimensions.slice(); + this.boundingMat.dim = dimensions[0]*2 + (dimensions[1] * 2) - 4; } else { - this.controlMat.dim = [4,4]; + this.positionMat.dim = [4,4]; } } - - this.assignControlMatToNurbs = function() { - this.nurbs.ctlmatrix(this.controlMat.name); + this.assignPositionMatToMesh = function() { + this.nurbs.ctlmatrix(this.positionMat.name); } } \ No newline at end of file diff --git a/meshwarp/PrivateFunctions.js b/meshwarp/PrivateFunctions.js index bca75f0..ecc58d8 100644 --- a/meshwarp/PrivateFunctions.js +++ b/meshwarp/PrivateFunctions.js @@ -33,4 +33,25 @@ function initNurbs() { gNurbs[i].initNurbs(gMeshSize.slice(0,2), nodeCTX.name, i); } } -initNurbs.local = 1; \ No newline at end of file +initNurbs.local = 1; + +function freeShapes() { + if (gUsingMeshesOrNurbs == "mesh") { + freeMeshes(); + } else if (gUsingMeshesOrNurbs == "nurbs") { + freeNurbs(); + } +} +freeShapes.local = 1; + +function initShapes() { + gShapes = []; + if (gUsingMeshesOrNurbs == "mesh") { + initMeshes(); + gShapes = gMeshes; // copy by reference + } else if (gUsingMeshesOrNurbs == "nurbs") { + initNurbs(); + gShapes = gNurbs; + } +} +initShapes.local = 1; \ No newline at end of file diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index 995b659..a74ee43 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -10,6 +10,7 @@ include("Canvas.js"); // GLOBAL VARIABLES var gMeshes = []; var gNurbs = []; +var gShapes = []; var gMousePosScreen = []; var gMinimumSelectionDist = 0.06; var gWindowDim = [512,512]; @@ -23,6 +24,9 @@ var gMeshesNumber = 4; declareattribute("gMeshesNumber", null, null, 1); var gMeshSize = [4, 8]; declareattribute("gMeshSize", null, null, 1); +var gUsingMeshesOrNurbs = "nurbs"; // USE MESHES OR NURBS +declareattribute("gUsingMeshesOrNurbs", null, null, 1); + // OBJECTS USED GLOBALLY @@ -68,11 +72,9 @@ function init(meshSizeX, meshSizeY) { gMeshSize = [meshSizeX, meshSizeY]; nodeCTX.drawto = drawto; videoplane.drawto = drawto; - // freeMeshes(); - // initMeshes(); - freeNurbs(); - initNurbs(); + freeShapes(); + initShapes(); gGraphics.initGraphicElements(); } @@ -86,21 +88,21 @@ function meshes(numberMeshes) { // Resize all the meshes function resize_meshes(meshSizeX, meshSizeY) { - for (mesh in gMeshes) { - gMeshes[mesh].resizeMesh(meshSizeX, meshSizeY); + for (mesh in gShapes) { + gShapes[mesh].resizeMesh(meshSizeX, meshSizeY); } } // Resize single mesh function resize_mesh(index, meshSizeX, meshSizeY) { - if (index < gMeshes.length && index >= 0) { - gMeshes[index].resizeMesh(meshSizeX, meshSizeY); + if (index < gShapes.length && index >= 0) { + gShapes[index].resizeMesh(meshSizeX, meshSizeY); } } function show_meshes(show) { - for (mesh in gMeshes) { - gMeshes[mesh].showMesh(show); + for (mesh in gShapes) { + gShapes[mesh].showMesh(show); } if (!show) { gGraphics.reset(); @@ -170,12 +172,12 @@ function swapcallback(event){ if (mouseClicked) { //print(gSelectionStruct.cellIndex) if (gSelectionStruct.cellIndex[0] != -1 && gSelectionStruct.meshIDToClick != -1) { // we are clicking on a vertex - gMeshes[gSelectionStruct.meshIDToClick].moveVertex(mouseWorld, gSelectionStruct.cellIndex.slice(0,2)); // move the vertex with the mouse + gShapes[gSelectionStruct.meshIDToClick].moveVertex(mouseWorld, gSelectionStruct.cellIndex.slice(0,2)); // move the vertex with the mouse } } else { // mouse is released // if we moved some vertices if (gSelectionStruct.meshIDToClick != -1) { - gMeshes[gSelectionStruct.meshIDToClick].calcBoundingPolygonMat() // recalculate the bounding matrix + gShapes[gSelectionStruct.meshIDToClick].calcBoundingPolygonMat(); // recalculate the bounding matrix gSelectionStruct.reset(); // reset the values in the selectionStruct } gGraphics.reset(); // delete the circle @@ -192,8 +194,8 @@ function swapcallback(event){ gSelectionStruct.reset(); // reset all the struct values // Iterate through meshes to check in which one the mouse is in - for (var mesh in gMeshes) { - var meshID = gMeshes[mesh].checkIfMouseInsideMesh(mouseWorld); // Get the ID of the mesh in which the mouse is in (if it's inside any) + for (var mesh in gShapes) { + var meshID = gShapes[mesh].checkIfMouseInsideMesh(mouseWorld); // Get the ID of the mesh in which the mouse is in (if it's inside any) if (meshID != -1) { gSelectionStruct.meshIDsToCheckArr.push(meshID); // push in this array all the IDs of the meshes the mouse is in (it could be more than one when meshes overlap) } @@ -204,7 +206,7 @@ function swapcallback(event){ } else { // if we are on a mesh, let's check if the mouse is close to a vertex for (var i=0; i Date: Fri, 16 Apr 2021 18:57:11 +0200 Subject: [PATCH 25/36] Deleted Canvas. Fixed Mesh mode. Implemented scale for new window size. --- meshwarp/Canvas.js | 7 +- meshwarp/Mesh.js | 290 +++++++++++++++++++++++++++++++---- meshwarp/PrivateFunctions.js | 54 ++----- meshwarp/meshwarp.js | 79 +++++----- meshwarp/meshwarp.maxpat | 210 ++++++++----------------- 5 files changed, 386 insertions(+), 254 deletions(-) diff --git a/meshwarp/Canvas.js b/meshwarp/Canvas.js index 91494fa..d64821a 100644 --- a/meshwarp/Canvas.js +++ b/meshwarp/Canvas.js @@ -47,7 +47,6 @@ function Canvas() { return -1; } } - this.mouseIsCloseToVertex = function(mouseWorld) { for (var i=0; i= 0; k--) { + var xVal = this.positionMat.getcell(k, this.positionMat.dim[1]-1)[0]; + var yVal = this.positionMat.getcell(k, this.positionMat.dim[1]-1)[1] + pad; + boundingArray.push([xVal, yVal]); + } + // LEFT + for (var z=this.positionMat.dim[1]-2; z > 0; z--) { + var xVal = this.positionMat.getcell(0, z)[0] - pad; + var yVal = this.positionMat.getcell(0, z)[1]; + boundingArray.push([xVal, yVal]); + } + // Transfer those vertices from the array to the boundingMat matrix + for (var i=0; i this.positionMat.dim[1]-1) { + cell[1] = 1; + } + if (cellIndex[0]-1 < 0) { + cell[0] = -gWindowRatio; + } + this.adjacentCellsMat.setcell1d(0, cell[0], cell[1], 0.0); // TOP LEFT + + cell = this.positionMat.getcell(centerX, topY).slice(); + if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { + cell[1] = 1; + } + if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { + cell[1] = 1; + } + this.adjacentCellsMat.setcell1d(1, cell[0], cell[1], 0.0); // TOP CENTER + + cell = this.positionMat.getcell(rightX, topY).slice(); + if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { + cell[1] = 1; + } + if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { + cell[0] = gWindowRatio; + } + this.adjacentCellsMat.setcell1d(2, cell[0], cell[1], 0.0); // TOP RIGHT + + cell = this.positionMat.getcell(rightX, centerY).slice(); + if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { + cell[0] = gWindowRatio; + } + this.adjacentCellsMat.setcell1d(3, cell[0], cell[1], 0.0); // RIGHT CENTER + + cell = this.positionMat.getcell(rightX, bottomY).slice(); + if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { + cell[0] = gWindowRatio; + } + if (cellIndex[1]-1 < 0) { + cell[1] = -1; + } + this.adjacentCellsMat.setcell1d(4, cell[0], cell[1], 0.0); // BOTTOM RIGHT + + cell = this.positionMat.getcell(centerX, bottomY).slice(); + if (cellIndex[1]-1 < 0) { + cell[1] = -1; + } + this.adjacentCellsMat.setcell1d(5, cell[0], cell[1], 0.0); // BOTTOM CENTER + + cell = this.positionMat.getcell(leftX, bottomY).slice(); + if (cellIndex[0]-1 < 0) { + cell[0] = -gWindowRatio; + } + if (cellIndex[1]-1 < 0) { + cell[1] = -1; + } + this.adjacentCellsMat.setcell1d(6, cell[0], cell[1], 0.0); // BOTTOM LEFT + + cell = this.positionMat.getcell(leftX, centerY).slice(); + if (cellIndex[0]-1 < 0) { + cell[0] = -gWindowRatio; + } + this.adjacentCellsMat.setcell1d(7, cell[0], cell[1], 0.0); // LEFT CENTER + } } diff --git a/meshwarp/PrivateFunctions.js b/meshwarp/PrivateFunctions.js index ecc58d8..9902971 100644 --- a/meshwarp/PrivateFunctions.js +++ b/meshwarp/PrivateFunctions.js @@ -1,57 +1,29 @@ +function setWindowRatio(dims) { + gWindowRatio = dims[0] / dims[1]; +} +setWindowRatio.local = 1; + +function setNodeDrawto() { + nodeCTX.drawto = drawto; + videoplane.drawto = drawto; +} +setNodeDrawto.local = 1; + function freeMeshes() { if (gMeshes.length > 0) { for (var mesh in gMeshes) { gMeshes[mesh].freeMesh(); } } + gMeshes = []; } freeMeshes.local = 1; -function freeNurbs() { - if (gNurbs.length > 0) { - for (var nurbs in gNurbs) { - gNurbs[nurbs].freeNurbs(); - } - } -} -freeNurbs.local = 1; - function initMeshes() { - postln("init meshes") gMeshes = []; for (var i=0; i 0) { + gMeshesNumber = numberMeshes; + freeMeshes(); + initMeshes(); + } } // Resize all the meshes function resize_meshes(meshSizeX, meshSizeY) { - for (mesh in gShapes) { - gShapes[mesh].resizeMesh(meshSizeX, meshSizeY); + for (mesh in gMeshes) { + gMeshes[mesh].resizeMesh(meshSizeX, meshSizeY); } } // Resize single mesh function resize_mesh(index, meshSizeX, meshSizeY) { - if (index < gShapes.length && index >= 0) { - gShapes[index].resizeMesh(meshSizeX, meshSizeY); + if (index < gMeshes.length && index >= 0) { + print("index "+index) + gMeshes[index].resizeMesh(meshSizeX, meshSizeY); } } function show_meshes(show) { - for (mesh in gShapes) { - gShapes[mesh].showMesh(show); + for (mesh in gMeshes) { + gMeshes[mesh].showMesh(show); } if (!show) { gGraphics.reset(); @@ -141,6 +140,8 @@ function setdrawto(newdrawto) { postln("setdrawto " + newdrawto); drawto = newdrawto; + setNodeDrawto(); + if(swaplisten) swaplisten.subjectname = ""; swaplisten = new JitterListener(drawto, swapcallback); @@ -155,10 +156,16 @@ function swapcallback(event){ case ("swap" || "draw"): // RENDER BANG if (gWindowDim[0] != nodeCTX.dim[0] || gWindowDim[1] != nodeCTX.dim[1]) { - setWindowRatio(nodeCTX.dim[0] / nodeCTX.dim[1]); + //print(nodeCTX.dim) + setWindowRatio(nodeCTX.dim); gWindowDim = nodeCTX.dim.slice(); - postln("window Dimensions: "+gWindowDim); - init(g); // RE INIT everything when window size is modified (temporary) + if (gMeshes.length < 1) { + gWindowPrevRatio = gWindowRatio; + init(gMeshSize[0], gMeshSize[1]); // RE INIT everything when window size is modified (temporary) + } + for (var mesh in gMeshes) { + gMeshes[mesh].scaleMesh(); + } } break; @@ -166,18 +173,17 @@ function swapcallback(event){ if (gShowMeshes) { gMousePosScreen = (event.args); var mouseClicked = gMousePosScreen[2]; - //postln(gMousePosScreen); var mouseWorld = gGraphics.transformMouseToWorld(gMousePosScreen); // transformMouseFromScreenToWorld2D(gMousePosScreen); if (mouseClicked) { //print(gSelectionStruct.cellIndex) if (gSelectionStruct.cellIndex[0] != -1 && gSelectionStruct.meshIDToClick != -1) { // we are clicking on a vertex - gShapes[gSelectionStruct.meshIDToClick].moveVertex(mouseWorld, gSelectionStruct.cellIndex.slice(0,2)); // move the vertex with the mouse + gMeshes[gSelectionStruct.meshIDToClick].moveVertex(mouseWorld, gSelectionStruct.cellIndex.slice(0,2)); // move the vertex with the mouse } } else { // mouse is released // if we moved some vertices if (gSelectionStruct.meshIDToClick != -1) { - gShapes[gSelectionStruct.meshIDToClick].calcBoundingPolygonMat(); // recalculate the bounding matrix + gMeshes[gSelectionStruct.meshIDToClick].calcBoundingPolygonMat(); // recalculate the bounding matrix gSelectionStruct.reset(); // reset the values in the selectionStruct } gGraphics.reset(); // delete the circle @@ -194,8 +200,8 @@ function swapcallback(event){ gSelectionStruct.reset(); // reset all the struct values // Iterate through meshes to check in which one the mouse is in - for (var mesh in gShapes) { - var meshID = gShapes[mesh].checkIfMouseInsideMesh(mouseWorld); // Get the ID of the mesh in which the mouse is in (if it's inside any) + for (var mesh in gMeshes) { + var meshID = gMeshes[mesh].checkIfMouseInsideMesh(mouseWorld); // Get the ID of the mesh in which the mouse is in (if it's inside any) if (meshID != -1) { gSelectionStruct.meshIDsToCheckArr.push(meshID); // push in this array all the IDs of the meshes the mouse is in (it could be more than one when meshes overlap) } @@ -206,7 +212,7 @@ function swapcallback(event){ } else { // if we are on a mesh, let's check if the mouse is close to a vertex for (var i=0; i Date: Fri, 16 Apr 2021 18:58:37 +0200 Subject: [PATCH 26/36] Physically removed Canvas.js and Nurbs.js --- meshwarp/Canvas.js | 208 --------------------------------------------- meshwarp/Nurbs.js | 48 ----------- 2 files changed, 256 deletions(-) delete mode 100644 meshwarp/Canvas.js delete mode 100644 meshwarp/Nurbs.js diff --git a/meshwarp/Canvas.js b/meshwarp/Canvas.js deleted file mode 100644 index d64821a..0000000 --- a/meshwarp/Canvas.js +++ /dev/null @@ -1,208 +0,0 @@ -function Canvas() { - this.ID = null; - - this.positionMat = new JitterMatrix(3, "float32", [10, 10]); - this.boundingMat = new JitterMatrix(3, "float32", 10); - this.adjacentCellsMat = new JitterMatrix(3, "float32", 8); - - this.initTextureCoordMat = function(texcoordMatrix) { - var xStartingPoint = (1.0/gMeshesNumber) * this.ID; - var xCoordTarget = xStartingPoint + (1.0/gMeshesNumber); // 0 a 1. +0.25 - - for (var i=0; i= 0; k--) { - var xVal = this.positionMat.getcell(k, this.positionMat.dim[1]-1)[0]; - var yVal = this.positionMat.getcell(k, this.positionMat.dim[1]-1)[1] + pad; - boundingArray.push([xVal, yVal]); - } - // LEFT - for (var z=this.positionMat.dim[1]-2; z > 0; z--) { - var xVal = this.positionMat.getcell(0, z)[0] - pad; - var yVal = this.positionMat.getcell(0, z)[1]; - boundingArray.push([xVal, yVal]); - } - // Transfer those vertices from the array to the boundingMat matrix - for (var i=0; i this.positionMat.dim[1]-1) { - cell[1] = 1; - } - if (cellIndex[0]-1 < 0) { - cell[0] = -gWindowRatio; - } - this.adjacentCellsMat.setcell1d(0, cell[0], cell[1], 0.0); // TOP LEFT - - cell = this.positionMat.getcell(centerX, topY).slice(); - if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { - cell[1] = 1; - } - if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { - cell[1] = 1; - } - this.adjacentCellsMat.setcell1d(1, cell[0], cell[1], 0.0); // TOP CENTER - - cell = this.positionMat.getcell(rightX, topY).slice(); - if (cellIndex[1]+1 > this.positionMat.dim[1]-1) { - cell[1] = 1; - } - if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { - cell[0] = gWindowRatio; - } - this.adjacentCellsMat.setcell1d(2, cell[0], cell[1], 0.0); // TOP RIGHT - - cell = this.positionMat.getcell(rightX, centerY).slice(); - if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { - cell[0] = gWindowRatio; - } - this.adjacentCellsMat.setcell1d(3, cell[0], cell[1], 0.0); // RIGHT CENTER - - cell = this.positionMat.getcell(rightX, bottomY).slice(); - if (cellIndex[0]+1 > this.positionMat.dim[0]-1) { - cell[0] = gWindowRatio; - } - if (cellIndex[1]-1 < 0) { - cell[1] = -1; - } - this.adjacentCellsMat.setcell1d(4, cell[0], cell[1], 0.0); // BOTTOM RIGHT - - cell = this.positionMat.getcell(centerX, bottomY).slice(); - if (cellIndex[1]-1 < 0) { - cell[1] = -1; - } - this.adjacentCellsMat.setcell1d(5, cell[0], cell[1], 0.0); // BOTTOM CENTER - - cell = this.positionMat.getcell(leftX, bottomY).slice(); - if (cellIndex[0]-1 < 0) { - cell[0] = -gWindowRatio; - } - if (cellIndex[1]-1 < 0) { - cell[1] = -1; - } - this.adjacentCellsMat.setcell1d(6, cell[0], cell[1], 0.0); // BOTTOM LEFT - - cell = this.positionMat.getcell(leftX, centerY).slice(); - if (cellIndex[0]-1 < 0) { - cell[0] = -gWindowRatio; - } - this.adjacentCellsMat.setcell1d(7, cell[0], cell[1], 0.0); // LEFT CENTER - } - -} \ No newline at end of file diff --git a/meshwarp/Nurbs.js b/meshwarp/Nurbs.js deleted file mode 100644 index 20e828b..0000000 --- a/meshwarp/Nurbs.js +++ /dev/null @@ -1,48 +0,0 @@ -function Nurbs() { - Canvas.call(this); // inherit from Canvas class - - this.nurbs = null; - - this.initNurbs = function(dimensions, drawto, ID) { - this.nurbs = new JitterObject("jit.gl.nurbs"); - this.nurbs.dim = [40, 40]; - this.nurbs.depth_enable = 0; - this.nurbs.layer = BACKGROUND; - this.nurbs.color = WHITE; - this.nurbs.ctlshow = 1; - this.nurbs.drawto = drawto; - // this.nurbs.tex_map = 1; - // this.nurbs.tex_plane_s = [0.25, 0, 0, 0]; - - - this.ID = ID; - this.setMeshDim(dimensions); - this.initPositionMat(); - this.assignPositionMatToMesh(); - this.calcBoundingPolygonMat(); - - this.assignTexture(this.nurbs); - } - - this.freeNurbs = function() { - if (this.controlMat) { - this.nurbs.freepeer(); - this.controlMat.freepeer(); - } - } - - this.setMeshDim = function(dimensions) { - if (dimensions[0] > 0 && dimensions[1] > 0) { - this.positionMat.dim = dimensions.slice(); - this.boundingMat.dim = dimensions[0]*2 + (dimensions[1] * 2) - 4; - } - else { - this.positionMat.dim = [4,4]; - } - } - - this.assignPositionMatToMesh = function() { - this.nurbs.ctlmatrix(this.positionMat.name); - } - -} \ No newline at end of file From db1f6f427d22aad17c479d136e760ea1f7ba041e Mon Sep 17 00:00:00 2001 From: FedFod Date: Fri, 16 Apr 2021 23:29:49 +0200 Subject: [PATCH 27/36] Stuck with NURBS listener THIS error --- meshwarp/Mesh.js | 92 ++++++++++++++++++++++++++-------------- meshwarp/Utilities.js | 10 ++++- meshwarp/meshwarp.js | 2 +- meshwarp/meshwarp.maxpat | 45 +++++++++++++++++--- 4 files changed, 110 insertions(+), 39 deletions(-) diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index a46f745..a693d30 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -5,12 +5,14 @@ function Mesh() { this.meshGrid = null; this.meshFull = null; this.nurbs = null; + this.nurbsDim = [10, 10]; this.useNurbs = -1; this.currentWindowRatio = -1; + this.nurbsLstnr = null; this.textureCoordMat = new JitterMatrix(2, "float32", [10, 10]);; - this.nurbsMat = new JitterMatrix(); + this.nurbsMat = new JitterMatrix(3, "float32", [4, 4]); this.positionMat = new JitterMatrix(3, "float32", [10, 10]); this.boundingMat = new JitterMatrix(3, "float32", 10); this.adjacentCellsMat = new JitterMatrix(3, "float32", 8); @@ -25,16 +27,21 @@ function Mesh() { this.initMeshFull(drawto); this.initNurbs(drawto); - this.setMeshDim(dimensions); // calculate and set matrices dimensions - this.initPositionMat(); - this.assignPositionMatToMesh(); // assign vertex mat to mesh - this.assignControlToNurbs(); - this.calcBoundingPolygonMat(); - - this.initTextureCoordMat(); - this.assignTextureCoordMatToMesh(); + this.setMeshDim(dimensions); // calculate and set matrices dimensions + this.initPositionMat(); // init vertex mat + if (this.useNurbs) { + this.assignNurbsMatToMesh(); // assign the matrix output from the nurbs to the mesh + } else { + this.assignPositionMatToMesh(); // assign vertex mat to mesh + } + this.assignControlMatToNurbs(); // assign vertex mat to nurbs + + this.calcBoundingPolygonMat(); // calculate + + this.initTextureCoordMat(); // init texture coord mat + this.assignTextureCoordMatToMesh(); // assign texture coord mat to mesh - this.assignTexture(this.meshFull); + this.assignTexture(); } this.initMeshPoints = function(drawto_) { @@ -69,14 +76,30 @@ function Mesh() { this.initNurbs = function(drawto_) { this.nurbs = new JitterObject("jit.gl.nurbs"); - this.nurbs.dim = [40, 40]; + this.nurbs.dim = this.nurbsDim.slice(); this.nurbs.depth_enable = 0; this.nurbs.layer = BACKGROUND; this.nurbs.color = WHITE; - this.nurbs.ctlshow = 0; + this.nurbs.ctlshow = 1; this.nurbs.matrixoutput = 1; - this.nurbs.enable = this.useNurbs; this.nurbs.drawto = drawto_; + this.nurbs.enable = this.useNurbs; + this.nurbs.name = "nurbs_"+this.ID; + + this.nurbsMat = new JitterMatrix(3, "float32", this.nurbs.dim); + + var self = this; + + this.nurbsLstnr = new JitterListener(this.nurbs.name, ( function(event) { + if (event.eventname == "matrixoutput") { + print(this.ID) + // create javascript matrix from matrixoutput event arg + var tempMat = new JitterMatrix(event.args[0]); + copy2DMatrixByValues(self.nurbsMat, tempMat); + tempMat.freepeer(); + // print("thisnurbsmat "+tempMat.getcell(0,0)); + } + }).bind(this) ); } this.freeMesh = function() { @@ -103,7 +126,11 @@ function Mesh() { if (dimensions[0] > 0 && dimensions[1] > 0) { this.positionMat.dim = dimensions.slice(); this.boundingMat.dim = dimensions[0]*2 + (dimensions[1] * 2) - 4; - this.textureCoordMat.dim = dimensions.slice(); + if (this.useNurbs) { + this.textureCoordMat.dim = this.nurbsDim.slice(); + } else { + this.textureCoordMat.dim = dimensions.slice(); + } } else { this.positionMat.dim = [3,3]; @@ -136,20 +163,20 @@ function Mesh() { this.meshFull.vertex_matrix(this.positionMat.name); } + this.assignNurbsMatToMesh = function() { + this.meshPoints.vertex_matrix(this.positionMat.name); + this.meshGrid.vertex_matrix(this.positionMat.name); + this.meshFull.vertex_matrix(this.nurbsMat.name); + } + this.assignTextureCoordMatToMesh = function() { this.meshFull.texcoord_matrix(this.textureCoordMat.name); } - this.assignControlToNurbs = function() { + this.assignControlMatToNurbs = function() { this.nurbs.ctlmatrix(this.positionMat.name); } - - this.assignNurbsMatToMesh = function() { - this.meshPoints.vertex_matrix(this.positionMat.name); - this.meshGrid.vertex_matrix(this.positionMat.name); - this.meshFull.vertex_matrix(this.positionMat.name); - } - + //------------------------------------------- this.initTextureCoordMat = function() { @@ -193,10 +220,11 @@ function Mesh() { } this.currentWindowRatio = gWindowRatio; this.assignPositionMatToMesh(); + if (this.useNurbs) { this.assignControlMatToNurbs(); } } - this.assignTexture = function(mesh) { - mesh.jit_gl_texture("TEST"); + this.assignTexture = function() { + this.meshFull.jit_gl_texture("TEST"); } this.checkIfMouseInsideMesh = function(mouseWorld) { @@ -226,17 +254,19 @@ function Mesh() { this.moveVertex = function(coordsWorld, cellIndex) { if (isPointInsidePolygon(coordsWorld, this.adjacentCellsMat)) { - this.setVertexPos(coordsWorld, cellIndex); - if (this.useNurbs) { - this.assignControlToNurbs(); - } else { + this.setVertexPosInMat(coordsWorld, cellIndex); + if (this.useNurbs) { + this.assignControlMatToNurbs(); + // print("mat "+this.nurbsMat.getcell(0,0)) + this.assignNurbsMatToMesh(); + } else { this.assignPositionMatToMesh(); - } - gGraphics.drawCircle(coordsWorld); + } + gGraphics.drawCircle(coordsWorld); } } - this.setVertexPos = function(coordsWorld, cellIndex) { + this.setVertexPosInMat = function(coordsWorld, cellIndex) { this.positionMat.setcell2d(cellIndex[0], cellIndex[1], coordsWorld[0], coordsWorld[1], 0.0); } diff --git a/meshwarp/Utilities.js b/meshwarp/Utilities.js index 7bcc062..288dafb 100644 --- a/meshwarp/Utilities.js +++ b/meshwarp/Utilities.js @@ -9,9 +9,15 @@ var MIDDLE_1 = 11; var FRONT = 12; +function copy2DMatrixByValues(mat1, mat2) { + mat1.dim = mat2.dim.slice(); -function switchDrawModeMeshes(mode) { - + for (var i=0; i Date: Fri, 16 Apr 2021 17:57:52 -0400 Subject: [PATCH 28/36] one possible implementation for the nurbs listener --- meshwarp/Mesh.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index a693d30..f9e2f39 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -1,3 +1,19 @@ +function nurbscallback(event) { + //post("nurbscallback: " + event.subjectname + " sent "+ event.eventname + " with (" + event.args + ")\n"); + if (event.eventname == "matrixoutput") { + var mesh = nurbsmap[event.subjectname]; + if(mesh) { + post("retrieved mesh " + mesh.ID + "\n"); + // create javascript matrix from matrixoutput event arg + var tempMat = new JitterMatrix(event.args[0]); + copy2DMatrixByValues(mesh.nurbsMat, tempMat); + tempMat.freepeer(); + // print("thisnurbsmat "+tempMat.getcell(0,0)); + } + } +} +var nurbsmap = {}; + function Mesh() { this.ID = -1; @@ -90,7 +106,9 @@ function Mesh() { var self = this; - this.nurbsLstnr = new JitterListener(this.nurbs.name, ( function(event) { + this.nurbsLstnr = new JitterListener(this.nurbs.name, nurbscallback); + nurbsmap[this.nurbs.name] = this; + /* this.nurbsLstnr = new JitterListener(this.nurbs.name, ( function(event) { if (event.eventname == "matrixoutput") { print(this.ID) // create javascript matrix from matrixoutput event arg @@ -99,7 +117,7 @@ function Mesh() { tempMat.freepeer(); // print("thisnurbsmat "+tempMat.getcell(0,0)); } - }).bind(this) ); + }).bind(this) ); */ } this.freeMesh = function() { @@ -112,6 +130,8 @@ function Mesh() { this.meshPoints.freepeer(); this.meshGrid.freepeer(); this.meshFull.freepeer(); + this.nurbsLstnr.subjectname = ""; + nurbsmap[this.nurbs.name] = null; this.nurbs.freepeer(); } } From 00096c83108b910cad05970d49024568fb8bcec3 Mon Sep 17 00:00:00 2001 From: FedFod Date: Sat, 17 Apr 2021 18:40:04 +0200 Subject: [PATCH 29/36] Added: switch mode without reinit. Fixed bugs. --- meshwarp/Mesh.js | 92 +++++++++++++++++++++++++--------------- meshwarp/meshwarp.js | 8 ++-- meshwarp/meshwarp.maxpat | 65 +++++++--------------------- 3 files changed, 78 insertions(+), 87 deletions(-) diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index f9e2f39..c76347b 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -3,12 +3,13 @@ function nurbscallback(event) { if (event.eventname == "matrixoutput") { var mesh = nurbsmap[event.subjectname]; if(mesh) { - post("retrieved mesh " + mesh.ID + "\n"); // create javascript matrix from matrixoutput event arg var tempMat = new JitterMatrix(event.args[0]); - copy2DMatrixByValues(mesh.nurbsMat, tempMat); - tempMat.freepeer(); - // print("thisnurbsmat "+tempMat.getcell(0,0)); + mesh.nurbsMat.frommatrix(tempMat); + if (!mesh.hasNurbsMat) { + mesh.assignNurbsMatToMesh(); + mesh.hasNurbsMat = 1; + } } } } @@ -21,11 +22,12 @@ function Mesh() { this.meshGrid = null; this.meshFull = null; this.nurbs = null; - this.nurbsDim = [10, 10]; + this.nurbsDim = [40, 40]; this.useNurbs = -1; this.currentWindowRatio = -1; this.nurbsLstnr = null; + this.hasNurbsMat = 0; this.textureCoordMat = new JitterMatrix(2, "float32", [10, 10]);; this.nurbsMat = new JitterMatrix(3, "float32", [4, 4]); @@ -46,20 +48,37 @@ function Mesh() { this.setMeshDim(dimensions); // calculate and set matrices dimensions this.initPositionMat(); // init vertex mat if (this.useNurbs) { - this.assignNurbsMatToMesh(); // assign the matrix output from the nurbs to the mesh + this.assignControlMatToNurbs(); // assign vertex mat to nurbs + // this.assignNurbsMatToMesh(); // assign the matrix output from the nurbs to the mesh + this.hasNurbsMat = 0; } else { this.assignPositionMatToMesh(); // assign vertex mat to mesh } - this.assignControlMatToNurbs(); // assign vertex mat to nurbs - this.calcBoundingPolygonMat(); // calculate + this.calcMeshBoundsMat(); // calculate this.initTextureCoordMat(); // init texture coord mat - this.assignTextureCoordMatToMesh(); // assign texture coord mat to mesh this.assignTexture(); } + this.changeMode = function(mode) { + if (mode != this.useNurbs) { + this.useNurbs = mode; + this.nurbs.enable = this.useNurbs; + if (this.useNurbs) { + this.assignControlMatToNurbs(); + // this.assignNurbsMatToMesh(); + this.hasNurbsMat = 0; + this.textureCoordMat.dim = this.nurbsDim.slice(); + } else { + this.assignPositionMatToMesh(); // assign vertex mat to mesh + this.textureCoordMat.dim = this.positionMat.dim.slice(); + } + this.initTextureCoordMat(); + } + } + this.initMeshPoints = function(drawto_) { this.meshPoints = new JitterObject("jit.gl.mesh"); this.meshPoints.draw_mode = "points"; @@ -96,7 +115,7 @@ function Mesh() { this.nurbs.depth_enable = 0; this.nurbs.layer = BACKGROUND; this.nurbs.color = WHITE; - this.nurbs.ctlshow = 1; + this.nurbs.ctlshow = 0; this.nurbs.matrixoutput = 1; this.nurbs.drawto = drawto_; this.nurbs.enable = this.useNurbs; @@ -104,20 +123,8 @@ function Mesh() { this.nurbsMat = new JitterMatrix(3, "float32", this.nurbs.dim); - var self = this; - this.nurbsLstnr = new JitterListener(this.nurbs.name, nurbscallback); nurbsmap[this.nurbs.name] = this; - /* this.nurbsLstnr = new JitterListener(this.nurbs.name, ( function(event) { - if (event.eventname == "matrixoutput") { - print(this.ID) - // create javascript matrix from matrixoutput event arg - var tempMat = new JitterMatrix(event.args[0]); - copy2DMatrixByValues(self.nurbsMat, tempMat); - tempMat.freepeer(); - // print("thisnurbsmat "+tempMat.getcell(0,0)); - } - }).bind(this) ); */ } this.freeMesh = function() { @@ -159,7 +166,13 @@ function Mesh() { } } - this.resizeMesh = function(sizeX, sizeY) { + this.resizeMesh = function(sizeX_, sizeY_) { + var sizeX = sizeX_; var sizeY = sizeY_; + + if (this.useNurbs) { + sizeX = Math.max(sizeX, 4); + sizeY = Math.max(sizeY, 4); + } var tempMat = new JitterMatrix(3, "float32", [sizeX, sizeY]); tempMat.interp = 1; @@ -170,10 +183,16 @@ function Mesh() { this.positionMat.frommatrix(tempMat); tempMat.freepeer(); - this.assignPositionMatToMesh(); + if (this.useNurbs) { + this.assignControlMatToNurbs(); // set the new position as the control matrix for nurbs + // this.assignNurbsMatToMesh(); + this.hasNurbsMat = 0; + } else { + this.assignPositionMatToMesh(); + } + this.initTextureCoordMat(); - this.assignTextureCoordMatToMesh(); - this.calcBoundingPolygonMat(); + this.calcMeshBoundsMat(); } @@ -202,7 +221,6 @@ function Mesh() { this.initTextureCoordMat = function() { var xStartingPoint = (1.0/gMeshesNumber) * this.ID; var xCoordTarget = xStartingPoint + (1.0/gMeshesNumber); // 0 a 1. +0.25 - for (var i=0; i= 0) { - print("index "+index) gMeshes[index].resizeMesh(meshSizeX, meshSizeY); } } @@ -183,7 +185,7 @@ function swapcallback(event){ } else { // mouse is released // if we moved some vertices if (gSelectionStruct.meshIDToClick != -1) { - gMeshes[gSelectionStruct.meshIDToClick].calcBoundingPolygonMat(); // recalculate the bounding matrix + gMeshes[gSelectionStruct.meshIDToClick].calcMeshBoundsMat(); // recalculate the bounding matrix only when finished dragging gSelectionStruct.reset(); // reset the values in the selectionStruct } gGraphics.reset(); // delete the circle diff --git a/meshwarp/meshwarp.maxpat b/meshwarp/meshwarp.maxpat index 025bf5f..33c8e67 100644 --- a/meshwarp/meshwarp.maxpat +++ b/meshwarp/meshwarp.maxpat @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 665.0, 162.0, 724.0, 744.0 ], + "rect" : [ 665.0, 154.0, 860.0, 752.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -39,34 +39,6 @@ "subpatcher_template" : "", "assistshowspatchername" : 0, "boxes" : [ { - "box" : { - "cols" : 20, - "fontface" : 0, - "fontname" : "Arial", - "fontsize" : 12.0, - "id" : "obj-7", - "maxclass" : "jit.cellblock", - "numinlets" : 2, - "numoutlets" : 4, - "outlettype" : [ "list", "", "", "" ], - "patching_rect" : [ 154.0, 655.0, 423.0, 200.0 ], - "rows" : 20 - } - - } -, { - "box" : { - "id" : "obj-6", - "maxclass" : "newobj", - "numinlets" : 1, - "numoutlets" : 2, - "outlettype" : [ "jit_matrix", "" ], - "patching_rect" : [ 310.0, 618.0, 155.0, 22.0 ], - "text" : "jit.gl.nurbs @matrixoutput 1" - } - - } -, { "box" : { "id" : "obj-49", "maxclass" : "toggle", @@ -96,7 +68,7 @@ "maxclass" : "comment", "numinlets" : 1, "numoutlets" : 0, - "patching_rect" : [ 525.0, 137.0, 113.0, 20.0 ], + "patching_rect" : [ 419.0, 136.0, 113.0, 20.0 ], "text" : "Resize single mesh" } @@ -107,7 +79,7 @@ "maxclass" : "comment", "numinlets" : 1, "numoutlets" : 0, - "patching_rect" : [ 525.0, 22.0, 106.0, 20.0 ], + "patching_rect" : [ 419.0, 21.0, 106.0, 20.0 ], "text" : "Resize all meshes" } @@ -118,7 +90,7 @@ "maxclass" : "comment", "numinlets" : 1, "numoutlets" : 0, - "patching_rect" : [ 577.0, 165.0, 37.0, 20.0 ], + "patching_rect" : [ 471.0, 164.0, 37.0, 20.0 ], "text" : "index" } @@ -131,7 +103,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 687.25, 187.0, 50.0, 22.0 ] + "patching_rect" : [ 581.25, 186.0, 50.0, 22.0 ] } } @@ -143,7 +115,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 631.25, 187.0, 50.0, 22.0 ] + "patching_rect" : [ 525.25, 186.0, 50.0, 22.0 ] } } @@ -156,7 +128,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 577.0, 187.0, 50.0, 22.0 ] + "patching_rect" : [ 471.0, 186.0, 50.0, 22.0 ] } } @@ -168,7 +140,7 @@ "numoutlets" : 1, "outlettype" : [ "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 527.75, 187.0, 24.0, 24.0 ] + "patching_rect" : [ 421.75, 186.0, 24.0, 24.0 ] } } @@ -179,7 +151,7 @@ "numinlets" : 4, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 527.75, 223.0, 166.75, 22.0 ], + "patching_rect" : [ 421.75, 222.0, 166.75, 22.0 ], "text" : "pack resize_mesh i i i" } @@ -216,7 +188,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 644.5, 57.0, 50.0, 22.0 ] + "patching_rect" : [ 538.5, 56.0, 50.0, 22.0 ] } } @@ -228,7 +200,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 580.5, 57.0, 50.0, 22.0 ] + "patching_rect" : [ 474.5, 56.0, 50.0, 22.0 ] } } @@ -240,7 +212,7 @@ "numoutlets" : 1, "outlettype" : [ "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 525.0, 57.0, 24.0, 24.0 ] + "patching_rect" : [ 419.0, 56.0, 24.0, 24.0 ] } } @@ -251,7 +223,7 @@ "numinlets" : 3, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 525.0, 93.0, 130.0, 22.0 ], + "patching_rect" : [ 419.0, 92.0, 130.0, 22.0 ], "text" : "pack resize_meshes i i" } @@ -413,7 +385,7 @@ "assistshowspatchername" : 0, "boxes" : [ { "box" : { - "embedstate" : [ [ "gMeshesNumber", 2 ], [ "gMeshSize", 4, 4 ], [ "gUsingMeshesOrNurbs", 0 ] ], + "embedstate" : [ [ "gUsingMeshesOrNurbs", 1 ], [ "gMeshesNumber", 4 ], [ "gMeshSize", 4, 4 ] ], "id" : "obj-8", "maxclass" : "newobj", "numinlets" : 1, @@ -453,7 +425,7 @@ ] } , - "patching_rect" : [ 86.690475821495056, 188.0, 93.0, 22.0 ], + "patching_rect" : [ 78.880953431129456, 182.0, 59.0, 22.0 ], "saved_object_attributes" : { "description" : "", "digest" : "", @@ -610,13 +582,6 @@ "source" : [ "obj-5", 0 ] } - } -, { - "patchline" : { - "destination" : [ "obj-7", 0 ], - "source" : [ "obj-6", 0 ] - } - } , { "patchline" : { From b55ccf087bca7f9f32d64ece4cc4d1d4498d0e85 Mon Sep 17 00:00:00 2001 From: FedFod Date: Sat, 17 Apr 2021 22:43:17 +0200 Subject: [PATCH 30/36] Fixed: bug with reset and NURBS mode. Changing mode doesn't reinit. --- meshwarp/Mesh.js | 13 ++++++++----- meshwarp/PrivateFunctions.js | 9 ++++++++- meshwarp/meshwarp.js | 8 ++------ meshwarp/meshwarp.maxpat | 8 ++++---- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index c76347b..e34091a 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -49,7 +49,6 @@ function Mesh() { this.initPositionMat(); // init vertex mat if (this.useNurbs) { this.assignControlMatToNurbs(); // assign vertex mat to nurbs - // this.assignNurbsMatToMesh(); // assign the matrix output from the nurbs to the mesh this.hasNurbsMat = 0; } else { this.assignPositionMatToMesh(); // assign vertex mat to mesh @@ -58,6 +57,7 @@ function Mesh() { this.calcMeshBoundsMat(); // calculate this.initTextureCoordMat(); // init texture coord mat + print(this.textureCoordMat.dim) this.assignTexture(); } @@ -121,7 +121,7 @@ function Mesh() { this.nurbs.enable = this.useNurbs; this.nurbs.name = "nurbs_"+this.ID; - this.nurbsMat = new JitterMatrix(3, "float32", this.nurbs.dim); + this.nurbsMat = new JitterMatrix(3, "float32", this.nurbs.dim.slice()); this.nurbsLstnr = new JitterListener(this.nurbs.name, nurbscallback); nurbsmap[this.nurbs.name] = this; @@ -150,19 +150,22 @@ function Mesh() { this.setMeshDim = function(dimensions) { + print("useN "+this.useNurbs) + print("dimensi "+dimensions) if (dimensions[0] > 0 && dimensions[1] > 0) { this.positionMat.dim = dimensions.slice(); this.boundingMat.dim = dimensions[0]*2 + (dimensions[1] * 2) - 4; if (this.useNurbs) { this.textureCoordMat.dim = this.nurbsDim.slice(); + print("texdim "+this.textureCoordMat.dim) } else { this.textureCoordMat.dim = dimensions.slice(); } } else { - this.positionMat.dim = [3,3]; - this.boundingMat.dim = 3*2 + (3 * 2) - 4; - this.textureCoordMat.dim = [3, 3]; + this.positionMat.dim = [4,4]; + this.boundingMat.dim = 4*2 + (4 * 2) - 4; + this.textureCoordMat.dim = [4, 4]; } } diff --git a/meshwarp/PrivateFunctions.js b/meshwarp/PrivateFunctions.js index 9902971..2fb86ed 100644 --- a/meshwarp/PrivateFunctions.js +++ b/meshwarp/PrivateFunctions.js @@ -23,7 +23,14 @@ function initMeshes() { gMeshes = []; for (var i=0; i Date: Mon, 19 Apr 2021 15:09:16 +0200 Subject: [PATCH 31/36] Fixed bugs, added attributes --- meshwarp/Mesh.js | 62 +++++---- meshwarp/PrivateFunctions.js | 81 +++++++++++- meshwarp/jit.gl.meshwarp.maxpat | 223 ++++++++++++++++++++++++++++++++ meshwarp/meshwarp.js | 86 +++--------- meshwarp/meshwarp.maxpat | 190 +++++---------------------- 5 files changed, 381 insertions(+), 261 deletions(-) create mode 100644 meshwarp/jit.gl.meshwarp.maxpat diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index e34091a..dd93084 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -24,10 +24,11 @@ function Mesh() { this.nurbs = null; this.nurbsDim = [40, 40]; - this.useNurbs = -1; + this.useNurbs = 0; this.currentWindowRatio = -1; this.nurbsLstnr = null; this.hasNurbsMat = 0; + this.textureName = ""; this.textureCoordMat = new JitterMatrix(2, "float32", [10, 10]);; this.nurbsMat = new JitterMatrix(3, "float32", [4, 4]); @@ -40,12 +41,14 @@ function Mesh() { this.useNurbs = useNurbs; this.currentWindowRatio = gWindowRatio; + var newDim = this.checkDimForNurbs(dimensions); + this.initMeshPoints(drawto); this.initMeshGrid(drawto); this.initMeshFull(drawto); this.initNurbs(drawto); - this.setMeshDim(dimensions); // calculate and set matrices dimensions + this.setMeshDim(newDim); // calculate and set matrices dimensions this.initPositionMat(); // init vertex mat if (this.useNurbs) { this.assignControlMatToNurbs(); // assign vertex mat to nurbs @@ -54,12 +57,8 @@ function Mesh() { this.assignPositionMatToMesh(); // assign vertex mat to mesh } - this.calcMeshBoundsMat(); // calculate - - this.initTextureCoordMat(); // init texture coord mat - print(this.textureCoordMat.dim) - - this.assignTexture(); + this.calcMeshBoundsMat(); // calculate mesh boundaries + this.initTextureCoordMat(); // init texture coord mat } this.changeMode = function(mode) { @@ -67,10 +66,7 @@ function Mesh() { this.useNurbs = mode; this.nurbs.enable = this.useNurbs; if (this.useNurbs) { - this.assignControlMatToNurbs(); - // this.assignNurbsMatToMesh(); - this.hasNurbsMat = 0; - this.textureCoordMat.dim = this.nurbsDim.slice(); + this.resizeMesh(this.positionMat.dim); } else { this.assignPositionMatToMesh(); // assign vertex mat to mesh this.textureCoordMat.dim = this.positionMat.dim.slice(); @@ -150,14 +146,11 @@ function Mesh() { this.setMeshDim = function(dimensions) { - print("useN "+this.useNurbs) - print("dimensi "+dimensions) if (dimensions[0] > 0 && dimensions[1] > 0) { this.positionMat.dim = dimensions.slice(); this.boundingMat.dim = dimensions[0]*2 + (dimensions[1] * 2) - 4; if (this.useNurbs) { this.textureCoordMat.dim = this.nurbsDim.slice(); - print("texdim "+this.textureCoordMat.dim) } else { this.textureCoordMat.dim = dimensions.slice(); } @@ -169,26 +162,21 @@ function Mesh() { } } - this.resizeMesh = function(sizeX_, sizeY_) { - var sizeX = sizeX_; var sizeY = sizeY_; + this.resizeMesh = function(dimensions) { + var newDim = this.checkDimForNurbs(dimensions); - if (this.useNurbs) { - sizeX = Math.max(sizeX, 4); - sizeY = Math.max(sizeY, 4); - } - var tempMat = new JitterMatrix(3, "float32", [sizeX, sizeY]); + var tempMat = new JitterMatrix(3, "float32", newDim); tempMat.interp = 1; tempMat.frommatrix(this.positionMat); - this.setMeshDim([sizeX, sizeY]); + this.setMeshDim(newDim); this.positionMat.frommatrix(tempMat); tempMat.freepeer(); if (this.useNurbs) { this.assignControlMatToNurbs(); // set the new position as the control matrix for nurbs - // this.assignNurbsMatToMesh(); this.hasNurbsMat = 0; } else { this.assignPositionMatToMesh(); @@ -218,12 +206,17 @@ function Mesh() { this.assignControlMatToNurbs = function() { this.nurbs.ctlmatrix(this.positionMat.name); } + + this.assignTextureToMesh = function(textureName) { + this.textureName = textureName; + this.meshFull.jit_gl_texture(this.textureName); + } //------------------------------------------- this.initTextureCoordMat = function() { - var xStartingPoint = (1.0/gMeshesNumber) * this.ID; - var xCoordTarget = xStartingPoint + (1.0/gMeshesNumber); // 0 a 1. +0.25 + var xStartingPoint = (1.0/meshes) * this.ID; + var xCoordTarget = xStartingPoint + (1.0/meshes); // 0 a 1. +0.25 for (var i=0; i 0 && numberMeshes < 20) { + meshes = numberMeshes; + freeMeshes(); + initMeshes(); + } +} +setHowManyMeshes.local = 1; + +// Resize all the meshes +function resizeAllMeshes(meshSizeX, meshSizeY) { + var xSize = Math.max(meshSizeX, 2); + var ySize = Math.max(meshSizeY, 2); + resize_meshes = [xSize, ySize]; + for (mesh in gMeshes) { + gMeshes[mesh].resizeMesh([xSize, ySize]); + } +} +resizeAllMeshes.local = 1; + +// Resize single mesh +function resizeSingleMesh(index, meshSizeX, meshSizeY) { + if (index < gMeshes.length) { + var xSize = Math.max(meshSizeX, 2); + var ySize = Math.max(meshSizeY, 2); + gMeshes[index].resizeMesh([xSize, ySize]); + } +} +resizeSingleMesh.local = 1; + +function showMeshes(show) { + for (mesh in gMeshes) { + gMeshes[mesh].showMesh(show); + } + if (!show) { + gGraphics.reset(); + } + gShowMeshes = show; +} +showMeshes.local = 1; + diff --git a/meshwarp/jit.gl.meshwarp.maxpat b/meshwarp/jit.gl.meshwarp.maxpat new file mode 100644 index 0000000..31d7c48 --- /dev/null +++ b/meshwarp/jit.gl.meshwarp.maxpat @@ -0,0 +1,223 @@ +{ + "patcher" : { + "fileversion" : 1, + "appversion" : { + "major" : 8, + "minor" : 2, + "revision" : 0, + "architecture" : "x64", + "modernui" : 1 + } +, + "classnamespace" : "box", + "rect" : [ 1059.0, 334.0, 640.0, 483.0 ], + "bglocked" : 0, + "openinpresentation" : 0, + "default_fontsize" : 12.0, + "default_fontface" : 0, + "default_fontname" : "Arial", + "gridonopen" : 1, + "gridsize" : [ 15.0, 15.0 ], + "gridsnaponopen" : 1, + "objectsnaponopen" : 1, + "statusbarvisible" : 2, + "toolbarvisible" : 1, + "lefttoolbarpinned" : 0, + "toptoolbarpinned" : 0, + "righttoolbarpinned" : 0, + "bottomtoolbarpinned" : 0, + "toolbars_unpinned_last_save" : 0, + "tallnewobj" : 0, + "boxanimatetime" : 200, + "enablehscroll" : 1, + "enablevscroll" : 1, + "devicewidth" : 0.0, + "description" : "", + "digest" : "", + "tags" : "", + "style" : "", + "subpatcher_template" : "", + "assistshowspatchername" : 0, + "boxes" : [ { + "box" : { + "id" : "obj-10", + "maxclass" : "toggle", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "int" ], + "parameter_enable" : 0, + "patching_rect" : [ 284.0, 128.0, 24.0, 24.0 ] + } + + } +, { + "box" : { + "id" : "obj-9", + "maxclass" : "toggle", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "int" ], + "parameter_enable" : 0, + "patching_rect" : [ 284.0, 52.0, 24.0, 24.0 ] + } + + } +, { + "box" : { + "id" : "obj-1", + "maxclass" : "newobj", + "numinlets" : 2, + "numoutlets" : 2, + "outlettype" : [ "", "" ], + "patching_rect" : [ 67.0, 113.0, 133.0, 22.0 ], + "text" : "routepass jit_gl_texture" + } + + } +, { + "box" : { + "id" : "obj-8", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 67.0, 221.0, 88.0, 22.0 ], + "saved_object_attributes" : { + "filename" : "meshwarp.js", + "parameter_enable" : 0 + } +, + "text" : "js meshwarp.js" + } + + } +, { + "box" : { + "comment" : "", + "id" : "obj-5", + "index" : 1, + "maxclass" : "inlet", + "numinlets" : 0, + "numoutlets" : 1, + "outlettype" : [ "jit_gl_texture" ], + "patching_rect" : [ 67.0, 65.0, 30.0, 30.0 ] + } + + } +, { + "box" : { + "attr" : "mode", + "id" : "obj-2", + "maxclass" : "attrui", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 284.0, 158.0, 150.0, 22.0 ] + } + + } +, { + "box" : { + "attr" : "meshes", + "id" : "obj-3", + "maxclass" : "attrui", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 284.0, 196.0, 150.0, 22.0 ] + } + + } +, { + "box" : { + "attr" : "resize_meshes", + "id" : "obj-4", + "maxclass" : "attrui", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 284.0, 232.0, 165.0, 22.0 ], + "text_width" : 108.0 + } + + } +, { + "box" : { + "attr" : "show_meshes", + "id" : "obj-6", + "maxclass" : "attrui", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 284.0, 87.0, 150.0, 22.0 ] + } + + } + ], + "lines" : [ { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-1", 1 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-1", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-2", 0 ], + "source" : [ "obj-10", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-2", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-3", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-4", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-1", 0 ], + "source" : [ "obj-5", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-6", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-6", 0 ], + "source" : [ "obj-9", 0 ] + } + + } + ] + } + +} diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index 41df89c..e91312a 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -14,18 +14,6 @@ var gWindowDim = [256, 256]; //nodeCTX.dim.slice(); var gWindowRatio = 1; var gWindowPrevRatio = gWindowRatio; var gShowMeshes = 1; -var gMeshesNumber = 4; -declareattribute("gMeshesNumber", null, null, 1); -var gMeshSize = [4, 4]; // default size 4x4 because of NURBS -declareattribute("gMeshSize", null, null, 1); -var gUsingMeshesOrNurbs = 0; //mesh // USE MESHES OR NURBS -declareattribute("gUsingMeshesOrNurbs", null, null, 1); - - -// OBJECTS USED GLOBALLY -// jit.3m to find max and min -var gJit3m = new JitterObject("jit.3m"); -var gGraphics = new GraphicElements(); // a structure to contain infos relative to the clicked mesh and vertex var gSelectionStruct = { @@ -41,71 +29,34 @@ var gSelectionStruct = { } }; -// JIT_GL_NODE -var nodeCTX = new JitterObject("jit.gl.node"); -nodeCTX.name = "##mesherNodeCTX##"; -nodeCTX.capture = 1; -nodeCTX.automatic = 1; -nodeCTX.adapt = 1; - -// VIDEOPLANE -var videoplane = new JitterObject("jit.gl.videoplane"); -videoplane.transform_reset = 2; -videoplane.color = WHITE; -videoplane.texture = nodeCTX.out_name; - -// CAMERA IN NODE -var nodeCamera = new JitterObject("jit.gl.camera"); -nodeCamera.drawto = nodeCTX.name; -nodeCamera.ortho = 2; - - //-----PUBLIC FUNCTIONS---------------- function reset() { init(); } -function mode(mode) { - if (mode == 0 || mode == 1) { - gUsingMeshesOrNurbs = mode; - for (var mesh in gMeshes) { - gMeshes[mesh].changeMode(mode); - } +function jit_gl_texture(texName) { + for (mesh in gMeshes) { + gMeshes[mesh].assignTextureToMesh(texName); } } -// Set number of meshes -function meshes(numberMeshes) { - if (numberMeshes > 0) { - gMeshesNumber = numberMeshes; - freeMeshes(); - initMeshes(); - } -} +// ATTRIBUTES +var mode = 0; // default: use mesh +declareattribute("mode", null, "setMode", 0); -// Resize all the meshes -function resize_meshes(meshSizeX, meshSizeY) { - for (mesh in gMeshes) { - gMeshes[mesh].resizeMesh(meshSizeX, meshSizeY); - } -} +var meshes = 4; +declareattribute("meshes", null, "setHowManyMeshes", 0); // STRANGE BEHAVIOUR -// Resize single mesh -function resize_mesh(index, meshSizeX, meshSizeY) { - if (index < gMeshes.length && index >= 0) { - gMeshes[index].resizeMesh(meshSizeX, meshSizeY); - } -} +var resize_meshes = [4, 4]; +declareattribute("resize_meshes", null, "resizeAllMeshes", 0); -function show_meshes(show) { - for (mesh in gMeshes) { - gMeshes[mesh].showMesh(show); - } - if (!show) { - gGraphics.reset(); - } - gShowMeshes = show; -} +var resize_mesh = [4, 4]; +declareattribute("resize_mesh", null, "resizeSingleMesh", 0); + +var show_meshes = 1; +declareattribute("show_meshes", null, "showMeshes", 0); + +//-------------------------------------------- // ROB //-------------------------------------------- @@ -154,12 +105,11 @@ function swapcallback(event){ case ("swap" || "draw"): // RENDER BANG if (gWindowDim[0] != nodeCTX.dim[0] || gWindowDim[1] != nodeCTX.dim[1]) { - //print(nodeCTX.dim) setWindowRatio(nodeCTX.dim); gWindowDim = nodeCTX.dim.slice(); if (gMeshes.length < 1) { gWindowPrevRatio = gWindowRatio; - init(gMeshSize[0], gMeshSize[1]); // RE INIT everything when window size is modified (temporary) + init(); // INIT if meshes don't exist } for (var mesh in gMeshes) { gMeshes[mesh].scaleMesh(); diff --git a/meshwarp/meshwarp.maxpat b/meshwarp/meshwarp.maxpat index 7763963..40864b9 100644 --- a/meshwarp/meshwarp.maxpat +++ b/meshwarp/meshwarp.maxpat @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 665.0, 154.0, 860.0, 752.0 ], + "rect" : [ 817.0, 145.0, 651.0, 752.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -46,7 +46,7 @@ "numoutlets" : 1, "outlettype" : [ "int" ], "parameter_enable" : 0, - "patching_rect" : [ 291.0, 54.0, 24.0, 24.0 ] + "patching_rect" : [ 267.0, 45.0, 24.0, 24.0 ] } } @@ -57,43 +57,10 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 291.0, 88.0, 55.0, 22.0 ], + "patching_rect" : [ 267.0, 79.0, 55.0, 22.0 ], "text" : "mode $1" } - } -, { - "box" : { - "id" : "obj-42", - "maxclass" : "comment", - "numinlets" : 1, - "numoutlets" : 0, - "patching_rect" : [ 419.0, 136.0, 113.0, 20.0 ], - "text" : "Resize single mesh" - } - - } -, { - "box" : { - "id" : "obj-40", - "maxclass" : "comment", - "numinlets" : 1, - "numoutlets" : 0, - "patching_rect" : [ 419.0, 21.0, 106.0, 20.0 ], - "text" : "Resize all meshes" - } - - } -, { - "box" : { - "id" : "obj-39", - "maxclass" : "comment", - "numinlets" : 1, - "numoutlets" : 0, - "patching_rect" : [ 471.0, 164.0, 37.0, 20.0 ], - "text" : "index" - } - } , { "box" : { @@ -103,7 +70,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 581.25, 186.0, 50.0, 22.0 ] + "patching_rect" : [ 519.5, 134.0, 50.0, 22.0 ] } } @@ -115,7 +82,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 525.25, 186.0, 50.0, 22.0 ] + "patching_rect" : [ 463.5, 134.0, 50.0, 22.0 ] } } @@ -128,7 +95,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 471.0, 186.0, 50.0, 22.0 ] + "patching_rect" : [ 409.25, 134.0, 50.0, 22.0 ] } } @@ -140,7 +107,7 @@ "numoutlets" : 1, "outlettype" : [ "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 421.75, 186.0, 24.0, 24.0 ] + "patching_rect" : [ 360.0, 134.0, 24.0, 24.0 ] } } @@ -151,7 +118,7 @@ "numinlets" : 4, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 421.75, 222.0, 166.75, 22.0 ], + "patching_rect" : [ 360.0, 170.0, 166.75, 22.0 ], "text" : "pack resize_mesh i i i" } @@ -164,7 +131,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 133.190475821495056, 21.0, 50.0, 22.0 ] + "patching_rect" : [ 177.190475821495056, 46.0, 50.0, 22.0 ] } } @@ -175,7 +142,7 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 133.190475821495056, 54.0, 67.0, 22.0 ], + "patching_rect" : [ 177.190475821495056, 79.0, 67.0, 22.0 ], "text" : "meshes $1" } @@ -188,7 +155,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 538.5, 56.0, 50.0, 22.0 ] + "patching_rect" : [ 479.5, 43.0, 50.0, 22.0 ] } } @@ -200,7 +167,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 474.5, 56.0, 50.0, 22.0 ] + "patching_rect" : [ 420.0, 43.0, 50.0, 22.0 ] } } @@ -212,7 +179,7 @@ "numoutlets" : 1, "outlettype" : [ "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 419.0, 56.0, 24.0, 24.0 ] + "patching_rect" : [ 360.0, 43.0, 24.0, 24.0 ] } } @@ -223,7 +190,7 @@ "numinlets" : 3, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 419.0, 92.0, 130.0, 22.0 ], + "patching_rect" : [ 360.0, 79.0, 139.0, 22.0 ], "text" : "pack resize_meshes i i" } @@ -236,7 +203,7 @@ "numoutlets" : 1, "outlettype" : [ "int" ], "parameter_enable" : 0, - "patching_rect" : [ 65.0, 73.0, 24.0, 24.0 ] + "patching_rect" : [ 57.380953431129456, 43.0, 24.0, 24.0 ] } } @@ -247,7 +214,7 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 65.0, 109.0, 102.0, 22.0 ], + "patching_rect" : [ 57.380953431129456, 79.0, 102.0, 22.0 ], "text" : "show_meshes $1" } @@ -259,7 +226,7 @@ "numinlets" : 1, "numoutlets" : 2, "outlettype" : [ "jit_gl_texture", "" ], - "patching_rect" : [ 28.190475821495056, 514.0, 458.0, 22.0 ], + "patching_rect" : [ 17.190475821495056, 448.0, 458.0, 22.0 ], "text" : "jit.movie @output_texture 1 @texture_name TEST @vol 0 @moviefile chickens.mp4" } @@ -309,7 +276,7 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 211.642860054969788, 82.0, 35.0, 22.0 ], + "patching_rect" : [ 84.5, 120.0, 35.0, 22.0 ], "text" : "reset" } @@ -344,108 +311,8 @@ "maxclass" : "newobj", "numinlets" : 1, "numoutlets" : 0, - "patcher" : { - "fileversion" : 1, - "appversion" : { - "major" : 8, - "minor" : 2, - "revision" : 0, - "architecture" : "x64", - "modernui" : 1 - } -, - "classnamespace" : "box", - "rect" : [ 967.0, 400.0, 640.0, 483.0 ], - "bglocked" : 0, - "openinpresentation" : 0, - "default_fontsize" : 12.0, - "default_fontface" : 0, - "default_fontname" : "Arial", - "gridonopen" : 1, - "gridsize" : [ 15.0, 15.0 ], - "gridsnaponopen" : 1, - "objectsnaponopen" : 1, - "statusbarvisible" : 2, - "toolbarvisible" : 1, - "lefttoolbarpinned" : 0, - "toptoolbarpinned" : 0, - "righttoolbarpinned" : 0, - "bottomtoolbarpinned" : 0, - "toolbars_unpinned_last_save" : 0, - "tallnewobj" : 0, - "boxanimatetime" : 200, - "enablehscroll" : 1, - "enablevscroll" : 1, - "devicewidth" : 0.0, - "description" : "", - "digest" : "", - "tags" : "", - "style" : "", - "subpatcher_template" : "", - "assistshowspatchername" : 0, - "boxes" : [ { - "box" : { - "embedstate" : [ [ "gUsingMeshesOrNurbs", 1 ], [ "gMeshesNumber", 2 ], [ "gMeshSize", 4, 4 ] ], - "id" : "obj-8", - "maxclass" : "newobj", - "numinlets" : 1, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 107.0, 195.0, 88.0, 22.0 ], - "saved_object_attributes" : { - "filename" : "meshwarp.js", - "parameter_enable" : 0 - } -, - "text" : "js meshwarp.js" - } - - } -, { - "box" : { - "comment" : "", - "id" : "obj-5", - "index" : 1, - "maxclass" : "inlet", - "numinlets" : 0, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 107.0, 66.0, 30.0, 30.0 ] - } - - } - ], - "lines" : [ { - "patchline" : { - "destination" : [ "obj-8", 0 ], - "source" : [ "obj-5", 0 ] - } - - } - ] - } -, - "patching_rect" : [ 60.0, 205.0, 59.0, 22.0 ], - "saved_object_attributes" : { - "description" : "", - "digest" : "", - "globalpatchername" : "", - "tags" : "" - } -, - "text" : "p mesher" - } - - } -, { - "box" : { - "attr" : "size", - "id" : "obj-18", - "maxclass" : "attrui", - "numinlets" : 1, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 28.190475821495056, 444.119050000000016, 260.0, 22.0 ] + "patching_rect" : [ 57.380953431129456, 222.0, 89.0, 22.0 ], + "text" : "jit.gl.meshwarp" } } @@ -453,21 +320,21 @@ "lines" : [ { "patchline" : { "destination" : [ "obj-1", 0 ], - "source" : [ "obj-14", 0 ] + "source" : [ "obj-10", 0 ] } } , { "patchline" : { - "destination" : [ "obj-5", 0 ], - "source" : [ "obj-17", 0 ] + "destination" : [ "obj-1", 0 ], + "source" : [ "obj-14", 0 ] } } , { "patchline" : { - "destination" : [ "obj-2", 0 ], - "source" : [ "obj-18", 0 ] + "destination" : [ "obj-5", 0 ], + "source" : [ "obj-17", 0 ] } } @@ -599,6 +466,13 @@ } ], "dependency_cache" : [ { + "name" : "jit.gl.meshwarp.maxpat", + "bootpath" : "D:/MyData/Lavori/Cycling74/MaxMapper_with_Rob/meshwarp", + "patcherrelativepath" : ".", + "type" : "JSON", + "implicit" : 1 + } +, { "name" : "meshwarp.js", "bootpath" : "D:/MyData/Lavori/Cycling74/MaxMapper_with_Rob/meshwarp", "patcherrelativepath" : ".", From 930b12e63520b03336e05d1d7c471ee133c77b6b Mon Sep 17 00:00:00 2001 From: Robert Ramirez Date: Mon, 19 Apr 2021 10:50:00 -0400 Subject: [PATCH 32/36] use new proxy class attribute to test for root context --- meshwarp/meshwarp.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index e91312a..dc23e67 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -79,11 +79,20 @@ function setdrawto(newdrawto) { if(proxy) { proxy.name = newdrawto; - //proxyattrs = proxy.send("getattributes"); - proxydrawto = proxy.send("getdrawto"); - if(proxydrawto !== null && proxydrawto !== undefined) { - // important! drawto is an array so get first element - return setdrawto(proxydrawto[0]); + //postln("drawto class " + proxy.class); + if(proxy.class !== undefined) { + if(proxy.class != "jit_gl_context_view") { + proxydrawto = proxy.send("getdrawto"); + // important! drawto is an array so get first element + return setdrawto(proxydrawto[0]); + } + } + else { + // remove once 8.2 is updated to support proxy.class + proxydrawto = proxy.send("getdrawto"); + if(proxydrawto !== null && proxydrawto !== undefined) { + return setdrawto(proxydrawto[0]); + } } } postln("setdrawto " + newdrawto); From 15a5fcbcba22cf61c16dfb247a276a5e8005792b Mon Sep 17 00:00:00 2001 From: FedFod Date: Mon, 19 Apr 2021 21:13:54 +0200 Subject: [PATCH 33/36] Created draft help file and fixed bugs --- meshwarp/Mesh.js | 6 +- ...eshwarp.maxpat => jit.gl.meshwarp.maxhelp} | 315 ++++++++---- meshwarp/jit.gl.meshwarp.maxpat | 191 ++++++- meshwarp/meshwarp.js | 4 +- meshwarp/meshwarp.maxhelp | 471 ------------------ 5 files changed, 401 insertions(+), 586 deletions(-) rename meshwarp/{meshwarp.maxpat => jit.gl.meshwarp.maxhelp} (54%) delete mode 100644 meshwarp/meshwarp.maxhelp diff --git a/meshwarp/Mesh.js b/meshwarp/Mesh.js index dd93084..11a8950 100644 --- a/meshwarp/Mesh.js +++ b/meshwarp/Mesh.js @@ -24,6 +24,8 @@ function Mesh() { this.nurbs = null; this.nurbsDim = [40, 40]; + this.enableMesh = gShowMeshes; + this.useNurbs = 0; this.currentWindowRatio = -1; this.nurbsLstnr = null; @@ -77,6 +79,7 @@ function Mesh() { this.initMeshPoints = function(drawto_) { this.meshPoints = new JitterObject("jit.gl.mesh"); + this.meshPoints.enable = this.enableMesh; this.meshPoints.draw_mode = "points"; this.meshPoints.depth_enable = 0; this.meshPoints.layer = FRONT; @@ -87,6 +90,7 @@ function Mesh() { this.initMeshGrid = function(drawto_) { this.meshGrid = new JitterObject("jit.gl.mesh"); + this.meshGrid.enable = this.enableMesh; this.meshGrid.draw_mode = "quad_grid"; this.meshGrid.depth_enable = 0; this.meshGrid.layer = MIDDLE; @@ -114,7 +118,7 @@ function Mesh() { this.nurbs.ctlshow = 0; this.nurbs.matrixoutput = 1; this.nurbs.drawto = drawto_; - this.nurbs.enable = this.useNurbs; + this.nurbs.enable = this.useNurbs * this.enableMesh; this.nurbs.name = "nurbs_"+this.ID; this.nurbsMat = new JitterMatrix(3, "float32", this.nurbs.dim.slice()); diff --git a/meshwarp/meshwarp.maxpat b/meshwarp/jit.gl.meshwarp.maxhelp similarity index 54% rename from meshwarp/meshwarp.maxpat rename to meshwarp/jit.gl.meshwarp.maxhelp index 40864b9..c654dd5 100644 --- a/meshwarp/meshwarp.maxpat +++ b/meshwarp/jit.gl.meshwarp.maxhelp @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 817.0, 145.0, 651.0, 752.0 ], + "rect" : [ 394.0, -850.0, 828.0, 529.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -39,6 +39,164 @@ "subpatcher_template" : "", "assistshowspatchername" : 0, "boxes" : [ { + "box" : { + "bubble" : 1, + "id" : "obj-39", + "linecount" : 2, + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 428.0, 182.119050145149231, 127.0, 38.0 ], + "presentation_linecount" : 2, + "text" : "Mode: 0 (mesh)\nMode: 1 (NURBS)" + } + + } +, { + "box" : { + "bubble" : 1, + "id" : "obj-38", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 447.0, 113.119050145149231, 127.0, 24.0 ], + "presentation_linecount" : 2, + "text" : "Number of meshes" + } + + } +, { + "box" : { + "bubble" : 1, + "bubbleside" : 2, + "id" : "obj-35", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 630.666666666666515, 163.761913895606995, 108.0, 39.0 ], + "text" : "Resize all meshes" + } + + } +, { + "box" : { + "id" : "obj-32", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 696.666666666666515, 202.0, 69.0, 20.0 ], + "text" : "vertical dim" + } + + } +, { + "box" : { + "id" : "obj-31", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 610.166666666666515, 202.023820519447327, 83.0, 20.0 ], + "text" : "horizontal dim" + } + + } +, { + "box" : { + "bubble" : 1, + "bubbleside" : 2, + "id" : "obj-29", + "linecount" : 2, + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 508.333333333333258, 319.0, 286.0, 53.0 ], + "text" : "Resize single mesh. \nSelect a mesh by its index (0 .. meshes-1) to resize." + } + + } +, { + "box" : { + "id" : "obj-24", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 708.333333333333258, 374.0, 69.0, 20.0 ], + "text" : "vertical dim" + } + + } +, { + "box" : { + "id" : "obj-22", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 624.0, 374.0, 83.0, 20.0 ], + "presentation_linecount" : 2, + "text" : "horizontal dim" + } + + } +, { + "box" : { + "id" : "obj-21", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 550.666666666666515, 374.0, 70.0, 20.0 ], + "text" : "mesh index" + } + + } +, { + "box" : { + "id" : "obj-12", + "linecount" : 2, + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 19.0, 65.0, 516.0, 34.0 ], + "text" : "The jit.gl.meshwarp allows to deform visual material projected on an arbitrary number of planes.\nIt can be used either for video-mapping or as a creative tool." + } + + } +, { + "box" : { + "fontface" : 1, + "fontsize" : 32.0, + "id" : "obj-7", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 19.0, 14.0, 241.0, 43.0 ], + "text" : "jit.gl.meshwarp" + } + + } +, { + "box" : { + "id" : "obj-4", + "maxclass" : "newobj", + "numinlets" : 0, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 74.785720109939575, 411.0, 71.0, 22.0 ], + "text" : "r meshwarp" + } + + } +, { + "box" : { + "id" : "obj-3", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 271.380953431129456, 289.119050145149231, 73.0, 22.0 ], + "text" : "s meshwarp" + } + + } +, { "box" : { "id" : "obj-49", "maxclass" : "toggle", @@ -46,7 +204,7 @@ "numoutlets" : 1, "outlettype" : [ "int" ], "parameter_enable" : 0, - "patching_rect" : [ 267.0, 45.0, 24.0, 24.0 ] + "patching_rect" : [ 393.190475821495056, 189.119050145149231, 24.0, 24.0 ] } } @@ -57,7 +215,7 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 267.0, 79.0, 55.0, 22.0 ], + "patching_rect" : [ 393.190475821495056, 223.119050145149231, 55.0, 22.0 ], "text" : "mode $1" } @@ -70,7 +228,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 519.5, 134.0, 50.0, 22.0 ] + "patching_rect" : [ 715.333333333333258, 394.0, 50.0, 22.0 ] } } @@ -82,7 +240,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 463.5, 134.0, 50.0, 22.0 ] + "patching_rect" : [ 637.999999999999886, 394.0, 50.0, 22.0 ] } } @@ -95,19 +253,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 409.25, 134.0, 50.0, 22.0 ] - } - - } -, { - "box" : { - "id" : "obj-35", - "maxclass" : "button", - "numinlets" : 1, - "numoutlets" : 1, - "outlettype" : [ "bang" ], - "parameter_enable" : 0, - "patching_rect" : [ 360.0, 134.0, 24.0, 24.0 ] + "patching_rect" : [ 560.666666666666629, 395.0, 50.0, 22.0 ] } } @@ -118,8 +264,8 @@ "numinlets" : 4, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 360.0, 170.0, 166.75, 22.0 ], - "text" : "pack resize_mesh i i i" + "patching_rect" : [ 483.333333333333258, 430.0, 251.0, 22.0 ], + "text" : "pak resize_single_mesh i i i" } } @@ -131,7 +277,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 177.190475821495056, 46.0, 50.0, 22.0 ] + "patching_rect" : [ 393.190475821495056, 113.119050145149231, 50.0, 22.0 ] } } @@ -142,7 +288,7 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 177.190475821495056, 79.0, 67.0, 22.0 ], + "patching_rect" : [ 393.190475821495056, 146.119050145149231, 67.0, 22.0 ], "text" : "meshes $1" } @@ -155,7 +301,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 479.5, 43.0, 50.0, 22.0 ] + "patching_rect" : [ 702.666666666666515, 225.119050145149231, 50.0, 22.0 ] } } @@ -167,19 +313,7 @@ "numoutlets" : 2, "outlettype" : [ "", "bang" ], "parameter_enable" : 0, - "patching_rect" : [ 420.0, 43.0, 50.0, 22.0 ] - } - - } -, { - "box" : { - "id" : "obj-17", - "maxclass" : "button", - "numinlets" : 1, - "numoutlets" : 1, - "outlettype" : [ "bang" ], - "parameter_enable" : 0, - "patching_rect" : [ 360.0, 43.0, 24.0, 24.0 ] + "patching_rect" : [ 626.666666666666515, 225.119050145149231, 50.0, 22.0 ] } } @@ -190,8 +324,8 @@ "numinlets" : 3, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 360.0, 79.0, 139.0, 22.0 ], - "text" : "pack resize_meshes i i" + "patching_rect" : [ 550.666666666666515, 261.119050145149231, 171.0, 22.0 ], + "text" : "pak resize_meshes i i" } } @@ -203,7 +337,7 @@ "numoutlets" : 1, "outlettype" : [ "int" ], "parameter_enable" : 0, - "patching_rect" : [ 57.380953431129456, 43.0, 24.0, 24.0 ] + "patching_rect" : [ 271.380953431129456, 187.119050145149231, 24.0, 24.0 ] } } @@ -214,7 +348,7 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 57.380953431129456, 79.0, 102.0, 22.0 ], + "patching_rect" : [ 271.380953431129456, 223.119050145149231, 102.0, 22.0 ], "text" : "show_meshes $1" } @@ -226,32 +360,8 @@ "numinlets" : 1, "numoutlets" : 2, "outlettype" : [ "jit_gl_texture", "" ], - "patching_rect" : [ 17.190475821495056, 448.0, 458.0, 22.0 ], - "text" : "jit.movie @output_texture 1 @texture_name TEST @vol 0 @moviefile chickens.mp4" - } - - } -, { - "box" : { - "id" : "obj-3", - "maxclass" : "message", - "numinlets" : 2, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 332.0, 294.119050145149231, 89.0, 22.0 ], - "text" : "fps 400, sync 0" - } - - } -, { - "box" : { - "id" : "obj-4", - "maxclass" : "message", - "numinlets" : 2, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 244.0, 294.119050145149231, 83.0, 22.0 ], - "text" : "fps 60, sync 1" + "patching_rect" : [ 33.642860054969788, 366.0, 405.0, 22.0 ], + "text" : "jit.movie @drawto ctx @output_texture 1 @vol 0 @moviefile chickens.mp4" } } @@ -265,7 +375,7 @@ "numinlets" : 1, "numoutlets" : 2, "outlettype" : [ "", "" ], - "patching_rect" : [ 233.142860054969788, 367.738093018531799, 80.0, 36.0 ] + "patching_rect" : [ 98.142860054969788, 247.119050145149231, 80.0, 36.0 ] } } @@ -276,7 +386,7 @@ "numinlets" : 2, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 84.5, 120.0, 35.0, 22.0 ], + "patching_rect" : [ 218.5, 223.119050145149231, 35.0, 22.0 ], "text" : "reset" } @@ -289,7 +399,7 @@ "numoutlets" : 1, "outlettype" : [ "int" ], "parameter_enable" : 0, - "patching_rect" : [ 91.642860054969788, 277.642863392829895, 33.476186752319336, 33.476186752319336 ] + "patching_rect" : [ 17.642860054969788, 182.023820519447327, 33.476186752319336, 33.476186752319336 ] } } @@ -300,8 +410,8 @@ "numinlets" : 1, "numoutlets" : 3, "outlettype" : [ "jit_matrix", "bang", "" ], - "patching_rect" : [ 91.642860054969788, 335.119050145149231, 302.0, 22.0 ], - "text" : "jit.world @floating 1 @size 160 120 @fps 400 @sync 0" + "patching_rect" : [ 17.642860054969788, 219.119050145149231, 180.0, 22.0 ], + "text" : "jit.world ctx @floating 1 @fsaa 1" } } @@ -311,8 +421,29 @@ "maxclass" : "newobj", "numinlets" : 1, "numoutlets" : 0, - "patching_rect" : [ 57.380953431129456, 222.0, 89.0, 22.0 ], - "text" : "jit.gl.meshwarp" + "patching_rect" : [ 33.642860054969788, 448.0, 209.0, 22.0 ], + "text" : "jit.gl.meshwarp ctx @show_meshes 1" + } + + } +, { + "box" : { + "background" : 1, + "bgcolor" : [ 1.0, 0.788235, 0.470588, 1.0 ], + "fontface" : 1, + "hint" : "", + "id" : "obj-93", + "ignoreclick" : 1, + "legacytextcolor" : 1, + "maxclass" : "textbutton", + "numinlets" : 1, + "numoutlets" : 3, + "outlettype" : [ "", "", "int" ], + "parameter_enable" : 0, + "patching_rect" : [ 52.142860054969788, 188.761913895606995, 20.0, 20.0 ], + "rounded" : 60.0, + "text" : "1", + "textcolor" : [ 0.34902, 0.34902, 0.34902, 1.0 ] } } @@ -326,17 +457,11 @@ } , { "patchline" : { - "destination" : [ "obj-1", 0 ], + "destination" : [ "obj-3", 0 ], + "midpoints" : [ 280.880953431129456, 246.0, 280.880953431129456, 246.0 ], "source" : [ "obj-14", 0 ] } - } -, { - "patchline" : { - "destination" : [ "obj-5", 0 ], - "source" : [ "obj-17", 0 ] - } - } , { "patchline" : { @@ -368,17 +493,11 @@ } , { "patchline" : { - "destination" : [ "obj-1", 0 ], + "destination" : [ "obj-3", 0 ], + "midpoints" : [ 402.690475821495056, 171.0, 375.0, 171.0, 375.0, 276.0, 280.880953431129456, 276.0 ], "source" : [ "obj-28", 0 ] } - } -, { - "patchline" : { - "destination" : [ "obj-2", 0 ], - "source" : [ "obj-3", 0 ] - } - } , { "patchline" : { @@ -403,14 +522,7 @@ } , { "patchline" : { - "destination" : [ "obj-36", 0 ], - "source" : [ "obj-35", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-1", 0 ], + "destination" : [ "obj-3", 0 ], "source" : [ "obj-36", 0 ] } @@ -424,14 +536,15 @@ } , { "patchline" : { - "destination" : [ "obj-2", 0 ], + "destination" : [ "obj-1", 0 ], "source" : [ "obj-4", 0 ] } } , { "patchline" : { - "destination" : [ "obj-1", 0 ], + "destination" : [ "obj-3", 0 ], + "midpoints" : [ 402.690475821495056, 276.0, 280.880953431129456, 276.0 ], "source" : [ "obj-47", 0 ] } @@ -445,14 +558,14 @@ } , { "patchline" : { - "destination" : [ "obj-1", 0 ], + "destination" : [ "obj-3", 0 ], "source" : [ "obj-5", 0 ] } } , { "patchline" : { - "destination" : [ "obj-1", 0 ], + "destination" : [ "obj-3", 0 ], "source" : [ "obj-8", 0 ] } diff --git a/meshwarp/jit.gl.meshwarp.maxpat b/meshwarp/jit.gl.meshwarp.maxpat index 31d7c48..0096841 100644 --- a/meshwarp/jit.gl.meshwarp.maxpat +++ b/meshwarp/jit.gl.meshwarp.maxpat @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 1059.0, 334.0, 640.0, 483.0 ], + "rect" : [ 676.0, -1019.0, 768.0, 485.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -39,6 +39,78 @@ "subpatcher_template" : "", "assistshowspatchername" : 0, "boxes" : [ { + "box" : { + "id" : "obj-16", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 317.0, 130.0, 108.0, 22.0 ], + "text" : "prepend setdrawto" + } + + } +, { + "box" : { + "id" : "obj-15", + "maxclass" : "newobj", + "numinlets" : 5, + "numoutlets" : 5, + "outlettype" : [ "", "", "", "", "" ], + "patching_rect" : [ 405.0, 96.0, 368.0, 22.0 ], + "text" : "routepass show_meshes mode resize_meshes resize_single_mesh" + } + + } +, { + "box" : { + "id" : "obj-14", + "maxclass" : "newobj", + "numinlets" : 2, + "numoutlets" : 2, + "outlettype" : [ "bang", "" ], + "patching_rect" : [ 370.0, 62.0, 54.0, 22.0 ], + "text" : "sel done" + } + + } +, { + "box" : { + "id" : "obj-7", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "", "" ], + "patching_rect" : [ 317.0, 33.0, 72.0, 22.0 ], + "text" : "patcherargs" + } + + } +, { + "box" : { + "id" : "obj-13", + "maxclass" : "newobj", + "numinlets" : 2, + "numoutlets" : 2, + "outlettype" : [ "jit_gl_texture", "" ], + "patching_rect" : [ 161.0, 122.0, 55.0, 22.0 ], + "text" : "jit.gl.slab" + } + + } +, { + "box" : { + "id" : "obj-12", + "maxclass" : "newobj", + "numinlets" : 2, + "numoutlets" : 2, + "outlettype" : [ "", "" ], + "patching_rect" : [ 161.0, 90.0, 113.0, 22.0 ], + "text" : "routepass jit_matrix" + } + + } +, { "box" : { "id" : "obj-10", "maxclass" : "toggle", @@ -46,7 +118,7 @@ "numoutlets" : 1, "outlettype" : [ "int" ], "parameter_enable" : 0, - "patching_rect" : [ 284.0, 128.0, 24.0, 24.0 ] + "patching_rect" : [ 388.0, 260.0, 24.0, 24.0 ] } } @@ -58,7 +130,7 @@ "numoutlets" : 1, "outlettype" : [ "int" ], "parameter_enable" : 0, - "patching_rect" : [ 284.0, 52.0, 24.0, 24.0 ] + "patching_rect" : [ 388.0, 184.0, 24.0, 24.0 ] } } @@ -69,7 +141,7 @@ "numinlets" : 2, "numoutlets" : 2, "outlettype" : [ "", "" ], - "patching_rect" : [ 67.0, 113.0, 133.0, 22.0 ], + "patching_rect" : [ 47.0, 60.0, 133.0, 22.0 ], "text" : "routepass jit_gl_texture" } @@ -81,7 +153,7 @@ "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 67.0, 221.0, 88.0, 22.0 ], + "patching_rect" : [ 46.0, 206.0, 88.0, 22.0 ], "saved_object_attributes" : { "filename" : "meshwarp.js", "parameter_enable" : 0 @@ -100,7 +172,7 @@ "numinlets" : 0, "numoutlets" : 1, "outlettype" : [ "jit_gl_texture" ], - "patching_rect" : [ 67.0, 65.0, 30.0, 30.0 ] + "patching_rect" : [ 47.0, 12.0, 30.0, 30.0 ] } } @@ -112,7 +184,7 @@ "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 284.0, 158.0, 150.0, 22.0 ] + "patching_rect" : [ 388.0, 290.0, 150.0, 22.0 ] } } @@ -124,7 +196,7 @@ "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 284.0, 196.0, 150.0, 22.0 ] + "patching_rect" : [ 388.0, 328.0, 150.0, 22.0 ] } } @@ -136,7 +208,7 @@ "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 284.0, 232.0, 165.0, 22.0 ], + "patching_rect" : [ 388.0, 364.0, 165.0, 22.0 ], "text_width" : 108.0 } @@ -149,14 +221,27 @@ "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 284.0, 87.0, 150.0, 22.0 ] + "patching_rect" : [ 388.0, 219.0, 150.0, 22.0 ] + } + + } +, { + "box" : { + "attr" : "resize_single_mesh", + "id" : "obj-11", + "maxclass" : "attrui", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 388.0, 398.0, 180.0, 22.0 ], + "text_width" : 127.0 } } ], "lines" : [ { "patchline" : { - "destination" : [ "obj-8", 0 ], + "destination" : [ "obj-12", 0 ], "source" : [ "obj-1", 1 ] } @@ -174,6 +259,76 @@ "source" : [ "obj-10", 0 ] } + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-11", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-13", 0 ], + "source" : [ "obj-12", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-12", 1 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-13", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-15", 0 ], + "source" : [ "obj-14", 1 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-15", 3 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-15", 2 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-15", 1 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-15", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "source" : [ "obj-16", 0 ] + } + } , { "patchline" : { @@ -209,6 +364,20 @@ "source" : [ "obj-6", 0 ] } + } +, { + "patchline" : { + "destination" : [ "obj-14", 0 ], + "source" : [ "obj-7", 1 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-16", 0 ], + "source" : [ "obj-7", 0 ] + } + } , { "patchline" : { diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index dc23e67..b7474e7 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -50,8 +50,8 @@ declareattribute("meshes", null, "setHowManyMeshes", 0); // STRANGE BEHAVIOUR var resize_meshes = [4, 4]; declareattribute("resize_meshes", null, "resizeAllMeshes", 0); -var resize_mesh = [4, 4]; -declareattribute("resize_mesh", null, "resizeSingleMesh", 0); +var resize_single_mesh = [0, 4, 4]; +declareattribute("resize_single_mesh", null, "resizeSingleMesh", 0); var show_meshes = 1; declareattribute("show_meshes", null, "showMeshes", 0); diff --git a/meshwarp/meshwarp.maxhelp b/meshwarp/meshwarp.maxhelp deleted file mode 100644 index 39f478d..0000000 --- a/meshwarp/meshwarp.maxhelp +++ /dev/null @@ -1,471 +0,0 @@ -{ - "patcher" : { - "fileversion" : 1, - "appversion" : { - "major" : 8, - "minor" : 2, - "revision" : 0, - "architecture" : "x64", - "modernui" : 1 - } -, - "classnamespace" : "box", - "rect" : [ 722.0, 179.0, 771.0, 749.0 ], - "bglocked" : 0, - "openinpresentation" : 0, - "default_fontsize" : 12.0, - "default_fontface" : 0, - "default_fontname" : "Arial", - "gridonopen" : 1, - "gridsize" : [ 15.0, 15.0 ], - "gridsnaponopen" : 1, - "objectsnaponopen" : 1, - "statusbarvisible" : 2, - "toolbarvisible" : 1, - "lefttoolbarpinned" : 0, - "toptoolbarpinned" : 0, - "righttoolbarpinned" : 0, - "bottomtoolbarpinned" : 0, - "toolbars_unpinned_last_save" : 0, - "tallnewobj" : 0, - "boxanimatetime" : 200, - "enablehscroll" : 1, - "enablevscroll" : 1, - "devicewidth" : 0.0, - "description" : "", - "digest" : "", - "tags" : "", - "style" : "", - "subpatcher_template" : "", - "assistshowspatchername" : 0, - "boxes" : [ { - "box" : { - "fontface" : 0, - "fontname" : "Lato", - "fontsize" : 47.0, - "id" : "obj-34", - "maxclass" : "comment", - "numinlets" : 1, - "numoutlets" : 0, - "patching_rect" : [ 14.0, 8.0, 319.0, 63.0 ], - "text" : "jit.gl.meshwarp" - } - - } -, { - "box" : { - "id" : "obj-30", - "maxclass" : "button", - "numinlets" : 1, - "numoutlets" : 1, - "outlettype" : [ "bang" ], - "parameter_enable" : 0, - "patching_rect" : [ 364.0, 216.0, 24.0, 24.0 ] - } - - } -, { - "box" : { - "id" : "obj-28", - "maxclass" : "number", - "numinlets" : 1, - "numoutlets" : 2, - "outlettype" : [ "", "bang" ], - "parameter_enable" : 0, - "patching_rect" : [ 489.404759526252747, 216.0, 50.0, 22.0 ] - } - - } -, { - "box" : { - "id" : "obj-27", - "maxclass" : "number", - "numinlets" : 1, - "numoutlets" : 2, - "outlettype" : [ "", "bang" ], - "parameter_enable" : 0, - "patching_rect" : [ 419.5, 216.0, 50.0, 22.0 ] - } - - } -, { - "box" : { - "id" : "obj-25", - "maxclass" : "newobj", - "numinlets" : 3, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 364.0, 260.0, 130.0, 22.0 ], - "text" : "pack resize_meshes i i" - } - - } -, { - "box" : { - "id" : "obj-15", - "maxclass" : "number", - "numinlets" : 1, - "numoutlets" : 2, - "outlettype" : [ "", "bang" ], - "parameter_enable" : 0, - "patching_rect" : [ 289.642860054969788, 215.0, 50.0, 22.0 ] - } - - } -, { - "box" : { - "id" : "obj-13", - "maxclass" : "number", - "numinlets" : 1, - "numoutlets" : 2, - "outlettype" : [ "", "bang" ], - "parameter_enable" : 0, - "patching_rect" : [ 235.642860054969788, 215.0, 50.0, 22.0 ] - } - - } -, { - "box" : { - "id" : "obj-11", - "maxclass" : "newobj", - "numinlets" : 3, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 211.642860054969788, 249.0, 67.0, 22.0 ], - "text" : "pak init 2 2" - } - - } -, { - "box" : { - "id" : "obj-20", - "maxclass" : "toggle", - "numinlets" : 1, - "numoutlets" : 1, - "outlettype" : [ "int" ], - "parameter_enable" : 0, - "patching_rect" : [ 86.523813247680664, 213.0, 24.0, 24.0 ] - } - - } -, { - "box" : { - "id" : "obj-14", - "maxclass" : "message", - "numinlets" : 2, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 86.523813247680664, 249.0, 102.0, 22.0 ], - "text" : "show_meshes $1" - } - - } -, { - "box" : { - "id" : "obj-10", - "maxclass" : "newobj", - "numinlets" : 1, - "numoutlets" : 2, - "outlettype" : [ "jit_gl_texture", "" ], - "patching_rect" : [ 86.523813247680664, 587.0, 458.0, 22.0 ], - "text" : "jit.movie @output_texture 1 @texture_name TEST @vol 0 @moviefile chickens.mp4" - } - - } -, { - "box" : { - "fontface" : 0, - "fontname" : "Arial", - "fontsize" : 12.0, - "id" : "obj-16", - "maxclass" : "jit.fpsgui", - "numinlets" : 1, - "numoutlets" : 2, - "outlettype" : [ "", "" ], - "patching_rect" : [ 233.142860054969788, 476.738093018531799, 80.0, 36.0 ] - } - - } -, { - "box" : { - "id" : "obj-9", - "maxclass" : "toggle", - "numinlets" : 1, - "numoutlets" : 1, - "outlettype" : [ "int" ], - "parameter_enable" : 0, - "patching_rect" : [ 86.523813247680664, 317.119050145149231, 33.476186752319336, 33.476186752319336 ] - } - - } -, { - "box" : { - "id" : "obj-2", - "maxclass" : "newobj", - "numinlets" : 1, - "numoutlets" : 3, - "outlettype" : [ "jit_matrix", "bang", "" ], - "patching_rect" : [ 137.642860054969788, 433.119050145149231, 210.0, 22.0 ], - "text" : "jit.world @floating 1 @fps 60 @fsaa 1" - } - - } -, { - "box" : { - "id" : "obj-1", - "maxclass" : "newobj", - "numinlets" : 2, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patcher" : { - "fileversion" : 1, - "appversion" : { - "major" : 8, - "minor" : 2, - "revision" : 0, - "architecture" : "x64", - "modernui" : 1 - } -, - "classnamespace" : "box", - "rect" : [ 967.0, 400.0, 640.0, 483.0 ], - "bglocked" : 0, - "openinpresentation" : 0, - "default_fontsize" : 12.0, - "default_fontface" : 0, - "default_fontname" : "Arial", - "gridonopen" : 1, - "gridsize" : [ 15.0, 15.0 ], - "gridsnaponopen" : 1, - "objectsnaponopen" : 1, - "statusbarvisible" : 2, - "toolbarvisible" : 1, - "lefttoolbarpinned" : 0, - "toptoolbarpinned" : 0, - "righttoolbarpinned" : 0, - "bottomtoolbarpinned" : 0, - "toolbars_unpinned_last_save" : 0, - "tallnewobj" : 0, - "boxanimatetime" : 200, - "enablehscroll" : 1, - "enablevscroll" : 1, - "devicewidth" : 0.0, - "description" : "", - "digest" : "", - "tags" : "", - "style" : "", - "subpatcher_template" : "", - "assistshowspatchername" : 0, - "boxes" : [ { - "box" : { - "embedstate" : [ [ "gMeshesNumber", 4 ], [ "gMeshSize", 4, 8 ] ], - "id" : "obj-8", - "maxclass" : "newobj", - "numinlets" : 1, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 107.0, 195.0, 88.0, 22.0 ], - "saved_object_attributes" : { - "filename" : "meshwarp.js", - "parameter_enable" : 0 - } -, - "text" : "js meshwarp.js" - } - - } -, { - "box" : { - "id" : "obj-6", - "maxclass" : "comment", - "numinlets" : 1, - "numoutlets" : 0, - "patching_rect" : [ 99.0, 36.0, 77.0, 20.0 ], - "text" : "from jit.world" - } - - } -, { - "box" : { - "comment" : "", - "id" : "obj-5", - "index" : 2, - "maxclass" : "inlet", - "numinlets" : 0, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 299.0, 64.0, 30.0, 30.0 ] - } - - } -, { - "box" : { - "comment" : "", - "id" : "obj-4", - "index" : 1, - "maxclass" : "inlet", - "numinlets" : 0, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 107.0, 64.0, 30.0, 30.0 ] - } - - } -, { - "box" : { - "id" : "obj-3", - "maxclass" : "comment", - "numinlets" : 1, - "numoutlets" : 0, - "patching_rect" : [ 145.0, 267.0, 150.0, 20.0 ], - "text" : "connect to jit.world" - } - - } -, { - "box" : { - "comment" : "", - "id" : "obj-1", - "index" : 1, - "maxclass" : "outlet", - "numinlets" : 1, - "numoutlets" : 0, - "patching_rect" : [ 106.0, 260.0, 30.0, 30.0 ] - } - - } - ], - "lines" : [ { - "patchline" : { - "destination" : [ "obj-8", 0 ], - "source" : [ "obj-4", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-8", 0 ], - "source" : [ "obj-5", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-1", 0 ], - "source" : [ "obj-8", 0 ] - } - - } - ] - } -, - "patching_rect" : [ 137.642860054969788, 317.119050145149231, 93.0, 22.0 ], - "saved_object_attributes" : { - "description" : "", - "digest" : "", - "globalpatchername" : "", - "tags" : "" - } -, - "text" : "p mesher" - } - - } - ], - "lines" : [ { - "patchline" : { - "destination" : [ "obj-2", 0 ], - "source" : [ "obj-1", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-1", 1 ], - "source" : [ "obj-11", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-11", 1 ], - "source" : [ "obj-13", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-1", 0 ], - "source" : [ "obj-14", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-11", 2 ], - "source" : [ "obj-15", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-16", 0 ], - "source" : [ "obj-2", 1 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-14", 0 ], - "source" : [ "obj-20", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-1", 1 ], - "source" : [ "obj-25", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-25", 1 ], - "source" : [ "obj-27", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-25", 2 ], - "source" : [ "obj-28", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-25", 0 ], - "source" : [ "obj-30", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-2", 0 ], - "source" : [ "obj-9", 0 ] - } - - } - ], - "dependency_cache" : [ { - "name" : "meshwarp.js", - "bootpath" : "D:/MyData/Lavori/Cycling74/MaxMapper_with_Rob/meshwarp", - "patcherrelativepath" : ".", - "type" : "TEXT", - "implicit" : 1 - } - ], - "autosave" : 0 - } - -} From abb482db2bc36220b336afa27f3aefda4474bf43 Mon Sep 17 00:00:00 2001 From: FedFod Date: Mon, 19 Apr 2021 21:18:24 +0200 Subject: [PATCH 34/36] added comment --- meshwarp/jit.gl.meshwarp.maxhelp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/meshwarp/jit.gl.meshwarp.maxhelp b/meshwarp/jit.gl.meshwarp.maxhelp index c654dd5..82367c3 100644 --- a/meshwarp/jit.gl.meshwarp.maxhelp +++ b/meshwarp/jit.gl.meshwarp.maxhelp @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 394.0, -850.0, 828.0, 529.0 ], + "rect" : [ 494.0, 192.0, 826.0, 527.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -39,6 +39,19 @@ "subpatcher_template" : "", "assistshowspatchername" : 0, "boxes" : [ { + "box" : { + "bubble" : 1, + "id" : "obj-42", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 47.142860054969788, 398.0, 333.0, 24.0 ], + "presentation_linecount" : 4, + "text" : "Send your image/video as a Texture to the jit.gl.meshwarp" + } + + } +, { "box" : { "bubble" : 1, "id" : "obj-39", @@ -180,7 +193,7 @@ "numinlets" : 0, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 74.785720109939575, 411.0, 71.0, 22.0 ], + "patching_rect" : [ 80.142860054969788, 435.0, 71.0, 22.0 ], "text" : "r meshwarp" } @@ -360,7 +373,7 @@ "numinlets" : 1, "numoutlets" : 2, "outlettype" : [ "jit_gl_texture", "" ], - "patching_rect" : [ 33.642860054969788, 366.0, 405.0, 22.0 ], + "patching_rect" : [ 33.642860054969788, 360.0, 405.0, 22.0 ], "text" : "jit.movie @drawto ctx @output_texture 1 @vol 0 @moviefile chickens.mp4" } @@ -421,7 +434,7 @@ "maxclass" : "newobj", "numinlets" : 1, "numoutlets" : 0, - "patching_rect" : [ 33.642860054969788, 448.0, 209.0, 22.0 ], + "patching_rect" : [ 33.642860054969788, 464.0, 209.0, 22.0 ], "text" : "jit.gl.meshwarp ctx @show_meshes 1" } From d545b668f90c64b052199ba9c529e256393a6cb0 Mon Sep 17 00:00:00 2001 From: Robert Ramirez Date: Tue, 20 Apr 2021 10:37:15 -0400 Subject: [PATCH 35/36] move files into package structure --- {meshwarp => code}/GraphicElements.js | 0 {meshwarp => code}/Mesh.js | 0 {meshwarp => code}/PrivateFunctions.js | 0 {meshwarp => code}/Utilities.js | 0 {meshwarp => code}/meshwarp.js | 0 {meshwarp => help}/jit.gl.meshwarp.maxhelp | 0 {meshwarp => patchers}/jit.gl.meshwarp.maxpat | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename {meshwarp => code}/GraphicElements.js (100%) rename {meshwarp => code}/Mesh.js (100%) rename {meshwarp => code}/PrivateFunctions.js (100%) rename {meshwarp => code}/Utilities.js (100%) rename {meshwarp => code}/meshwarp.js (100%) rename {meshwarp => help}/jit.gl.meshwarp.maxhelp (100%) rename {meshwarp => patchers}/jit.gl.meshwarp.maxpat (100%) diff --git a/meshwarp/GraphicElements.js b/code/GraphicElements.js similarity index 100% rename from meshwarp/GraphicElements.js rename to code/GraphicElements.js diff --git a/meshwarp/Mesh.js b/code/Mesh.js similarity index 100% rename from meshwarp/Mesh.js rename to code/Mesh.js diff --git a/meshwarp/PrivateFunctions.js b/code/PrivateFunctions.js similarity index 100% rename from meshwarp/PrivateFunctions.js rename to code/PrivateFunctions.js diff --git a/meshwarp/Utilities.js b/code/Utilities.js similarity index 100% rename from meshwarp/Utilities.js rename to code/Utilities.js diff --git a/meshwarp/meshwarp.js b/code/meshwarp.js similarity index 100% rename from meshwarp/meshwarp.js rename to code/meshwarp.js diff --git a/meshwarp/jit.gl.meshwarp.maxhelp b/help/jit.gl.meshwarp.maxhelp similarity index 100% rename from meshwarp/jit.gl.meshwarp.maxhelp rename to help/jit.gl.meshwarp.maxhelp diff --git a/meshwarp/jit.gl.meshwarp.maxpat b/patchers/jit.gl.meshwarp.maxpat similarity index 100% rename from meshwarp/jit.gl.meshwarp.maxpat rename to patchers/jit.gl.meshwarp.maxpat From 8ac5bb181b7036b10956df57d1545ecfe6e65553 Mon Sep 17 00:00:00 2001 From: Robert Ramirez Date: Tue, 20 Apr 2021 10:49:14 -0400 Subject: [PATCH 36/36] some package file placeholders, help file tweaks --- extras/meshwarp-launcher.maxpat | 84 ++++++++++++++++++++++++++++++++ help/jit.gl.meshwarp.maxhelp | 29 +++++------ icon.png | Bin 0 -> 13843 bytes package-info.json | 22 +++++++++ patchers/jit.gl.meshwarp.maxpat | 4 +- 5 files changed, 123 insertions(+), 16 deletions(-) create mode 100644 extras/meshwarp-launcher.maxpat create mode 100644 icon.png create mode 100644 package-info.json diff --git a/extras/meshwarp-launcher.maxpat b/extras/meshwarp-launcher.maxpat new file mode 100644 index 0000000..acc3902 --- /dev/null +++ b/extras/meshwarp-launcher.maxpat @@ -0,0 +1,84 @@ +{ + "patcher" : { + "fileversion" : 1, + "appversion" : { + "major" : 8, + "minor" : 2, + "revision" : 0, + "architecture" : "x64", + "modernui" : 1 + } +, + "classnamespace" : "box", + "rect" : [ 59.0, 104.0, 641.0, 354.0 ], + "bglocked" : 0, + "openinpresentation" : 0, + "default_fontsize" : 12.0, + "default_fontface" : 0, + "default_fontname" : "Arial", + "gridonopen" : 1, + "gridsize" : [ 15.0, 15.0 ], + "gridsnaponopen" : 1, + "objectsnaponopen" : 1, + "statusbarvisible" : 2, + "toolbarvisible" : 1, + "lefttoolbarpinned" : 0, + "toptoolbarpinned" : 0, + "righttoolbarpinned" : 0, + "bottomtoolbarpinned" : 0, + "toolbars_unpinned_last_save" : 0, + "tallnewobj" : 0, + "boxanimatetime" : 200, + "enablehscroll" : 1, + "enablevscroll" : 1, + "devicewidth" : 0.0, + "description" : "", + "digest" : "", + "tags" : "", + "style" : "", + "subpatcher_template" : "", + "assistshowspatchername" : 0, + "boxes" : [ { + "box" : { + "fontsize" : 30.178794438211202, + "id" : "obj-3", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 76.0, 70.260000000000005, 468.0, 40.0 ], + "text" : "Meshwarp Launcher will go here..." + } + + } +, { + "box" : { + "id" : "obj-1", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 246.0, 209.0, 89.0, 22.0 ], + "text" : "jit.gl.meshwarp" + } + + } + ], + "lines" : [ ], + "dependency_cache" : [ { + "name" : "jit.gl.meshwarp.maxpat", + "bootpath" : "~/dev/cycling/meshwarp/patchers", + "patcherrelativepath" : "../patchers", + "type" : "JSON", + "implicit" : 1 + } +, { + "name" : "meshwarp.js", + "bootpath" : "~/dev/cycling/meshwarp/code", + "patcherrelativepath" : "../code", + "type" : "TEXT", + "implicit" : 1 + } + ], + "autosave" : 0 + } + +} diff --git a/help/jit.gl.meshwarp.maxhelp b/help/jit.gl.meshwarp.maxhelp index 82367c3..b4e31b7 100644 --- a/help/jit.gl.meshwarp.maxhelp +++ b/help/jit.gl.meshwarp.maxhelp @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 494.0, 192.0, 826.0, 527.0 ], + "rect" : [ 34.0, 79.0, 826.0, 527.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -37,6 +37,7 @@ "tags" : "", "style" : "", "subpatcher_template" : "", + "helpsidebarclosed" : 1, "assistshowspatchername" : 0, "boxes" : [ { "box" : { @@ -46,7 +47,6 @@ "numinlets" : 1, "numoutlets" : 0, "patching_rect" : [ 47.142860054969788, 398.0, 333.0, 24.0 ], - "presentation_linecount" : 4, "text" : "Send your image/video as a Texture to the jit.gl.meshwarp" } @@ -59,8 +59,7 @@ "maxclass" : "comment", "numinlets" : 1, "numoutlets" : 0, - "patching_rect" : [ 428.0, 182.119050145149231, 127.0, 38.0 ], - "presentation_linecount" : 2, + "patching_rect" : [ 428.0, 182.119050145149231, 127.0, 37.0 ], "text" : "Mode: 0 (mesh)\nMode: 1 (NURBS)" } @@ -73,7 +72,6 @@ "numinlets" : 1, "numoutlets" : 0, "patching_rect" : [ 447.0, 113.119050145149231, 127.0, 24.0 ], - "presentation_linecount" : 2, "text" : "Number of meshes" } @@ -122,7 +120,7 @@ "maxclass" : "comment", "numinlets" : 1, "numoutlets" : 0, - "patching_rect" : [ 508.333333333333258, 319.0, 286.0, 53.0 ], + "patching_rect" : [ 508.333333333333258, 319.0, 286.0, 52.0 ], "text" : "Resize single mesh. \nSelect a mesh by its index (0 .. meshes-1) to resize." } @@ -145,7 +143,6 @@ "numinlets" : 1, "numoutlets" : 0, "patching_rect" : [ 624.0, 374.0, 83.0, 20.0 ], - "presentation_linecount" : 2, "text" : "horizontal dim" } @@ -168,7 +165,7 @@ "maxclass" : "comment", "numinlets" : 1, "numoutlets" : 0, - "patching_rect" : [ 19.0, 65.0, 516.0, 34.0 ], + "patching_rect" : [ 19.0, 65.0, 516.0, 33.0 ], "text" : "The jit.gl.meshwarp allows to deform visual material projected on an arbitrary number of planes.\nIt can be used either for video-mapping or as a creative tool." } @@ -181,7 +178,7 @@ "maxclass" : "comment", "numinlets" : 1, "numoutlets" : 0, - "patching_rect" : [ 19.0, 14.0, 241.0, 43.0 ], + "patching_rect" : [ 19.0, 14.0, 241.0, 42.0 ], "text" : "jit.gl.meshwarp" } @@ -388,7 +385,7 @@ "numinlets" : 1, "numoutlets" : 2, "outlettype" : [ "", "" ], - "patching_rect" : [ 98.142860054969788, 247.119050145149231, 80.0, 36.0 ] + "patching_rect" : [ 98.142860054969788, 247.119050145149231, 80.0, 35.0 ] } } @@ -418,6 +415,10 @@ } , { "box" : { + "frozen_object_attributes" : { + "rect" : [ 895, 39, 1535, 519 ] + } +, "id" : "obj-2", "maxclass" : "newobj", "numinlets" : 1, @@ -593,15 +594,15 @@ ], "dependency_cache" : [ { "name" : "jit.gl.meshwarp.maxpat", - "bootpath" : "D:/MyData/Lavori/Cycling74/MaxMapper_with_Rob/meshwarp", - "patcherrelativepath" : ".", + "bootpath" : "~/dev/cycling/meshwarp/patchers", + "patcherrelativepath" : "../patchers", "type" : "JSON", "implicit" : 1 } , { "name" : "meshwarp.js", - "bootpath" : "D:/MyData/Lavori/Cycling74/MaxMapper_with_Rob/meshwarp", - "patcherrelativepath" : ".", + "bootpath" : "~/dev/cycling/meshwarp/code", + "patcherrelativepath" : "../code", "type" : "TEXT", "implicit" : 1 } diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..97b510490fe8c721ac096218d046b13ac497dc11 GIT binary patch literal 13843 zcmeHuc|2R)^DteW7F8Oxv_sgkg2W=J>W7c#3Y2Rc$|1ZoT7M2)SmLvbd++&{iKZeYMiT&^S@JrVJQha&n zf1z2|ULO8$dmk<8cJWi@iOt*at}hD<2haY&%95Qcz@&E9^|qCtm6@rAgO`WGgNI)B zjtW5@-uqZA;2;fV)5Fp4fk=>tyQi;4ke1j1ga)&{-whHIIRNo<(-N~XyDp;Z<>M%F zNkK*7q8Nl-L_`Ga^Uz7-<~99)(V16TVlIAu-WniKU|^s^pt6FOk26T|^5x5*i%K9R zC3z-LBL7S0nxn6SkE^$ztCy$9KHUfQUjBYsVq*IP{pa(0o_?-Q z{~gKG_g}V{41)IWfD{!jg8oCBi3;BD)iC#Qb!3jbPamQPK7jnc`u-gU4B8+3|Cr2g zP7ivStU}nqp#MBJ2)pTL>ANf}%56s1uHFt}T^c+3PR?NX;zY;Tn7oVkalp^K2?fzc z{$;-7r=P!!HW9g!GI71J`6%b|@^XDdD~z%DL(4g^Hy^J?3m|}P{2w(0mO77zZ7pJy zwF2r~Wq6`lSPvaJ&OLW?A}K~l6|pWFW12kfxb{Tq%H#bz?5u1p6W2u#F2dLi=fXB} z-mr0tTzPy&RHTq!P=<*ra^1x%=dU8zS01g;-9oI4uB{+q2^S9Hj=gllGhm|;HKKa%;Q zW`EYqA8U4CS^t>kKl{v|P4kaC^T#*)f8%IQWQ8GHLav3ipE58F-(9ft+Pqk*IW{jv zg3vywp)q;(>+=%!^0(blEW^@XCO7-uWdoAbp;i%c&TD9o&<`Eh(>Yv!47l+-dT4w#tkFUvz6p}xWYfd~qEEOXhJcm5K@zb}r z)3SBzJ7<;GdNe3(-XvAldXk+ZCv1lZELd!zjdKtd);qL!=gm`Lgsnm9O0RD|)o{+2 z(_ClbC@ARD^vAwXX-_%lO< ze&P71fsZzpmSW|1^j&|WaWJEWqvxA{y)Luc{nb&_kds!5pO+wf)*kMJs>VHyIKA)F z4}~$K1?1MoUuun?rsoV8tqO6k1UnIBGt>gc&a{E{RzG^!!_zm%9z#_F?*}W9WBL<} z8k{Hf+19RzGb&@Dw6*p6Uq6Qs5GC@5*d&a9erf2L;fKWoIE*j}YU9&h2TV5p|! z+kKeS9OnJhADE5z)ES|Gp$Dl6HjDPuEhlp^IH_%^6g+dmnUup|D$Q8=`~Z!ZyROzs z?@kTGQ1epBVdRk1%}BBci1!YazwohjB&w71U%-(vHc|QG{GZeEk z1M2N*0Y0a{=8Et*93cuvW zCoTp*Rp5>C9ik06prUKH`(hv}aS3ZDW)hvj#D}fB8|U6~0EvgBK!{G0c$%kAYL00S zb8fshZ=^tGpwnqu!<8p!p+doNA2qn(kRIIv#+DzD8 zuBC~y=?Ut7SbGi9VxS}FU3O9+=C3oOfO3YxTs>w}pB3O0QFFwh8NW^wTOXH^pG5xF z&5q7b$AIAGfc6!J@)5*fZNC2oBe->Y%*$uE%Qhegv4kUsk~C8-F{|mRO!=>OTqrZp z9O;+hZ~S=Fsg?D?nO$!t6Crpy^AShL_cWjoKbhK;+mL_>>2|YKWD092rTZ$UmPfkysh6p8uEvMlx-~Ou z$(U{EEggYuP$*O25qH0VAiil{p~Q3ew7LY^>QD^n!UuDFv;kkw_82)luphGf28w4N z`s^CRZ?{pC$?IW%8HM=ffNaQwK-LPmCyObrj{0z@IJF2nXHuyHtl>6+&ntw zxwTDTgir3Q@>4e~n+DRIyrLuOdI<@n-tdiDlG&}#vg0Vm{CP5>H>3o|Tm}g=EHy58 z(|uOMZb&sBJi*F!-rf+G;jWRX^1SvnR!ZKx~f<&j;NL+-@wQ&(Q z4XCLFJJTblAahr_WH9BrQ&89=4m&$lVjZt)(h;@2tHb5{Y(?OKkt%}VB;Lo}vzNjd zXp$CL#m3wD?iV}-WhJrZ_bmTCz=(-{^76wrrKy;}#p+=$w~_3Tl{5HQEE0jTYy6_8 zaINET%nE7GBz!nY(%#H7ryZ2Nh&DV^jHxTf4uu^ql2Dk64V_r zUX8Y5i-p{^z!IVj=UmsEg5TcCdt}lT(&L+7>we1C%kaM89P%f=p*S6&yL`hlpf-oM zZMNDRjFeE5RdmmI-XB_n&)=w{2DG6`UX?+sm4Pj8K6wk)&TXgXan69YR%h+)VQD-1 zS4%12?wo-$iXL@L$gj^`z@M>8>$OwJC#+Wn=CyMZuiFo;V`wd8iAoSqvGj=Qxe=6T z&knVHC3Ix#MJUsJ<_XdoaYEUkFjFHhpZ8@p9;$Wccsf>Q?o|4u(|x9t+n1xj8CeR* z0f$Z6Kcx`=+s=|6Ha*A+!rn#$7pNPV;n4802GD#SE1AKs+Y3jx7Xb>iDn&1*rTvtW z)~0vH{9073ybC;bJ(&oVjjdgHj#G$=rR^_l_w4=O)cxf_MZDr|H@fF4hg>IlDIiuS zj%f#}f}5w8UW0H7#mwo4QE5c?gs_caXP^4oJdZ&T<&3?6CUQ9j(5z}7w23d+TdNNs zo}m66mPo#}_$%(IDHXtA1U9w_IW;R!h45|<5S2^%tLYD2Pd`+37plT7{|z_#aNmcy z`A0n0e;?maM6L|#kcHX@X(isY&zEOJgF+`IW-q5nGi_Kc`L6L|n~5xtsL4Yh?2Mnf zftu-P5ua*a8K+?a+bFWM54~YdyS&X=X(x}Iz1OM!HCkz02PIm0-W9m6vecVhWmMX( zWVZcSZ9T4nvIbIPBvh;yw)chYjlY|LptZr+n%>Y^Wqv$%aIL1If9Q#k5he?gk-AZQ zvQ|zQr~9LtR|uBVWxRERaM3z{;{zx+6n*D;#Q0hpcvR<%TH@FlqUf?q=0+GwIuE-7 zhxFD}!P`{YIOYv7S*l){;nOjls$k5#nU~Cn*81P(V;9Xd@(Z)1BzJ~WHjr!#2FLtn zoa?<$G9&HWUL!FrlwN?1IN_(&`1(b_p=vt|Ho?+1#@$IN48hnr}av_#Ow@sE&p= zjS`SX_-70Fx^z2JenNu(*UdoDEx&$6)h-Oj{QU-3xrn=Q>FFwO@3d#=mt~kOuj@0t zufH_x@93Dfjdx_qa2i!5s@G3YcO8gN=Le1EDB|45LO8W2s^3>XD)1M+t}#~b5|Zd3 z=x}!XI8HKr0!haai=r-h@@Ol~&n+UF)m^;DfYp8pL-rg#U~=JJBvKCs%Dx58}a&t0~x~EpS@85!^ zVu@-NlAj;ItHn}0M>V~g=O#Lbrn7b2V8a z@7(6n^$|V+z*awAJ7eJG$MmYunPEtcXx&gI`d8?WAy76M*u3Q7r8(*huCpU4?gsIZ zTCm~xHQjnB-pD#>St0O4SLjIEL%!wWZnB;bPsGYoU~a?R4T+7bSXb3*^Gkd7+J1`! z>r(K%k$HCR)alY8zX8hM4~gnAXWB6f=xf#q#)2^y(}uhXfT`RRT=*KC-f14LqzSnn zqy+`W@9q(w2i*F$F^LWTS@#~Z5k9MKAquKy1dag;G?NX6polNJ!ZjAPv7kNDs?s9vgmbvzr@{iCx*EKglDXXW&)KGHWA>{(O9&wbzRV084)m_l_-w5gr8Lxd)_4ZYI zw2}3B84zX6uCyI4Pth7HZ{OQSw^s`o1DOf-;@#8Q!tjZK>r+o;>GYPig*FGl(6mf- z0;0@ur;R(#MOM=MUcaZ{Ei~V;scFfcQM2tNY9=4V9EPnuygKy~y=fxO!clszwei=> z_n{+ok_DE|vL{>#o|JpHv81Os`aJPDR63`CLzvv*oXlH?ZjbM5oF;w1g}B<0f}Y>i z>KQfPe&-yqAl2p4_>18@`J{$FhWf2Gb1?YqF;d0oF~v5Dv9899cg4)&m$-q!CFIk# zf%9D>35K|b-+Jz7ul4CNx3sHC@V(%0Z`erEjdGUq+LX{}(Gt{Cy&o5z7V>0RHa+UYxl8X<`j+JcQpszVzvi zs`Zi_;Sq|r*6-}dB6WruuY3eMvrCR(?7WV3M6W7G_;yQEB2Mw=#ob8pyYl^E=+RG? zoRxFj$DU}Rgoaja+k(9UxMOL7@Oj2 z$YONdpyx1ihEzXeT8L`3vcDK0k!3o&=&68fi|J<78odo-+~{FXv_b_^{b=_8hU zA;3&9qv?uBC5F$ftLBz4_KaQi%baBSki=VPtlQ*5K0x`K zFZhJ8W%{|yI|5}GA+P8iFLowHus~hjZbZJd(uw6Je&PZ7?0^fXhCyKwv9>a zcg%|jQ)z$qhAsQ18VXDbD<<*a-y+I`L3^3?AtM78mPhRGR_kO}oxoPc)|SXtFO@4n zn-GLS?8W>*jpB!0wSsm_Ad8U!%(lIr3m6a2p=|$Zj$vj4y|u9zqJUHgGa$H>pj6o_ z)M*cvyDU7CEI(e6p>FPPjm?x7YHhu%RgZD73&uqAX%EdmE*^H2!ry4)a6Z-c98MpZ z1k_hYpDX4KY{KU`#lasG9|h?HVqam3O&0G70D`}1)_+YY$T-2*xE%>pJS>>8O}Y_)G3QR zgGvPOH*}hWPgv}{!zNuq0-6CxrSY*8vH_5+jgnt;loXl=H*cDq=)|#)%b?yRFBIdV zjj+dZ<#QOxp92*fipd#R=+hB zZig?l0vu*y2eMYp&;s=bw(*6AE*G{Bx-7=nSlCAd{j_qhw!aJ4`y?=%jA&2C+Ly^E zbHxG-c1VuRurWGVH3XCAnAnhlJ0|B@|80bZgVhqJ?<0xBKl#gWV4nR>ts(K`o%!5(`l&wR~0V3h<)&Z4@=756=m5+O8CjoP{kY zwD>9Dx%Ud;s~!vF5ZX)VKR#{l#_>YZlOf$v?a64b`q-VzHt6J<6tO17TiGBcYk zdg}u4uLkP&*>HgMKb{5{RofS58I138vOR-ex&mgkAW3pl-GOd1RNBrP$@^bgp6&@3 zJlSaa(c;PHpKFlI)qvyk5|l*e0SqX!uv?Tijh{$gO=_7d&-O8*dZaoCQa?D*t)==? z$w&QhrPJk09=K9PPS`A+P9lnKSlNy%KzS0W{lvlQ>O+^(D1XD-7AOMZXAyCu*4Q`Q z8l9mAp02Zs<-x+Tny?FPhX3?Q=?7tp4cbBs28rtPSgqcMn^O_0o{E|~GqUH2;UiET zlpBsDsU0pJF-9%Ue=NUtatqwk47Ci;Il-?PS5de50980Yxi?8s9MtOd>o-W2?-a=I z?sZK9CR;5xN!DXm3yA{R$=k2FB%xJt+xNL7>))xJlSu@wE!dEQYk4z=07AwX1|rDA z8G;R;A2QGu6z7JGRhw%vB70~BT-8Yiyi;>)J9WiF1NQ>7mjs-WYRs| zmpU}nqSt&0>+xuT&fcRzJzF3Pl+`mBtmf{TI)k$4P!xn;`Q?NQK0!@5%uD56QWx@5 zU-AHx)&COPi>Y5d6T`dp06|2YtO^1DVjI#SzwCABx;z%|E9|<%((b(!)EM^t`VyKF zFHPSY&vGv__<-|9xGSEFpntvk4fLxmgwiU4CEC`y*?|XoCLbc(&vy<6PBDvH`09tsYKJ?w+4|X-?laLVSNT8f8CD zhf7ui&^^)V$TQg39`y{$@$rilIHtIw#*GS4t#xo?OAPNjQhrEf*o#3&;N{AZjLa-X zlQ#BQIezTR>TE46bQaV;?~LdKy?Wk?nWF~{DeKDz_{YKAPD)N`ZcaR9#)kqiJ24?a z;uc3%1H3{;N1br&C&;L(dNs5#iYVW1__%te5o$zxZyPe=KiiP*iY1ML+|HG5cPz)C z%U8dYjy~%xMomq0q1*j=RuA{D(pE`|Hkbik*)Tfe>bLC&Tp?ED4}B&gkMXVFN%zAS zh$X8N?L*(qyxkZdZDA%Wp<8OtA7B{rm0RiLKp{HN;Vu;y_#5_l_?LHu%~;z$^Ez zV}A$;>`Oyku6||pxfkbb6{)w)(=xY4wViucFrw`1WDL+YQKzG>8lWkB>E0!j5ZyKx z`ht8i{;&u!0$e|sncnENwP|mfP$|uQEN52MxnOtESsJcIyF*QO#C|2TEc;j4Qxs)N zxU)E3y$^NdXDe?S9Vto~$bedFJ)9&IZJ#4itw^43ieW!rUyvNLKXW0@6p!jbYDT;U zzI6Th;zFLAwJEUcUI2>v^rXg{ELD#dQ@lm@fF|$eE1oQ1u2F>(nnlj9;{0TOhGsjO4|Mp)*Prq|TQTf? z?g!IlcxwIg7{pG05A4~{Tt1C|y}Q*VHM$af4`J1W_Io?2B2;Ko7pGbN`q@iYIdMBD zuw8(3v;AMN^74>|_gNlIxvR*m0e?}aK#>!K!dEu;YZ;T9c0Jm<8nX^Rli%kL12;dqHldeP#wP5uk+P*kiF5dp!(_gm)(r!9bh&?cJ72}a z4tD6-d>a7=v_ONV8Eo|2i2($|Wb}mBH681JRFlR{@mHVKrWZ8od4$W3T{QWjlqI=Y z9nyqeQ5iep)E0)L&OZWd1w~6I62mv(Cf{2&M%`v5d&N9Jj17ByNQK zBnlH*H_y+EE}NX0i7lPvik_Vq$^0tc-nj~iH7lsbN4Eg;6-tf8ccOum&>Ua4Wrp8B zWVy(y>>o9>0s5c`$!1%;J})XCYB|~moPXTOdH)**;ZaH$ZTc(?=B{>kr;9=t`?3*NBKyUCHI{l7%=Q zyqS@cED#Zzqh-#&@uKo<;Tec|lgK|R^)+fagw0()TD@!HYPrmN!cn%cbk7hnC)*fg zZOvo;Z#j)i^4cT824NZMeNxcUuc%5pRkHe=v_g1lc)RLPTfZAQjR~-yV2R3&jOTMj zMyhB&k{9lR7u@Y@hVjT(x#Za7A&Vt#pgoWrfhzmZac6w+0{o>_F8ll8$jItet&_JC zZ+$}E$|=H#E8v=-xos-jOAUm@MC6V@%4ExqBIjlEsq78d2koHoy)Qw+y8wQ*cvxXc z`c!&CtO*Z}!VbSr*i3dwIE(dPCZ33CTy+S)y<6l;e7{-Q9yUxIsB8W;^u)0m(ZU&7 z+|i_et}wRfPNcexjHe91NaEx~+|%hP^vGsH@d9z#!F3@NHi=tOBo@iR<>{M+@z;Qv zHAx8}uO4&_M?QvoY&BAIZ?d<4@`E>7OQcx6ForqSHW%rMp$?O$YCa`cWDQhC8Cm}$ z)pI|#>_-Q?MY*6{cD?n~?0a?g5JDI&&s@NAeKdlx>%1;H-k5Eh%geN0{CaWI{0-Yl z>BSi)f-}Ml2E046@jf*70k`F`#Prvj3Ha00r;vu#yHmen;YYvB^)_BK`=*^7i#kl5 zy2oApTtGH*^uuts#neTQf5#dn=$T$dk;F-y=Qilq8peS8}={_x`yv3KW=pI{qH z+4k&v0XcL~CzjH;%k{f1ZR`s3H5R8vzrlWy8S5cH6XO6tgo$G~*L+oa>-a&%+7%s| z_5r|=fWxe8VQO>NfRP995e0cznFs-CA00s@Gsou*$_5-1 zzgaNzHWtA;f(LVX$t;Dd`iM_E0IL%dDQpR3s0Ws9@5rSc_8sT}`)NrWaXy;Q-7fC?wKfS)eNB{r; literal 0 HcmV?d00001 diff --git a/package-info.json b/package-info.json new file mode 100644 index 0000000..b4378fd --- /dev/null +++ b/package-info.json @@ -0,0 +1,22 @@ +{ + "name" : "meshwarp", + "version" : "0.0.1", + "author" : "Cycling '74", + "description" : "Deform visual material projected on an arbitrary number of planes", + "max_version_min" : "8.2.0", + "max_version_max" : "none", + "os" : { + "macintosh" : { + "min_version" : "none", + "platform" : [ "x64" ] + } +, + "windows" : { + "min_version" : "none", + "platform" : [ "x64" ] + } + + } +, + "homepatcher" : "meshwarp-launcher.maxpat" +} diff --git a/patchers/jit.gl.meshwarp.maxpat b/patchers/jit.gl.meshwarp.maxpat index 0096841..8dbbccd 100644 --- a/patchers/jit.gl.meshwarp.maxpat +++ b/patchers/jit.gl.meshwarp.maxpat @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 676.0, -1019.0, 768.0, 485.0 ], + "rect" : [ 568.0, 79.0, 876.0, 485.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -171,7 +171,7 @@ "maxclass" : "inlet", "numinlets" : 0, "numoutlets" : 1, - "outlettype" : [ "jit_gl_texture" ], + "outlettype" : [ "" ], "patching_rect" : [ 47.0, 12.0, 30.0, 30.0 ] }