|
M3G 1.1 -- Jun 22, 2005 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.microedition.m3g.Object3D javax.microedition.m3g.Fog
An Appearance component encapsulating attributes for fogging.
Fogging is done according to the OpenGL 1.3 specification, section 3.10, with the exception that the EXP2 mode is not supported. The same approximations in fog computation are allowed as in OpenGL: Firstly, the fog function may be evaluated at vertices and then interpolated to obtain the per-fragment values, and secondly, the distance from the camera to the fragment center may be approximated with the fragment's Z coordinate.
Field Summary | |
static int |
EXPONENTIAL
A parameter to setMode , specifying exponential
fog. |
static int |
LINEAR
A parameter to setMode , specifying linear
fog. |
Constructor Summary | |
Fog()
Constructs a new Fog object with default values. |
Method Summary | |
int |
getColor()
Retrieves the current color of this Fog. |
float |
getDensity()
Retrieves the fog density of exponential fog. |
float |
getFarDistance()
Retrieves the linear fog far distance. |
int |
getMode()
Retrieves the current fog mode. |
float |
getNearDistance()
Retrieves the linear fog near distance. |
void |
setColor(int RGB)
Sets the color of this Fog. |
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.m3g.Object3D |
addAnimationTrack, animate, duplicate, find, getAnimationTrack, getAnimationTrackCount, getReferences, getUserID, getUserObject, removeAnimationTrack, setUserID, setUserObject |
Field Detail |
public static final int EXPONENTIAL
A parameter to setMode
, specifying exponential
fog. The fog blending factor f is calculated according
to the formula:
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
. The result is clamped to the [0, 1]
range.
public static final int LINEAR
A parameter to setMode
, specifying linear
fog. The fog blending factor f is calculated according
to the formula:
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
. The result is clamped
to the [0, 1] range. If far == near, that is, the far and near
distances are equal, the result is undefined.
The smaller the fog blending factor is, the more of the fog color is blended in to the rasterized fragment. The blending factor reaches its minimum at the far plane, and the maximum at the near plane.
Constructor Detail |
public Fog()
Constructs a new Fog object with default values. The default values are:
LINEAR
Method Detail |
public void setMode(int mode)
Sets the fog mode to either linear or exponential.
mode
- the fog mode to set; one of the symbolic constants
listed above
java.lang.IllegalArgumentException
- if mode
is not
LINEAR
or EXPONENTIAL
getMode
public int getMode()
Retrieves the current fog mode.
setMode
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.
Note that this setting has no effect
on rendering
unless the type of this Fog
is (or is later set to) LINEAR
.
near
- distance to the linear fog near planefar
- distance to the linear fog far planepublic float getNearDistance()
Retrieves the linear fog near distance.
setLinear
public float getFarDistance()
Retrieves the linear fog far distance.
setLinear
public void setDensity(float density)
Sets the fog density for exponential fog.
Note that this setting has no effect
on rendering
unless the type of this Fog
is (or is later set to) EXPONENTIAL
.
density
- the density to set for this Fog
java.lang.IllegalArgumentException
- if density < 0
getDensity
public float getDensity()
Retrieves the fog density of exponential fog.
setDensity
public void setColor(int RGB)
Sets the color of this Fog. The high order byte of the color value (that is, the alpha component) is ignored.
RGB
- the color to set for this Fog in 0x00RRGGBB formatgetColor
public int getColor()
Retrieves the current color of this Fog. The high order byte of the color value (that is, the alpha component) is guaranteed to be zero.
setColor
|
M3G 1.1 -- Jun 22, 2005 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |