View Full Version : How to move sourcelights?
02-08-2001, 12:56 AM
I've been trying to move sourcelights around my 3d-world, but whatever i tried (for example editing the position-array and calling a glLightfv in my glScene func.), the lighting didn't change at all. Maybe I misunderstand the position, what does it need 4 coordinates for, anyway?
02-08-2001, 05:25 AM
>>what does it need 4 coordinates for, anyway
Fairly simple. It's a homogenous coordinate (x, y, z, w). For directional lights you put w = 0.0 which doesn't specify a point in space but only a direction _vector_ (x, y, z).
For point and spot lights you normally set w = 1.0 to define a _position_ (x/w, y/w, z/w)
The light position or direction is affected by the modelview matrix.
If you want to transform the light with your other geometry, put glLightfv(GL_LIGHTi, GL_POSITION, myPositionArray) after the modelview matrix has been set.
02-11-2001, 04:53 AM
Thanks, I'll try that. I think my main problem was understanding the w-coordinate.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.