#### Archived

This topic is now archived and is closed to further replies.

# Is it possible to create a moving light position and how please?

This topic is 6350 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m wondering If I can have a light source rotate around an object so it shines light at different points on the object throughout its rotation? is it possible and will someone please tell me how to do it please? Thank you a lot. Scran

##### Share on other sites
I think you can use glLightfv along with the GL_POSITION tag, but I''m not posative. Good luck with it.

A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."

##### Share on other sites
Hey, I thought I''d bring this up now (even though it''s not part of this topic, sorry!):

How is it that people can just give people answers and give them the proper function to use? Is it out of memory? Do you look it up? It just sorta fascinates me...Sorry, I am a newbie!

##### Share on other sites
people get really confused with lighting, and with good reason.

When you call something like:

float fLightPos[4] = {1,0,0,1};
glLightfv(GL_LIGHT0, GL_POSITION,fLightPos);

the important thing is when you call it. Not what the value is.

its Becuase OpenGL will pass the array fLightPos through the modelview matrix, so if your matrix is setup for drawing an object way into the distance (gltranslare, rotate, etc), passing through fLightPos would then put the light right next to the object, where as calling it just after a loadIdentity would put the light right next to the view position.

So, to rotate the light (the quick and dirty way) pretend you are drawing a rotating object, using glRotatef and such, set the light to something like 0,0,10 and the light will then be rotating around your object 10 units above it.

##### Share on other sites
The Red book and chapter06, you lazy duck.

##### Share on other sites
yes, you should read the red book, the lighting chapter (6 probably). there was something about moving lights in there.

---

cone3d

http://cone3d.gz.ee
-> soon http://cone3d.gamedev.net

##### Share on other sites
take a look at http://nate.scuzzy.net/programming/ and search for the fake dynamic lights tutorial, source code included !

glHorizon_Project

www.web-discovery.net

1. 1
2. 2
3. 3
4. 4
Rutin
13
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633695
• Total Posts
3013378
×