POV-Ray : Newsgroups : povray.general : Making labels that don't rotate while object does : Making labels that don't rotate while object does Server Time
8 Aug 2024 14:16:03 EDT (-0400)
  Making labels that don't rotate while object does  
From: David Mathog
Date: 27 Nov 2000 12:48:53
Message: <3A222E05.1EE37B6A@caltech.edu>
I'm going slightly batty with this one - any help will be greatly
appreciated.

I've got a set of objects in POVRAY coordinates and
to make them rotate/zoom/translate the location,look_at,right, up,
and direction vectors are moved around.  That works fine.  Then I try
to put labels into the frame so that they are stable in the viewed
frame.  That is, they run along the final images X axis like a caption,
and it goes wrong most of the time. This works correctly if the view
is in the XY,XZ, or YZ plane, or
even down the 1,1,1 vector, but in between there are slight in plane
rotations of the text. They are still placed correctly though in
the final image's X,Y coordinates.  Following my signature there
is a file example.pov showing this effect with Povray 3.1g. 
The image contains spheres at the edges of a 100 unit cube and a
string of Mg atoms running from the origin out to 100,100,100. 
Render it with

povray "+Iexample.pov" "+L/usr/common/povray31/include"
   "+W640" "+H480" "+FP"  "+Oexample.ppm"
   
In the resulting image the orientation or the ORIGINAL povray
coordinates
(those of the spheres) are now:

         Y axis
         o         o
         ^
       o |       o
         |
         |
         |
         0 ----->  o X axis
        /
       o         o
       Z axis

The logic I used was:

 1.  Initial coordinates had a unit rotation matrix and 
     RIGHT   =  (1.3333,0,0)  (640 x 480 image)
     UP      =  (1,0,0)
     LOCATION= (-1,0,0)
     LOOKAT  =  (0,0,0)
     DIRECTION= (1,0,0)

 2.  The forward rotation matrix to the new view (which is part way
between
     down the Z axis and the 1,1,1 vector):

          0.9221,   -0.1690,    0.3480
          0.0612,    0.9519,    0.3001
         -0.3820,   -0.2555,    0.8882

 3.  The text is placed and then rotated by the inverse of this matrix
     followed by a sign change on the 3rd column. That should place the
     text in the appropriate position in the POVRAY coordinates where
     the object lives.  And it almost works, but not quite.

What am I doing wrong here?

Thanks,

David Mathog
manager, sequence analysis facility
Biology Division, Caltech

************************** begin example **********************


//frame: 3

// rotation matrix + offset vector 
//        0.9221,   -0.1690,    0.3480,
//        0.0612,    0.9519,    0.3001,
//       -0.3820,   -0.2555,    0.8882,
//      100.0000,    0.0000,    0.0000

//-----globals_from_povinterp----
#declare my_linearvar = 0.5000  ;
#declare my_cyclevar  = 0.0000  ;


//-----various_includes----
// POV-Ray ray tracer scene file, generated by Swiss-PdbViewer  3.60
// 100 100 n 1
// File:Z:\simple.pov
// Swiss-PdbViewer can be retrieved by anonymous ftp at:
// http://www.expasy.ch/spdbv/mainpage.html
//
// POV-Ray can be retrieved at: http://www.povray.org
// Mega POV can be retrieved at: http://nathan.kopp.com/patched.htm 
// N.Guex, 1995-2000
//
#version 3    // this scene uses POV-Ray 3.x syntax

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

// ------ COLORS ---------

#declare ATM_FINISH = finish {specular 0.9 roughness 0.001 ambient rgb
<0.3,0.3,0.3> }
#declare RIBBON_FINISH = finish {specular 0.9 roughness 0.001 ambient
rgb <0.3,0.3,0.3>}
#declare SURF_FINISH = finish {specular 0.9 roughness 0.001 ambient rgb
<0.3,0.3,0.3>}
#declare EDM1_tex = texture {pigment {colour red 0.475 green 0.000 blue
0.000 } finish {specular 1 roughness 0.001}}
#declare EDM2_tex = texture {pigment {colour red 0.475 green 0.475 blue
0.475 } finish {specular 1 roughness 0.001}}
#declare N_tex = texture { pigment { colour red 0.224 green 0.318 blue
1.000 } finish{ ATM_FINISH }}
#declare C_tex = texture { pigment { colour red 1.000 green 1.000 blue
1.000 } finish{ ATM_FINISH }}
#declare O_tex = texture { pigment { colour red 1.000 green 0.000 blue
0.000 } finish{ ATM_FINISH }}
#declare P_tex = texture { pigment { colour red 1.000 green 0.659 blue
0.075 } finish{ ATM_FINISH }}
#declare H_tex = texture { pigment { colour red 0.275 green 0.800 blue
1.000 } finish{ ATM_FINISH }}
#declare S_tex = texture { pigment { colour red 1.000 green 0.922 blue
0.000 } finish{ ATM_FINISH }}
#declare X_tex = texture { pigment { colour red 0.624 green 0.624 blue
0.624 } finish{ ATM_FINISH }}
#declare SSBnd_tex = texture { pigment { colour red 1.000 green 0.922
blue 0.000 } finish{ ATM_FINISH }}
#declare HBnd_tex = texture { pigment { colour red 0.000 green 1.000
blue 0.000 filter 0.0} finish{ ATM_FINISH }}
#declare WkHBnd_tex = texture { pigment { colour red 0.561 green 0.675
blue 0.561 filter 0.0} finish{ ATM_FINISH }}
#declare Clash_tex = texture { pigment { colour red 1.000 green 0.424
blue 1.000 filter 0.0} finish{ ATM_FINISH }}

// ------ Bonds radii ---------

#declare rRIBN = 0.06   // flat Ribbon radius
#declare rEDM = 0.025   // EDM cylinder radius
#declare rSURF = 0.025   // SURFACE cylinder radius (when not filled
surf.)
#declare r_Atm = 0.200   // atom radius
#declare r_Bnd = 0.200   // bond radius
#declare r_HBnd = 0.075   // H-bond radius
#declare CA_relativeSize = 1.000   // enlargement factor for CA

 #declare rDOT_SURF = 0.05 // radius for accessible surf. dots.

 #declare VDW_factor = 0.200   // changing this value will alter the
radius of "joining" atoms

// ---- Radius for  atoms ----
// ---- Radius for "spacefilled" atoms end with '_' ----
 #declare rMg = 5.00 * VDW_factor
 #declare rMg_ = 5.10
// ---- Radius for "joining" atoms ----
// when atom radii below are all set to 1.0, you obtain a smooth
"sticks" model

// ---- some TEXT parameters ----
 #declare r_UserDist = .04   // radius of distances measurement lines
 #declare Label_scale = .4   // Text height in angstroms
 #declare Label_XDecal = 0  // Horizontal offset from CA
 #declare Label_YDecal = 0 // Vertical offset from CA

 #declare Label_ZDecal = (-0.5) // offset from CA toward camera

 #declare Dist_scale = .4   // Text height in angstroms
 #declare Dist_XDecal = (-.6) // Horizontal offset from middle of H-bond
 #declare Dist_YDecal =  0   // Vertical offset from middle of H-bond

 #declare Dist_ZDecal = (-.25)  // Depth offset from middle of H-bond

#declare Label_tex = texture { pigment { colour red 1.000 green 1.000
blue 0.000 } finish{ metallic }}
#declare LABEL_FINISH = finish {specular 1 roughness 0.001}
#declare Dist_tex = texture { pigment { colour red 1.000 green 1.000
blue 0.000 } finish{ metallic }}
//************ OBJECTS *********
// POV-Ray ray tracer scene file, generated by Swiss-PdbViewer
// File:Z:\simple.inc
// Swiss-PdbViewer can be retrieved by anonymous ftp from:
// http://www.expasy.ch/spdbv/mainpage.html
//
// POV-Ray can be retrieved at: http://www.povray.org
// N.Guex, 1995-1999
//

//  MG 4 
#declare A0_shape=union{
sphere  {<5.00,5.00,-5.00>,rMg texture{X_tex}}
bounded_by{box{<3.00,3.00,-7.00>,<7.00,7.00,-3.00>}}
}

//  MG 5 
#declare A1_shape=union{
sphere  {<10.00,10.00,-10.00>,rMg texture{X_tex}}
bounded_by{box{<8.00,8.00,-12.00>,<12.00,12.00,-8.00>}}
}

//  MG 6 
#declare A2_shape=union{
sphere  {<15.00,15.00,-15.00>,rMg texture{X_tex}}
bounded_by{box{<13.00,13.00,-17.00>,<17.00,17.00,-13.00>}}
}

//  MG 7 
#declare A3_shape=union{
sphere  {<20.00,20.00,-20.00>,rMg texture{X_tex}}
bounded_by{box{<18.00,18.00,-22.00>,<22.00,22.00,-18.00>}}
}

//  MG 8 
#declare A4_shape=union{
sphere  {<25.00,25.00,-25.00>,rMg texture{X_tex}}
bounded_by{box{<23.00,23.00,-27.00>,<27.00,27.00,-23.00>}}
}

//  MG20 
#declare A5_shape=union{
sphere  {<30.00,30.00,-30.00>,rMg texture{X_tex}}
bounded_by{box{<28.00,28.00,-32.00>,<32.00,32.00,-28.00>}}
}

//  MG21 
#declare A6_shape=union{
sphere  {<40.00,40.00,-40.00>,rMg texture{X_tex}}
bounded_by{box{<38.00,38.00,-42.00>,<42.00,42.00,-38.00>}}
}

//  MG22 
#declare A7_shape=union{
sphere  {<50.00,50.00,-50.00>,rMg texture{X_tex}}
bounded_by{box{<48.00,48.00,-52.00>,<52.00,52.00,-48.00>}}
}

//  MG23 
#declare A8_shape=union{
sphere  {<60.00,60.00,-60.00>,rMg texture{X_tex}}
bounded_by{box{<58.00,58.00,-62.00>,<62.00,62.00,-58.00>}}
}

