PDA

View Full Version : Assigning Normals for all triangles in a fan?



rjh57
04-07-2003, 08:38 AM
Is it possible to assign a glNormal for EACH (!!) of the triangles in a GL_TRIANGLE_FAN suchs as:
glBegin(GL_TRIANGLE_FAN );
glNormal3i(...);
glVertex3i(...);
glVertex3i(...);
glVertex3i(...);
glNormal3i(...);
glVertex3i(...);
glNormal3i(...);
glVertex3i(...);
glNormal3i(...);
glVertex3i(...);
glEnd();

or do I have to use

glBegin(GL_TRIANGLES);
glNormal3i(...);
glVertex3i(...);
glVertex3i(...);
glVertex3i(...);
glEnd();
glBegin(GL_TRIANGLES);
glNormal3i(...);
glVertex3i(...);
glVertex3i(...);
glVertex3i(...);
glEnd();
...

for each triangle? Thanks.

Zengar
04-07-2003, 09:50 AM
Why don't you simply try?

Deiussum
04-07-2003, 10:25 AM
If you want flat shading for triangles in a triangle fan, I think you'll have to use glShadeModel(GL_FLAT) and change the normal for the last vertex of each discrete triangle.

e.g.

glShadeModel(GL_FLAT);
glBegin(GL_TRIANGLE_FAN);
glVertex3f();
glVertex3f();
glNormal3f(triangle1normal);
glVertex3f();
glNormal3f(triangle2normal);
glVertex3f();
glNormal3f(triangle3normal);
glVertex3f();
etc.
glEnd();

If you want smooth shading, just supply a normalized average of all the face normals for each vertex.

Edit: Oops. You said fan, not strip. Same basic principle applies, though.

[This message has been edited by Deiussum (edited 04-07-2003).]