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

Thread: how to calculate normal for each vertex?

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    singapore
    Posts
    2

    how to calculate normal for each vertex?

    what formula can i use to calculate normal for vertex??
    i use this parametric formula for my object:
    x=1.6f*(cos(0.5*angle1)*cos(0.5*angle1)*cos(0.5*an gle1));
    y=1.6f*(cos(angle2)*sin(0.5*angle1)*cos(angle2)*si n(0.5*angle1)*cos(angle2)*sin(0.5*angle1));
    z=1.6f*sin(angle2)*sin(0.5*angle1);

    can anyone pls give me example how to use parametric function in opengl??i put it under double loop and i failed to get good shape. i just started studying com graphics this week.

    [This message has been edited by caesar5 (edited 03-01-2004).]

    [This message has been edited by caesar5 (edited 03-01-2004).]

  2. #2
    Junior Member Regular Contributor
    Join Date
    Sep 2000
    Location
    Lubbock, TX, USA
    Posts
    197

    Re: how to calculate normal for each vertex?

    Iterate through all triangles of your mesh. For each vertex of each triangle, take the cross product of the two edges the vertex is part of and store it associated to the vertex (you'll get several normals for each vertex, because every vertex can be part of several faces). Add all normals for each vertex. Normalize. Voila

  3. #3
    Intern Contributor
    Join Date
    Feb 2004
    Posts
    98

    Re: how to calculate normal for each vertex?

    You can use auto-normals and evaluators to render your geometry.

    OR you can take cross-products of the partial derivatives to find the normal.

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    1

    Re: how to calculate normal for each vertex?

    By the way, could U show me how to render the parametric object in OpenGL in step-by-step instructions as i'm a newbie for this one

  5. #5
    Member Regular Contributor
    Join Date
    Sep 2000
    Location
    Inside an xbox
    Posts
    279

    Re: how to calculate normal for each vertex?

    Just take the vertex normal from your favourite 3D program ( 3dsmax, maya, lw.. ) in your exporter

  6. #6
    Junior Member Newbie
    Join Date
    Mar 2004
    Location
    Earth
    Posts
    19

    Re: how to calculate normal for each vertex?

    Take a look at the NeHe Tutorials , they will be invaluable if you're learning to code in OpenGL. (Or spend some $$ on a book like I did)

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    San Diego, CA, USA
    Posts
    604

    Re: how to calculate normal for each vertex?

    C'mon guys, he's got an analytic formula here!

    Caesar, you should take advantage of this fact and use the gradient operator to find your normals (ask if you need more info on this). You don't need to pre-tesselate or use any adjacency information then, and the normals will probably end up being smoother.

    Don't forget to normalize the result

Posting Permissions

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