Forums > Jitter

generating gl.mesh points, ignoring empty cells

November 17, 2011 | 10:05 am

How can I make ignore ’empty’ (zeroed) cells when manually sending vertex matrices to it, or otherwise remove them? At the moment my nice clean mesh is spoiled by a bunch of triangles reaching out to 0. 0. 0.

I’m sure theres probably an easy solution, but I’ve spent so long on it I can no longer see woods or trees.

My instinct was to use jit.iter to route all the non-zero cells into a new single-row matrix, but that requires you to know the number of cells needed in advance (unless you can add cells dynamically? – its been a while since I was in matrix-land).

I’ve taken that idea to the point I’m jit.glue ing extra columns onto the matrix, but it all seems hopelessly inefficient to be run multiple times per frame (plus that solution currently reports ‘invalid glue output’).

Is it possible to send individual messages for the vertices? That would solve my pre-made matrix issues.

November 17, 2011 | 4:50 pm

Hi bferns,
You’ll need to use an index matrix to tell which cells are actually relevant to the geometry you want to draw. There are a number of ways to generate the indices, but they’re highly dependent on how the data is arranged in your vertex matrix.

November 18, 2011 | 8:25 am

Thanks Wesley – that sounds exactly what I need (and the ‘the index array is an array of indexes’ reference description is a little tautological!). I can see its a one plane integer matrix – is it simply 0/1 or do the values modify the order of rendering?

November 21, 2011 | 8:33 am

I’ve gone with the assumption that its a simple on/off state for the index matrix cells (as feeding in incrementing integers for each cell drew nothing). I have this so far, but it appears to be only rendering a partial row whether I feed it 0s and 1s or 0s and 255s in char or long types:

— Pasted Max Patch, click to expand. —

If you disconnect the index matrix on the rightmost mesh input and re-initialise the mesh object (delete then undo) you’ll see the mesh I’m trying to trim the circle from. Looking at the expr I stole to generate the vertex matrix, to me it seems that the dims (640×480) from the original video matrix should still apply when it comes to masking the circle.

November 21, 2011 | 5:12 pm

hi bferns. maybe this wikipedia article will help clarify:

also look at the link, Face-Vertex Meshes.
eg, if you wanted to draw the first three faces of the image in that article, your index array would contain the values 0, 4, 5, 0, 5, 1, 1, 5, 6

October 22, 2013 | 4:29 pm

I have a similar issue, so I’m posting here.
I have a point cloud generated with Kinect and jit.openni
For some reason, there is just a "blind spot", a single matrix cell with Z value 0 (the red dot in the attached image). I can make it disappear by changing its color or altering its position when I’m in draw_mode points, but I can’t use any other draw_mode, because it causes odd faces to be generated.

I’m struggling with edgeflag and index arrays to try to tell to simply ignore that point, but it seems I can’t understand how they work.
Any practical example would be very appreciated.

I’m attaching an example patch and a matrix file to show the issue.

— Pasted Max Patch, click to expand. —


  1. Screen-shot-2013-10-23-at-1.21.10-


October 23, 2013 | 1:25 am

I now understand that the "single point" actually are all the "black" cells in the jit.matrix…

October 23, 2013 | 3:33 am

I almost found a solution, using Wesley Smith’s xray.jit.cellminmax object


— Pasted Max Patch, click to expand. —


I used the [p CalcGLHeight] and [p Pixel2GL] found in xray.jit cellminmax helpfile to relocate the "zero" points. Since Wesley’s example was using a 2d mesh, I’m now missing the correct method to calculate the Z values of the points…
(see image attached)

  1. Screen-shot-2013-10-23-at-12.26.24-


Viewing 8 posts - 1 through 8 (of 8 total)

Forums > Jitter