com.jme.image
Class Texture

java.lang.Object
  extended bycom.jme.image.Texture

public class Texture
extends java.lang.Object

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, filter options, apply options and correction options. Default values are as follows: mipmap - MM_NONE, filter - FM_NEAREST, wrap - WM_CLAMP_S_CLAMP_T, apply - AM_MODULATE, correction - CM_AFFINE.

Version:
$Id: Texture.java,v 1.18 2004/10/07 19:27:16 renanse Exp $
Author:
Mark Powell
See Also:
Image

Field Summary
static int ACF_ADD
           
static int ACF_ADD_SIGNED
           
static int ACF_DOT3_RGB
           
static int ACF_DOT3_RGBA
           
static int ACF_INTERPOLATE
           
static int ACF_MODULATE
           
static int ACF_REPLACE
           
static int ACF_SUBTRACT
           
static int ACO_ONE_MINUS_SRC_ALPHA
           
static int ACO_ONE_MINUS_SRC_COLOR
           
static int ACO_SRC_ALPHA
           
static int ACO_SRC_COLOR
           
static int ACS_CONSTANT
           
static int ACS_PREVIOUS
           
static int ACS_PRIMARY_COLOR
           
static int ACS_TEXTURE
           
static int ACSC_FOUR
           
static int ACSC_ONE
           
static int ACSC_TWO
           
static int AM_BLEND
          Apply modifier that combines the color of the pixel with the texture color, such that the final color value is Cv = (1 - Ct) Cf.
static int AM_COMBINE
          Apply modifier combines two textures.
static int AM_DECAL
          Apply modifier that replaces the color values of the pixel but makes use of the alpha values.
static int AM_MODULATE
          Apply modifier multiples the color of the pixel with the texture color.
static int AM_REPLACE
          Apply modifier that replaces the previous pixel color with the texture color.
static int CM_AFFINE
          Correction modifier makes no color corrections, and is the fastest.
static int CM_PERSPECTIVE
          Correction modifier makes color corrections based on perspective and is slower than CM_AFFINE.
static int EM_IGNORE
           
static int EM_NONE
           
static int EM_SPHERE
           
static int FM_LINEAR
          Filter option to return the weighted average of the four texture elements that are closest to the center of the pixel being textured.
static int FM_NEAREST
          Filter option to return the value of the texture element that is nearest to the center of the pixel being textured.
static int MM_LINEAR
          Mipmap option to return the weighted average of the four texture elements that are closest to the center of the pixel being textured.
static int MM_LINEAR_LINEAR
          Mipmap option that picks the two mipmaps that most closely match the size of the pixel being textured and uses MM_LINEAR criteria.
static int MM_LINEAR_NEAREST
          Mipmap option that picks the two mipmaps that most closely match the size of the pixel being textured and uses MM_NEAREST criteria.
static int MM_NEAREST
          Mipmap option to return the value of the texture element that is nearest to the center of the pixel being textured.
static int MM_NEAREST_LINEAR
          Mipmap option that picks the mipmap most closely matches the size of the pixel being textured and uses MM_LINEAR criteria.
static int MM_NEAREST_NEAREST
          Mipmap option that picks the mipmap that most closely matches the size of the pixel being textured and uses MM_NEAREST criteria.
static int MM_NONE
          Mipmap option for no mipmap.
static int WM_BCLAMP_S_BCLAMP_T
          Wrapping modifier that clamps both the S and T values of the texture.
static int WM_CLAMP_S_CLAMP_T
          Wrapping modifier that clamps both the S and T values of the texture.
static int WM_CLAMP_S_WRAP_T
          Wrapping modifier that clamps the S value but wraps the T value of the texture.
static int WM_ECLAMP_S_ECLAMP_T
          Wrapping modifier that clamps both the S and T values of the texture.
static int WM_WRAP_S_CLAMP_T
          Wrapping modifier that wraps the S value but clamps the T value of the texture.
static int WM_WRAP_S_WRAP_T
          Wrapping modifier that wraps both the S and T values of the texture.
 
Constructor Summary
Texture()
          Constructor instantiates a new Texture object with default attributes.
Texture(float aniso)
          Constructor instantiates a new Texture object with given attributes.
 
Method Summary
 Texture createSimpleClone()
          Retreive a basic clone of this Texture (ie, clone everything but the image data, which is shared)
 boolean equals(java.lang.Object other)
           
 float getAnisoLevel()
           
 int getApply()
          getApply returns the apply mode for the texture.
 java.nio.FloatBuffer getBlendColor()
          getBlendColor returns the buffer that contains the texture's tint color.
 java.nio.FloatBuffer getBlendColorBuffer()
          getBlendColorBuffer returns the buffer that contains the color values that are used to tint the texture.
 int getCombineFuncAlpha()
           
 int getCombineFuncRGB()
           
 int getCombineOp0Alpha()
           
 int getCombineOp0RGB()
           
 int getCombineOp1Alpha()
           
 int getCombineOp1RGB()
           
 int getCombineOp2Alpha()
           
 int getCombineOp2RGB()
           
 float getCombineScaleAlpha()
           
 float getCombineScaleRGB()
           
 int getCombineSrc0Alpha()
           
 int getCombineSrc0RGB()
           
 int getCombineSrc1Alpha()
           
 int getCombineSrc1RGB()
           
 int getCombineSrc2Alpha()
           
 int getCombineSrc2RGB()
           
 int getCorrection()
          getCorrection returns the correction mode for the texture.
 int getEnvironmentalMapMode()
           
 int getFilter()
          getFilter returns the filter mode for the texture.
 Image getImage()
          getImage returns the image data that makes up this texture.
 java.lang.String getImageLocation()
           
 int getMipmap()
          getMipmap returns the mipmap mode for the texture.
 int getMipmapState()
          getMipmapState returns the current mipmap state of this texture.
 int getTextureId()
          getTextureId returns the texture id of this texture.
 int getWrap()
          getWrap returns the wrap mode for the texture.
 boolean needsFilterRefresh()
           
 boolean needsWrapRefresh()
           
 void setAnisoLevel(float level)
          Deprecated. Must set aniso level when loading texture from manager.
 void setApply(int apply)
          setApply sets the apply mode for this texture.
 void setBlendColor(ColorRGBA color)
          setBlendColor sets the color to be used to tint the texture.
 void setBlendColorBuffer(java.nio.FloatBuffer blendColorBuffer)
          setBlendColorBuffer sets the buffer that contains the color values that are used to tint the texture.
 void setCombineFuncAlpha(int combineFuncAlpha)
           
 void setCombineFuncRGB(int combineFuncRGB)
           
 void setCombineOp0Alpha(int combineOp0Alpha)
           
 void setCombineOp0RGB(int combineOp0RGB)
           
 void setCombineOp1Alpha(int combineOp1Alpha)
           
 void setCombineOp1RGB(int combineOp1RGB)
           
 void setCombineOp2Alpha(int combineOp2Alpha)
           
 void setCombineOp2RGB(int combineOp2RGB)
           
 void setCombineScaleAlpha(float combineScaleAlpha)
           
 void setCombineScaleRGB(float combineScaleRGB)
           
 void setCombineSrc0Alpha(int combineSrc0Alpha)
           
 void setCombineSrc0RGB(int combineSrc0RGB)
           
 void setCombineSrc1Alpha(int combineSrc1Alpha)
           
 void setCombineSrc1RGB(int combineSrc1RGB)
           
 void setCombineSrc2Alpha(int combineSrc2Alpha)
           
 void setCombineSrc2RGB(int combineSrc2RGB)
           
 void setCorrection(int correction)
          setCorrection sets the image correction mode for this texture.
 void setEnvironmentalMapMode(int envMapMode)
           
 void setFilter(int filter)
          setFilter sets the texture filter mode for this texture.
 void setImage(Image image)
          setImage sets the image object that defines the texture.
 void setImageLocation(java.lang.String imageLocation)
           
 void setMipmapState(int mipmapState)
          setMipmapState sets the mipmap state for this texture.
 void setNeedsFilterRefresh(boolean needed)
           
 void setNeedsWrapRefresh(boolean needed)
           
 void setTextureId(int textureId)
          setTextureId sets the texture id for this texture.
 void setWrap(int wrap)
          setWrap sets the wrap mode of this texture.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MM_NONE

public static final int MM_NONE
Mipmap option for no mipmap.

See Also:
Constant Field Values

MM_NEAREST

public static final int MM_NEAREST
Mipmap option to return the value of the texture element that is nearest to the center of the pixel being textured.

See Also:
Constant Field Values

MM_LINEAR

public static final int MM_LINEAR
Mipmap option to return the weighted average of the four texture elements that are closest to the center of the pixel being textured.

See Also:
Constant Field Values

MM_NEAREST_NEAREST

public static final int MM_NEAREST_NEAREST
Mipmap option that picks the mipmap that most closely matches the size of the pixel being textured and uses MM_NEAREST criteria.

See Also:
Constant Field Values

MM_NEAREST_LINEAR

public static final int MM_NEAREST_LINEAR
Mipmap option that picks the mipmap most closely matches the size of the pixel being textured and uses MM_LINEAR criteria.

See Also:
Constant Field Values

MM_LINEAR_NEAREST

public static final int MM_LINEAR_NEAREST
Mipmap option that picks the two mipmaps that most closely match the size of the pixel being textured and uses MM_NEAREST criteria.

See Also:
Constant Field Values

MM_LINEAR_LINEAR

public static final int MM_LINEAR_LINEAR
Mipmap option that picks the two mipmaps that most closely match the size of the pixel being textured and uses MM_LINEAR criteria.

See Also:
Constant Field Values

FM_NEAREST

public static final int FM_NEAREST
Filter option to return the value of the texture element that is nearest to the center of the pixel being textured.

See Also:
Constant Field Values

FM_LINEAR

public static final int FM_LINEAR
Filter option to return the weighted average of the four texture elements that are closest to the center of the pixel being textured.

See Also:
Constant Field Values

WM_CLAMP_S_CLAMP_T

public static final int WM_CLAMP_S_CLAMP_T
Wrapping modifier that clamps both the S and T values of the texture.

See Also:
Constant Field Values

WM_CLAMP_S_WRAP_T

public static final int WM_CLAMP_S_WRAP_T
Wrapping modifier that clamps the S value but wraps the T value of the texture.

See Also:
Constant Field Values

WM_WRAP_S_CLAMP_T

public static final int WM_WRAP_S_CLAMP_T
Wrapping modifier that wraps the S value but clamps the T value of the texture.

See Also:
Constant Field Values

WM_WRAP_S_WRAP_T

public static final int WM_WRAP_S_WRAP_T
Wrapping modifier that wraps both the S and T values of the texture.

See Also:
Constant Field Values

WM_ECLAMP_S_ECLAMP_T

public static final int WM_ECLAMP_S_ECLAMP_T
Wrapping modifier that clamps both the S and T values of the texture. Uses CLAMP_TO_EDGE.

See Also:
Constant Field Values

WM_BCLAMP_S_BCLAMP_T

public static final int WM_BCLAMP_S_BCLAMP_T
Wrapping modifier that clamps both the S and T values of the texture. Uses CLAMP_TO_BORDER.

See Also:
Constant Field Values

AM_REPLACE

public static final int AM_REPLACE
Apply modifier that replaces the previous pixel color with the texture color.

See Also:
Constant Field Values

AM_DECAL

public static final int AM_DECAL
Apply modifier that replaces the color values of the pixel but makes use of the alpha values.

See Also:
Constant Field Values

AM_MODULATE

public static final int AM_MODULATE
Apply modifier multiples the color of the pixel with the texture color.

See Also:
Constant Field Values

AM_BLEND

public static final int AM_BLEND
Apply modifier that combines the color of the pixel with the texture color, such that the final color value is Cv = (1 - Ct) Cf. Where Ct is the color of the texture and Cf is the initial pixel color.

See Also:
Constant Field Values

AM_COMBINE

public static final int AM_COMBINE
Apply modifier combines two textures.

See Also:
Constant Field Values

CM_AFFINE

public static final int CM_AFFINE
Correction modifier makes no color corrections, and is the fastest.

See Also:
Constant Field Values

CM_PERSPECTIVE

public static final int CM_PERSPECTIVE
Correction modifier makes color corrections based on perspective and is slower than CM_AFFINE.

See Also:
Constant Field Values

ACF_REPLACE

public static final int ACF_REPLACE
See Also:
Constant Field Values

ACF_MODULATE

public static final int ACF_MODULATE
See Also:
Constant Field Values

ACF_ADD

public static final int ACF_ADD
See Also:
Constant Field Values

ACF_ADD_SIGNED

public static final int ACF_ADD_SIGNED
See Also:
Constant Field Values

ACF_SUBTRACT

public static final int ACF_SUBTRACT
See Also:
Constant Field Values

ACF_INTERPOLATE

public static final int ACF_INTERPOLATE
See Also:
Constant Field Values

ACF_DOT3_RGB

public static final int ACF_DOT3_RGB
See Also:
Constant Field Values

ACF_DOT3_RGBA

public static final int ACF_DOT3_RGBA
See Also:
Constant Field Values

ACS_TEXTURE

public static final int ACS_TEXTURE
See Also:
Constant Field Values

ACS_PRIMARY_COLOR

public static final int ACS_PRIMARY_COLOR
See Also:
Constant Field Values

ACS_CONSTANT

public static final int ACS_CONSTANT
See Also:
Constant Field Values

ACS_PREVIOUS

public static final int ACS_PREVIOUS
See Also:
Constant Field Values

ACO_SRC_COLOR

public static final int ACO_SRC_COLOR
See Also:
Constant Field Values

ACO_ONE_MINUS_SRC_COLOR

public static final int ACO_ONE_MINUS_SRC_COLOR
See Also:
Constant Field Values

ACO_SRC_ALPHA

public static final int ACO_SRC_ALPHA
See Also:
Constant Field Values

ACO_ONE_MINUS_SRC_ALPHA

public static final int ACO_ONE_MINUS_SRC_ALPHA
See Also:
Constant Field Values

ACSC_ONE

public static final int ACSC_ONE
See Also:
Constant Field Values

ACSC_TWO

public static final int ACSC_TWO
See Also:
Constant Field Values

ACSC_FOUR

public static final int ACSC_FOUR
See Also:
Constant Field Values

EM_NONE

public static final int EM_NONE
See Also:
Constant Field Values

EM_IGNORE

public static final int EM_IGNORE
See Also:
Constant Field Values

EM_SPHERE

public static final int EM_SPHERE
See Also:
Constant Field Values
Constructor Detail

Texture

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


Texture

public Texture(float aniso)
Constructor instantiates a new Texture object with given attributes.

Method Detail

getBlendColorBuffer

public java.nio.FloatBuffer getBlendColorBuffer()
getBlendColorBuffer returns the buffer that contains the color values that are used to tint the texture.

Returns:
the buffer that contains the texture tint color.

setBlendColorBuffer

public void setBlendColorBuffer(java.nio.FloatBuffer blendColorBuffer)
setBlendColorBuffer sets the buffer that contains the color values that are used to tint the texture.

Parameters:
blendColorBuffer - the buffer that contains the texture tint color.

