From: John Stone (johns_at_ks.uiuc.edu)
Date: Sat Feb 06 2010 - 15:01:42 CST

Marc,
  I'm going to have to get back to you on this later in the
week, as it turns out there appears to be a small bug in Tachyon
that is preventing things from working properly in my testing.
It seems I must have broken the behavior of the focal plane distance
code when rewriting the camera implementation some time ago.

For the time being however, here's a VMD Tcl script that will
transform VMD molecule coordinates into Tachyon world coordinates,
and eye coordinates, giving a distance in eye space that one would
use for the depth of field focal plane distance (once the bug is
fixed in the recent versions of Tachyon...):

proc calcdofflfrompos { doftargetpos } {
  # convert to Tachyon left-handed coordinate system by negating Z
  set ZN {{1 0 0 0} {0 1 0 0} {0 0 -1 0} {0 0 0 1}}

  set T [lindex [molinfo top get global_matrix ] 0]
  set S [lindex [molinfo top get scale_matrix] 0]
  set R [lindex [molinfo top get rotate_matrix] 0]
  set C [lindex [molinfo top get center_matrix ] 0]
  set t [transoffset {0 0 -2}]
  set it [measure inverse $t]
  set G [transmult $ZN $T $S $R $C]

  # compute position in Tachyon world coordinates
  set transdoftargetpos [coordtrans $G $doftargetpos]
  puts "target pos (world): $transdoftargetpos"

  # recompute position in Tachyon's camera/eye coordinates
  set transdoftargetpos [coordtrans $it $transdoftargetpos]
  puts "target pos (eye): $transdoftargetpos"

  puts "radial dist. from eye to target: [veclength $transdoftargetpos]"
  
  # Since we know that VMD emits a fixed camera orientation
  # and rotates the molecule instead, we can use the Z coord
  # to determine focal plane distance.
  puts "Z dist. from eye to focal plane: [lindex $transdoftargetpos 2]"
  set focaldist [lindex $transdoftargetpos 2]
  
  return $focaldist
}

To use the script to compute Tachyon world coordinates and/or
plane-of-focus distance for use in depth of field renderings,
you'd do something like:
  set sel [atomselect top "index 1"]
  set pos [lindex [$sel get { x y z }] 0]
  calcdofflfrompos $pos

I'll get back to you again later in the week after I have
a closer look at what's going on in the Tachyon camera code.

Cheers,
  John

On Sat, Feb 06, 2010 at 11:15:34AM -0600, John Stone wrote:
>
> Marc,
> The focal length parameter is expressed Tachyon's world
> coordinate system, but this isn't the same as the molecule's
> coordinate system you're used to within VMD. If you like, I
> can provide you with some Tcl scripts that will convert from
> molecule coordinates to Tachyon's world coordinates, this can
> also be used to add special lighting and/or geometry beyond what
> VMD knows how to export itself. I'm heading into the lab in a while
> to finish working on a paper, while I'm there I'll dig up the
> Tcl scripts I mentioned and send them to you after I do a few
> tests.
>
> Cheers,
> John
>
> On Sat, Feb 06, 2010 at 05:07:07PM +0100, Marc Baaden wrote:
> >
> > Hi,
> >
> > I was experimenting with Tachyon's depth of field camera option to
> > highlight some parts of a scene generated with VMD. It is however not
> > quite clear to me how I can determine where the focus of the rendering
> > will be. Is it at the origin (0,0,0)? Is there any easy way to
> > determine which settings are needed to focus on a given atom/residue/
> > fragement of a molecule?
> >
> > Thanks in advance,
> > Marc
> >
> >
> > NB: Here is the changes that I made to the Tachyon file generated by VMD:
> >
> > [..]
> > Camera
> > projection perspective_dof
> > focallength 0.75
> > aperture 0.02
> > Zoom 0.666667
> > [..]
> >
> >
> > --
> > Dr. Marc Baaden - Institut de Biologie Physico-Chimique, Paris
> > mailto:baaden_at_smplinux.de - http://www.baaden.ibpc.fr
> > FAX: +33 15841 5026 - Tel: +33 15841 5176 ou +33 609 843217
> >
> >
>
> --
> NIH Resource for Macromolecular Modeling and Bioinformatics
> Beckman Institute for Advanced Science and Technology
> University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
> Email: johns_at_ks.uiuc.edu Phone: 217-244-3349
> WWW: http://www.ks.uiuc.edu/~johns/ Fax: 217-244-6078

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
Email: johns_at_ks.uiuc.edu                 Phone: 217-244-3349
  WWW: http://www.ks.uiuc.edu/~johns/      Fax: 217-244-6078