View Full Version : Light probs... again...
11-22-2000, 08:55 AM
I don't think I understand the opengl-light-model correctly.
How can I set the radius of the light How can I set the stuph to light up
I've got the basics working however, somehow I cant figure out the above. The normals get calculated like :
float Ax, Ay, Az;
float Bx, By, Bz;
float Cx, Cy, Cz;
Ax = x1;
Ay = y1;
Az = z1;
Bx = x2 - x1;
By = y2 - y1;
Bz = z2 - z1;
Cx=Ay*Bz - By*Az;
Cy=Az*Bx - Bz*Ax;
Cz=Ax*By - Bx*Ay;
l = (float)sqrt(Cx*Cx + Cy*Cy + Cz*Cz);
this->Normals[i+j*this->LevelWidth].x += Cx / l;
this->Normals[i+j*this->LevelWidth].y += Cy / l;
this->Normals[i+j*this->LevelWidth].z += Cy / l;
Help -- Divide
[This message has been edited by Divide Overflow (edited 11-22-2000).]
How can I set the radius of the light
It works so ...
d = distance between the light's position and the vertex
kc = GL_CONSTANT_ATTENUATION
kl = GL_LINEAR_ATTENUATION
kq = GL_QUADRATIC_ATTENUATION
glLightf(GL_LIGHT0, GL_POSITION, pa):
glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 2.0);
glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 1.0);
glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.5);
Let say we have a full intensity Blue (255) - result will be 255*AttenuationFactor.
For more info go from http://www.opengl.org
-> OpenGL Programming Guide Version 1.0
-> Chapter 5 Lighting
it's a very good guide!
11-24-2000, 04:50 AM
Thanx for your help.
Found the bug, turned out to be a bug in my normal-interpolation-routine (I really love that word http://www.opengl.org/discussion_boards/ubb/biggrin.gif)
11-24-2000, 04:53 AM
Say I got these 2 lights setup like this :
Light1->Position.x = 0;
Light1->Position.y = 0;
Light1->Position.z = 0;
Light1->Ambient.a = 1.0f;
Light1->Ambient.r = 0.3f;
Light1->Ambient.g = 0.3f;
Light1->Ambient.b = 0.3f;
Light1->Diffuse.a = 1.0f;
Light1->Diffuse.r = 0.0f;
Light1->Diffuse.g = 0.0f;
Light1->Diffuse.b = 0.0f;
Light1->Specular.a = 1.0f;
Light1->Specular.r = 0.3f;
Light1->Specular.g = 0.3f;
Light1->Specular.b = 0.3f;
Light2->Position.x = 0;
Light2->Position.y = 0;
Light2->Position.z = 0;
Light2->Ambient.a = 1.0f;
Light2->Ambient.r = 1.0f;
Light2->Ambient.g = 0.0f;
Light2->Ambient.b = 0.0f;
Light2->Diffuse.a = 1.0f;
Light2->Diffuse.r = 1.0f;
Light2->Diffuse.g = 0.0f;
Light2->Diffuse.b = 0.0f;
Light2->Specular.a = 1.0f;
Light2->Specular.r = 1.0f;
Light2->Specular.g = 0.0f;
Light2->Specular.b = 0.0f;
Shouldn't they be both visible and not just light 1 ?
Are you sure it's only the first light that is visible? They are both placed at the same position, so it might look like that it's only one light.
And another thing, did you enable the second light at all?
11-24-2000, 05:11 AM
Well, it might be that the 'sun' light "overwrites" the red light, but I'm sure its enabled. If I glDisable() the first light the 2nd light becomes visible.
[This message has been edited by Divide Overflow (edited 11-24-2000).]
11-30-2000, 11:52 AM
Okay, forget the above posts.
I just want an example of a lightball that floats over a floor... (so basically a light which moves above a polygon http://www.opengl.org/discussion_boards/ubb/smile.gif)
[This message has been edited by Divide Overflow (edited 11-30-2000).]
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.