setBlendColor

public void setBlendColor(ColorRGBA color)
setBlendColor sets the color to be used to tint the texture. This color is used to create the new blend color buffer.

Parameters:
color - the color of the texture tint.

getMipmapState

public int getMipmapState()
getMipmapState returns the current mipmap state of this texture.

Returns:
the mipmap state of this texture.

setMipmapState

public void setMipmapState(int mipmapState)
setMipmapState sets the mipmap state for this texture. If the state is invalid it is set to MM_NONE.

Parameters:
mipmapState - the new mipmap state.

setApply

public void setApply(int apply)
setApply sets the apply mode for this texture. If an invalid value is passed, it is set to AM_MODULATE;

Parameters:
apply - the apply mode for this texture.

setCorrection

public void setCorrection(int correction)
setCorrection sets the image correction mode for this texture. If an invalid value is passed, it is set to CM_AFFINE.

Parameters:
correction - the correction mode for this texture.

setFilter

public void setFilter(int filter)
setFilter sets the texture filter mode for this texture. If an invalid value is passed, it is set to FM_NEAREST.

Parameters:
filter - the filter mode for this texture.

setImage

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

Parameters:
image - the image that defines the texture.

setWrap

public void setWrap(int wrap)
setWrap sets the wrap mode of this texture. If an invalid value is passed, it is set to WM_ECLAMP_S_ECLAMP_T.

Parameters:
wrap - the wrap mode for this 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.

getMipmap

public int getMipmap()
getMipmap returns the mipmap mode for the texture.

Returns:
the mipmap mode of the texture.

getCorrection

public int getCorrection()
getCorrection returns the correction mode for the texture.

Returns:
the correction mode for the texture.

getApply

public int getApply()
getApply returns the apply mode for the texture.

Returns:
the apply mode of the texture.

getBlendColor

public java.nio.FloatBuffer getBlendColor()
getBlendColor returns the buffer that contains the texture's tint color.

Returns:
the buffer that contains the texture's tint color.

getWrap

public int getWrap()
getWrap returns the wrap mode for the texture.

Returns:
the wrap mode of the texture.

getFilter

public int getFilter()
getFilter returns the filter mode for the texture.

Returns:
the filter mode of the texture.

getCombineFuncRGB

public int getCombineFuncRGB()
Returns:
Returns the combineFuncRGB.

setCombineFuncRGB

public void setCombineFuncRGB(int combineFuncRGB)
Parameters:
combineFuncRGB - The combineFuncRGB to set.

getCombineOp0Alpha

public int getCombineOp0Alpha()
Returns:
Returns the combineOp0Alpha.

setCombineOp0Alpha

public void setCombineOp0Alpha(int combineOp0Alpha)
Parameters:
combineOp0Alpha - The combineOp0Alpha to set.

getCombineOp0RGB

public int getCombineOp0RGB()
Returns:
Returns the combineOp0RGB.

setCombineOp0RGB

public void setCombineOp0RGB(int combineOp0RGB)
Parameters:
combineOp0RGB - The combineOp0RGB to set.

getCombineOp1Alpha

public int getCombineOp1Alpha()
Returns:
Returns the combineOp1Alpha.

setCombineOp1Alpha

public void setCombineOp1Alpha(int combineOp1Alpha)
Parameters:
combineOp1Alpha - The combineOp1Alpha to set.

getCombineOp1RGB

public int getCombineOp1RGB()
Returns:
Returns the combineOp1RGB.

setCombineOp1RGB

public void setCombineOp1RGB(int combineOp1RGB)
Parameters:
combineOp1RGB - The combineOp1RGB to set.

getCombineOp2Alpha

public int getCombineOp2Alpha()
Returns:
Returns the combineOp2Alpha.

setCombineOp2Alpha

public void setCombineOp2Alpha(int combineOp2Alpha)
Parameters:
combineOp2Alpha - The combineOp2Alpha to set.

