com.jme.scene.state
Class TextureState

java.lang.Object
  extended bycom.jme.scene.state.RenderState
      extended bycom.jme.scene.state.TextureState
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
LWJGLTextureState

public abstract class TextureState
extends RenderState

TextureState maintains a texture state for a given node and it's children. The state maintains a single texture object at a time. It is not within the scope of this class to generate the texture, and is recommended that TextureManager be used to create the Texture objects.

Version:
$Id: TextureState.java,v 1.16 2005/02/10 21:48:29 renanse Exp $
Author:
Mark Powell
See Also:
TextureManager, Serialized Form

Field Summary
static int COMBINE_CLOSEST
          Combine texture states starting from the given Spatial and working towards the root.
static int COMBINE_FIRST
          Combine texture states starting from the root node and working towards the given Spatial.
static int COMBINE_RECENT_ENABLED
          Similar to COMBINE_CLOSEST, but if a disabled state is encountered, it will stop combining at that point.
protected  int firstTexture
           
static int INHERIT
          Inherit mode from parent.
protected  int lastTexture
           
protected static float maxAnisotropic
           
protected static int numTexUnits
          The current number of used texture units.
static int OFF
          Ignore textures.
static int REPLACE
          Do not combine texture states, just use the most recent one.
protected static boolean supportsMultiTexture
          True if multitexturing is supported.
protected static boolean supportsS3TCCompression
          True if S3TC compression is supported.
protected  Texture[] texture
          The texture(s).
 
Fields inherited from class com.jme.scene.state.RenderState
RS_ALPHA, RS_ATTRIBUTE, RS_CULL, RS_DITHER, RS_FOG, RS_FRAGMENT_PROGRAM, RS_GLSL_SHADER_OBJECTS, RS_LIGHT, RS_MATERIAL, RS_MAX_STATE, RS_SHADE, RS_STENCIL, RS_TEXTURE, RS_VERTEX_PROGRAM, RS_WIREFRAME, RS_ZBUFFER
 
Constructor Summary
TextureState()
          Constructor instantiates a new TextureState object.
 
Method Summary
abstract  void delete(int unit)
          Removes the texture of the given unit.
abstract  void deleteAll()
          Removes all Texture set in this TextureState.
 float getMaxAnisotropic()
          Returns the maximum anisotropic filter.
 int getNumberOfUnits()
          getNumberOfUnits returns the number of texture units the computer's graphics card supports.
 Texture getTexture()
          getTexture gets the texture that is assigned to the first texture unit.
 Texture getTexture(int textureUnit)
          getTexture retrieves the texture being used by the state in a particular texture unit.
 int getType()
          getType returns this type of render state.
 boolean isS3TCAvailable()
          Returns if S3TC compression is available for textures.
protected  void resetFirstLast()
          Updates firstTexture to be the first non-null Texture, and lastTexture to be the last non-null texture.
 void setTexture(Texture texture)
          setTexture sets a single texture to the first texture unit.
 void setTexture(Texture texture, int textureUnit)
          setTexture sets the texture object to be used by the state.
 
Methods inherited from class com.jme.scene.state.RenderState
apply, extract, isEnabled, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OFF

public static final int OFF
Ignore textures.

See Also:
Constant Field Values

COMBINE_FIRST

public static final int COMBINE_FIRST
Combine texture states starting from the root node and working towards the given Spatial. Ignore disabled states.

See Also:
Constant Field Values

COMBINE_CLOSEST

public static final int COMBINE_CLOSEST
Combine texture states starting from the given Spatial and working towards the root. Ignore disabled states.

See Also:
Constant Field Values

COMBINE_RECENT_ENABLED

public static final int COMBINE_RECENT_ENABLED
Similar to COMBINE_CLOSEST, but if a disabled state is encountered, it will stop combining at that point.

See Also:
Constant Field Values

INHERIT

public static final int INHERIT
Inherit mode from parent.

See Also:
Constant Field Values

REPLACE

public static final int REPLACE
Do not combine texture states, just use the most recent one.

See Also:
Constant Field Values

texture

protected transient Texture[] texture
The texture(s).


numTexUnits

protected static int numTexUnits
The current number of used texture units.


maxAnisotropic

protected static float maxAnisotropic

supportsMultiTexture

protected static boolean supportsMultiTexture
True if multitexturing is supported.


supportsS3TCCompression

protected static boolean supportsS3TCCompression
True if S3TC compression is supported.


firstTexture

protected transient int firstTexture

lastTexture

protected transient int lastTexture
Constructor Detail

TextureState

public TextureState()
Constructor instantiates a new TextureState object.

Method Detail

getType

public int getType()
getType returns this type of render state. (RS_TEXTURE).

Specified by:
getType in class RenderState
Returns:
An int identifying this render state.
See Also:
RenderState.getType()

setTexture

public void setTexture(Texture texture)
setTexture sets a single texture to the first texture unit.

Parameters:
texture - the texture to set.

getTexture

public Texture getTexture()
getTexture gets the texture that is assigned to the first texture unit.

Returns:
the texture in the first texture unit.

setTexture

public void setTexture(Texture texture,
                       int textureUnit)
setTexture sets the texture object to be used by the state. The texture unit that this texture uses is set, if the unit is not valid, i.e. less than zero or greater than the number of texture units supported by the graphics card, it is ignored.

Parameters:
texture - the texture to be used by the state.
textureUnit - the texture unit this texture will fill.

getTexture

public Texture getTexture(int textureUnit)
getTexture retrieves the texture being used by the state in a particular texture unit.

Parameters:
textureUnit - the texture unit to retrieve the texture from.
Returns:
the texture being used by the state. If the texture unit is invalid, null is returned.

getNumberOfUnits

public int getNumberOfUnits()
getNumberOfUnits returns the number of texture units the computer's graphics card supports.

Returns:
the number of texture units supported by the graphics card.

delete

public abstract void delete(int unit)
Removes the texture of the given unit.

Parameters:
unit - The unit of the Texture to remove.

deleteAll

public abstract void deleteAll()
Removes all Texture set in this TextureState.


getMaxAnisotropic

public float getMaxAnisotropic()
Returns the maximum anisotropic filter.

Returns:
The maximum anisotropic filter.

isS3TCAvailable

public boolean isS3TCAvailable()
Returns if S3TC compression is available for textures.

Returns:
true if S3TC is available.

resetFirstLast

protected void resetFirstLast()
Updates firstTexture to be the first non-null Texture, and lastTexture to be the last non-null texture.