## exact positioning of elements in gl.sketch

Dec 15, 2008 at 11:04am

# exact positioning of elements in gl.sketch

Hi all,

I was wondering how I can position a couple of videoplanes on a pixel-
accurate position within an opengl environment.
Here’s the thing : I have a background image (on a videoplane filling
the screen), with 2 holes cut out, using alphachannels. I know where
and how big these holes are in pixels, but how do I translate this to
opengl so I can position 2 other videoplanes on the exact location?

Trial and error gives me the right spot, but there’s got to be someway
to do this without guessing, right?

regards,

Brecht.

#41355
Dec 15, 2008 at 11:30am

GL will normalize
coordinates across [-1, 1] x [-1, 1]

HTH

#147193
Dec 15, 2008 at 11:41am

so divide 1 by the input

0.0 0.0 will be the middle

Anybody tell me how many decimal points GL will use for positioning?

If I divide 1 by four then everything is easy as you get 0.25
BUT if I have 1 by 14 then I get 7.142857142857e-02

So for accurate positioning how many places do I use say for a position message?

#147194
Dec 15, 2008 at 12:50pm

Ok. That was simple… so basically it could be done like this :
trigger display to get resolution, input pixels, output gl coords.

– Pasted Max Patch, click to expand. –

On 15 Dec 2008, at 12:30, Carl Rohumaa wrote:

>
> GL will normalize
> coordinates across [-1, 1] x [-1, 1]
>
> HTH

#147195
Dec 15, 2008 at 12:54pm

Well, sort of works for me, there’s some bugs in there :) Too quick
with it.

On 15 Dec 2008, at 13:50, Brecht Debackere wrote:

> Ok. That was simple… so basically it could be done like this :
> trigger display to get resolution, input pixels, output gl coords.
>
>

– Pasted Max Patch, click to expand. –

>
>
>
> On 15 Dec 2008, at 12:30, Carl Rohumaa wrote:
>
>>
>> GL will normalize
>> coordinates across [-1, 1] x [-1, 1]
>>
>> HTH
>

#147196
Dec 15, 2008 at 1:09pm

Can’t open your patch as I am only on Max4.6

You will need to get the scale right on the videoplane and then send messages like @position 0.5 -0.5 to get stuff in the right place.

I am using @texture_reset 2 message in the videoplane in my context

#147197
Dec 15, 2008 at 1:15pm

I have started drawing this stuff on paper so I can visualize what I am doing before I start inputting numbers. BTW the coordinates will be from the middle of your object so you might have to take this into account.

So anybody tell me how many decimal places to use? So for example if my calculations give me 0.3141592653589793 etc

#147198
Dec 15, 2008 at 1:45pm

you could of course send jit.gl.render the ‘screentoworld x y z’
message and get the gl coords out of its dumpout

On 15 Dec 2008, at 14:15, Carl Rohumaa wrote:

>
> I have started drawing this stuff on paper so I can visualize what I
> am doing before I start inputting numbers. BTW the coordinates will
> be from the middle of your object so you might have to take this
> into account.
>
> So anybody tell me how many decimal places to use? So for example if
> my calculations give me 0.3141592653589793 etc

#147199

You must be logged in to reply to this topic.