com.jme.image
Class Texture

java.lang.Object
  extended by com.jme.image.Texture
All Implemented Interfaces:
Savable
Direct Known Subclasses:
Texture1D, Texture2D, Texture3D, TextureCubeMap

public abstract class Texture
extends java.lang.Object
implements Savable

Texture defines a texture object to be used to display an image on a piece of geometry. The image to be displayed is defined by the Image class. All attributes required for texture mapping are contained within this class. This includes mipmapping if desired, magnificationFilter options, apply options and correction options. Default values are as follows: minificationFilter - NearestNeighborNoMipMaps, magnificationFilter - NearestNeighbor, wrap - EdgeClamp on S,T and R, apply - Modulate, enivoronment - None.

Version:
$Id: Texture.java 4356 2009-05-21 19:28:41Z andreas.meisel@gmx.net $
Author:
Mark Powell, Joshua Slack
See Also:
Image

Nested Class Summary
static class Texture.ApplyMode
           
static class Texture.CombinerFunctionAlpha
           
static class Texture.CombinerFunctionRGB
           
static class Texture.CombinerOperandAlpha
           
static class Texture.CombinerOperandRGB
           
static class Texture.CombinerScale
           
static class Texture.CombinerSource
           
static class Texture.DepthTextureCompareFunc
          The shadowing texture compare function
static class Texture.DepthTextureCompareMode
          The shadowing texture compare mode
static class Texture.DepthTextureMode
          The type of depth texture translation to output
static class Texture.EnvironmentalMapMode
           
static class Texture.MagnificationFilter
           
static class Texture.MinificationFilter
           
static class Texture.RenderToTextureType
          When doing RenderToTexture operations with this texture, this value indicates what content to render into this texture.
static class Texture.Type
           
static class Texture.WrapAxis
           
static class Texture.WrapMode
           
 
Field Summary
static boolean DEFAULT_STORE_TEXTURE
           
 
Constructor Summary
Texture()
          Constructor instantiates a new Texture object with default attributes.
 
Method Summary
abstract  Texture createSimpleClone()
           
 Texture createSimpleClone(Texture rVal)
          Retreive a basic clone of this Texture (ie, clone everything but the image data, which is shared)
 boolean equals(java.lang.Object other)
           
 float getAnisotropicFilterPercent()
           
 Texture.ApplyMode getApply()
          getApply returns the apply mode for the texture.
 ColorRGBA getBlendColor()
          getBlendColor returns the color set to be used with CombinerSource.Constant for this texture (as applicable) If null, black is assumed.
 ColorRGBA getBorderColor()
          getBorderColor returns the color to be used for border operations.
 java.lang.Class<? extends Texture> getClassTag()
           
 Texture.CombinerFunctionAlpha getCombineFuncAlpha()
           
 Texture.CombinerFunctionRGB getCombineFuncRGB()
           
 Texture.CombinerOperandAlpha getCombineOp0Alpha()
           
 Texture.CombinerOperandRGB getCombineOp0RGB()
           
 Texture.CombinerOperandAlpha getCombineOp1Alpha()
           
 Texture.CombinerOperandRGB getCombineOp1RGB()
           
 Texture.CombinerOperandAlpha getCombineOp2Alpha()
           
 Texture.CombinerOperandRGB getCombineOp2RGB()
           
 Texture.CombinerScale getCombineScaleAlpha()
           
 Texture.CombinerScale getCombineScaleRGB()
           
 Texture.CombinerSource getCombineSrc0Alpha()
           
 Texture.CombinerSource getCombineSrc0RGB()
           
 Texture.CombinerSource getCombineSrc1Alpha()
           
 Texture.CombinerSource getCombineSrc1RGB()
           
 Texture.CombinerSource getCombineSrc2Alpha()
           
 Texture.CombinerSource getCombineSrc2RGB()
           
 Texture.DepthTextureCompareFunc getDepthCompareFunc()
          Get the depth texture compare function
 Texture.DepthTextureCompareMode getDepthCompareMode()
          Get the depth texture compare mode
 Texture.DepthTextureMode getDepthMode()
          Get the depth texture apply mode
 Texture.EnvironmentalMapMode getEnvironmentalMapMode()
           
 Image getImage()
          getImage returns the image data that makes up this texture.
 java.lang.String getImageLocation()
           
 Texture.MagnificationFilter getMagnificationFilter()
           
 Matrix4f getMatrix()
           
 int getMemoryReq()
           
 Texture.MinificationFilter getMinificationFilter()
           
 Quaternion getRotation()
           
 Texture.RenderToTextureType getRTTSource()
           
 Vector3f getScale()
           
 int getTextureId()
          getTextureId returns the texture id of this texture.
 TextureKey getTextureKey()
           
 Vector3f getTranslation()
           
