
First I want to thank Sven for solving the problem with the missing normals. But now I am a little bit confused. I'm sure to heard about that if you specify the vertexes of a polygon (with glBegin GL_POLYGON in c) counterclockwise then the normalvector is set automatically. That means if you look at a plane the normal vector points to you. Is'nt that true? My example problem seems to show that this is definitly not true. So if I want to use light (and that will be very often) and I have to specify these vectors by myself then I can't use the renderPrimitive Polygon or Quad in situ because the calculation of a normal vector of a polygon isnt that trivial. The simplest way I see is to reduce this calculation to a normal vector calculation of a triangle. So I'm forced to define a new function makePoly taking a list of Points, calculating the normal and draw a polygon with this points. Otherwise I have to write down some points more then one time, the first time in the makenormal-function and in the secont at the render call. 1. Is this the way? 2. Where is it used that normals aren't right-angeled to the polygon-plan? 3. Exists there some higher-level function. With best regards Patrick

Patrick Scheibe wrote:
But now I am a little bit confused. I'm sure to heard about that if you specify the vertexes of a polygon (with glBegin GL_POLYGON in c) counterclockwise then the normalvector is set automatically. That means if you look at a plane the normal vector points to you.
Is'nt that true?
No, it isn't. Some of the higher-level operations (e.g. evaluators, NURBS, quadrics) can optionally auto-generate normals, but this isn't the case for the basic rendering primitives (glBegin/glEnd). In fact, this can't be implemented, because the normal has to be specified prior to each glVertex call, but you don't know the face normal until you've specified at least three vertices. Furthermore, computing the face normal is only useful if you want "flat" shading, which often isn't the case.
My example problem seems to show that this is definitly not true. So if I want to use light (and that will be very often) and I have to specify these vectors by myself then I can't use the renderPrimitive Polygon or Quad in situ because the calculation of a normal vector of a polygon isnt that trivial. The simplest way I see is to reduce this calculation to a normal vector calculation of a triangle. So I'm forced to define a new function makePoly taking a list of Points, calculating the normal and draw a polygon with this points. Otherwise I have to write down some points more then one time, the first time in the makenormal-function and in the secont at the render call.
1. Is this the way?
Yes; OpenGL doesn't do this for you so, one way or another, you have to do it yourself.
2. Where is it used that normals aren't right-angeled to the polygon-plan?
It's often the case that a polygon mesh is just a sampling of a smooth surface. In such cases, the normal is a property of the vertex, not the face. I.e. where a vertex is common to multiple faces, the vertex has a single normal; for any given face, each vertex will typically have a different normal.
3. Exists there some higher-level function.
No.
--
Glynn Clements

Patrick Scheibe wrote:
[...] But now I am a little bit confused. I'm sure to heard about that if you specify the vertexes of a polygon (with glBegin GL_POLYGON in c) counterclockwise then the normalvector is set automatically. [...]
I think you refer to the fact that OpenGL has a notion of "front" and "back" for polygons. You can control which order (clockwise or counter-clockwise) should be considerered "front" via frontFace. Another tip regarding normals and lighting: Most of the time it's a good idea to have normals of unit length. If your application can't assure this, normalize and rescaleNormal can help. Cheers, S.
participants (3)
-
Glynn Clements
-
Patrick Scheibe
-
Sven Panne