Click to See Complete Forum and Search --> : incorrect normal vector problem


garma
October 2nd, 2005, 05:11 PM
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.

http://csr.oli.tudelft.nl/huizen/hg/tmp/fractal.jpg

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


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

garma
October 2nd, 2005, 05:20 PM
ok ok I'm so sorry.. this might be the single most stupid thing I've ever posted on the internet. I noticed my problem the minute I hit submit.

of course, I needed to substitute some x's by y's and z's. this indeed solved my problem.

I'm very sory, and thank you for your interest.

*leaves for a dark corner to weep silently*