abstract  Texture.Type getType()
           
abstract  Texture.WrapMode getWrap(Texture.WrapAxis axis)
          getWrap returns the wrap mode for a given coordinate axis on this texture.
 boolean hasBorder()
           
 boolean isStoreTexture()
           
 void read(JMEImporter e)
           
 void setAnisotropicFilterPercent(float percent)
           
 void setApply(Texture.ApplyMode apply)
          setApply sets the apply mode for this texture.
 void setBlendColor(ColorRGBA color)
          setBlendColor sets a color that is used with CombinerSource.Constant
 void setBorderColor(ColorRGBA color)
          setBorderColor sets the color used when texture operations encounter the border of a texture.
 void setCombineFuncAlpha(Texture.CombinerFunctionAlpha combineFuncAlpha)
           
 void setCombineFuncRGB(Texture.CombinerFunctionRGB combineFuncRGB)
           
 void setCombineOp0Alpha(Texture.CombinerOperandAlpha combineOp0Alpha)
           
 void setCombineOp0RGB(Texture.CombinerOperandRGB combineOp0RGB)
           
 void setCombineOp1Alpha(Texture.CombinerOperandAlpha combineOp1Alpha)
           
 void setCombineOp1RGB(Texture.CombinerOperandRGB combineOp1RGB)
           
 void setCombineOp2Alpha(Texture.CombinerOperandAlpha combineOp2Alpha)
           
 void setCombineOp2RGB(Texture.CombinerOperandRGB combineOp2RGB)
           
 void setCombineScaleAlpha(Texture.CombinerScale combineScaleAlpha)
           
 void setCombineScaleRGB(Texture.CombinerScale combineScaleRGB)
           
 void setCombineSrc0Alpha(Texture.CombinerSource combineSrc0Alpha)
           
 void setCombineSrc0RGB(Texture.CombinerSource combineSrc0RGB)
           
 void setCombineSrc1Alpha(Texture.CombinerSource combineSrc1Alpha)
           
 void setCombineSrc1RGB(Texture.CombinerSource combineSrc1RGB)
           
 void setCombineSrc2Alpha(Texture.CombinerSource combineSrc2Alpha)
           
 void setCombineSrc2RGB(Texture.CombinerSource combineSrc2RGB)
           
 void setDepthCompareFunc(Texture.DepthTextureCompareFunc depthCompareFunc)
          Set the depth texture compare function param depthCompareFunc The depth texture compare function
 void setDepthCompareMode(Texture.DepthTextureCompareMode depthCompareMode)
          Set the depth texture compare mode
 void setDepthMode(Texture.DepthTextureMode depthMode)
          Set the depth texture apply mode param depthMode The depth texture apply mode
 void setEnvironmentalMapMode(Texture.EnvironmentalMapMode envMapMode)
           
 void setHasBorder(boolean hasBorder)
           
 void setImage(Image image)
          setImage sets the image object that defines the texture.
 void setImageLocation(java.lang.String imageLocation)
           
 void setMagnificationFilter(Texture.MagnificationFilter magnificationFilter)
           
 void setMatrix(Matrix4f matrix)
           
 void setMinificationFilter(Texture.MinificationFilter minificationFilter)
           
 void setRenderToTextureType(Texture.RenderToTextureType rttSource)
           
 void setRotation(Quaternion rotation)
           
 void setScale(Vector3f scale)
           
 void setStoreTexture(boolean storeTexture)
           
 void setTextureId(int textureId)
          setTextureId sets the texture id for this texture.
 void setTextureKey(TextureKey tkey)
           
 void setTranslation(Vector3f translation)
           
abstract  void setWrap(Texture.WrapAxis axis, Texture.WrapMode mode)
          setWrap sets the wrap mode of this texture for a particular axis.
abstract  void setWrap(Texture.WrapMode mode)
          setWrap sets the wrap mode of this texture for all axis.
 void updateMemoryReq()
           
 void write(JMEExporter e)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_STORE_TEXTURE

public static boolean DEFAULT_STORE_TEXTURE
Constructor Detail

Texture

public Texture()
Constructor instantiates a new Texture object with default attributes.

Method Detail

setBlendColor

public void setBlendColor(ColorRGBA color)
setBlendColor sets a color that is used with CombinerSource.Constant

Parameters:
color - the new blend color - or null for the default (black)

setBorderColor

public void setBorderColor(ColorRGBA color)
setBorderColor sets the color used when texture operations encounter the border of a texture.

Parameters:
color - the new border color - or null for the default (black)

getMinificationFilter

public Texture.MinificationFilter getMinificationFilter()
Returns:
the MinificationFilterMode of this texture.

setMinificationFilter

public void setMinificationFilter(Texture.MinificationFilter minificationFilter)
Parameters:
minificationFilter - the new MinificationFilterMode for this texture.
Throws:
java.lang.IllegalArgumentException - if minificationFilter is null

getMagnificationFilter

public Texture.MagnificationFilter getMagnificationFilter()
Returns:
the MagnificationFilterMode of this texture.

setMagnificationFilter

public void setMagnificationFilter(Texture.MagnificationFilter magnificationFilter)
Parameters:
magnificationFilter - the new MagnificationFilter for this texture.
Throws:
java.lang.IllegalArgumentException - if magnificationFilter is null

setApply

public void setApply(Texture.ApplyMode apply)
setApply sets the apply mode for this texture.

Parameters:
apply - the apply mode for this texture.
Throws:
java.lang.IllegalArgumentException - if apply is null

setImage

public void setImage(Image image)
setImage sets the image object that defines the texture.

Parameters:
image - the image that defines the texture.

getTextureId

public int getTextureId()
getTextureId returns the texture id of this texture. This id is required to be unique to any other texture objects running in the same JVM. However, no guarantees are made that it will be unique, and as such, the user is responsible for this.

Returns:
the id of the texture.

setTextureId

public void setTextureId(int textureId)
setTextureId sets the texture id for this texture. Zero means no id is set.

Parameters:
textureId - the texture id of this texture.

getImage

public Image getImage()
getImage returns the image data that makes up this texture. If no image data has been set, this will return null.

Returns:
the image data that makes up the texture.

getApply

public Texture.ApplyMode getApply()
getApply returns the apply mode for the texture.

Returns:
the apply mode of the texture.

getBlendColor

public ColorRGBA getBlendColor()
getBlendColor returns the color set to be used with CombinerSource.Constant for this texture (as applicable) If null, black is assumed.

Returns:
the blend color.

getBorderColor

public ColorRGBA getBorderColor()
getBorderColor returns the color to be used for border operations. If null, black is assumed.

Returns:
the border color.

setWrap

public abstract void setWrap(Texture.WrapAxis axis,
                             Texture.WrapMode mode)
setWrap sets the wrap mode of this texture for a particular axis.

