Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class Fog

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.Node
          extended by org.j3d.aviatrix3d.Leaf
              extended by org.j3d.aviatrix3d.Fog
All Implemented Interfaces:
java.lang.Comparable, CascadeRenderable, Cullable, EffectRenderable, LeafCullable, ObjectRenderable, Renderable

public class Fog
extends Leaf
implements LeafCullable, ObjectRenderable, EffectRenderable

Describes a fog rendering effect.

All types of fog are reprensented in a single class. If the parameter type is not useful for the fog mode, it is ignored.

Fog may act either locally or globally. If an instance of the fog node is registered with the ViewEnvironment, then it shall act as a global fog effect for the world. If it is not, then may act as a local effect, scoped the group node that contains it (like lights). Local fog effects must be explicitly enabled, otherwise only the global is used. If, during a traversal from the root of the tree down to a leaf, multiple Fog node instances are encountered, then only the closest to the Leaf is used. If multiple instances are provided in the same Group node instance, the chosen one is implementation independent.

When combined with fog coordinates on the geometry, local fog provides volumetric fog effects.

By default, fog is not enabled and global only.

Rendering Implementation Tips

See the EffectRenderable interface for definition of the scoping and effects bounds.

Internationalisation Resource Names

Version:
$Revision: 1.25 $
Author:
Justin Couch

Field Summary
static int EXPONENTIAL
          Set the fog mode to exponential curve
static int EXPONENTIAL_2
          Set the fog mode to exponential-squared curve
static int LINEAR
          Set the fog mode to linear
 
Fields inherited from class org.j3d.aviatrix3d.Node
bounds, implicitBounds, INVALID_BOUNDS, parent
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler
 
Fields inherited from interface org.j3d.aviatrix3d.rendering.LeafCullable
AUDIO_CULLABLE, CLIP_CULLABLE, FOG_CULLABLE, GEOMETRY_CULLABLE, LIGHT_CULLABLE, OVERRIDE_CULLABLE
 
Constructor Summary
Fog()
          Constructs a fog node with the default mode set to linear the colour set to white and global only.
Fog(float[] c)
          Construct a fog using the given colour and assumes a linear mode.
Fog(float[] c, boolean global)
          Construct a fog using the given colour and choice of gloval effect, assuming a linear mode.
Fog(int mode)
          Construct a fog using the given mode and with the colour set to white.
Fog(int mode, boolean global)
          Construct a fog using the given mode and the option of selecting local or global effects.
Fog(int mode, float[] c)
          Construct a fog using the given mode and colour.
Fog(int mode, float[] c, boolean global)
          Construct a fog using the given mode and colour and selection of global state.
 
Method Summary
 int compareTo(Fog fog)
          Compares this object with the specified object for order.
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 boolean equals(Fog fog)
          Compares this object with the specified object to check for equivalence.
 boolean equals(java.lang.Object o)
          Compare this object for equality to the given object.
 void getColor(float[] c)
          Get the current drawing colour
 int getCullableType()
          Get the type that this cullable represents.
 float getDensityRate()
          Get the current decay rate.
 BoundingVolume getEffectBounds()
          Get the current bounding volume that this light effects.
 void getLinearDistance(float[] values)
          Get the two distance values for the linear fog settings.
 int getMode()
          Get the current decay rate.
 Renderable getRenderable()
          Get the child renderable of this object.
 boolean isEnabled()
          Get the current enabled state of the light.
 boolean isGlobalOnly()
          Get the current setting of the global-only flag.
protected  void markBoundsDirty()
          Mark this node as having dirty bounds due to one of it's children having their bounds changed.
 void postRender(javax.media.opengl.GL gl)
          Restore all openGL state to the given drawable.
 void render(javax.media.opengl.GL gl)
          Issue ogl commands needed for this component
 void setColor(float[] c)
          Change the fog colour to the new colour.
 void setDensityRate(float rate)
          Set the exponential decay factor.
 void setEffectBounds(BoundingVolume bounds)
          Set the bounds that will effect the range of this light.
 void setEnabled(boolean state)
          Set the enabled state of the light.
 void setGlobalOnly(boolean enable)
          Set whether the fog should act in local or global mode.
 void setLinearDistance(float start, float end)
          Set the distance functions for the fog when in linear mode.
 void setMode(int type)
          Set the type of fog to be rendered.
 
Methods inherited from class org.j3d.aviatrix3d.Node
boundsChanged, checkForCyclicParent, getBounds, getParent, recomputeBounds, removeParent, requestBoundsUpdate, setBounds, setParent, updateBounds, updateParentBounds
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setLive, setUpdateHandler, setUserData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.j3d.aviatrix3d.rendering.LeafCullable
getBounds
 

Field Detail

EXPONENTIAL

public static final int EXPONENTIAL
Set the fog mode to exponential curve

See Also:
Constant Field Values

EXPONENTIAL_2

public static final int EXPONENTIAL_2
Set the fog mode to exponential-squared curve

See Also:
Constant Field Values

LINEAR

public static final int LINEAR
Set the fog mode to linear

See Also:
Constant Field Values
Constructor Detail

Fog

public Fog()
Constructs a fog node with the default mode set to linear the colour set to white and global only.


Fog

public Fog(int mode)
Construct a fog using the given mode and with the colour set to white.

Parameters:
mode - One of LINEAR, EXPONENTIAL or EXPONENTIAL_2

Fog

public Fog(int mode,
           boolean global)
Construct a fog using the given mode and the option of selecting local or global effects. The colour set to white.

