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/


|