Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Omni light?

  1. #1
    Junior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    102

    Omni light?

    How can I create a omni light? And I don't want it to put a new color on my objects, is this possible?
    It's kinda hard to get a ball look like a ball without a light... :P
    CyBBe

  2. #2
    Junior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    200

    Re: Omni light?

    Hi there!

    Since, I am not a native english speaker (as everybody figured out already ), I am not really sure If I got it (sorry).

    Ever tried a light that only emits a ambient color?

    Just a thought,

    LG

  3. #3
    Junior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    102

    Re: Omni light?

    No, I haven't but that's what I would like to know how to do...

    /me are not from an english speaking country either. :-)
    CyBBe

  4. #4
    Junior Member Newbie
    Join Date
    May 2000
    Posts
    4

    Re: Omni light?

    hi
    i want to know that also?!!
    how did they do that?!!!
    dodododoooo

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Feb 2000
    Location
    France
    Posts
    1,118

    Re: Omni light?

    OK, here is something that should work :

    --------------------------------------------

    GLfloat AmbientColor[4]={0.2,0.2,0.2,1}; // Ambient - Grey
    GLfloat DiffuseColor[4]={0.2,0,0,1}; // Diffuse - Red
    GLfloat SpecularColor[4]={0.0,0.2,0.2,1}; // Specular - Cyan
    GLfloat Position[4]={0,0,100,1}; // Light Position at (0,0,100);
    /*
    Note : the 4th coordinates is !=0 for a positional light
    (when you give its actual position !) and 0 for a directional light
    (ie : for the sun. A light that is far, far away is directional).
    */

    GLfloat Direction[3]={0,0,0}; // Light Direction
    /*
    Note : the direction is used only when you specify a value which
    is not 180 for GL_SPOT_CUTOFF. If you do that, you do not have uniform
    lighting anymore. But here, we want an omni light so the direction
    is not important...
    */

    GLfloat SpotExponent=0;
    /*
    Note : this specifies how focused is your light beam. But for an
    omni light, there is no beam !
    */

    GLfloat SpotCutOff=180; // See above //
    GLfloat m_ConstantAttenuation=1;
    GLfloat m_LinearAttenuation=0;
    GLfloat m_QuadraticAttenuation=0;
    /*
    Note : this means we do not attenuate the light according to
    its distance from the light source */

    glLightfv(GL_LIGHT0,GL_AMBIENT,AmbientColor);
    glLightfv(GL_LIGHT0,GL_DIFFUSE,DiffuseColor);
    glLightfv(GL_LIGHT0,GL_SPECULAR,SpecularColor);
    glLightfv(GL_LIGHT0,GL_POSITION,m_Position);
    glLightfv(GL_LIGHT0,GL_SPOT_EXPONENT,&m_SpotExpone nt);
    glLightfv(GL_LIGHT0,GL_SPOT_CUTOFF,&m_CutOff);
    glLightfv(GL_LIGHT0,GL_SPOT_DIRECTION,m_Direction) ;
    glLightfv(GL_LIGHT0,GL_CONSTANT_ATTENUATION,&m_Con stantAttenuation);
    glLightfv(GL_LIGHT0,GL_LINEAR_ATTENUATION,&m_Linea rAttenuation);
    glLightfv(GL_LIGHT0,GL_QUADRATIC_ATTENUATION,&m_Qu adraticAttenuation);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHTING);

    /*Now, if you do not want to assign material to your objects but
    want the objects to use what you specify with glColor, you have
    to use the following :*/

    glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_D IFFUSE);

    /* This means that the Ambient and Diffuse material will use the
    values specified by glColor. Otherwise, you have to use glMaterial.
    Note that there are plenty of different parameters so you should
    have a look at glColorMaterial function in your docs. */

    glEnable(GL_COLOR_MATERIAL);

    /* This enable the Color Material mode we specified above */

    ------------------------------------------

    I hope I did not forget anything.

    It was a real pain for me to understand OpenGL lights when I started so I really know what you are feeling.

    Nevertheless, after some practice on simple things, you should be able to do whatever you want with the lights.

    Have fun and do not hesitate to contact me if this code does not work.

    Best regards.

    Eric

  6. #6
    Intern Contributor
    Join Date
    May 2000
    Posts
    67

    Re: Omni light?

    From what I get from your post, CyBBe, you're looking for a directional light... That will light up the whole scence, kinda like (as Eric said) sunlight. A positional light is like a lightbulb. The farther an object is from it, the dimmer it is. A directional light should be quite a bit faster than a positional one... Hopefully this is understandable...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •