Forums > Jitter

coords of 3d cube as a single matrix?

Apr 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. —
Apr 12 2014 | 1:23 am

Not behind my computer right now. But if im right the 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 (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 2 years by  Andro.
Apr 12 2014 | 5:21 am

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

Apr 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 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.

Apr 12 2014 | 1:07 pm

Hopefully this is clearer…

— Pasted Max Patch, click to expand. —
Apr 14 2014 | 11:32 am

i would try something like the following:

-- Pasted Max Patch, click to expand. --

Apr 14 2014 | 8:07 pm

Yes! Thank you Rob!

Apr 21 2014 | 6:57 pm

Hmm… I’ve been having the damnedest time getting 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 as a matrix. Apparently that’s not the way it works? :/

Apr 22 2014 | 5:56 am

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

-- Pasted Max Patch, click to expand. --

Jun 15 2016 | 10:49 am

here’s an example building a cube completely in [gen]. I was getting rounding errors so there’s a healthy use of [trunc] and [floor] objects.

— Pasted Max Patch, click to expand. —

i’m not completely pleased with it because the coordinates don’t actually extend from (0,1), but it’s definitely a start.

Jun 15 2016 | 11:24 am

ok ignore the above and the issue about the coordinates, that was an insanely easy fix:

— Pasted Max Patch, click to expand. —
Viewing 11 posts - 1 through 11 (of 11 total)

Forums > Jitter