screentoworld zdepth problem

Mar 13, 2012 at 8:22am

screentoworld zdepth problem

Hello I was hoping someone could help with a problem i’ve run into…

Im trying to draw in 3d. I’m using a wacom tablet, its X-Y values are converted into X-Y screen co-ordinates using jit.gl.render screentoworld message. The pressure is going to be the Z depth, this is where the problems arise.

Im using a patch I found long ago on this forum to move the camera around, to be precise the code lets the camera orbit 0,0,0. Using the code I can enter the camera amplitude i.e. how far the camera is from 0,0,0.

As i move the camera around I always want to be able to draw on the plane that bisects 0,0,0.

0,0,0 is always in the centre of the screen.

After reading the manual and lots of posts on here i thought that the below would hold true in regard to screentoworld’s z depth component-

If-

camera amplitude = 100
near_clip = 1
far_clip =1000

Then

entering 0.1 (1000/100) into screentoworld’s Z depth would allow me to draw on the plane that bisects 0,0,0.

However this is not the case. Screentoworlds Z-depth seems to not to operate linearly…

The below holds true

If CamAmplitude = 200 then Zdepth = 0.996

CA = 100 Zd = 0.991
CA = 50 Zd = 0.981
CA = 12.5 Zd = 0.961
CA = 6.25 Zd = 0.921
CA = 3.125 Zd = 0.681

Logically

CA = 1000 Zd = 1
CA = 1 Zd = 0

The above is true to three decimal places. As you can see every time CA halves Zd goes down by double what it went down before.

Now possibly this is an issue with the code I’m using to move the camera around or possibly its non-linearity in the Z component of screentoworld.

This has had me stumped for 1 and half days so it would be wonderful if someone could help.

Below is an example patch.

Thanks
Will

`

– Pasted Max Patch, click to expand. –

*edit in this patch far_clip is at 1001 but it shouldnt throw the patch too far off!

#62340
Mar 13, 2012 at 5:05pm

if you want to know the screen-Z position of the world origin, send the message “worldtoscreen 0 0 0″

then use the returned z component of worldtoscreen with your screen x and y positions for the “screentoworld” message.

let me know if that doesn’t work.

#225191

You must be logged in to reply to this topic.