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 7 of 7 Topic 4759 of 5061
Post > Topic >>

Re: Why are lights moving?

by Sourcerer <enlorkMAKNI@[EMAIL PROTECTED] > May 25, 2008 at 10:46 PM

On Wed, 21 May 2008 11:14:13 -0700 (PDT), General wrote:

> On May 20, 8:40 pm, Sourcerer <enlorkMA...@[EMAIL PROTECTED]
> wrote:
>> So I started out with OpenGL recently and I wanted to make a simple
>> simulation of our Solar System (although the main light source isn't
the
>> Sun). It looks quite nice when viewed from above.
>>
>> My next move was to implement changing perspectives. For example, when
I
>> hit a button on my keyboard, I should be looking from the Earth towards
the
>> Sun. And the Earth, of course, keeps circling the Sun along with me on
it.
>>
>> But alas, with this change of perspective, the light source moved too,
and
>> it moves with me all the time. I defined light thus:
>>
>> 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);
>>
>> glEnable(GL_LIGHTING);
>> glEnable(GL_LIGHT0);
>>
>> I change perspective by loading identity matrix and then calling
>> gluLookAt() to say where I want to look.
>>
>> So, why does this light move with me? How can I make it stay at the
same
>> place all the time while I change camera position?
>>
>> The Red Book isn't very helpful in this issue because the example given
>> there has stationary light only until I change perspective, so it's no
>> good.
>>
>> --
>> "Let's see what's out there. Engage."
>> Jean Luc Picard, Star Trek: TNG, Encounter at
Farpointhttp://pinpoint.wordpress.com/
> 
> Hi m8,
> 
> Just repeat the following lines again after the gluLookAt command:
> gluLookAt(....
> glLightfv(GL_LIGHT0, GL_POSITION, lightSourcePosition);
> glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, lightSourceDirection);
> 
> it will work.

Thanks, that worked perfectly.

-- 
"Let's see what's out there. Engage."
Jean Luc Picard, Star Trek: TNG, Encounter at Farpoint
http://pinpoint.wordpress.com/
 




 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 15:00:10 PST 2009.