Gareth,

        Yes...triangles needs normals in order to compute lighting.  You can
compute a single normal using cross products between any two sides of the
triangle, but you do have to be concerned about handedness, both in terms of
the normal direction, and in the ordering of vertices.  

        If I recall correctly, OpenGL triangles should be right handed: so
if you're facing the front of the triangle with the normal pointed at you,
then the vertices should be drawn with counter-clockwise ordering.  In other
words, with vertices: p1, p2, p3, the cross product (p2 - p1) X (p3 - p1)
should point in the same direction as the triangle normal.  If it doesn't,
then swap the ordering of any two points.

Cheers,
Warren

--
mailto:war...@delsci.com
Warren L. DeLano, Ph.D.
Principal Scientist
DeLano Scientific LLC
Voice (650)-346-1154 
Fax   (650)-593-4020
  

> -----Original Message-----
> From: pymol-users-ad...@lists.sourceforge.net 
> [mailto:pymol-users-ad...@lists.sourceforge.net] On Behalf Of 
> Gareth Stockwell
> Sent: Wednesday, June 09, 2004 8:33 AM
> To: pymol-users
> Subject: [PyMOL] CGO raytracing problem
> 
> 
> Hello,
> 
> I have a problem ray-tracing some CGO objects.  Basically I 
> have a script which produces a surface, in the form of a load 
> of CGO triangles.  This is done using a command which looks like:
> 
> my_cgo = [ BEGIN, TRIANGLES, 
> 
>   COLOR, r, g, b,
>   VERTEX x1, y1, z1,
>   VERTEX x2, y2, z2,
>   VERTEX x3, y3, z3, 
> 
>   ...
> 
>   END
> ]
> 
> (See attached script cgo.py for an example)
> 
> This works fine, until I try to ray-trace it.  What I see is 
> that, from some angles, it ray-traces OK, but then if I 
> rotate by 45 or 90 degrees, the ray-traced image gets darker 
> until it disappears.
> 
> I suspect that surface normals are the problem - do I need to 
> compute and then explictly state a normal for each vertex?
> 
> Gareth
> 
> 
> --
> Gareth Stockwell <gar...@ebi.ac.uk>
> European Bioinformatics Institute
> 



Reply via email to