Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## simogl.effect.light
Class Light

    java.lang.Object
      simogl.effect.light.Light

    public class Light

extends java.lang.Object

This class is used to set light sources in the scene

Author:
  Frank Bruns

Constructor Summary
`Light(float x, float y, float z, int lightNr)` Creates a new light source at the specified position

Method Summary
`void` | `draw(javax.media.opengl.GL gl)` This method draws the light to the scene with all its properties
`float` | `getAttenuationConstant()` Returns the constant attenuation value
`float` | `getAttenuationLinear()` Returns the linear attenuation value
`float` | `getAttenuationQuadratic()` Returns the quadric attenuation
`float[]` | `getColorAmbient()` Returns the color of the ambient light
`float[]` | `getColorDiffuese()` Returns the color of the diffuse light
`float[]` | `getColorSpecular()` Returns the color of the specular light
`int` | `getLightNumberFrom0to7()` Returns an simple integer value (0-7) representing the openGl constants GL.GL_LIGHT0 upto GL.GL_LIGHT7
`Point3D` | `getPosition()` Returns the current position of the light source
`Point3D` | `getSpotDirection()` Returns the direction of the spot light
`float` | `getSpotExponent()` Returns the value for spot exponent
`boolean` | `isDirectional()` Determines whether this light is a directional light
`boolean` | `isEnabled()` Determins whether the light source is enabled
`boolean` | `isEnabledAmbient()` Determins whether the ambient light is enabled
`boolean` | `isEnabledDiffuse()` Determins whether the diffuse light is enabled
`boolean` | `isEnabledSpecular()` Determins whether the specular light is enabled
`boolean` | `isPositional()` Determines whether this light is a positional light
`boolean` | `isSpot()` Determines whether this light is a spot light
`void` | `setAttenuationConstant(float factor)` Sets the constant attenuation value.
`void` | `setAttenuationLinear(float factor)` Sets the linear attenuation value.
`void` | `setAttenuationQuadratic(float factor)` Sets the quadric attenuation value.
`void` | `setColorAmbient(float red, float green, float blue, float alpha)` Sets the RGBA color of the ambient light
`void` | `setColorDiffuse(float red, float green, float blue, float alpha)` Sets the RGBA color of the diffuse light
`void` | `setColorSpecular(float red, float green, float blue, float alpha)` Sets the RGBA color of the specular light
`void` | `setDirectional()` Turns the light source into a directional light source
`void` | `setEnabled(boolean activate)` Enables (true) or disables (false) the light source.
`void` | `setEnabledAmbient(boolean activate)` Enables (true) or disables (false) the ambient light
`void` | `setEnabledDiffuse(boolean activate)` Enables (true) or disables (false) the diffuse light
`void` | `setEnabledSpecular(boolean activate)` Enables (true) or disables (false) the specular light
`static void` | `setGlobalAmbientLight(javax.media.opengl.GL gl, float red, float green, float blue, float alpha)` Sets the color of the global ambient background light.
`void` | `setPosition(float x, float y, float z)` Sets the position of the light source
`void` | `setPositional()` Turns the light source into a positional light source
`void` | `setSpot(float spotCutOff, float spotExponent)` Turns this light to a spot light.
`void` | `setSpotDirection(float x, float y, float z)` Set the direction of the spot light
`void` | `setSpotExponent(float value)` Sets the value for the spot exponent.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Light

    public Light(float x,
                 float y,
                 float z,
                 int lightNr)

  Creates a new light source at the specified position

  Parameters:
    `x` - x-coordinate
    `y` - y-coordinate
    `z` - z-coordinate
    `lightNr` - number from 0 to 7

Method Detail

### setPosition

    public void setPosition(float x,
                            float y,
                            float z)

  Sets the position of the light source

  Parameters:
    `x` - x-coordinate
    `y` - y-coordinate
    `z` - z-coordinate

### getPosition

    public Point3D getPosition()

  Returns the current position of the light source

  Returns:
    light's position

### setDirectional

    public void setDirectional()

  Turns the light source into a directional light source

### isDirectional

    public boolean isDirectional()

  Determines whether this light is a directional light

  Returns:
    is directional light? -> true or false

### setPositional

    public void setPositional()

  Turns the light source into a positional light source

### isPositional

    public boolean isPositional()

  Determines whether this light is a positional light

  Returns:
    is positional light? -> true or false

### setSpot

    public void setSpot(float spotCutOff,
                        float spotExponent)

  Turns this light to a spot light. Beeing a spot light means usually being a positional light, too, becaus it commonly does make no sense to use a directional light as a spot light.
  The parameter spotCutOff describes the angle of the light spot's cone. It accepts values from 0.0f - 90.0f or excatly 180.0f (simple positional light). The parameter spotExponent describes the focus intensity of the spot light. The higher the value the more focused is the spot light to its center. You can compare the effect with a focused flashlight.

  Parameters:
    `spotCutOff` - angle from 0.0f-90.0f or exactly 180.0f degrees
    `spotExponent` - factor to focus the spot light

### isSpot

    public boolean isSpot()

  Determines whether this light is a spot light

  Returns:
    is spot light? -> true or false