//  MG24 
#declare A9_shape=union{
sphere  {<70.00,70.00,-70.00>,rMg texture{X_tex}}
bounded_by{box{<68.00,68.00,-72.00>,<72.00,72.00,-68.00>}}
}

//  MG25 
#declare A10_shape=union{
sphere  {<80.00,80.00,-80.00>,rMg texture{X_tex}}
bounded_by{box{<78.00,78.00,-82.00>,<82.00,82.00,-78.00>}}
}

//  MG26 
#declare A11_shape=union{
sphere  {<90.00,90.00,-90.00>,rMg texture{X_tex}}
bounded_by{box{<88.00,88.00,-92.00>,<92.00,92.00,-88.00>}}
}

//  MG27 
#declare A12_shape=union{
sphere  {<0.00,0.00,0.00>,rMg texture{X_tex}}
bounded_by{box{<-2.00,-2.00,-2.00>,<2.00,2.00,2.00>}}
}

//  MG10 
#declare A13_shape=union{
sphere  {<100.00,0.00,0.00>,rMg texture{X_tex}}
bounded_by{box{<98.00,-2.00,-2.00>,<102.00,2.00,2.00>}}
}

//  MG11 
#declare A14_shape=union{
sphere  {<0.00,100.00,0.00>,rMg texture{X_tex}}
bounded_by{box{<-2.00,98.00,-2.00>,<2.00,102.00,2.00>}}
}

//  MG12 
#declare A15_shape=union{
sphere  {<0.00,0.00,-100.00>,rMg texture{X_tex}}
bounded_by{box{<-2.00,-2.00,-102.00>,<2.00,2.00,-98.00>}}
}

//  MG13 
#declare A16_shape=union{
sphere  {<0.00,100.00,-100.00>,rMg texture{X_tex}}
bounded_by{box{<-2.00,98.00,-102.00>,<2.00,102.00,-98.00>}}
}

//  MG14 
#declare A17_shape=union{
sphere  {<100.00,0.00,-100.00>,rMg texture{X_tex}}
bounded_by{box{<98.00,-2.00,-102.00>,<102.00,2.00,-98.00>}}
}

//  MG15 
#declare A18_shape=union{
sphere  {<100.00,100.00,0.00>,rMg texture{X_tex}}
bounded_by{box{<98.00,98.00,-2.00>,<102.00,102.00,2.00>}}
}

//  MG16 
#declare A19_shape=union{
sphere  {<100.00,100.00,-100.00>,rMg texture{X_tex}}
bounded_by{box{<98.00,98.00,-102.00>,<102.00,102.00,-98.00>}}
}

// ------- Accessible Dot Surf. --------
//END



// ----- simple -----
object{ A0_shape }   //  MG 4 
object{ A1_shape }   //  MG 5 
object{ A2_shape }   //  MG 6 
object{ A3_shape }   //  MG 7 
object{ A4_shape }   //  MG 8 
object{ A5_shape }   //  MG20 
object{ A6_shape }   //  MG21 
object{ A7_shape }   //  MG22 
object{ A8_shape }   //  MG23 
object{ A9_shape }   //  MG24 
object{ A10_shape }   //  MG25 
object{ A11_shape }   //  MG26 
object{ A12_shape }   //  MG27 
object{ A13_shape }   //  MG10 
object{ A14_shape }   //  MG11 
object{ A15_shape }   //  MG12 
object{ A16_shape }   //  MG13 
object{ A17_shape }   //  MG14 
object{ A18_shape }   //  MG15 
object{ A19_shape }   //  MG16 
   text{ttf "cyrvetic.ttf", " MG16 ",.5,0.1*x 
   texture{ pigment{ colour red 1.00 green 1.00 blue 1.00} finish{
LABEL_FINISH }} scale <Label_scale,Label_scale,Label_scale>
   translate
<-100.000+Label_XDecal,0.000+Label_YDecal,0.000+Label_ZDecal>}


//-----captions_from_povinterp----
   text{ttf "cyrvetic.ttf", "down Z->down (1,1,1)",0.0,0.0
     texture{ pigment{ colour red 1.00 green 1.00 blue 1.00}finish{
LABEL_FINISH }} scale<104,104,104>
     matrix <
        0.9221,    0.0612,    0.3820,
       -0.1690,    0.9519,    0.2555,
        0.3480,    0.3001,   -0.8882,
    -1909.2278, -632.9749, 3498.6069
     >
   }

//************ CAMERA *********
camera { location  <  361.3149,  311.6474, -922.2031>
         direction <   -0.3480,   -0.3001,    0.8882>
         up        <   -0.1690,    0.9519,    0.2555>
         right     <    1.2295,    0.0816,    0.5093>
         look_at   <    0.0000,    0.0000,    0.0000>
         angle 26
}
 
//************ LIGHTS *********
#declare Intensity = 2
background { color rgb < 0.000, 0.000, 0.275 >}
object { light_source {<-1486.2982, 2381.7993,-2029.2732> color rgb
Intensity*1.000 }}
//END


Post a reply to this message

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