# light direction

Sorry I am new to opengl and have this embarrasing question:

How do we position in opengl a light 50 degrees above the viewer and 70 degrees to its right?

Originally posted by mikemor:
[b]Sorry I am new to opengl and have this embarrasing question:

How do we position in opengl a light 50 degrees above the viewer and 70 degrees to its right?

[/b]

You read the sections appropriate in the opengl redbook… (it’s everywhere) look in the section of Viewing and Lighting…

Thanks. I have looked in the red book and I know that I should use glLightfv() with the direction of the light relatively to the viewer as the arguments. What I dont know is what does it mean
“a light 50 degrees above the viewer and
70 degrees to its right”
i.e. how do I translate this info into a direction to be fed to glLightfv?

thanks

I think thats where the maths stuff comes in. It sounds like you can imagine a triangle and using Pythagoras Theorem and/or sine and cosine calculations you can figure out the xyz position of the light… well theoretically. Not too hot on this maths stuff for graphics yet. Having to hook out my old maths books again

Perhaps someone else can confirm this… I sure hope I was right saying this stuff

Tina

Thanks. Yes, I think you are right that I need to solve some sort of triangle but I am not sure what exactly is the triangle. Does anybody?
Thanks

Math is the number one thing you need to know if you are going to do 3D graphics.

I am thinking that 50 degrees above is as if the viewer was facing the sun and it was at an angle above him at 50 degrees. Which gives up a hight of the light.

Then the 70 degrees to the right, means the sun is move to the right, but still at the 50 degree hight.

I don’t have my code handy, to write it.
But any good algebra book with have the cos/sin functions to find it.

Originally posted by mikemor:
Thanks. Yes, I think you are right that I need to solve some sort of triangle but I am not sure what exactly is the triangle. Does anybody?
Thanks