ScreenToWorld Oddness

Feb 27, 2013 at 2:49am

ScreenToWorld Oddness

The Screentoworld message to jit.gl.render gives me results which I cannot figure out. This is the first time I have tried to use these commands, and I can’t figure out what they are supposed to do.

In my case, I would like to map 3d objects to positions on a plane. The positions of these objects should correspond to tracked aspects of the video which is the texture of the plane. I can do this by writing code to which I supply the dimensions of the video, the aspects of the 3d world, etc. but I was under the impression that I could use “screentoworld” for the same functionality. There must be a fundamental difference between what I expect and what is happening.

In the attatched MaxPat, I am simply trying to understand the relationship between the values I feed to the “screentoworld” message and the values I receive from the jit.gl.render object. What I expect is that if I give a screen coordinate of x=0, I should get a value representing the leftmost edge of the visible gl world. Instead, x=0 gives me -0.055228. If I then put this value into “worldtoscreen”, I get 152 back.

What “screen” is being considered, and what “world”?

Thanks in advance!

– Pasted Max Patch, click to expand. –
#66749
Feb 27, 2013 at 8:26pm

hi lembert.dome.
take a look at the following patch. if this doesn’t clear things up, please let me know what is not clear.

– Pasted Max Patch, click to expand. –
#240187
Feb 27, 2013 at 10:37pm

Ah! Thank you!
The difficulties I experienced were simply that I did not know the context. One important point: it is important to set the screenToWorld Z-position relative to the WorldToScreen Z-position after changing render-camera position.

What I am working on is akin to this patch:

– Pasted Max Patch, click to expand. –

`
The thing which made it work for me is to scale the video resolution to the x and y scale of the vidplane, and set the Z-position the same on vidplane and intersecting gridshape.

Next, I want to figure out an elegant way of doing the transform on the screen to world (my subpatcher) so the red sphere can follow rotations of the vidplane. Any hints?

Thanks again!

#240188

You must be logged in to reply to this topic.