de.rico.engine.effect.light.ogllight
Class AbstractLight

java.lang.Object
  extended by de.rico.engine.effect.light.ogllight.AbstractLight
All Implemented Interfaces:
LightIface
Direct Known Subclasses:
DirectionalLight, PositionalLight

public abstract class AbstractLight
extends java.lang.Object
implements LightIface

Abstract base class for OpenGL based lighting.

Author:
Frank Bruns

Constructor Summary
AbstractLight(int lightNumber)
          Creates a new light with the specified light number
 
Method Summary
 void bind(javax.media.opengl.GL gl)
          Starts using the light.
 void destroy()
          Destroys the light.
 Color4f getAmbient()
          Returns the ambient color
 Color4f getDiffuse()
          Returns the diffuse color
 int getLightNr()
          Returns the light number in its representation of a value from 0 to 7
 int getLightNrOGLConst()
          Returns the light number in its representation as an OpenGL constant from GL.GL_LIGHT0 to GL.GL_LIGHT7
 Color4f getSpecular()
          Returns the specular color
 boolean isEnabled()
          Determines whether the light is enabled.
 void release(javax.media.opengl.GL gl)
          Stops using the light.
 void setAmbient(Color4f ambient)
          Sets the ambient color of the light
 void setAmbient(float red, float green, float blue, float alpha)
          Sets the ambient color of the light
 void setDiffuse(Color4f diffuse)
          Sets the diffuse color of the light
 void setDiffuse(float red, float green, float blue, float alpha)
          Sets the diffuse color of the light
 void setEnabled(boolean enable)
          Enables or disables the light source
 void setSpecular(Color4f spec)
          Sets the specular color of the light
 void setSpecular(float red, float green, float blue, float alpha)
          Sets the specular color of the light
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractLight

public AbstractLight(int lightNumber)
Creates a new light with the specified light number

Parameters:
lightNumber - light number from 0 to 7
Method Detail

bind

public void bind(javax.media.opengl.GL gl)
Description copied from interface: LightIface
Starts using the light. All objects that are rendered after the call to this method, will be affected by the light, if no special treatment was performed on those objects.

Specified by:
bind in interface LightIface

release

public void release(javax.media.opengl.GL gl)
Description copied from interface: LightIface
Stops using the light. Objects that are rendered after a call to this method won't be affected by the light.

Specified by:
release in interface LightIface

destroy

public void destroy()
Description copied from interface: LightIface
Destroys the light.

Specified by:
destroy in interface LightIface

getLightNr

public int getLightNr()
Returns the light number in its representation of a value from 0 to 7

Returns:
light number as value from 0 to 7

getLightNrOGLConst

public int getLightNrOGLConst()
Returns the light number in its representation as an OpenGL constant from GL.GL_LIGHT0 to GL.GL_LIGHT7

Returns:
light number as an OpenGL constant from GL.GL_LIGHT0 to GL.GL_LIGHT7

setAmbient

public void setAmbient(float red,
                       float green,
                       float blue,
                       float alpha)
Sets the ambient color of the light

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

setAmbient

public void setAmbient(Color4f ambient)
Sets the ambient color of the light

Parameters:
ambient - ambient color

setDiffuse

public void setDiffuse(float red,
                       float green,
                       float blue,
                       float alpha)
Sets the diffuse color of the light

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

setDiffuse

public void setDiffuse(Color4f diffuse)
Sets the diffuse color of the light

Parameters:
diffuse - diffuse color

setSpecular

public void setSpecular(float red,
                        float green,
                        float blue,
                        float alpha)
Sets the specular color of the light

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

setSpecular

public void setSpecular(Color4f spec)
Sets the specular color of the light

Parameters:
spec - specular color

getAmbient

public Color4f getAmbient()
Returns the ambient color

Returns:
ambient color

getDiffuse

public Color4f getDiffuse()
Returns the diffuse color

Returns:
diffuse color

getSpecular

public Color4f getSpecular()
Returns the specular color

Returns:
specular color

setEnabled

public void setEnabled(boolean enable)
Description copied from interface: LightIface
Enables or disables the light source

Specified by:
setEnabled in interface LightIface
Parameters:
enable - true --> enable light, false --> disable light

isEnabled

public boolean isEnabled()
Determines whether the light is enabled.

Returns:
is enabled? --> true=yes, false=no