Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Graphics > OpenGL 3D API > Why are lights ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 7 Topic 4759 of 4952
Post > Topic >>

Why are lights moving?

by Sourcerer <enlorkMAKNI@[EMAIL PROTECTED] > May 20, 2008 at 09:40 PM

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 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
tan12V112 Mon Oct 6 15:06:50 CDT 2008.