Results 1 to 6 of 6

Thread: light direction

  1. #1
    Member Contributor
    Join Date
    Sep 2002
    Posts
    61

    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?

  2. #2
    Junior Member Newbie
    Join Date
    Sep 2002
    Posts
    2

    Re: light direction

    Originally posted by mikemor:
    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?

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

  3. #3
    Member Contributor
    Join Date
    Sep 2002
    Posts
    61

    Re: light direction

    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

  4. #4

    Re: light direction

    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
    Learning OpenGL while working on sourceforge projects:
    https://sourceforge.net/projects/simulant/ and
    https://sourceforge.net/projects/projectnova/

  5. #5
    Member Contributor
    Join Date
    Sep 2002
    Posts
    61

    Re: light direction

    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

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: light direction

    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

Similar Threads

  1. Light with a direction
    By joejoe in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-16-2010, 03:05 AM
  2. Direction of the light
    By KeSh in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 04-25-2004, 02:19 AM
  3. Direction of light
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-16-2003, 12:07 AM
  4. Draw cone in the direction of light
    By fcoutel in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 08-29-2002, 06:14 AM
  5. Directional light's direction with GetLight()?
    By my_hero in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-16-2001, 03:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean