JSR-184 Public Review Draft - Apr. 30, 2003.

javax.microedition.m3d
Class Fog

java.lang.Object
  |
  +--javax.microedition.m3d.Object3D
        |
        +--javax.microedition.m3d.Fog

public class Fog
extends Object3D

An Appearance component encapsulating attributes for fogging.

See Also:
Binary format

Field Summary
static int FOG_EXPONENTIAL
          Specifies exponential fog.
static int FOG_LINEAR
          Specifies linear fog.
 
Fields inherited from class javax.microedition.m3d.Object3D
userObject
 
Constructor Summary
Fog()
          Constructs a new Fog object with default values.
 
Method Summary
 int getColor()
          Returns the current fog color.
 float getDensity()
          Returns the fog density of exponential fog.
 float getFarDistance()
          Returns the linear fog end distance.
 int getMode()
          Retrieves the current fog mode.
 float getNearDistance()
          Returns the linear fog near distance.
 void setColor(int RGB)
          Sets the fog folor.
 void setDensity(float density)
          Sets the fog density for exponential fog.
 void setLinear(float near, float far)
          Sets the near and far distances for linear fog.
 void setMode(int mode)
          Sets the fog mode to either linear or exponential.
 
Methods inherited from class javax.microedition.m3d.Object3D
addAnimationTrack, animate, clone, find, getAnimationTrack, getAnimationTrackCount, getReferences, getUserID, removeAnimationTrack, setUserID
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FOG_LINEAR

public static final int FOG_LINEAR

Specifies linear fog. The fog blending factor f is calculated according to the formula:

f = (far - z) / (far - near),
where z is the distance, in camera coordinates, from the camera origin to the fragment center; and near and far are the distances set in setLinear.

See Also:
Constant Field Values

FOG_EXPONENTIAL

public static final int FOG_EXPONENTIAL

Specifies exponential fog. The fog blending factor f is calculated according to the formula:

f = exp(-dz),
where z is the distance, in camera coordinates, from the camera origin to the fragment center; and d is the fog density set in setDensity.

See Also:
Constant Field Values
Constructor Detail

Fog

public Fog()

Constructs a new Fog object with default values. The default values are:

Method Detail

setMode

public void setMode(int mode)

Sets the fog mode to either linear or exponential.

Parameters:
mode - either FOG_LINEAR or FOG_EXPONENTIAL
Throws:
java.lang.IllegalArgumentException - if mode is not one of the constant values listed above
See Also:
getMode

getMode

public int getMode()

Retrieves the current fog mode.

Returns:
the current fogging mode: FOG_LINEAR or FOG_EXPONENTIAL
See Also:
setMode

setLinear

public void setLinear(float near,
                      float far)

Sets the near and far distances for linear fog. Note that the near distance does not have to be smaller than the far distance, although that is usually the case. The distances are not allowed to be equal, however.

Parameters:
near - distance to the linear fog near plane
far - distance to the linear fog far plane
Throws:
java.lang.IllegalArgumentException - if near = far

getNearDistance

public float getNearDistance()

Returns the linear fog near distance.

Returns:
distance to the linear fog near plane
See Also:
setLinear

getFarDistance

public float getFarDistance()

Returns the linear fog end distance.

Returns:
distance to the linear fog far plane
See Also:
setLinear

setDensity

public void setDensity(float density)

Sets the fog density for exponential fog.

Parameters:
density - the fog density in floating point
See Also:
getDensity

getDensity

public float getDensity()

Returns the fog density of exponential fog.

Returns:
the fog density in floating point
See Also:
setDensity

setColor

public void setColor(int RGB)

Sets the fog folor. The high order byte of the color value (that is, the alpha component) is ignored.

Parameters:
RGB - the new fog color in 0x00RRGGBB format
See Also:
getColor

getColor

public int getColor()

Returns the current fog color.

Returns:
the current fog color in 0x00RRGGBB format
See Also:
setColor

JSR-184 Public Review Draft - Apr. 30, 2003.

Copyright © 2003 Nokia Corporation. See the Copyright Notice for details.