POV-Ray : Newsgroups : povray.advanced-users : Extract 2D screen coordinates from 3D : Re: Extract 2D screen coordinates from 3D Server Time25 Sep 2021 15:24:03 EDT (-0400)
 Re: Extract 2D screen coordinates from 3D
 From: kurtz le pirate Date: 22 Feb 2020 03:55:21 Message: <5e50ec79@news.povray.org>
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#5e50ec79%40news.povray.org",
"headline": "Re: Extract 2D screen coordinates from 3D",
"dateCreated": "2020-02-22T08:55:21+00:00",
"datePublished": "2020-02-22T08:55:21+00:00",
"author": {
"@type": "Person",
"name": "kurtz le pirate"
}
}
On 17/02/2020 04:00, Mike Horvath wrote:
>
> If it helps, the latest version of this script is on GitHub.
>
> https://github.com/mjhorvath/POVRay-Updated-Screen-Inc
>
> See if that solves your problem and let me know.

I put the test image in p.b.i. and yes it's OK
Code used in my scene :

#include "screen_mjh.inc"
...
// set the sky vector
Set_Camera_Sky(y)
// set the type of projection (orthographic or perspective)
Set_Camera_Orthographic(false)
// set width in relation to height
Set_Camera_Aspect(image_width,image_height)
// set the location, look_at, and angle
Set_Camera(CamLoc, CamLookAt, CamAngle)
...
...
#declare pt1 = <6,4,6>;
drawPoint(pt1, rPoint, Red, true)
#declare ScreenXY1 = Get_Screen_XY(pt1);
#declare Text1 = text { ttf "crystal.ttf" "Pt1" 0.01 <0, 0, 0> pigment {
color Red } scale 0.03 }
Screen_Object(Text1, <ScreenXY1.x/image_width,
1-(ScreenXY1.y/image_height)> , 0.01, false, 1)

#declare pt2 = <-3,2,-5>;
drawPoint(pt2, rPoint, Cyan, true)
#declare ScreenXY2 = Get_Screen_XY(pt2);
#declare Text2 = text { ttf "crystal.ttf" "Pt2" 0.01 <0, 0, 0> pigment {
color Cyan } scale 0.03 }
Screen_Object(Text2, <ScreenXY2.x/image_width,
1-(ScreenXY2.y/image_height)> , 0.01, false, 1)

#declare pt3 = <4,6,-1>;
drawPoint(pt3, rPoint, Orange, true)
#declare ScreenXY3 = Get_Screen_XY(pt3);
#declare Text3 = text { ttf "crystal.ttf" "Pt3" 0.01 <0, 0, 0> pigment {
color Orange } scale 0.03 }
Screen_Object(Text3, <ScreenXY3.x/image_width,
1-(ScreenXY3.y/image_height)> , 0.01, false, 1)

However, some very small adjustments need to be made as you can see.
Get_Screen_XY() return coordinates in "image unit" and they must be
reduced to [0..1] and vertical position must also be changed with
1-value. Resulting in :
<ScreenXY/image_width, 1-(ScreenXY.y/image_height)>
for the *location* parameter of the *Screen_Object* macro.

Great !!

--
Kurtz le pirate
Compagnie de la Banquise
```