jit.gl.gridshape scale like jit.gl.sketch quad?

Duffield's icon

Hey Guys,

I hope I'm not missing something painfully obvious. But is there any way to change the dimensions of jit.gl.gridshape like one would a quad (i.e., using corner positions). One solution I tried was to change the anchor point on jit.gl.gridshape, however, this only affected the position origin and not the scaling.

The main task I'm trying to accomplish is that I want to make dynamic EQ bars in open.gl, so I want the position of the bottom corners to be fixed, but the top going up and down to sound. I'm trying to find a more efficient way of drawing multiple shapes along an axes (i.e., like a for loop and class in something like in Processing), which is why I'm trying to move away from jit.sketch with moving / drawing a shape..

I have this working with jit.gl.sketch and quads, however, I'm trying to improve my coding habits in terms of elegance, and trying to set the position via something like jit.expr (which I don't remotely get how to apply to this even after starting at it for hours and many patches) or jit.gl.multiples so I can make an array of shapes and iterate their positions.

Thanks in advance

LSka's icon
Max Patch
Copy patch and select New From Clipboard in Max.

I usually apply a combination of "scale" and "position":

Duffield's icon

Thanks!

I was thinking of doing that...it just seems...inelegant...despite that it's still simple.

Duffield's icon

Hey Guys,

Just thought I'd share my progress as I find the documentation on jit.gl.multiple lacking. I'm almost there, however, I'm encountering some problems (although I feel like the issue lies with jit.expr

In my patch I have a jit.expr that multiples the Y coordinates by another matrix to get the height of the EQ bars. Right now they're all set to one height just for simplicity, but I want them to eventually to be independent. I'm trying to just use one matrix and change the height of the bars via jit.fill values to the second plane of the matrix but can't seem to get it working. Any suggestions? I'm sure I'm missing something (some of this type of matrix storage / manipulation for coordinates is newer territory for me despite staring at jit.recipes for a while).

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

I'm happy to share my fully working version with comments to help people with the parts that confused me.

LSka's icon
Max Patch
Copy patch and select New From Clipboard in Max.

here's a quick'n dirty fix.

But a while ago I made something nicer: I'm going to search it and post it here.

LSka's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here's a cleaner version:

Duffield's icon

Thanks @LSKA, this is great! Very elegant!

I just have a few questions just to make sure I understand fully how it works (resulting in me asking less questions on these forums :) )

In the example that started all of this (before getting into jit.gl.multiple), we took the Y-scale value, subtracted it's growth from the position on a single [jit.gl.gridshape]. In my patch, I took this concept and applied it to [jit.gl.multiple] and it worked, however, for all of them.

In the "dirty fix" which was your modification of my patch, this did not work perfectly, as the baseline shifts up and down with the height (although I'm not certain why unless it's a little bit of massaging the sequence of events). Your cleaner version is beautiful, so here is where I will focus.

MY UNDERSTANDING:OF YOUR CLEANER VERSION PATCH:
In the last post (the cleaner version), I see that the [jit.matrix heights] is outputted into a list, which gets sent into the [jit.expr] as well as the [p Scale]. I think I pretty much understand what's going on in [p Scale], what I don't understand is whether or not we are still subtracting the position to compensate for the varying Y-height of the objects scale parameters.

I notice you modified the [jit.expr] by subtracting one from the second plane (the Y-position coordintates), but this just sets the bottom Y-position for the bars. If I attach a jit.spill my values on plane 2 (the one containing the Y-coordinates) are set to 0.

In [p Scale] if I remove the list coming into the [jit.pack], the bottom position of the planes shifts with scaling, however they remain the same size. This isn't unexpected as the values coming in for the height, are cut off, however the position shifts still.

MY QUESTION:
How is subtraction process of the height increasing from the position decreasing happening? I feel like there's something very simple I'm not seeing / cluing into.

Thanks in advance!

LSka's icon

The answer is very simple: the position is controlled by the [jit.expr], but I believe you are watching the wrong plane. Remember that in Max and Jitter most of the counts start from 0, so plane X is 0, Y is 1, and Z is 2. If you use [jit.spiil @plane 2] you are extracting the Z plane, which is set to 0 by jit.expr. Try plane 1 instead.

Duffield's icon

Doh! I should've slept :)

Yep was looking at the wrong plane. I

understood that the position was in [jit.expr] but I had a misunderstanding about what the simple math was doing. My brain was that as the height was raising, the position was inversely subtracting to compensate rather than add. Bah! Sorry, for overlooking these super simple things!

Thanks so much for your help!