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 4 of 4

Thread: Normals & strip triangles

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2003
    Posts
    15

    Normals & strip triangles

    Hi !
    How should I define my table when I want to work with strip triangles with normales when I use glDrawElements ?
    With simples triangles are there just 1 normal defined for just 1 vertex, but with strip ones it is much less vertex definied (we don't should repeating the defiinition for some vertices).
    I have really no ideo of how does it works, have someone any example ?
    M@o

  2. #2
    Intern Newbie
    Join Date
    Apr 2003
    Posts
    34

    Re: Normals & strip triangles

    You have an array of vertices which you pass to glVertexPointer. So, you then must have a corresponding array of normals which you pass to glNormalPointer. Now when you call glDrawElements, the index array will not only pick out the correct vertices, but also the correct normals, assuming that the elements in the normals array are in the same order as the elements in the vertex array.

    If you want to know how to calculate the normals, just ask.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2003
    Posts
    15

    Re: Normals & strip triangles

    Originally posted by cragwolf:
    You have an array of vertices which you pass to glVertexPointer. So, you then must have a corresponding array of normals which you pass to glNormalPointer. Now when you call glDrawElements, the index array will not only pick out the correct vertices, but also the correct normals, assuming that the elements in the normals array are in the same order as the elements in the vertex array.

    If you want to know how to calculate the normals, just ask.

    Does it works normals array for Triangles strip ? With glDrawElements too ?
    How do U make with the average ? (smooth shading it is ?)

    M@o

  4. #4
    Intern Newbie
    Join Date
    Apr 2003
    Posts
    34

    Re: Normals & strip triangles

    Originally posted by Mao:
    Does it works normals array for Triangles strip ? With glDrawElements too ?
    Yes.

    How do U make with the average ? (smooth shading it is ?)
    I assume you already know how to calculate the normal for a triangle. For an array of triangle strips, the normal for a particular vertex can be calculated by averaging the normals for each of the 6 triangles surrounding the vertex. You could do:

    normvert := (n1+n2+n3+n4+n5+n6)/6;

    But a slightly better method is to weight each of the six surrounding normals by the angle their triangles make at the vertex. You can also preserve some edges if you like, especially if adjacent normals differ by too much.

Posting Permissions

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