## OpenGL: How To Scale X,Y So that it is independent of Z?

Jan 6, 2013 at 2:19pm

# OpenGL: How To Scale X,Y So that it is independent of Z?

Hello, I am trying to scale my X,Y values so that they are always between -1 to 1, and adjusting Z will only influence their size but not their position (the same behavior Z has when X,Y both are 0, but instead it can be anywhere on the screen). I don’t know how to achieve this scaling though. I can’t figure out the ratio of Z to X,Y. Here is a test patch:

– Pasted Max Patch, click to expand. –

Thanks for any help!

#49317
Jan 8, 2013 at 2:53pm

hi rob, thanks for the reply. i am familiar with the @scale attribute, but my question is how to account for the difference in X,Y values when Z values change? imagine the screen you view the openGL window on as a 2 dimensional plane, with X values and Y values always being between -1 and 1. If I change the Z value, the location of the objects on this 2 dimensional plane will also change (though their actual x,y values stay the same, the appearance is that with lower Z values, the objects move progressively inward). How can I adjust X and Y according to Z, so that when Z values change, the ‘appearance’ of X and Y stays the same (though the actual values get shifted according to the difference in Z)? I hope I am making myself clear! :-P Sounds a little complicated, here is a simple patch to illustrate my conundrum:

– Pasted Max Patch, click to expand. –
#177199

You must be logged in to reply to this topic.