Convert a matrix into 3D points

ganeshnrao's icon

I am just starting out with Max Jitter. I am trying to convert a 1-plane matrix (jit.matrix) with gray-scale values into a point-cloud. I want to use the cell numbers as x and y values for drawing points, and the cell's value (0-255) as the z for the points in the cloud. I would like to avoid using any plugins and third party apps, because I want to learn to do this purely with Max Jitter. Any ideas?

Wetterberg's icon

look at jit.gl.multiple - it's perfect for this type of stuff. Essentially it'll let you create multiple objects, with variables based on matrix inputs.

Open up its helpfile. You'll see a subpatcher that's called "p InitialGLParams". This has four matrix outputs going into jit.gl.multiple. See it?

jit.gl.multiple has @glparams for position, rotatexyx, scale and texture. you want to play with one with a single input for "position"

dtr's icon

This patch does exactly that, in 2 ways. Is meant for making the kinect depth map into a pointcloud. You should be able to extract what you need from it.

Rob Ramirez's icon

here's a very basic example of turning the output of bfg into a point-cloud using gl.mesh.

Max Patch
Copy patch and select New From Clipboard in Max.

the trick is to combine the output of jit.expr, which simply gives us our x and y values going from -1 to 1 (snorm) with the output of bfg, which gives us our z displacement.

ganeshnrao's icon

Thanks Rob Ramirez, that was precisely what I was looking for!