Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Assigning Normals for all triangles in a fan?

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2000
    Posts
    9

    Assigning Normals for all triangles in a fan?

    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.

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,979

    Re: Assigning Normals for all triangles in a fan?

    Why don't you simply try?

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,797

    Re: Assigning Normals for all triangles in a fan?

    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).]
    Deiussum
    Software Engineer and OpenGL enthusiast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •