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 counterclockwise 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:warren@...
Warren L. DeLano, Ph.D.
Principal Scientist
DeLano Scientific LLC
Voice (650)3461154
Fax (650)5934020
> Original Message
> From: pymolusersadmin@...
> [mailto:pymolusersadmin@...] On Behalf Of
> Gareth Stockwell
> Sent: Wednesday, June 09, 2004 8:33 AM
> To: pymolusers
> Subject: [PyMOL] CGO raytracing problem
>
>
> Hello,
>
> I have a problem raytracing 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 raytrace it. What I see is
> that, from some angles, it raytraces OK, but then if I
> rotate by 45 or 90 degrees, the raytraced 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 <gareth@...>
> European Bioinformatics Institute
>
