Forums > Jitter

coords of 3d cube as a single matrix?

April 11, 2014 | 3:03 pm

I know this is basic.. but jitter has remained a frustration for me since day one – and my shitty math skills don’t help the matter. :/

I need to enumerate the coordinates for a cube of a given dimension and store them as a single matrix which can then be rendered as a set of points in openGL.

I can generate the coords for a single ‘slice’ of a cube (using jit.expr to normalize the values of an input matrix), but it’s not clear to me (1) how to render the entire cube (I assume a combination of mesh + multiple would work?) and (2) the best way to store all the coords of the cube as a single matrix. The latter might not be necessary, but I need to be able to easily apply functions to all of the coords.

I hope that makes sense. I have been at this for days and my brain hurts.

– Pasted Max Patch, click to expand. –

April 12, 2014 | 1:23 am

Not behind my computer right now. But if im right the jit.gl.mesh object has around 5 to 6 inlets, the 1st inlet is the vertex array, so each vertex should have 3 pieces of data, xyz location. Feed in 8 vertex and you should have a cube, draw them in the right order or the drawing method could get messy.
To be sure how jitter wants the vertex array I think you can also get a jit.gl.platonic (set shape to cube) set matrix_out to 1, plug this into a jitter.matrix and see how the data is being sent out.

  • This reply was modified 5 months by  Andro.

April 12, 2014 | 5:21 am

And if im correct you have to send in more than a single matrix for jit.gl.mesh. I’d check the reference file.


April 12, 2014 | 12:38 pm

Andro, thanks very much for the reply!

Ya know, I think the best way to work this out is to enumerate all coordinate values of a cube into a single matrix. I can do that in Max with cascading uzis.. storing the coords in a coll and then dumping w/ setcell to fill a matrix. That way jit.gl.mesh works like a charm. Very straight forward.

It appears that my only snag is figuring out how to enumerate all values of a cube (of n-dimension) <i>within jitter</i>. I need to somehow iterate or loop values within jitter and I don’t know how do that. Better yet, I need to figure out how to enumerate the coords inside jit.gen… I need it to be as fast as possible.

I will post an example later today.

Thanks again for helping out.


April 12, 2014 | 1:07 pm

Hopefully this is clearer…

– Pasted Max Patch, click to expand. –

April 14, 2014 | 11:32 am

i would try something like the following:

– Pasted Max Patch, click to expand. –

April 14, 2014 | 8:07 pm

Yes! Thank you Rob!


April 21, 2014 | 6:57 pm

Hmm… I’ve been having the damnedest time getting jit.gl.mesh to output a matrix. Does @matrixoutput 1 not do this?

I assumed that I could specify coords for the mesh and then rotate the object with updated coords sent out the left outlet of jit.gl.mesh as a matrix. Apparently that’s not the way it works? :/


April 22, 2014 | 5:56 am

hi,
you could do the rotation in gen. It’s more easy if you want to find coords points .
mathieu

– Pasted Max Patch, click to expand. –

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