Hi all,
I’m doing my first strides in a OF based project.
I’m simulating a map interface by drawing images on the z=0 plane.
I’m having problems with using ofCamera.screenToWorld to get points on the z=0 plane. The problem is that apparently I don’t properly understand the meaning of the screen z value.
I tried understand the problem by reading the usual materials here and there but to no avail. I’ll demonstrate my problems with examples.
My view size is 768x1024 (iPad).
I have an ofCamera “hanged above”, its values are:
position = 0,0,354.72402343750002
lookat = 0,0,0
fov = 60
nearClip = 8.86809921
farClip = 8868.0996
I found the following problems:

If I put screen z = 0, I should be getting a point on the near clip, right? but:
screenToWorld(384,512,0) gets me (0,0,337.005554)
but according to my calculations, I think it should be:
354.72402343750002  8.86809921 = 345.855924227

If I put z = 0.5, I was expecting to be half the way between the near and the far plane:
354.72402343750002  (8868.0996 /2) = 4079.32577656
but:
screenToWorld(384,512,0.5) gets me (0,0,319.357758)
which I totally don’t understand.
BTW, the far plane calculation does sort of work for me:
screenToWorld(384,512,1) gets me (0,0,8513.30664)
and 354.72402343750002  8868.0996 = 8513.37557656
(which is close enough??)
I tried calculating which screen z I need to give in order to get world z = 0 but to no avail. I resorted to “cheating”, by asking worldToScreen for the correct value:
worldToScreen (0,0,0) got me (384,512,0.95195198).
But I desperately want to understand how to calculate 0.95195198 myself.
Any help on the matter will be appreciated.
Thanks,
Tal