com.motorola.iden.micro3d
Class Light

java.lang.Object
  |
  +--com.motorola.iden.micro3d.Light

public class Light
extends java.lang.Object

Light class contains and manages lighting setting. The Micro3D engine supports two types of lighting: ambient light and directional light. For directional light, only a single white light is supported. The Light class can be used to specify the intensity and direction for the light.

When setting the light intensity a value of 4096 is equivalent to 1.0 (100%). The intensity of ambient light is set independently of the directional light intensity. Depending on the sum of ambient light intensity and directional light intensity, the displayed color will be close to white. However, even at the maximum, the color's extent will be 1.0 and that of the original texture color. When the sum of the abient light intensity and directional light intensity is greater than 4096, the colors for the brightest spots will be adjusted to the 1.0 intensity. The width of the shadows expressed by the normals will be thinner the greater the sum of the ambient light intensity and directional light intensity.

If the directional light strength is 100% (4096) and the light is shown directly in front of the object, the untouched texture RGB value is rendered.


MOTOROLA and the Stylized M Logo are registered trademarks of Motorola, Inc. Reg. U.S. Pat. & Tm. Off.
© COPYRIGHT 2003-2004 MOTOROLA, Inc. All Rights Reserved.


Field Summary
static int MAX_AMBIENT_LIGHT_INTENSITY
          Maximum ambient light intensity.
static int MAX_DIRECTIONAL_LIGHT_INTENSITY
          Maximum directional light intensity.
static int MIN_AMBIENT_LIGHT_INTENSITY
          Minimum ambient light intensity.
static int MIN_DIRECTIONAL_LIGHT_INTENSITY
          Minimum directional light intensity.
 
Constructor Summary
Light(int ambientIntensity, Vector3D direction, int directionalIntensity)
          Creates a Light object with the specified parameters.
 
Method Summary
 int getAmbientIntensity()
          Returns the ambient light intensity for this Light object.
 int getDirectionalIntensity()
          Returns the directional light intensity for this Light object.
 Vector3D getDirectionVector()
          Returns the Vector3D representing the direction of light for this Light object.
 void setAmbientIntensity(int intensity)
          Sets the ambient light intensity for this Light object.
 void setDirectionalIntensity(int intensity)
          Sets the directional light intensity for this Light object.
 void setDirectionVector(Vector3D direction)
          Sets and enables or disables directional lighting for this Light object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_AMBIENT_LIGHT_INTENSITY

public static final int MIN_AMBIENT_LIGHT_INTENSITY
Minimum ambient light intensity. The minumum value for the ambient light intensity is 0.

MAX_AMBIENT_LIGHT_INTENSITY

public static final int MAX_AMBIENT_LIGHT_INTENSITY
Maximum ambient light intensity. The maximum value for the ambient light intensity is 4096.

MIN_DIRECTIONAL_LIGHT_INTENSITY

public static final int MIN_DIRECTIONAL_LIGHT_INTENSITY
Minimum directional light intensity. The minimum value for the directional light intensity is 0

MAX_DIRECTIONAL_LIGHT_INTENSITY

public static final int MAX_DIRECTIONAL_LIGHT_INTENSITY
Maximum directional light intensity. The maximum value for the directional light intensity is 16384.
Constructor Detail

Light

public Light(int ambientIntensity,
             Vector3D direction,
             int directionalIntensity)
      throws java.lang.IllegalArgumentException
Creates a Light object with the specified parameters.

The specified ambient light intensity must be in the range [0, 4096]. Values less than 0 will be adjusted to 0, while values greater than 4096 will be adjusted to 4096.

The specified directional light intensity must be in the range [0, 16384]. Values less than 0 will be adjusted to 0, while values greater than 16384 will be adjusted to 16834.

The specified light direction must be a non-zero vector. If the direction vector is null, directional lighting is disabled.

Parameters:
ambientIntensity - the ambient light intensity.
direction - the directional light vector, or null to disable directional lighting.
directionalIntensity - the directional light intensity value.
Throws:
java.lang.IllegalArgumentException - if the specified direction vector is a zero vector.
Method Detail

getAmbientIntensity

public int getAmbientIntensity()
Returns the ambient light intensity for this Light object.

Returns:
the ambient light intensity.

setAmbientIntensity

public void setAmbientIntensity(int intensity)
Sets the ambient light intensity for this Light object.

Intensity values range from 0 to 4096. Values less than 0 will be adjusted to 0 (Light.MIN_AMBIENT_LIGHT_INTENSITY), while values greater than 4096 will be adjusted to 4096 (Light.MAX_AMBIENT_LIGHT_INTENSITY).

Parameters:
intensity - the ambient light intensity.
See Also:
MIN_AMBIENT_LIGHT_INTENSITY, MAX_AMBIENT_LIGHT_INTENSITY

getDirectionVector

public Vector3D getDirectionVector()
Returns the Vector3D representing the direction of light for this Light object. If directional lighting is not set this method returns null.

Returns:
the directional light vector.

setDirectionVector

public void setDirectionVector(Vector3D direction)
                        throws java.lang.IllegalArgumentException
Sets and enables or disables directional lighting for this Light object. The Vector3D should describe the direction of light or null to disable directional lighting.

Parameters:
direction - the directional light vector, or null to disable directional lighting.
Throws:
java.lang.IllegalArgumentException - if the direction vector is a zero vector.

getDirectionalIntensity

public int getDirectionalIntensity()
Returns the directional light intensity for this Light object.

Returns:
the directional light intensity.

setDirectionalIntensity

public void setDirectionalIntensity(int intensity)
Sets the directional light intensity for this Light object. The directional vector must not be null for this value to take effect. The valid range for the directional light intensity is [0, 16384]. Values less than 0 will be adjusted to 0 (Light.MIN_DIRECTIONAL_LIGHT_INTENSITY), while values greater than 16384 will be adjusted to 16384 (Light.MAX_DIRECTIONAL_LIGHT_INTENSITY). The intensity value of 4096 is equivalent to intensity of 1.00 (100%). If the intensity is 100% and the light is shown directly in front of the object, the untouched texture RGB value is rendered.

Parameters:
intensity - the directional light intensity.
See Also:
setDirectionVector(com.motorola.iden.micro3d.Vector3D), MIN_DIRECTIONAL_LIGHT_INTENSITY, MAX_DIRECTIONAL_LIGHT_INTENSITY