Is it possible to have multiple triangle strips with one jit.gl.mesh?

hollyhook's icon

I have a array of points in 3D recorded with kinect. I send this array as a matrix to jit.gl.mesh. The draw_mode is tri_strip, and I send an index array to let jit.gl.mesh know how to combine the points to triangles. So far it works fine.

Now I wonder how I could start a new strip of triangles? It happens that my 3D points are not necessarily adjacent. Is this possible with tri_strip? or do I have to use triangles instead?

Rob Ramirez's icon

i think you can have a strip per matrix row if you send in a 2D matrix. requires that each strip have the same number of vertices. if that doesn't work for you than create a jit.gl.mesh per strip, and use something like JS or poly~ to manage them.

hollyhook's icon

Thanks, Rob, so glad to see your skull img here...

That would be one strip per matrix row, then. The index matrix (rightmost inlet of jit.gl.meh) should then also be multidimensional then? each row contains indexes of a single strip?

It could work for meshes shaped like a blanket. For the kinect data, the vertix matrix contains many points which should not be indexed, like 0,0,0. Therefore the strips cannot have identical number of triangles --> the number of indexes per strip vary. Any idea how to fill up the index matrix? With negative entries in the index matrix, max crashes.

Rob Ramirez's icon

if you're using an index matrix, then you should just use @draw_mode triangles i think. there is no requirement for the triangles to be connected.

diablodale's icon

Assuming a few things that are not written above... could you send the whole unedited pointcloud to jit.gl.mesh and then:
1) Use near/far clip to get rid of geometry you don't want
or
2) Use a geometry shader to inspect each vertex and throw away any triangles you don't want drawn? E.g., discard any triangles having a vertex being (0,0,0).

An approach like this might leverage the existing ease of using gl.mesh while getting the filtering you want.

hollyhook's icon

thanks diablodale, for you suggestion. There are so many ways to proceed, and I'm not sure if i choosed the right one. This is what I did:

I wrote a little filter (in js right now) which gets a coordinate, and returns a matrix with all points that are closely located to the starting point, resp closely located to points closely located to the starting point, etc. Will probably release it some time. It efficintly reduces the number of points in the cloud.

Next thing I did was creating triangle index, I dropped the idea of using tri_strip right now, as I still can't see how to use for that kind of data.

Next, I feed that triangles into jit.gl.mesh, noticing that the auto_normals didn`t work (or I did expect something different) so now I also calculate the normals in js.

I learned a lot by doing everything on my own, but I wonder if that is the way to do it? Are there other means in Max to get the result, and I just didn't found them? Or is that such a unusual thing to do? If I continue to do so, my next step might be to integrate pcl library as external...

diablodale's icon

Usually there are many ways to achieve a result. Perhaps what you describe is one of them.

It is not completely clear what you are trying to do, therefore I can only provide ideas as above. I gave two ideas and Rob gave one. It is your role to explore and test the ideas available to you to see which works best for your specific need.

hollyhook's icon

Yes, as always you are totaly right... I was just a bit complaining around, sorry for spreading bad vibrations. My goal was to render a human body part in 3D, like a head or a hand. The solution I found is surely not the best one. As you say, I have to explore and test other ways to solve it. I was just hoping that there would be a shortcut.