Is there an opengl function (I'm using java) that will return the
direction a face is pointing (relative to the viewer) after it's
drawn/rotated/translated.
The faces will be flat quads so I would assume anything at a right angle
to a vertex of the quad (parallel to the face's centre normal) would be
equivalent.
I can write something that will work this out from the quad and the
transforms but I feel there is likely to be a function already but I
don't know what it is called
No, OpenGL does rendering, not 3D math.
> Sorry if this is s simplistic question but...
>
> Is there an opengl function (I'm using java) that will return the
> direction a face is pointing (relative to the viewer) after it's
> drawn/rotated/translated.
No, OpenGL does not provide such functionality. It's a rendering API, not a
3D math library.
It's simple enough to implement, though: Multiplicate the surface normal by
the inverse transpose of the modelview matrix. The most difficult step is
determining the inverse of the modelview matrix.
Wolfgang
Thanks for letting me know searching for the function was wasting my time
...or transform the viewer by the modelview matrix.
> It's simple enough to implement, though: Multiplicate the surface normal by
> the inverse transpose of the modelview matrix. The most difficult step is
> determining the inverse of the modelview matrix.
Technically, this should be the signed area of the face. Not that
"surface normal" is not right, but it might be confused with the
vertex normals.
> Technically, this should be the signed area of the face. Not that
> "surface normal" is not right, but it might be confused with the
> vertex normals.
<nitpicking>
surface != face
I wrote surface normal for a reason: If the vertices are derived from an
analytical description, then one can get a smooth normal for every point on
the surface. Vertices are point samples somewhere on such a surface, so the
vertex normal _is_ the surface normal at the position of the vertex.
The transformation rules are invariant of the data representation.
</nitpicking>
Wolfgang
Yes, I was nitpicking also.
The original post did say explicitly "flat quads". However, I was more
thinking about
the OpenGL way of determining front facing vs. back facing. For that,
neither
the vertex normals NOR the "surface normal" is used.
--
Andy V