javax.media.j3d

## Class SpotLight

- java.lang.Object
- - javax.media.j3d.SceneGraphObject
  - - javax.media.j3d.Node
    - - javax.media.j3d.Leaf
      - - javax.media.j3d.Light
        - - javax.media.j3d.PointLight
          - - javax.media.j3d.SpotLight

-     public class SpotLight
      extends PointLight

  The SpotLight object specifies an attenuated light source at a fixed point in space that radiates light in a specified direction from the light source. A SpotLight has the same attributes as a PointLight node, with the addition of the following:

  - Direction - The axis of the cone of light. The default direction is (0.0, 0.0, -1.0). The spot light direction is significant only when the spread angle is not PI radians (which it is by default).

  - Spread angle - The angle in radians between the direction axis and a ray along the edge of the cone. Note that the angle of the cone at the apex is then twice this value. The range of values is [0.0,PI/2] radians, with a special value of PI radians. Values lower than 0 are clamped to 0 and values over PI/2 are clamped to PI. The default spread angle is PI radians.

  - Concentration - Specifies how quickly the light intensity attenuates as a function of the angle of radiation as measured from the direction of radiation. The light's intensity is highest at the center of the cone and is attenuated toward the edges of the cone by the cosine of the angle between the direction of the light and the direction from the light to the object being lit, raised to the power of the spot concentration exponent. The higher the concentration value, the more focused the light source. The range of values is [0.0,128.0]. The default concentration is 0.0, which provides uniform light distribution.

  A spot light contributes to diffuse and specular reflections, which depend on the orientation and position of an object's surface. A spot light does not contribute to ambient reflections.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `ALLOW_CONCENTRATION_READ` Specifies that the Node allows reading its spot lights concentration information.
    `static int` | `ALLOW_CONCENTRATION_WRITE` Specifies that the Node allows writing to its spot lights concentration information.
    `static int` | `ALLOW_DIRECTION_READ` Specifies that the Node allows reading its spot lights direction information.
    `static int` | `ALLOW_DIRECTION_WRITE` Specifies that the Node allows writing to its spot lights direction information.
    `static int` | `ALLOW_SPREAD_ANGLE_READ` Specifies that the Node allows reading its spot lights spread angle information.
    `static int` | `ALLOW_SPREAD_ANGLE_WRITE` Specifies that the Node allows writing to its spot lights spread angle information.

    - ### Fields inherited from class javax.media.j3d.PointLight

      `ALLOW_ATTENUATION_READ, ALLOW_ATTENUATION_WRITE, ALLOW_POSITION_READ, ALLOW_POSITION_WRITE`

    - ### Fields inherited from class javax.media.j3d.Light

      `ALLOW_COLOR_READ, ALLOW_COLOR_WRITE, ALLOW_INFLUENCING_BOUNDS_READ, ALLOW_INFLUENCING_BOUNDS_WRITE, ALLOW_SCOPE_READ, ALLOW_SCOPE_WRITE, ALLOW_STATE_READ, ALLOW_STATE_WRITE`

    - ### Fields inherited from class javax.media.j3d.Node

      `ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_LOCALE_READ, ALLOW_PARENT_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SpotLight()` Constructs a SpotLight node with default parameters.
    `SpotLight(boolean lightOn, Color3f color, Point3f position, Point3f attenuation, Vector3f direction, float spreadAngle, float concentration)` Constructs and initializes a SpotLight node using the specified parameters.
    `SpotLight(Color3f color, Point3f position, Point3f attenuation, Vector3f direction, float spreadAngle, float concentration)` Constructs and initializes a SpotLight node using the specified parameters.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Node` | `cloneNode(boolean forceDuplicate)` Used to create a new instance of the node.
    `float` | `getConcentration()` Gets spot light concentration.
    `void` | `getDirection(Vector3f direction)` Gets this Light's current direction and places it in the parameter specified.
    `float` | `getSpreadAngle()` Gets spot light spread angle.
    `void` | `setConcentration(float concentration)` Sets spot light concentration.
    `void` | `setDirection(float x, float y, float z)` Sets light direction.
    `void` | `setDirection(Vector3f direction)` Sets this Light's current direction and places it in the parameter specified.
    `void` | `setSpreadAngle(float spreadAngle)` Sets spot light spread angle.

    - ### Methods inherited from class javax.media.j3d.PointLight

      `getAttenuation, getPosition, setAttenuation, setAttenuation, setPosition, setPosition`

    - ### Methods inherited from class javax.media.j3d.Light

      `addScope, getAllScopes, getColor, getEnable, getInfluencingBoundingLeaf, getInfluencingBounds, getScope, indexOfScope, insertScope, numScopes, removeAllScopes, removeScope, removeScope, setColor, setEnable, setInfluencingBoundingLeaf, setInfluencingBounds, setScope, updateNodeReferences`

    - ### Methods inherited from class javax.media.j3d.Node

      `cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocale, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable`

    - ### Methods inherited from class javax.media.j3d.SceneGraphObject

      `clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### ALLOW_SPREAD_ANGLE_WRITE

          public static final int ALLOW_SPREAD_ANGLE_WRITE

      Specifies that the Node allows writing to its spot lights spread angle information.
      See Also:
        Constant Field Values

    - #### ALLOW_SPREAD_ANGLE_READ

          public static final int ALLOW_SPREAD_ANGLE_READ

      Specifies that the Node allows reading its spot lights spread angle information.
      See Also:
        Constant Field Values

    - #### ALLOW_CONCENTRATION_WRITE

          public static final int ALLOW_CONCENTRATION_WRITE

      Specifies that the Node allows writing to its spot lights concentration information.
      See Also:
        Constant Field Values

    - #### ALLOW_CONCENTRATION_READ

          public static final int ALLOW_CONCENTRATION_READ

      Specifies that the Node allows reading its spot lights concentration information.
      See Also:
        Constant Field Values

    - #### ALLOW_DIRECTION_WRITE

          public static final int ALLOW_DIRECTION_WRITE

      Specifies that the Node allows writing to its spot lights direction information.
      See Also:
        Constant Field Values

    - #### ALLOW_DIRECTION_READ

          public static final int ALLOW_DIRECTION_READ

      Specifies that the Node allows reading its spot lights direction information.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SpotLight

          public SpotLight()

      Constructs a SpotLight node with default parameters. The default values are as follows:
      direction : (0,0,-1)
      spread angle : PI radians
      concentration : 0.0

    - #### SpotLight

          public SpotLight(Color3f color,
                   Point3f position,
                   Point3f attenuation,
                   Vector3f direction,
                   float spreadAngle,
                   float concentration)

      Constructs and initializes a SpotLight node using the specified parameters.
      Parameters:
        `color` - the color of the light source
        `position` - the position of the light in three-space
        `attenuation` - the attenuation (constant, linear, quadratic) of the light
        `direction` - the direction of the light
        `spreadAngle` - the spread angle of the light
        `concentration` - the concentration of the light

    - #### SpotLight

          public SpotLight(boolean lightOn,
                   Color3f color,
                   Point3f position,
                   Point3f attenuation,
                   Vector3f direction,
                   float spreadAngle,
                   float concentration)

      Constructs and initializes a SpotLight node using the specified parameters.
      Parameters:
        `lightOn` - flag indicating whether this light is on or off
        `color` - the color of the light source
        `position` - the position of the light in three-space
        `attenuation` - the attenuation (constant, linear, quadratic) of the light
        `direction` - the direction of the light
        `spreadAngle` - the spread angle of the light
        `concentration` - the concentration of the light

  - ### Method Detail

    - #### setSpreadAngle

          public void setSpreadAngle(float spreadAngle)

      Sets spot light spread angle.
      Parameters:
        `spreadAngle` - the new spread angle for spot light
      Throws:
        `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph.

    - #### getSpreadAngle

          public float getSpreadAngle()

      Gets spot light spread angle.
      Returns:
        the new spread angle for spot light. The value returned is the clamped value.
      Throws:
        `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

    - #### setConcentration

          public void setConcentration(float concentration)

      Sets spot light concentration.
      Parameters:
        `concentration` - the new concentration for spot light
      Throws:
        `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

    - #### getConcentration

          public float getConcentration()

      Gets spot light concentration.
      Returns:
        the new concentration for spot light
      Throws:
        `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

    - #### setDirection

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

      Sets light direction.
      Parameters:
        `x` - the new X direction
        `y` - the new Y direction
        `z` - the new Z direction
      Throws:
        `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

    - #### setDirection

          public void setDirection(Vector3f direction)

      Sets this Light's current direction and places it in the parameter specified.
      Parameters:
        `direction` - the vector that will receive this node's direction
      Throws:
        `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

    - #### getDirection

          public void getDirection(Vector3f direction)

      Gets this Light's current direction and places it in the parameter specified.
      Parameters:
        `direction` - the vector that will receive this node's direction
      Throws:
        `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

    - #### cloneNode

          public Node cloneNode(boolean forceDuplicate)

      Used to create a new instance of the node. This routine is called by `cloneTree` to duplicate the current node.
      Overrides:
        `cloneNode` in class `PointLight`
      Parameters:
        `forceDuplicate` - when set to `true`, causes the `duplicateOnCloneTree` flag to be ignored. When `false`, the value of each node's `duplicateOnCloneTree` variable determines whether NodeComponent data is duplicated or copied.
      See Also:
        `Node.cloneTree()`, `Node.cloneNode(boolean)`, `Node.duplicateNode(javax.media.j3d.Node, boolean)`, `NodeComponent.setDuplicateOnCloneTree(boolean)`

Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.