PDA

View Full Version : How to create a cone of light



orion
09-23-2005, 12:09 AM
Good morning (here it's 10 A.M.)!
I don't know if this question has been already asked. If so, sorry in advance.
I need to create a cone of light that goes from a little lamp on the floor to the ceiling,inside a room. I've put a positional red light just on the lamp towards the point of the ceiling i want to reach, but i can only see the brightness on the wall and ceiling. Instead i'd like to see the cone of light that starts from the lamp and stops to the ceiling. I've tried with different exponent of the spotlight with no result. Even done with fog, but i still don't see the cone.
Any ideas? :rolleyes:
Thanx

Vexator
09-23-2005, 02:02 AM
what you have so far is a point light - what you want is a spot light. to transform your point light into a a spot light, you have to add three lines of code:

glLightfv( GL_LIGHT0, GL_SPOT_DIRECTION, Direction );
glLightf( GL_LIGHT0, GL_SPOT_EXPONENT, Exponent );
glLightf( GL_LIGHT0, GL_SPOT_CUTOFF, Cutoff );

Direction has to be a float array of size 3, the other two variables have to be floats.

memfr0b
09-23-2005, 02:18 AM
In OpenGL, lights are only used to compute the color of vertices. They aren't visible themselves.

The same goes for fog. It only affects the color of vertices (and thereby polygons). You never see fog unless there is some geometry that is affected.

If you want to have a visible light cone, you need to model one, using an appropriate blend mode. You might try a gray cone with glBlendFunc(GL_ONE, GL_ONE). And make sure you render the cone last.

09-23-2005, 03:52 AM
Thanx, i'll try as soon as possible :)