Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Function name for a face direction after rotation?

0 views
Skip to first unread message

Arlo

unread,
Nov 21, 2009, 5:53:48 AM11/21/09
to
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.

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

fungus

unread,
Nov 21, 2009, 5:59:06 AM11/21/09
to
On Nov 21, 11:53 am, Arlo <adsln...@mselva.demon.co.uk> wrote:
> 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 rendering, not 3D math.

Wolfgang Draxinger

unread,
Nov 21, 2009, 6:21:36 AM11/21/09
to
Arlo wrote:

> 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

Arlo

unread,
Nov 21, 2009, 9:53:57 AM11/21/09
to
Hi Wolfgang, didn't want to reinvent the wheel.

Thanks for letting me know searching for the function was wasting my time

fungus

unread,
Nov 22, 2009, 3:14:30 PM11/22/09
to
On Nov 21, 12:21 pm, Wolfgang Draxinger <wdraxin...@darkstargames.de>
wrote:

>
> 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.
>

...or transform the viewer by the modelview matrix.

Andy V

unread,
Nov 22, 2009, 11:18:40 PM11/22/09
to
On Nov 21, 6:21 am, Wolfgang Draxinger <wdraxin...@darkstargames.de>
wrote:
> Arlo wrote:

> 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.

Wolfgang Draxinger

unread,
Nov 23, 2009, 4:44:49 AM11/23/09
to
Andy V wrote:

> 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

Andy V

unread,
Nov 23, 2009, 9:38:08 PM11/23/09
to
On Nov 23, 4:44 am, Wolfgang Draxinger <wdraxin...@darkstargames.de>
wrote:

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

0 new messages