  | 
  | 
 
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
/*
right=up.eye
eye=right.up
up=eye.right
*/
#declare campos = <0,80,-250>;
#declare cameye = vnormalize(<20,12,0>-campos);
#declare camup = <0,1,0>;
#declare camright = vnormalize(vcross(camup,cameye));
#declare camup = vnormalize(vcross(cameye,camright));
#declare FontSize = _clamp(1.7,0.1,2);
#declare camang = 40;
camera {
  location campos
  right camright
  up camup *(image_height/image_width)
  direction cameye*(image_height/image_width)
  angle camang
}
#macro label(Text,objv,r,col)
#local vl = vlength(objv-campos)/88;
#local pnt = camup*((r*.95)+vl*FontSize)+objv;
#local eye = vnormalize(pnt-campos);
object {
  text {
    ttf "Arial.ttf" Text 2 0
    texture {  pigment { rgb col }  finish { ambient 1 diffuse 0 } }
  }
  translate x*(strlen(Text)*-0.28)
  scale <vl*FontSize,vl*FontSize,vl*FontSize>
popmatrix(vnormalize(vcross(camup,eye)),vnormalize(vcross(eye,vcross(camup,eye))),eye,pnt)
  no_shadow
}
#end
label("HELLO 162",<60,24,80>,48,<0.0196, 0.0196, 0.2156>)
label("Here are 492",y* 29.9,24*.8,<0.30196, 0.0196, 0.2156>)
so u can likely tweak to get the result
 Post a reply to this message 
 
Attachments: 
Download 'labels9.png' (213 KB)
 
  
Preview of image 'labels9.png'
   
   
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
reminder, popmatrix() is Matrix_Trans(A, B, C, D) in POV.
transforms.inc
translations are easier when u stick to same name funcs.
limited RAM upstairs.
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
oh right, now I remember. for bottom text, consider font height.
#macro label(Text,objv,r,col,top)
#local vl = vlength(objv-campos)/88;
#if (top)
#local pnt = camup*(r*1.05)+objv;
#else
#local pnt = -camup*(vl*FontSize+r)+objv;
#end
#local eye = vnormalize(pnt-campos);
object {
  text {
    ttf "Arial.ttf" Text 2 0
    texture {  pigment { rgb col }  finish { ambient 1 diffuse 0 } }
  }
  translate x*(strlen(Text)*-0.25)
  scale <vl*FontSize,vl*FontSize,vl*FontSize>
popmatrix(vnormalize(vcross(camup,eye)),vnormalize(vcross(eye,vcross(camup,eye))),eye,pnt)
  no_shadow
}
#end
 Post a reply to this message 
 
Attachments: 
Download 'golfdimples10.png' (87 KB)
 
  
Preview of image 'golfdimples10.png'
   
   
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
and finally, start with
#declare camup = <-1,1,0>;
text is transformed, and its normal points at camera.
 
 Post a reply to this message 
 
Attachments: 
Download 'golfdimples11.png' (95 KB)
 
  
Preview of image 'golfdimples11.png'
   
   
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
remove redundant,
add scale to text centering. done.
/*
right=up.eye
eye=right.up
up=eye.right
*/
#declare campos = <0,80,-250>;
#declare cameye = vnormalize(<20,12,0>-campos);
#declare camup = <-1,1,0>;
#declare camright = vnormalize(vcross(camup,cameye));
#declare camup = vnormalize(vcross(cameye,camright));
#declare FontSize = _clamp(1.7,0.1,2);
#declare camang = 40;
camera {
  location campos
  right camright
  up camup *(image_height/image_width)
  direction cameye*(image_height/image_width)
  angle camang
}
#include "transforms.inc"
#macro label(Text,objv,r,col,top)
#local vl = vlength(objv-campos)/88;
#if (top)
#local pnt = camup*(r*1.05)+objv;
#else
#local pnt = -camup*(vl*FontSize+r)+objv;
#end
#local eye = vnormalize(pnt-campos);
object {
  text {
    ttf "Arial.ttf" Text 2 0
    texture {  pigment { rgb col }  finish { ambient 1 diffuse 0 } }
  }
  translate x*(strlen(Text)*-0.15*FontSize)
  scale vl*FontSize
  Matrix_Trans(vnormalize(vcross(camup,eye)),camup,eye,pnt)
  no_shadow
}
#end
label("HELLO 162",<60,24,80>,48,<0.0196, 0.0196, 0.2156>,1)
label("Here are 492",y* 29.9,24*.8,<0.30196, 0.0196, 0.2156>,0)
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
As for 3D point to screen xy, you'll need a few things.
POV's Perspective Matrix
InvertMatrix function
CameraMatrix 4x4
inv cam to world matrix, subv(pnt-campos)
pop world matrix
if (point[2] > 0) pop perspective matrix
which returns xy;
That's your camera.
> 0 because u dont have eyes in the back of your head.
if < 0, do nothing, move-on to the next pnt/star/object.
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
if you're fairly quick, u have one more question looming ---
unresolved constant of "88" -
represents a perspective cancel.
how much bigger to stay the same size at a distance?
 ... so that's your home work, resolve the last constant.
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
"Melody" <nomail@nomail> wrote:
> if you're fairly quick, u have one more question looming ---
> unresolved constant of "88" -
>
> represents a perspective cancel.
>
> how much bigger to stay the same size at a distance?
>  ... so that's your home work, resolve the last constant.
time's up. pencil's down, a trick question doesn't require math.
88 = ground 0.
a constant.
distance at which u see object of size 1 at size 1.
perspective is all about divide by Z.
but that may not be POV, which may include near far points and doodads.
close enough tho.
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
self adjusting to stay the same size at another FOV
fl = 1/tan(radians(fov/Aspect/2));
// fl * centerx = actual focal length
vlen / 88 becomes ...
vlen / (fl * 23.6)
or simply vlen / fl;
that was the bonus answer nobody got.
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
On 19/01/2020 07:16, Melody wrote:
> #macro label(Text,objv,r,col,top)
> #local vl = vlength(objv-campos)/88;
> #if (top)
> #local pnt = camup*(r*1.05)+objv;
> #else
> #local pnt = -camup*(vl*FontSize+r)+objv;
> #end
> #local eye = vnormalize(pnt-campos);
> object {
>    text {
>      ttf "Arial.ttf" Text 2 0
>      texture {  pigment { rgb col }  finish { ambient 1 diffuse 0 } }
>    }
>    translate x*(strlen(Text)*-0.15*FontSize)
>    scale vl*FontSize
>    Matrix_Trans(vnormalize(vcross(camup,eye)),camup,eye,pnt)
>    no_shadow
> }
> #end
Thank for this macro. It seems to be working perfectly.
My firt try with **label()**
Thanks :)
-- 
Kurtz le pirate
Compagnie de la Banquise
 Post a reply to this message 
 
Attachments: 
Download 'norma_triangle2.jpg' (43 KB)
 
  
Preview of image 'norma_triangle2.jpg'
   
   
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 
 | 
  |