creating a cube with jit.gen

Marigold Maripol's icon

hi all-

i noticed there are primitives available in jit.gen for torus, sphere, cylinder, plane, and cone - yet there is no "cube". i am curious why that is and whether there is a simple way to write one.

thanks !

TFL's icon

I don't know reason why there is no cube in jit.gen, and I don't the math to create one, but you can still generate the vertex coordinates outside of jit.gen using a [jit.gl.gridshape @shape cube @matrixoutput 1] if you want custom matrix dimension/number of vertices, or [jit.gl.plato @shape cube @matrixoutput1] if you want the bare minimum triangles for a cube (2 per face).

Marigold Maripol's icon

hi all-

just wanted to follow-up on this, since i'm running into this problem again and trying specifically to avoid an external object.

while i'd like a cube in jit.gen, i'm also very curious to understand why it's not there already.

Matteo Marson's icon

HI,

A simple way to get a cube in Gen is by clipping a sphere:

Or if you need something more similar to what jit.gl.gridshape does, you can "cubify" a closed cylinder:

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