×

Discussion Board

Results 1 to 3 of 3

Thread: Normals vector

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    22

    Normals vector

    Hi!
    I made a 3d model and I load it into OpenGL ES, but the illumination is wrong! I look at the example simplelightin particular the duck model: the number of the normals is the same of the vertices; I try a to make a lot of simple model but the number of the of normals is never equal to the vertices number. Hoe Can I have a correct illumination of my model?
    Thanks!

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Posts
    68
    Hi.

    OpenGL ES (and standard OpenGL API, when used with vertex arrays) takes the per-vertex data from the vertex arrays. Whenever Nth vertex coordinate is fetched from corresponding vertex array, color/normal/texture coordinate is fetched also from Nth position in the corresponding array.

    If your model does not have normals for each vertex, you will have to replicate normals so that every vertex coordinate has also some meaningful normal behind the normal array at the same index. Some options:

    - duplicate normals (some normals may not be valid depending on how you do it)

    - generate normals by yourself from the triangle data in the application (normal for vertex N in typical application is the average of the normals of triangles that share vertex N)

    - generate normals in similar way in some external tool

    - find an exporter that is able to generate the right normals (for each vertex)


    In my opinion, the best solution is to not store the normals and just generate them during the initialization phase (smaller model file). In typical application (not requiring hand-tuned normals for some lighting tricks), averaged normals of connected triangles is enough.


    Jani Vaarala
    Graphics Architect
    Nokia

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    22
    Thank you very much for your answer!
    In my case, I've created a cube in milkshape3d and exported it in a .h file. In this file I have 20 vertices, 12 faces and 6 normal:

    Point3 Box01_vertex[] = {
    {-9.750000, 9.500000, 10.125000},
    {-9.750000, -9.500000, 10.125000},
    {10.000000, 9.500000, 10.125000},
    {10.000000, -9.500000, 10.125000},
    {10.000000, 9.500000, 10.125000},
    {10.000000, -9.500000, 10.125000},
    {10.000000, 9.500000, -9.625000},
    {10.000000, -9.500000, -9.625000},
    {10.000000, 9.500000, -9.625000},
    {10.000000, -9.500000, -9.625000},
    {-9.750000, 9.500000, -9.625000},
    {-9.750000, -9.500000, -9.625000},
    {-9.750000, 9.500000, -9.625000},
    {-9.750000, -9.500000, -9.625000},
    {-9.750000, 9.500000, 10.125000},
    {-9.750000, -9.500000, 10.125000},
    {-9.750000, 9.500000, 10.125000},
    {10.000000, 9.500000, 10.125000},
    {-9.750000, -9.500000, 10.125000},
    {10.000000, -9.500000, 10.125000}

    Point3 Box01_normal[] = {
    {0.000000, 0.000000, 1.000000},
    {1.000000, 0.000000, 0.000000},
    {0.000000, 0.000000, -1.000000},
    {-1.000000, 0.000000, 0.000000},
    {0.000000, 1.000000, 0.000000},
    {0.000000, -1.000000, 0.000000}


    What normal I have to consider, or to duplicate, for a correct illumination?
    Thanks!
    Giacomo
    Last edited by alabama83; 2005-06-24 at 23:58.

Posting Permissions

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