# Class DirectionalLight

java.lang.Object
javax.media.j3d.SceneGraphObject
javax.media.j3d.Node
javax.media.j3d.Leaf
javax.media.j3d.Light
javax.media.j3d.DirectionalLight

public class DirectionalLight extends Light
A DirectionalLight node defines an oriented light with an origin at infinity. It has the same attributes as a Light node, with the addition of a directional vector to specify the direction in which the light shines. A directional light has parallel light rays that travel in one direction along the specified vector. Directional light contributes to diffuse and specular reflections, which in turn depend on the orientation of an object's surface but not its position. A directional light does not contribute to ambient reflections.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`ALLOW_DIRECTION_READ`
Specifies that the Node allows access to its object's direction information.
`static final int`
`ALLOW_DIRECTION_WRITE`
Specifies that the Node allows writing to its object's direction information.

### Fields inherited from class 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 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
Description
`DirectionalLight()`
Constructs a DirectionalLight node with default parameters.
`DirectionalLight(boolean lightOn, javax.vecmath.Color3f color, javax.vecmath.Vector3f direction)`
Constructs and initializes a directional light.
`DirectionalLight(javax.vecmath.Color3f color, javax.vecmath.Vector3f direction)`
Constructs and initializes a directional light.

## Method Summary

Modifier and Type
Method
Description
`Node`
`cloneNode(boolean forceDuplicate)`
Used to create a new instance of the node.
`void`
`getDirection(javax.vecmath.Vector3f direction)`
Gets this Light's current direction and places it in the parameter specified.
`void`
`setDirection(float x, float y, float z)`
Set light direction.
`void`
`setDirection(javax.vecmath.Vector3f direction)`
Set light direction.

### Methods inherited from class Light

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

### Methods inherited from class Node

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

### Methods inherited from class SceneGraphObject

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

### Methods inherited from class Object

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

## Field Details

### ALLOW_DIRECTION_READ

public static final int ALLOW_DIRECTION_READ
Specifies that the Node allows access to its object's direction information.

See Also:
  - Constant Field Values

### ALLOW_DIRECTION_WRITE

public static final int ALLOW_DIRECTION_WRITE
Specifies that the Node allows writing to its object's direction information.

See Also:
  - Constant Field Values

## Constructor Details

### DirectionalLight

public DirectionalLight()
Constructs a DirectionalLight node with default parameters. The default values are as follows:

direction : (0,0,-1)

### DirectionalLight

public DirectionalLight(javax.vecmath.Color3f color, javax.vecmath.Vector3f direction)
Constructs and initializes a directional light.

Parameters:
  `color` - the color of the light source
  `direction` - the direction vector pointing from the light to the object

### DirectionalLight

public DirectionalLight(boolean lightOn, javax.vecmath.Color3f color, javax.vecmath.Vector3f direction)
Constructs and initializes a directional light.

Parameters:
  `lightOn` - flag indicating whether this light is on or off
  `color` - the color of the light source
  `direction` - the direction vector pointing from the light to the object

## Method Details

### setDirection

public void setDirection(javax.vecmath.Vector3f direction)
Set light direction.

Parameters:
  `direction` - the new direction
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)
Set 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

### getDirection

public void getDirection(javax.vecmath.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 `Node`
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(Node, boolean)`
  - `NodeComponent.setDuplicateOnCloneTree(boolean)`