getCombineOp2RGB

public int getCombineOp2RGB()
Returns:
Returns the combineOp2RGB.

setCombineOp2RGB

public void setCombineOp2RGB(int combineOp2RGB)
Parameters:
combineOp2RGB - The combineOp2RGB to set.

getCombineScaleAlpha

public float getCombineScaleAlpha()
Returns:
Returns the combineScaleAlpha.

setCombineScaleAlpha

public void setCombineScaleAlpha(float combineScaleAlpha)
Parameters:
combineScaleAlpha - The combineScaleAlpha to set.

getCombineScaleRGB

public float getCombineScaleRGB()
Returns:
Returns the combineScaleRGB.

setCombineScaleRGB

public void setCombineScaleRGB(float combineScaleRGB)
Parameters:
combineScaleRGB - The combineScaleRGB to set.

getCombineSrc0Alpha

public int getCombineSrc0Alpha()
Returns:
Returns the combineSrc0Alpha.

setCombineSrc0Alpha

public void setCombineSrc0Alpha(int combineSrc0Alpha)
Parameters:
combineSrc0Alpha - The combineSrc0Alpha to set.

getCombineSrc0RGB

public int getCombineSrc0RGB()
Returns:
Returns the combineSrc0RGB.

setCombineSrc0RGB

public void setCombineSrc0RGB(int combineSrc0RGB)
Parameters:
combineSrc0RGB - The combineSrc0RGB to set.

getCombineSrc1Alpha

public int getCombineSrc1Alpha()
Returns:
Returns the combineSrc1Alpha.

setCombineSrc1Alpha

public void setCombineSrc1Alpha(int combineSrc1Alpha)
Parameters:
combineSrc1Alpha - The combineSrc1Alpha to set.

getCombineSrc1RGB

public int getCombineSrc1RGB()
Returns:
Returns the combineSrc1RGB.

setCombineSrc1RGB

public void setCombineSrc1RGB(int combineSrc1RGB)
Parameters:
combineSrc1RGB - The combineSrc1RGB to set.

getCombineSrc2Alpha

public int getCombineSrc2Alpha()
Returns:
Returns the combineSrc2Alpha.

setCombineSrc2Alpha

public void setCombineSrc2Alpha(int combineSrc2Alpha)
Parameters:
combineSrc2Alpha - The combineSrc2Alpha to set.

getCombineSrc2RGB

public int getCombineSrc2RGB()
Returns:
Returns the combineSrc2RGB.

setCombineSrc2RGB

public void setCombineSrc2RGB(int combineSrc2RGB)
Parameters:
combineSrc2RGB - The combineSrc2RGB to set.

getCombineFuncAlpha

public int getCombineFuncAlpha()
Returns:
Returns the combineFuncAlpha.

setCombineFuncAlpha

public void setCombineFuncAlpha(int combineFuncAlpha)
Parameters:
combineFuncAlpha - The combineFuncAlpha to set.

setEnvironmentalMapMode

public void setEnvironmentalMapMode(int envMapMode)

getEnvironmentalMapMode

public int getEnvironmentalMapMode()

toString

public java.lang.String toString()

getImageLocation

public java.lang.String getImageLocation()

setImageLocation

public void setImageLocation(java.lang.String imageLocation)

getAnisoLevel

public float getAnisoLevel()

setAnisoLevel

public void setAnisoLevel(float level)
Deprecated. Must set aniso level when loading texture from manager.

Parameters:
level - float

setNeedsFilterRefresh

public void setNeedsFilterRefresh(boolean needed)

needsFilterRefresh

public boolean needsFilterRefresh()

setNeedsWrapRefresh

public void setNeedsWrapRefresh(boolean needed)

needsWrapRefresh

public boolean needsWrapRefresh()

equals

public boolean equals(java.lang.Object other)

createSimpleClone

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

Returns:
Texture