Talk About Network

Google





Graphics > OpenGL 3D API > Re: Why are lig...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 7 Topic 4759 of 5061
Post > Topic >>

Re: Why are lights moving?

by "jbwest" <jbwest@[EMAIL PROTECTED] > May 20, 2008 at 06:56 PM

"Sourcerer" <enlorkMAKNI@[EMAIL PROTECTED]
> wrote in message 
news:jwnr5c1ltwdo.14dr6h1t1oq0v$.dlg@[EMAIL PROTECTED]
> On Tue, 20 May 2008 14:19:40 -0700 (PDT), fungus wrote:
>
>> On May 20, 9:40 pm, Sourcerer <enlorkMA...@[EMAIL PROTECTED]
> wrote:
>>>
>>> GLfloat lightSourcePosition[] = {10.0, 10.0, 10.0, 0.0};
>>> GLfloat lightSourceDirection[] = {0.0, 0.0, 0.0, 0.0};
>>>
>>> glLightfv(GL_LIGHT0, GL_POSITION, lightSourcePosition);
>>> glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, lightSourceDirection);
>>>
>>
>> My copy of the manual says: "The position is transformed by the
>> modelview matrix when glLight is called"
>>
>> Maybe that's the problem.
>
> Well, that doesn't really matter (i.e. I could live with that). What
> matters is that the position of the light is transformed every time I
> change the modelview matrix -- after the light is already placed in the
> scene, by doing glLoadIdentity() and gluLookAt() -- and I don't want
that
> to happen.
>
> If that can't work, is there another way to change my perspective in the
> scene which won't move the light with me?
>
> -- 
> "Let's see what's out there. Engage."
> Jean Luc Picard, Star Trek: TNG, Encounter at Farpoint
> http://pinpoint.wordpress.com/

Check out the FAQ:

"Here are some more specific questions, and their answers:

  a.. How can I make my light position stay fixed relative to my eye 
position? How do I make a headlight?
  You need to specify your light in eye coordinate space. To do so, set
the 
ModelView matrix to the identity, then specify your light position. To
make 
a headlight (a light that appears to be positioned at or near the eye and 
****ning along the line of sight), set the ModelView to the identity, set
the 
light position at (or near) the origin, and set the direction to the 
negative Z axis.

  When a light's position is fixed relative to the eye, you don't need to 
respecify the light position for every frame. Typically, you specify it
once 
when your program initializes.

  a.. How can I make my light stay fixed relative to my scene? How can I
put 
a light in the corner and make it stay there while I change my view?
  As your view changes, your ModelView matrix also changes. This means 
you'll need to respecify the light position, usually at the start of every

frame. A typical application will display a frame with the following 
pseudocode:

    Set the view transform. Set the light position 
//glLightfv(GL_LIGHT_POSITION,.) Send down the scene or model geometry.
Swap 
buffers.
  If your light source is part of a light fixture, you also may need to 
specify a modeling transform, so the light position is in the same
location 
as the surrounding fixture geometry.

  a.. How can I make a light that moves around in a scene?
  Again, you'll need to respecify this light position every time the view 
changes. Additionally, this light has a dynamic modeling transform that
also 
needs to be in the ModelView matrix before you specify the light position.

In pseudocode, you need to do something like:

    Set the view transform Push the matrix stack Set the model transform
to 
update the light's position Set the light position 
//glLightfv(GL_LIGHT_POSITION,.) Pop the matrix stack Send down the scene
or 
model geometry Swap buffers. "
 




 7 Posts in Topic:
Why are lights moving?
Sourcerer <enlorkMAKNI  2008-05-20 21:40:36 
Re: Why are lights moving?
fungus <openglMYSOCKS@  2008-05-20 14:19:40 
Re: Why are lights moving?
Sourcerer <enlorkMAKNI  2008-05-21 00:00:05 
Re: Why are lights moving?
"jbwest" <jb  2008-05-20 18:56:53 
Re: Why are lights moving?
fungus <openglMYSOCKS@  2008-05-20 16:45:44 
Re: Why are lights moving?
General <mariodantunes  2008-05-21 11:14:13 
Re: Why are lights moving?
Sourcerer <enlorkMAKNI  2008-05-25 22:46:35 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 16:10:52 PST 2009.