CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    Sep 2005
    Posts
    42

    incorrect normal vector problem

    note: this question was the result of ignorance from my side, please move along if you don't want to waste your time. thanks for your time

    hey y'all,

    i have this weird problem with my normals wich is probably best explained with this screenshot.



    you're looking at a terrain generator using QUADS and the Plasma fractal algorithm, for those familiar with that, with 1 yellow light. as you can see the result is not quite as expected. It is like there are only 2 normals in this scene. I have no idea where I'm going wrong. this is my code that goes with the call of the first glVertex3f (3 similar pieces of code follow this one):

    Code:
    glNormal3f((normalmap[i][j].x + normalmap[i][nextj].x + normalmap[previ][nextj].x + normalmap[previ][j].x) / 4,
    (normalmap[i][j].x + normalmap[i][nextj].x + normalmap[previ][nextj].x + normalmap[previ][j].x) / 4,
    (normalmap[i][j].x + normalmap[i][nextj].x + normalmap[previ][nextj].x + normalmap[previ][j].x) / 4);
    				glVertex3f(vectorarray[0].x,vectorarray[0].y,vectorarray[0].z);
    
    glGetFloatv(GL_CURRENT_NORMAL, normalcheck);
    cout << "x,y,z " << normalcheck[0] << " " << normalcheck[1] << " " << normalcheck[2] << "\n";
    the 'normalmap' contains pre-calculated normals of the individual quads. I'm quite positive they are correct. the long term which adds the normalmap items and divides them by 4 returns a sensible number (it's quite small), however, the glGetFloatv() call doesn't do anything with the normalcheck array, and thus the cout line just returns the initialisation values of that normalcheck array.

    when I calculated the normals on a per-face basis, they appeared to be correct.

    any clues? I'd be grateful since I have no idea what to google for
    Last edited by garma; October 2nd, 2005 at 05:27 PM.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured