coords of 3d cube as a single matrix?
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.
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.
And if im correct you have to send in more than a single matrix for jit.gl.mesh. I'd check the reference file.
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) within jitter. 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.
Hopefully this is clearer...
i would try something like the following:
Yes! Thank you Rob!
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? :/
hi,
you could do the rotation in gen. It's more easy if you want to find coords points .
mathieu
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.
i'm not completely pleased with it because the coordinates don't actually extend from (0,1), but it's definitely a start.
ok ignore the above and the issue about the coordinates, that was an insanely easy fix: