POV-Ray : Newsgroups : povray.general : Keep the text oriented toward the camera : Re: Keep the text oriented toward the camera Server Time
28 Jul 2024 22:16:33 EDT (-0400)
  Re: Keep the text oriented toward the camera  
From: MichaelJF
Date: 15 Jan 2014 10:35:01
Message: <web.52d6a9a4c5b03d678e0aa5d50@news.povray.org>
"YoM" <yoh### [at] gmailcom> wrote:
> Thank you. Maybe I don't understand Screen_Object variables but with:
> Screen_Object ( text {
>   ttf "cyrvetic.ttf" "TEST" 0, 0
>   pigment { Black }
>   translate <-2.311276, -3.133184, 0.000000>
> },<0,0>, <0.01,0.01>, true, 1 )
>
> my text is still not oriented toward my camera.

I think YoM will put a text object somewhere into the scene and adjust it with
the camera. Than the following code may be of help. May be it will not work with
every location and sky vector, but if not, exchanging the signs within the
Shear_Trans call should help. And it will adjust the first letter approximately
correct only. But for a short text setting the thickness to zero again it
should yield acceptable results.

The code uses transforms.inc which is included by shapes.inc here already.
Otherwise transforms.inc has to be included off course.

Best regards,
Michael

#include "colors.inc"
#include "textures.inc"
#include "shapes.inc"

// finish options
#declare ambientCoef = 0.2;
#declare diffuseCoef = 0.8;
#declare specularCoef = 0.8;

#declare CamLoc = <22.424428, 27.372077, 22.881150>;
#declare CamSky = <-0.190369, 0.724010, -0.663000>;
#declare Cam_LA = <1.214010, 0.842058, 0.000000>;
camera {
  perspective
  location CamLoc
  sky  CamSky
  right -x*image_width/image_height
  angle  30.000000*image_width/image_height
  look_at  Cam_LA
}

light_source {
  <22.424428, 27.372077, 22.881150>
  color  <1.0, 1.0, 1.0>*0.8
}

background {
  color rgb  <1.000000, 1.000000, 1.000000>
}

#declare Farben = array[10]
#declare Farben[0] = Red;
#declare Farben[1] = Yellow;
#declare Farben[2] = Blue;
#declare Farben[3] = Green;
#declare Farben[4] = Cyan;
#declare Farben[5] = Magenta;
#declare Farben[6] = Orange;
#declare Farben[7] = Black;
#declare Farben[8] = SlateBlue;
#declare Farben[9] = YellowGreen;

#declare Zufall = seed(3187);
#for(i,1,25)
   #declare TextLowerLeft=<-2.211276, -3.033184, 0.100000>  //  your original
position of the text object
                            + <rand(Zufall)*10,rand(Zufall)*10,rand(Zufall)*10>;
// add a random compenent
   #declare TransVec1=vnormalize(TextLowerLeft-CamLoc);
   #declare TransVec2=vnormalize(vcross(TransVec1,CamSky));
   #declare TransVec3=vnormalize(vcross(TransVec1,TransVec2)); // for the case
that CamSky and Transvec1 are not perpendicular

   text {
     ttf "cyrvetic.ttf" "Test" 1, 0  // increased thickness for testing the
orientation
                                     // only the first letter will
     pigment { Farben[int(rand(Zufall)*9.99)] }

      Shear_Trans(TransVec2,-TransVec3,TransVec1) translate TextLowerLeft
   }
#end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.