Parameters:
axis - the texture axis to define a wrapmode on.
mode - the wrap mode for the given axis of the texture.
Throws:
java.lang.IllegalArgumentException - if axis or mode are null or invalid for this type of texture

setWrap

public abstract void setWrap(Texture.WrapMode mode)
setWrap sets the wrap mode of this texture for all axis.

Parameters:
mode - the wrap mode for the given axis of the texture.
Throws:
java.lang.IllegalArgumentException - if mode is null or invalid for this type of texture

getWrap

public abstract Texture.WrapMode getWrap(Texture.WrapAxis axis)
getWrap returns the wrap mode for a given coordinate axis on this texture.

Parameters:
axis - the axis to return for
Returns:
the wrap mode of the texture.
Throws:
java.lang.IllegalArgumentException - if axis is null or invalid for this type of texture

getType

public abstract Texture.Type getType()

getCombineFuncRGB

public Texture.CombinerFunctionRGB getCombineFuncRGB()
Returns:
Returns the combineFuncRGB.

setCombineFuncRGB

public void setCombineFuncRGB(Texture.CombinerFunctionRGB combineFuncRGB)
Parameters:
combineFuncRGB - The combineFuncRGB to set.
Throws:
java.lang.IllegalArgumentException - if combineFuncRGB is null

getCombineOp0Alpha

public Texture.CombinerOperandAlpha getCombineOp0Alpha()
Returns:
Returns the combineOp0Alpha.

setCombineOp0Alpha

public void setCombineOp0Alpha(Texture.CombinerOperandAlpha combineOp0Alpha)
Parameters:
combineOp0Alpha - The combineOp0Alpha to set.
Throws:
java.lang.IllegalArgumentException - if combineOp0Alpha is null

getCombineOp0RGB

public Texture.CombinerOperandRGB getCombineOp0RGB()
Returns:
Returns the combineOp0RGB.

setCombineOp0RGB

public void setCombineOp0RGB(Texture.CombinerOperandRGB combineOp0RGB)
Parameters:
combineOp0RGB - The combineOp0RGB to set.
Throws:
java.lang.IllegalArgumentException - if combineOp0RGB is null

getCombineOp1Alpha

public Texture.CombinerOperandAlpha getCombineOp1Alpha()
Returns:
Returns the combineOp1Alpha.

setCombineOp1Alpha

public void setCombineOp1Alpha(Texture.CombinerOperandAlpha combineOp1Alpha)
Parameters:
combineOp1Alpha - The combineOp1Alpha to set.
Throws:
java.lang.IllegalArgumentException - if combineOp1Alpha is null

getCombineOp1RGB

public Texture.CombinerOperandRGB getCombineOp1RGB()
Returns:
Returns the combineOp1RGB.

setCombineOp1RGB

public void setCombineOp1RGB(Texture.CombinerOperandRGB combineOp1RGB)
Parameters:
combineOp1RGB - The combineOp1RGB to set.
Throws:
java.lang.IllegalArgumentException - if combineOp1RGB is null

getCombineOp2Alpha

public Texture.CombinerOperandAlpha getCombineOp2Alpha()
Returns:
Returns the combineOp2Alpha.

setCombineOp2Alpha

public void setCombineOp2Alpha(Texture.CombinerOperandAlpha combineOp2Alpha)
Parameters:
combineOp2Alpha - The combineOp2Alpha to set.
Throws:
java.lang.IllegalArgumentException - if combineOp2Alpha is null

getCombineOp2RGB

public Texture.CombinerOperandRGB getCombineOp2RGB()
Returns:
Returns the combineOp2RGB.

setCombineOp2RGB

public void setCombineOp2RGB(Texture.CombinerOperandRGB combineOp2RGB)
Parameters:
combineOp2RGB - The combineOp2RGB to set.
Throws:
java.lang.IllegalArgumentException - if combineOp2RGB is null

getCombineScaleAlpha

public Texture.CombinerScale getCombineScaleAlpha()
Returns:
Returns the combineScaleAlpha.

setCombineScaleAlpha

public void setCombineScaleAlpha(Texture.CombinerScale combineScaleAlpha)
Parameters:
combineScaleAlpha - The combineScaleAlpha to set.
Throws:
java.lang.IllegalArgumentException - if combineScaleAlpha is null

getCombineScaleRGB

public Texture.CombinerScale getCombineScaleRGB()
Returns:
Returns the combineScaleRGB.

setCombineScaleRGB

public void setCombineScaleRGB(Texture.CombinerScale combineScaleRGB)
Parameters:
combineScaleRGB - The combineScaleRGB to set.
Throws:
java.lang.IllegalArgumentException - if combineScaleRGB is null

getCombineSrc0Alpha

public Texture.CombinerSource getCombineSrc0Alpha()
Returns:
Returns the combineSrc0Alpha.

setCombineSrc0Alpha

public void setCombineSrc0Alpha(Texture.CombinerSource combineSrc0Alpha)
Parameters:
combineSrc0Alpha - The combineSrc0Alpha to set.
Throws:
java.lang.IllegalArgumentException - if combineSrc0Alpha is null

getCombineSrc0RGB

public Texture.CombinerSource getCombineSrc0RGB()
Returns:
Returns the combineSrc0RGB.

setCombineSrc0RGB

public void setCombineSrc0RGB(Texture.CombinerSource combineSrc0RGB)
Parameters:
combineSrc0RGB - The combineSrc0RGB to set.
Throws:
java.lang.IllegalArgumentException - if combineSrc0RGB is null

getCombineSrc1Alpha

public Texture.CombinerSource getCombineSrc1Alpha()
Returns:
Returns the combineSrc1Alpha.

setCombineSrc1Alpha

public void setCombineSrc1Alpha(Texture.CombinerSource combineSrc1Alpha)
Parameters:
combineSrc1Alpha - The combineSrc1Alpha to set.
Throws:
java.lang.IllegalArgumentException - if combineSrc1Alpha is null

getCombineSrc1RGB

public Texture.CombinerSource getCombineSrc1RGB()
Returns:
Returns the combineSrc1RGB.

setCombineSrc1RGB

public void setCombineSrc1RGB(Texture.CombinerSource combineSrc1RGB)
Parameters:
combineSrc1RGB - The combineSrc1RGB to set.
Throws:
java.lang.IllegalArgumentException - if combineSrc1RGB is null

getCombineSrc2Alpha

public Texture.CombinerSource getCombineSrc2Alpha()
Returns:
Returns the combineSrc2Alpha.

setCombineSrc2Alpha

public void setCombineSrc2Alpha(Texture.CombinerSource combineSrc2Alpha)
Parameters:
combineSrc2Alpha - The combineSrc2Alpha to set.
Throws:
java.lang.IllegalArgumentException - if combineSrc2Alpha is null

getCombineSrc2RGB

public Texture.CombinerSource getCombineSrc2RGB()
Returns:
Returns the combineSrc2RGB.

setCombineSrc2RGB

public void setCombineSrc2RGB(Texture.CombinerSource combineSrc2RGB)
Parameters:
combineSrc2RGB - The combineSrc2RGB to set.
Throws:
java.lang.IllegalArgumentException - if combineSrc2RGB is null

getCombineFuncAlpha

public Texture.CombinerFunctionAlpha getCombineFuncAlpha()
Returns:
Returns the combineFuncAlpha.

setCombineFuncAlpha

public void setCombineFuncAlpha(Texture.CombinerFunctionAlpha combineFuncAlpha)
Parameters:
combineFuncAlpha - The combineFuncAlpha to set.
Throws:
java.lang.IllegalArgumentException - if combineFuncAlpha is null

setEnvironmentalMapMode

public void setEnvironmentalMapMode(Texture.EnvironmentalMapMode envMapMode)
Parameters:
envMapMode -
Throws:
java.lang.IllegalArgumentException - if envMapMode is null

getEnvironmentalMapMode

public Texture.EnvironmentalMapMode getEnvironmentalMapMode()

getImageLocation

public java.lang.String getImageLocation()

setImageLocation

public void setImageLocation(java.lang.String imageLocation)

getAnisotropicFilterPercent

public float getAnisotropicFilterPercent()
Returns:
the anisotropic filtering level for this texture as a percentage (0.0 - 1.0)

setAnisotropicFilterPercent

public void setAnisotropicFilterPercent(float percent)
Parameters:
percent - the anisotropic filtering level for this texture as a percentage (0.0 - 1.0)

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

createSimpleClone

public abstract Texture createSimpleClone()

createSimpleClone

public Texture createSimpleClone(Texture rVal)
Retreive a basic clone of this Texture (ie, clone everything but the image data, which is shared)

Returns:
Texture

getRotation

public Quaternion getRotation()
Returns:
Returns the rotation.

setRotation

public void setRotation(Quaternion rotation)
Parameters:
rotation - The rotation to set.

getMatrix

public Matrix4f getMatrix()
Returns:
the texture matrix set on this texture or null if none is set.

setMatrix

public void setMatrix(Matrix4f matrix)
Parameters:
matrix - The matrix to set on this Texture. If null, rotation, scale and/or translation will be used.

getScale

public Vector3f getScale()
Returns:
Returns the scale.

setScale

public void setScale(Vector3f scale)
Parameters:
scale - The scale to set.

getTranslation

public Vector3f getTranslation()
Returns:
Returns the translation.

setTranslation

public void setTranslation(Vector3f translation)
Parameters:
translation - The translation to set.

getRTTSource

public Texture.RenderToTextureType getRTTSource()
Returns:
Returns the rttSource.

setRenderToTextureType

public void setRenderToTextureType(Texture.RenderToTextureType rttSource)
Parameters:
rttSource - The rttSource to set.
Throws:
java.lang.IllegalArgumentException - if rttSource is null

getMemoryReq

public int getMemoryReq()
Returns:
the estimated footprint of this texture in bytes

updateMemoryReq

public void updateMemoryReq()

write

public void write(JMEExporter e)
           throws java.io.IOException
Specified by:
write in interface Savable
Throws:
java.io.IOException

read

public void read(JMEImporter e)
          throws java.io.IOException
Specified by:
read in interface Savable
Throws:
java.io.IOException

getClassTag

public java.lang.Class<? extends Texture> getClassTag()
Specified by:
getClassTag in interface Savable

setTextureKey

public void setTextureKey(TextureKey tkey)

getTextureKey

public TextureKey getTextureKey()

isStoreTexture

public boolean isStoreTexture()

setStoreTexture

public void setStoreTexture(boolean storeTexture)

hasBorder

public boolean hasBorder()

setHasBorder

public void setHasBorder(boolean hasBorder)

getDepthCompareFunc

public Texture.DepthTextureCompareFunc getDepthCompareFunc()
Get the depth texture compare function

Returns:
The depth texture compare function

setDepthCompareFunc

public void setDepthCompareFunc(Texture.DepthTextureCompareFunc depthCompareFunc)
Set the depth texture compare function param depthCompareFunc The depth texture compare function


getDepthMode

public Texture.DepthTextureMode getDepthMode()
Get the depth texture apply mode

Returns:
The depth texture apply mode

setDepthMode

public void setDepthMode(Texture.DepthTextureMode depthMode)
Set the depth texture apply mode param depthMode The depth texture apply mode


getDepthCompareMode

public Texture.DepthTextureCompareMode getDepthCompareMode()
Get the depth texture compare mode

Returns:
The depth texture compare mode

setDepthCompareMode

public void setDepthCompareMode(Texture.DepthTextureCompareMode depthCompareMode)
Set the depth texture compare mode

Parameters:
depthCompareMode - The depth texture compare mode