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: Normals

  1. #1
    Guest

    Normals

    Hello all!

    Im calculating normals for every vertex, but in the end, it looks almost as if I was using GL_FLAT instead of GL_SMOOTH, anyway
    the way I calculate them is:
    C
    |\
    | \
    |__\B
    A

    A normal:

    v1=B-A
    v2=C-A
    nv=cross(v1,v2)
    d=sqrt((vn.x * vn.x) + (vn.y * vn.y) + (vn.z * vn.z))
    vn.x/=d
    vn.y/=d
    vn.z/=d

    B Normal:

    v1=C-B
    v2=A-B
    nv=cross(v1,v2)
    d=sqrt((vn.x * vn.x) + (vn.y * vn.y) + (vn.z * vn.z))
    vn.x/=d
    vn.y/=d
    vn.z/=d

    C Normal:

    v1=A-C
    v2=B-C
    nv=cross(v1,v2)
    d=sqrt((vn.x * vn.x) + (vn.y * vn.y) + (vn.z * vn.z))
    vn.x/=d
    vn.y/=d
    vn.z/=d

    I think this is the right way to do it, isnt it?

    Thx

  2. #2
    Intern Contributor
    Join Date
    Jan 2003
    Location
    UK
    Posts
    51

    Re: Normals

    All of the above calculate the same normal, the normal of the face. If you want smoothed normals: calculate all face normals, then for each vertex average the face normals of the faces that use that vertex.

  3. #3
    Guest

    Re: Normals

    Dam, i feel dumb :|
    Thx, ur very right

Posting Permissions

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