j3d.org Aviatrix3D

org.j3d.aviatrix3d
Class SpotLight

java.lang.Object
  extended byorg.j3d.aviatrix3d.SceneGraphObject
      extended byorg.j3d.aviatrix3d.Node
          extended byorg.j3d.aviatrix3d.Leaf
              extended byorg.j3d.aviatrix3d.Light
                  extended byorg.j3d.aviatrix3d.SpotLight

public class SpotLight
extends Light

Representation of a spot light source.

A spot light has a direction, location and directs light as a conical shape in the given direction. Within the spotlight, there's a maximum angle that the light is effective to, and a drop-off rate of the light from the center to the maximum angle.

Version:
$Revision: 1.9 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class org.j3d.aviatrix3d.Light
diffuseColor, enabled, specularColor
 
Fields inherited from class org.j3d.aviatrix3d.Node
bounds, implicitBounds, INVALID_BOUNDS, parent
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, updateHandler, WRITE_TIMING_MSG
 
Constructor Summary
SpotLight()
          Creates a light with the colour set to black.
SpotLight(float[] col)
          Create a light with the given base colour.Colour must be in the range [0, 1] otherwise an exception is generated.
SpotLight(float[] col, float[] pos, float[] dir)
          Create a light with the given base colour.Colour must be in the range [0, 1] otherwise an exception is generated.
 
Method Summary
 void getAttenuation(float[] values)
          Set the attenuation factors for the light.
 float getCutOffAngle()
          Get the current gut-off angle.
 void getDirection(float[] dir)
          Retrieve the current direction vector from the light.
 float getDropOffRateExponent()
          Get the current drop off exponent rate.
 void getPosition(float[] pos)
          Retrieve the current position vector from the light.
protected  void markBoundsDirty()
          Mark this node as having dirty bounds due to one of it's children having their bounds changed.
 void postRender(net.java.games.jogl.GL gl, net.java.games.jogl.GLU glu)
           
 void postRender(net.java.games.jogl.GL gl, net.java.games.jogl.GLU glu, int lightId)
           
 void render(net.java.games.jogl.GL gl, net.java.games.jogl.GLU glu)
          This method is called to render this node.
 void render(net.java.games.jogl.GL gl, net.java.games.jogl.GLU glu, int lightId)
          Overloaded form of the render() method to render the light details given the specific Light ID used by OpenGL.
 void setAttenuation(float[] values)
          Set the attenuation factors for the light.
 void setAttenuation(float constant, float linear, float quad)
          Set the attenuation factors for the light.
 void setCutOffAngle(float angle)
          Set the cut-off angle.
 void setDirection(float[] dir)
          Set the direction to the new value.
 void setDirection(float x, float y, float z)
          Set the direction to the new value.
 void setDropOffRateExponent(float exp)
          Set the value of the exponent that can be used to control how the light intensity drops off from the center to the cut off angle.
 void setPosition(float[] pos)
          Set the position to the new value.
 void setPosition(float x, float y, float z)
          Set the position to the new value.
 
Methods inherited from class org.j3d.aviatrix3d.Light
getDiffuseColor, getSpecularColor, isEnabled, setDiffuseColor, setEnabled, setSpecularColor
 
Methods inherited from class org.j3d.aviatrix3d.Node
boundsChanged, checkForCyclicParent, getBounds, getParent, recomputeBounds, removeParent, setBounds, setLive, setParent, updateBounds
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, dataChanged, getUserData, isLive, setUpdateHandler, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpotLight

public SpotLight()
Creates a light with the colour set to black.


SpotLight

public SpotLight(float[] col)
          throws java.lang.IllegalArgumentException
Create a light with the given base colour.Colour must be in the range [0, 1] otherwise an exception is generated.

Parameters:
col - The new colour value to use

SpotLight

public SpotLight(float[] col,
                 float[] pos,
                 float[] dir)
          throws java.lang.IllegalArgumentException
Create a light with the given base colour.Colour must be in the range [0, 1] otherwise an exception is generated.

Parameters:
col - The new colour value to use
dir - The direction of the light
Method Detail

render

public void render(net.java.games.jogl.GL gl,
                   net.java.games.jogl.GLU glu,
                   int lightId)
Overloaded form of the render() method to render the light details given the specific Light ID used by OpenGL. Since the active light ID for this node may vary over time, a fixed ID cannot be used by OpenGL. The renderer will always call this method rather than the normal render() method. The normal post render will still be called

Specified by:
render in class Light
Parameters:
gl - The GL context to render with
glu - The GL utility context to render with
lightId - the ID of the light to make GL calls with

postRender

public void postRender(net.java.games.jogl.GL gl,
                       net.java.games.jogl.GLU glu,
                       int lightId)
Specified by:
postRender in class Light

render

public void render(net.java.games.jogl.GL gl,
                   net.java.games.jogl.GLU glu)
This method is called to render this node. All openGL commands needed to render the node should be executed. Any transformations needed should be added to the transformation stack premultiplied. This method must be re-entrant as it can be called from multiple places at once.

Overrides:
render in class Node
Parameters:
gl - The gl context to draw with
glu - The utility context to draw with

postRender

public void postRender(net.java.games.jogl.GL gl,
                       net.java.games.jogl.GLU glu)
Overrides:
postRender in class Node

markBoundsDirty

protected void markBoundsDirty()
Mark this node as having dirty bounds due to one of it's children having their bounds changed.

Overrides:
markBoundsDirty in class Node

setCutOffAngle

public void setCutOffAngle(float angle)
                    throws java.lang.IllegalArgumentException,
                           InvalidWriteTimingException
Set the cut-off angle. The angle must lie in the range [0, 90] degrees. Although OpenGL allows the special value of 180 to be used, that functions just like a pointlight, so use that class instead.

Parameters:
angle - The angle in degrees [0, 90]
Throws:
java.lang.IllegalArgumentException - The angle was outside the range
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getCutOffAngle

public float getCutOffAngle()
Get the current gut-off angle. The angle will lie in the range [0, 90] degrees.

Returns:
The angle in degrees [0, 90]

setDropOffRateExponent

public void setDropOffRateExponent(float exp)
                            throws java.lang.IllegalArgumentException,
                                   InvalidWriteTimingException
Set the value of the exponent that can be used to control how the light intensity drops off from the center to the cut off angle. By default a value of zero is used, and provides an even light value from beginning to edge.

Parameters:
exp - The value of the exponent
Throws:
java.lang.IllegalArgumentException - The exponent was less than zero
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getDropOffRateExponent

public float getDropOffRateExponent()
Get the current drop off exponent rate.

Returns:
A value greater than or equal to zero.

setDirection

public void setDirection(float[] dir)
                  throws InvalidWriteTimingException
Set the direction to the new value. Direction is a vector that the light is shining.

Parameters:
dir - The new direction value to use
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

setDirection

public void setDirection(float x,
                         float y,
                         float z)
                  throws InvalidWriteTimingException
Set the direction to the new value. Direction is a vector that the light is shining.

Parameters:
x - The x component of the direction value to use
y - The y component of the direction value to use
z - The z component of the direction value to use
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getDirection

public void getDirection(float[] dir)
Retrieve the current direction vector from the light.

Parameters:
dir - An array to copy the direction into

setPosition

public void setPosition(float[] pos)
                 throws InvalidWriteTimingException
Set the position to the new value. Position is a vector that the light is shining.

Parameters:
pos - The new position value to use
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

setPosition

public void setPosition(float x,
                        float y,
                        float z)
                 throws InvalidWriteTimingException
Set the position to the new value. Position is a vector that the light is shining.

Parameters:
x - The x component of the position value to use
y - The y component of the position value to use
z - The z component of the position value to use
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getPosition

public void getPosition(float[] pos)
Retrieve the current position vector from the light.

Parameters:
pos - An array to copy the position into

setAttenuation

public void setAttenuation(float constant,
                           float linear,
                           float quad)
                    throws InvalidWriteTimingException
Set the attenuation factors for the light. See class header documentation for more inforamtion on these values.

Parameters:
constant - The constant attenuation factor
linear - The linear attenuation factor
quad - The quadratic attenuation factor
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

setAttenuation

public void setAttenuation(float[] values)
                    throws InvalidWriteTimingException
Set the attenuation factors for the light. See class header documentation for more inforamtion on these values.

Parameters:
values - Each value in the order:
[0] The constant attenuation factor
[1] The linear attenuation factor
[2] The quadratic attenuation factor
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getAttenuation

public void getAttenuation(float[] values)
Set the attenuation factors for the light. See class header documentation for more inforamtion on these values.

Parameters:
values - Array to copy the values into, in the order:
[0] The constant attenuation factor
[1] The linear attenuation factor
[2] The quadratic attenuation factor

j3d.org Aviatrix3D

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - j3d.org