First of all, i want to thank everyone for the wealth of info that is on this site, it has helped me get over other issues which i have come across. The current issue however, i cant seem to find an explaination for!
I have been working on a small game for my computer science uni course, but have ran into a little issue with lighting. Basically, the lights aren’t working as i would expect to, i must be setting something wrong, but i cant figure out what!
The image attached probably explains this better than i can in words, butbasically i am drawing two rectangles (track start, and then the length), texturing them, creating the normals etc. but as you can see, the lighting stops on the first rectangle, and then restarts on the second rectangle.
What i am trying to implement is a light in the middle of the track, but i cant figure out how to do this.
My lighting function is as follows:
void initLighting()
{
// set up light colours (ambient, diffuse, specular)
GLfloat lightLa[] = {1.0, 0.0, 0.0, 1.0}; // ambient
GLfloat lightLd[] = {1.0, 1.0, 1.0, 1.0}; // diffuse
GLfloat lightLs[] = {1.0, 1.0, 1.0, 1.0}; // specular
float lightPs[4] = {20, 20, -200, 1}; // position of light
glLightfv(GL_LIGHT0, GL_AMBIENT, lightLa);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightLd);
glLightfv(GL_LIGHT0, GL_SPECULAR, lightLs);
glLightfv(GL_LIGHT0, GL_POSITION, lightPs);
GLfloat materialMs[] = {1.0f, 1.0f, 1.0f, 1.0f}; // specular
GLfloat materialMe[] = {1.0f, 1.0f, 1.0f, 1.0f}; // emission
glLightfv(GL_LIGHT0, GL_AMBIENT, materialMs);
glLightfv(GL_LIGHT0, GL_DIFFUSE, materialMe);
//glLightfv(GL_LIGHT0, GL_CONSTANT_ATTENUATION, lightPos);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
}
Any help would be greatly appreciated.
Thanks,
Dale