Parameters:
mode - One of LINEAR, EXPONENTIAL or EXPONENTIAL_2
global - true if this is a global-only fog effect

Fog

public Fog(int mode,
           float[] c)
Construct a fog using the given mode and colour.

Parameters:
mode - One of LINEAR, EXPONENTIAL or EXPONENTIAL_2
c - The initial colour to use for the fog

Fog

public Fog(float[] c)
Construct a fog using the given colour and assumes a linear mode.

Parameters:
c - The initial colour to use for the fog

Fog

public Fog(float[] c,
           boolean global)
Construct a fog using the given colour and choice of gloval effect, assuming a linear mode.

Parameters:
c - The initial colour to use for the fog
global - true if this is a global-only fog effect

Fog

public Fog(int mode,
           float[] c,
           boolean global)
Construct a fog using the given mode and colour and selection of global state.

Parameters:
mode - One of LINEAR, EXPONENTIAL or EXPONENTIAL_2
c - The initial colour to use for the fog
global - true if this is a global-only fog effect
Method Detail

getCullableType

public int getCullableType()
Get the type that this cullable represents.

Specified by:
getCullableType in interface LeafCullable
Returns:
One of the _CULLABLE constants

getRenderable

public Renderable getRenderable()
Get the child renderable of this object.

Specified by:
getRenderable in interface LeafCullable
Returns:
an array of nodes

isEnabled

public boolean isEnabled()
Get the current enabled state of the light.

Specified by:
isEnabled in interface CascadeRenderable
Returns:
The current state

isGlobalOnly

public boolean isGlobalOnly()
Get the current setting of the global-only flag.

Specified by:
isGlobalOnly in interface EffectRenderable
Returns:
true if for global use only, false otherwise

getEffectBounds

public BoundingVolume getEffectBounds()
Get the current bounding volume that this light effects. If the light is to effect everything for infinite distance, then this will return null.

Specified by:
getEffectBounds in interface EffectRenderable
Returns:
A bounding volume if there is to be bounds, null for none.

render

public void render(javax.media.opengl.GL gl)
Issue ogl commands needed for this component

Specified by:
render in interface ObjectRenderable
Parameters:
gl - The gl context to draw with

postRender

public void postRender(javax.media.opengl.GL gl)
Restore all openGL state to the given drawable.

Specified by:
postRender in interface ObjectRenderable
Parameters:
gl - The gl context to draw with

markBoundsDirty

protected void markBoundsDirty()
Mark this node as having dirty bounds due to one of it's children having their bounds changed.

Overrides:
markBoundsDirty in class Node

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The objec to be compared
Returns:
-1, 0 or 1 depending on order
Throws:
java.lang.ClassCastException - The specified object's type prevents it from being compared to this Object

equals

public boolean equals(java.lang.Object o)
Compare this object for equality to the given object.

Specified by:
equals in interface Renderable
Overrides:
equals in class java.lang.Object
Parameters:
o - The object to be compared
Returns:
True if these represent the same values

setEnabled

public void setEnabled(boolean state)
                throws InvalidWriteTimingException
Set the enabled state of the light. Can use this to turn it on and off in a general fashion.

Parameters:
state - The new state of the light
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

setGlobalOnly

public void setGlobalOnly(boolean enable)
                   throws InvalidWriteTimingException
Set whether the fog should act in local or global mode.

Parameters:
enable - true to force this fog to be used for global rendering only
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

setEffectBounds

public void setEffectBounds(BoundingVolume bounds)
                     throws InvalidWriteTimingException
Set the bounds that will effect the range of this light. The bounds are used as a secondary scoping capability to define which objects should or should not be effected based on whether their bounding volumes intersect with this volume. If the light is to effect everything then this value should be set to null, otherwise it defines the bounds in the local coordinate system of the light.

Parameters:
bounds - A volume to use or null to clear
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

setColor

public void setColor(float[] c)
              throws InvalidWriteTimingException
Change the fog colour to the new colour. Fog colour only takes RGB.

Parameters:
c - The colour to copy in
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getColor

public void getColor(float[] c)
Get the current drawing colour

Parameters:
c - An array of length 3 or more to copy the colour to

setLinearDistance

public void setLinearDistance(float start,
                              float end)
                       throws InvalidWriteTimingException
Set the distance functions for the fog when in linear mode.

Parameters:
start - The closest distance that fog starts at
end - The distance that the fog is fully opaque at
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getLinearDistance

public void getLinearDistance(float[] values)
Get the two distance values for the linear fog settings. The values are returned in the provided array with index 0 being the start and index 1 being the end.

Parameters:
values - An array to copy the values into

setDensityRate

public void setDensityRate(float rate)
                    throws InvalidWriteTimingException
Set the exponential decay factor.

Parameters:
rate - A value that should be greater than zero
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getDensityRate

public float getDensityRate()
Get the current decay rate.

Returns:
a value > 0

setMode

public void setMode(int type)
             throws InvalidWriteTimingException
Set the type of fog to be rendered. The type is one of the 3 pre-defined modes described in the class header.

Parameters:
type - One of EXPONENTIAL, EXPONENTIAL_2, or LINEAR
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getMode

public int getMode()
Get the current decay rate.

Returns:
One of EXPONENTIAL, EXPONENTIAL_2, or LINEAR

compareTo

public int compareTo(Fog fog)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Parameters:
fog - The program instance to be compared
Returns:
-1, 0 or 1 depending on order

equals

public boolean equals(Fog fog)
Compares this object with the specified object to check for equivalence.

Parameters:
fog - The program instance to be compared
Returns:
true if the objects represent identical values

Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org