### setSpotDirection

    public void setSpotDirection(float x,
                                 float y,
                                 float z)

  Set the direction of the spot light

  Parameters:
    `x` - x-coordinate
    `y` - y-coordinate
    `z` - z-coordinate

### getSpotDirection

    public Point3D getSpotDirection()

  Returns the direction of the spot light

  Returns:
    direction of the spotlight

### setSpotExponent

    public void setSpotExponent(float value)

  Sets the value for the spot exponent. Only use values in the intervall from 0.0f - 128.0f. Values other than that will cause an openGl error

  Parameters:
    `value` - spot exponent (0.0f - 128.0f)

### getSpotExponent

    public float getSpotExponent()

  Returns the value for spot exponent

  Returns:
    spot exponent

### setColorAmbient

    public void setColorAmbient(float red,
                                float green,
                                float blue,
                                float alpha)

  Sets the RGBA color of the ambient light

  Parameters:
    `red` - amount of red
    `green` - amount of green
    `blue` - amount of blue
    `alpha` - amount of alpha

### getColorAmbient

    public float[] getColorAmbient()

  Returns the color of the ambient light

  Returns:
    color of ambient light

### setColorDiffuse

    public void setColorDiffuse(float red,
                                float green,
                                float blue,
                                float alpha)

  Sets the RGBA color of the diffuse light

  Parameters:
    `red` - amount of red
    `green` - amount of green
    `blue` - amount of blue
    `alpha` - amount of alpha

### getColorDiffuese

    public float[] getColorDiffuese()

  Returns the color of the diffuse light

  Returns:
    color of diffuse light

### setColorSpecular

    public void setColorSpecular(float red,
                                 float green,
                                 float blue,
                                 float alpha)

  Sets the RGBA color of the specular light

  Parameters:
    `red` - amount of red
    `green` - amount of green
    `blue` - amount of blue
    `alpha` - amount of alpha

### getColorSpecular

    public float[] getColorSpecular()

  Returns the color of the specular light

  Returns:
    color of specular light

### setEnabled

    public void setEnabled(boolean activate)

  Enables (true) or disables (false) the light source. That completetly switches this light of. Ambient, diffuse and specular parts of the light are off, too.

  Parameters:
    `activate` - set enabled? -> true or false

### isEnabled

    public boolean isEnabled()

  Determins whether the light source is enabled

  Returns:
    is enabled? -> true or false

### setEnabledAmbient

    public void setEnabledAmbient(boolean activate)

  Enables (true) or disables (false) the ambient light

  Parameters:
    `activate` - set enabled? -> true or false

### isEnabledAmbient

    public boolean isEnabledAmbient()

  Determins whether the ambient light is enabled

  Returns:
    is enabled? -> true or false

### setEnabledDiffuse

    public void setEnabledDiffuse(boolean activate)

  Enables (true) or disables (false) the diffuse light

  Parameters:
    `activate` - set enabled? -> true or false

### isEnabledDiffuse

    public boolean isEnabledDiffuse()

  Determins whether the diffuse light is enabled

  Returns:
    is enabled? -> true or false

### setEnabledSpecular

    public void setEnabledSpecular(boolean activate)

  Enables (true) or disables (false) the specular light

  Parameters:
    `activate` - set enabled? -> true or false

### isEnabledSpecular

    public boolean isEnabledSpecular()

  Determins whether the specular light is enabled

  Returns:
    is enabled? -> true or false

### setAttenuationConstant

    public void setAttenuationConstant(float factor)

  Sets the constant attenuation value. Calling this method set the other attenuation behaviors to zero

  Parameters:
    `factor` - constant attenuation factor

### getAttenuationConstant

    public float getAttenuationConstant()

  Returns the constant attenuation value

  Returns:
    constant attenuation factor

### setAttenuationLinear

    public void setAttenuationLinear(float factor)

  Sets the linear attenuation value. Calling this method set the other attenuation behaviors to zero

  Parameters:
    `factor` - linear attenuation factor

### getAttenuationLinear

    public float getAttenuationLinear()

  Returns the linear attenuation value

  Returns:
    linear attenuation factor

### setAttenuationQuadratic

    public void setAttenuationQuadratic(float factor)

  Sets the quadric attenuation value. Calling this method set the other attenuation behaviors to zero

  Parameters:
    `factor` - quadric attenuation factor

### getAttenuationQuadratic

    public float getAttenuationQuadratic()

  Returns the quadric attenuation

  Returns:
    quadric attenuation

### getLightNumberFrom0to7

    public int getLightNumberFrom0to7()

  Returns an simple integer value (0-7) representing the openGl constants GL.GL_LIGHT0 upto GL.GL_LIGHT7

  Returns:
    integer value instead of openGL constant

### draw

    public void draw(javax.media.opengl.GL gl)

  This method draws the light to the scene with all its properties

  Parameters:
    `gl` -

### setGlobalAmbientLight

    public static void setGlobalAmbientLight(javax.media.opengl.GL gl,
                                             float red,
                                             float green,
                                             float blue,
                                             float alpha)

  Sets the color of the global ambient background light. Set all parameters to 0.0f, if you would like to archieve perfect darkness in your scene, while all other light sources must be disabled, too.

  Parameters:
    `red` - amount of red
    `green` - amount of green
    `blue` - amount of blue
    `alpha` - alpha-value

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD