Approaches to drawing a variable thickness opencube in GL

ifranco's icon

Hi Maxers,
what options are there to creating a structure similar to an open cube in GL but with a variable width (thickness)? I’d like to it to be procedural (gridshape, sketch, mesh) in order to transform it freely.

Thanks!
Ivan

Andro's icon

Hi Ivan.
Maybe you could post a picture showing what you mean.
The jit.gl.gridshape object can create an open cube. @shape open cube.
But I'm not sure how you'd change the thickness.
I would personally make my model in blender then use jit.gl.model @matrix output 1 to jit.gl.mesh.
I imagine you'll have to unpack parts of the vertex array and manipulate them with jit.gen to change it in a generative manner.

Rob Ramirez's icon

as andro mentioned, lots of ways to go about this, but more than likely you want to use jit.gl.mesh, and adjust the @line_width attribute. below is an example that creates a cube using the matrixoutput of gl.gridshape (because of the way gl.gridshape creates it's geometry using a "grid", outlining a cube requires concating 3 gridshapes together). you may just want to create your own geometry matrices by hand (setcell 0 0 val -1 -1 -1, etc).

if the line_width parameter does not give you enough control over the lines (which it probably won't), you can use jit.gl.path @pathstyle ribbon. i've provided an example of both of these techniques below.

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

lastly, if you really want to have control, you should look at creating a geometry shader that generates polygons of variable thickness for every line passed in. you will have to search the googles for an example of that. max comes with some geometry shader examples, that will get you started (search in the browser for "gm.", gm.videopoint is a good one to study)

ifranco's icon

Hi, thank you both for these good suggestions. I was wrapping my head around understanding how to subtract entities (iit.concat). Also the path is a good way to go about it. I was getting frustrated with the low level of control provided by glwidth.

Cheers!
Ivan

Andro's icon

Hi Ifranco,

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

Was thinking about your post and remembered something I was working on a while ago with distance functions.
Heres a patch which creates an open cube with the jit.gl.isosurf object.
I've added a bunch of parameters to allows you to change pretty much everything you want with the open cube.
Hope this helps you out.

daddymax's icon

That is a wonderful patch andro - thanks for the annotations too - like many people GEN still hurts my brain and this sort of thing lets me poke around and experiment.

Andro's icon

Your welcome. If you check my profile you'll see a post with signed distance functions. Theres around 10 examples with different shapes in one patch. Plus the link to the web page where i found the formula

daddymax's icon

Brilliant - thanks again - will see if i can get my head around the idea with these patches. At this late stage in life i really wish id have taken math more seriously in high school and university.