hmi.graphics.util.basicobjects
Class SimpleLightState

java.lang.Object
  extended by hmi.graphics.util.basicobjects.SimpleLightState
All Implemented Interfaces:
GLRenderObject

public class SimpleLightState
extends Object
implements GLRenderObject

A basic positional or directional light object. The assumption is that color attributes, and position or direction are set during initialization, and that the light is permanently bound to one of the fixed OpenGL lights. The position is passed to OpenGL for every render call, so that it will take the ModelView transform into account.


Field Summary
private  float[] ambient
           
private  float[] diffuse
           
private  boolean enabled
           
private  int gl_light
           
private  float[] originpos
           
private  float[] position
           
private  float[] specular
           
 
Constructor Summary
SimpleLightState(int gl_light)
          common initialization for new DirectionalLights.
 
Method Summary
 float[] getPosition()
          Returns a reference to the position float array of this light
 void glInit(GLRenderContext gl)
          called during initialization phase of the renderer.
 void glRender(GLRenderContext gl)
          Rendering a light means: set position, taking into account the current ModelView transformation.
 void setAmbientColor(float r, float g, float b)
          sets the ambient color of the light.
 void setDiffuseColor(float r, float g, float b)
          sets the diffuse color of the light.
 void setDirection(float x, float y, float z)
          Turns the light into a direction light, and sets the direction from which the light is shining.
 void setEnabled(boolean e)
          Easy way to disable this light object, for testing purposes.
 void setPosition(float[] pos)
          Turns the light into a positional light, and sets the position from which the light is shining.
 void setPosition(float x, float y, float z)
          Turns the light into a positional light, and sets the position from which the light is shining.
 void setSpecularColor(float r, float g, float b)
          sets the specular color of the light.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ambient

private float[] ambient

diffuse

private float[] diffuse

specular

private float[] specular

position

private float[] position

originpos

private float[] originpos

enabled

private boolean enabled

gl_light

private int gl_light
Constructor Detail

SimpleLightState

public SimpleLightState(int gl_light)
common initialization for new DirectionalLights.

Method Detail

setAmbientColor

public void setAmbientColor(float r,
                            float g,
                            float b)
sets the ambient color of the light. Should be called before initialization.


setDiffuseColor

public void setDiffuseColor(float r,
                            float g,
                            float b)
sets the diffuse color of the light. Should be called before initialization.


setSpecularColor

public void setSpecularColor(float r,
                             float g,
                             float b)
sets the specular color of the light. Should be called before initialization.


setPosition

public void setPosition(float x,
                        float y,
                        float z)
Turns the light into a positional light, and sets the position from which the light is shining. Should be called before initialization.


setPosition

public void setPosition(float[] pos)
Turns the light into a positional light, and sets the position from which the light is shining. Should be called before initialization.


getPosition

public float[] getPosition()
Returns a reference to the position float array of this light


setDirection

public void setDirection(float x,
                         float y,
                         float z)
Turns the light into a direction light, and sets the direction from which the light is shining. Should be called before initialization.


setEnabled

public void setEnabled(boolean e)
Easy way to disable this light object, for testing purposes. It must be called before initialization, i.e. not during the render phase anymore.


glInit

public void glInit(GLRenderContext gl)
called during initialization phase of the renderer. It binds the attributes, like color, to some OpenGL light.

Specified by:
glInit in interface GLRenderObject

glRender

public void glRender(GLRenderContext gl)
Rendering a light means: set position, taking into account the current ModelView transformation. Optionally, a small sphere is rendered, to indicate the position of the light.

Specified by:
glRender in interface GLRenderObject