Class TextureState

java.lang.Object
com.ardor3d.renderer.state.RenderState
com.ardor3d.renderer.state.TextureState
All Implemented Interfaces:
Savable

public class TextureState extends RenderState
TextureState maintains a texture state for a given node and it's children. The number of states that a TextureState can maintain at one time is equal to the number of texture units available on the GPU. 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.
See Also:
  • Field Details

    • MAX_TEXTURES

      public static final int MAX_TEXTURES
      See Also:
    • _defaultTexture

      protected static Texture _defaultTexture
    • defaultTextureLoaded

      protected static boolean defaultTextureLoaded
    • _texture

      protected List<Texture> _texture
      The texture(s).
    • _keyCache

      public transient TextureKey[] _keyCache
    • DEFAULT_TEXTURE_SOURCE

      public static ResourceSource DEFAULT_TEXTURE_SOURCE
  • Constructor Details

    • TextureState

      public TextureState()
      Constructor instantiates a new TextureState object.
  • Method Details

    • getType

      public RenderState.StateType getType()
      Specified by:
      getType in class RenderState
      Returns:
      An statetype enum value for the subclass.
      See Also:
    • 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.
    • removeTexture

      public boolean removeTexture(Texture tex)
    • removeTexture

      public boolean removeTexture(int textureUnit)
    • clearTextures

      public void clearTextures()
      Removes all textures in this texture state. Does not delete them from the graphics card.
    • setCorrectionType

      public void setCorrectionType(TextureState.CorrectionType type)
      setCorrectionType sets the image correction type for this texture state.
      Parameters:
      type - the correction type for this texture.
      Throws:
      IllegalArgumentException - if type is null
    • getCorrectionType

      public TextureState.CorrectionType getCorrectionType()
      getCorrectionType returns the correction mode for the texture state.
      Returns:
      the correction type for the texture state.
    • getNumberOfSetTextures

      public int getNumberOfSetTextures()
      Returns the number of textures this texture manager is maintaining.
      Returns:
      the number of textures.
    • getMaxTextureIndexUsed

      public int getMaxTextureIndexUsed()
      Returns the max index in this TextureState that contains a non-null Texture.
      Returns:
      the max index, or -1 if no textures are contained by this state.
    • getTextureKey

      public final TextureKey getTextureKey(int textureUnit)
      Fast access for retrieving a TextureKey. A return is guaranteed when textureUnit is any number under or equal to the highest texture unit currently in use. This value can be retrieved with getNumberOfSetTextures. A higher value might result in unexpected behavior such as an exception being thrown.
      Parameters:
      textureUnit - The texture unit from which to retrieve the TextureKey.
      Returns:
      the TextureKey, or null if there is none.
    • write

      public void write(OutputCapsule capsule) throws IOException
      Specified by:
      write in interface Savable
      Overrides:
      write in class RenderState
      Throws:
      IOException
    • read

      public void read(InputCapsule capsule) throws IOException
      Specified by:
      read in interface Savable
      Overrides:
      read in class RenderState
      Throws:
      IOException
    • getDefaultTextureImage

      public static Image getDefaultTextureImage()
    • getDefaultTexture

      public static Texture getDefaultTexture()
    • createStateRecord

      public StateRecord createStateRecord(ContextCapabilities caps)
      Specified by:
      createStateRecord in class RenderState
    • extract

      public RenderState extract(Stack<? extends RenderState> stack, Spatial spat)
      Description copied from class: RenderState
      Extracts from the stack the correct renderstate that should apply to the given spatial. This is mainly used for RenderStates that can be cumulitive such as TextureState or LightState. By default, the top of the static is returned. This function should not be called by users directly.
      Overrides:
      extract in class RenderState
      Parameters:
      stack - The stack to extract render states from.
      spat - The spatial to apply the render states too.
      Returns:
      The render state to use.