org.xith3d.scenegraph
Class Texture

java.lang.Object
  extended by org.xith3d.scenegraph.SceneGraphObject
      extended by org.xith3d.scenegraph.NodeComponent
          extended by org.xith3d.scenegraph.Texture
All Implemented Interfaces:
org.jagatoo.datatypes.Enableable, org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, org.jagatoo.loaders.textures.AbstractTexture
Direct Known Subclasses:
Texture2D, Texture3D, TextureCubeMap

public abstract class Texture
extends NodeComponent
implements org.jagatoo.loaders.textures.AbstractTexture, org.jagatoo.datatypes.Enableable

A Texture represents an image to be applied to a Shape3D's Appearance. The renderer positiones the Texture on the Shape's Geometry according to its texture coordinates.

One Texture instance can be reused for for an arbitrary number of Shapes.


Nested Class Summary
static class Texture.MipmapMode
           
 
Field Summary
 
Fields inherited from class org.xith3d.scenegraph.SceneGraphObject
XITH3D_USERDATAKEY_OLDUSERDATA
 
Constructor Summary
Texture(org.jagatoo.opengl.enums.TextureType type, org.jagatoo.opengl.enums.TextureFormat format)
          Constructs a new Texture object.
Texture(org.jagatoo.opengl.enums.TextureType type, org.jagatoo.opengl.enums.TextureFormat format, int boundaryWidth)
          Constructs a new Texture object.
 
Method Summary
 void addImage(org.jagatoo.loaders.textures.AbstractTextureImage image)
           
protected abstract  void checkImageType(TextureImage image)
          This method is called by setImage(int, TextureImage).
protected  void duplicateNodeComponent(NodeComponent original, boolean forceDuplicate)
          
 void enableAutoFreeLocalData()
          This marks this Texture to free its local (RAM) texture-data after it has been sent to OpenGL.
protected  void finalize()
          
 void freeOpenGLResources(CanvasPeer canvasPeer)
          This method frees OpenGL resources (names) for all this NodeComponent and all child-components.
 org.openmali.vecmath2.Colorf getBoundaryColor()
          Gets the boundary color.
 org.openmali.vecmath2.Colorf getBoundaryColor(org.openmali.vecmath2.Colorf c)
           
 org.jagatoo.opengl.enums.TextureBoundaryMode getBoundaryModeS()
          Gets the boundary mode S.
 org.jagatoo.opengl.enums.TextureBoundaryMode getBoundaryModeT()
          Gets the boundary mode T.
 int getBoundaryWidth()
           
 java.lang.String getCacheKey()
          
static org.jagatoo.opengl.enums.TextureFilter getDefaultFilter()
           
 org.jagatoo.opengl.enums.TextureFilter getFilter()
           
 org.jagatoo.opengl.enums.TextureFormat getFormat()
           
 int getHeight()
           
 TextureImage getImage(int level)
          Gets the image for the specified mipmap level.
 int getImagesCount()
          Get the number of elements in the images array.
 Texture.MipmapMode getMipMapMode()
          Gets the mipmap mode for texture mapping for this texture.
 SceneGraphOpenGLReferences getOpenGLReferences()
           
 int getOriginalHeight()
           
 org.openmali.types.twodee.Sized2iRO getOriginalSize()
           
 int getOriginalWidth()
           
 java.lang.String getResourceName()
           
 org.openmali.types.twodee.Sized2iRO getSize()
           
 long getStateId()
           
 org.jagatoo.opengl.enums.TextureType getType()
           
 int getWidth()
           
 boolean hasSizeChanged()
           
 boolean isDirty()
           
 boolean isEnabled()
          Is texture mapping enabled for this texture.
 boolean isMarkedAsLocalDataToBeFreed()
           
 void removeFromCache()
          Removes the Texture from the Cache, so that it can be deleted in OpenGL, if it is not used anymore anywhere else.
 void setBoundaryColor(org.openmali.vecmath2.Colorf color)
          Sets the boundary color.
 void setBoundaryColor(float r, float g, float b, float a)
           
 void setBoundaryModeS(org.jagatoo.opengl.enums.TextureBoundaryMode mode)
          Sets the boundary mode S.
 void setBoundaryModes(org.jagatoo.opengl.enums.TextureBoundaryMode modeS, org.jagatoo.opengl.enums.TextureBoundaryMode modeT)
          Sets the boundary modes S and T.
 void setBoundaryModeT(org.jagatoo.opengl.enums.TextureBoundaryMode mode)
          Sets the boundary mode T.
 void setBoundaryWidth(int boundaryWidth)
           
 void setCacheKey(java.lang.String cacheKey)
          
static void setDefaultFilter(org.jagatoo.opengl.enums.TextureFilter defaultFilter)
          Sets the default filter for textures.
 void setEnabled(boolean enabled)
          Enables disable texture mapping for this texture.
 void setFilter(org.jagatoo.opengl.enums.TextureFilter filter)
          Sets the texture filter.
 void setImage(int level, org.jagatoo.loaders.textures.AbstractTextureImage image)
          
 void setImage(int level, TextureImage image)
          Sets the image data for a specified mipmap level.
 void setResourceName(java.lang.String resName)
           
 void setSizeChanged()
           
 java.lang.String toString()
          
 
Methods inherited from class org.xith3d.scenegraph.NodeComponent
cloneNodeComponent, freeOpenGLResources, getDuplicateOnCloneTree, getModListener, isChanged, isChanged2, setChanged, setDuplicateOnCloneTree, setModListener
 
Methods inherited from class org.xith3d.scenegraph.SceneGraphObject
getName, getUserData, getUserData, getUserDataMap, isLive, setLive, setName, setUserData, setUserData, setUserDataRecursive, setUserDataRecursive
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jagatoo.loaders.textures.AbstractTexture
getName, setName
 

Constructor Detail

Texture

public Texture(org.jagatoo.opengl.enums.TextureType type,
               org.jagatoo.opengl.enums.TextureFormat format,
               int boundaryWidth)
Constructs a new Texture object.

Parameters:
type -
format -
boundaryWidth -

Texture

public Texture(org.jagatoo.opengl.enums.TextureType type,
               org.jagatoo.opengl.enums.TextureFormat format)
Constructs a new Texture object.

Parameters:
type -
format -
Method Detail

getType

public final org.jagatoo.opengl.enums.TextureType getType()
Specified by:
getType in interface org.jagatoo.loaders.textures.AbstractTexture

getFormat

public final org.jagatoo.opengl.enums.TextureFormat getFormat()
Specified by:
getFormat in interface org.jagatoo.loaders.textures.AbstractTexture
Returns:
this Texture's format

setEnabled

public void setEnabled(boolean enabled)
Enables disable texture mapping for this texture.

Specified by:
setEnabled in interface org.jagatoo.datatypes.Enableable

isEnabled

public final boolean isEnabled()
Is texture mapping enabled for this texture.

Specified by:
isEnabled in interface org.jagatoo.datatypes.Enableable

isDirty

public final boolean isDirty()

checkImageType

protected abstract void checkImageType(TextureImage image)
This method is called by setImage(int, TextureImage). It checks the added image's type and throws an exception, if the type is not accepted.

Parameters:
image -

setImage

public void setImage(int level,
                     TextureImage image)
Sets the image data for a specified mipmap level.


setImage

public final void setImage(int level,
                           org.jagatoo.loaders.textures.AbstractTextureImage image)

Specified by:
setImage in interface org.jagatoo.loaders.textures.AbstractTexture

addImage

public final void addImage(org.jagatoo.loaders.textures.AbstractTextureImage image)

getImage

public final TextureImage getImage(int level)
Gets the image for the specified mipmap level.

Specified by:
getImage in interface org.jagatoo.loaders.textures.AbstractTexture

getImagesCount

public final int getImagesCount()
Get the number of elements in the images array. This doesn't mean that each one of the elements is non-null.

Specified by:
getImagesCount in interface org.jagatoo.loaders.textures.AbstractTexture

getMipMapMode

public final Texture.MipmapMode getMipMapMode()
Gets the mipmap mode for texture mapping for this texture.


setSizeChanged

public void setSizeChanged()

hasSizeChanged

public final boolean hasSizeChanged()

getSize

public final org.openmali.types.twodee.Sized2iRO getSize()

getWidth

public final int getWidth()
Specified by:
getWidth in interface org.jagatoo.loaders.textures.AbstractTexture

getHeight

public final int getHeight()
Specified by:
getHeight in interface org.jagatoo.loaders.textures.AbstractTexture

getOriginalSize

public final org.openmali.types.twodee.Sized2iRO getOriginalSize()

getOriginalWidth

public final int getOriginalWidth()

getOriginalHeight

public final int getOriginalHeight()

setBoundaryModeS

public final void setBoundaryModeS(org.jagatoo.opengl.enums.TextureBoundaryMode mode)
Sets the boundary mode S.

Parameters:
mode -

getBoundaryModeS

public final org.jagatoo.opengl.enums.TextureBoundaryMode getBoundaryModeS()
Gets the boundary mode S.


setBoundaryModeT

public final void setBoundaryModeT(org.jagatoo.opengl.enums.TextureBoundaryMode mode)
Sets the boundary mode T.

Parameters:
mode -

getBoundaryModeT

public final org.jagatoo.opengl.enums.TextureBoundaryMode getBoundaryModeT()
Gets the boundary mode T.


setBoundaryModes

public final void setBoundaryModes(org.jagatoo.opengl.enums.TextureBoundaryMode modeS,
                                   org.jagatoo.opengl.enums.TextureBoundaryMode modeT)
Sets the boundary modes S and T.

Parameters:
modeS -
modeT -

setBoundaryColor

public void setBoundaryColor(org.openmali.vecmath2.Colorf color)
Sets the boundary color.


setBoundaryColor

public final void setBoundaryColor(float r,
                                   float g,
                                   float b,
                                   float a)

getBoundaryColor

public final org.openmali.vecmath2.Colorf getBoundaryColor()
Gets the boundary color.


getBoundaryColor

public final org.openmali.vecmath2.Colorf getBoundaryColor(org.openmali.vecmath2.Colorf c)

setBoundaryWidth

public void setBoundaryWidth(int boundaryWidth)

getBoundaryWidth

public final int getBoundaryWidth()

setDefaultFilter

public static void setDefaultFilter(org.jagatoo.opengl.enums.TextureFilter defaultFilter)
Sets the default filter for textures.

Parameters:
defaultFilter -

getDefaultFilter

public static org.jagatoo.opengl.enums.TextureFilter getDefaultFilter()
Returns:
the default filter for textures.

setFilter

public final void setFilter(org.jagatoo.opengl.enums.TextureFilter filter)
Sets the texture filter.


getFilter

public final org.jagatoo.opengl.enums.TextureFilter getFilter()
Returns:
the texture filter.

getStateId

public final long getStateId()
Returns:
the state ID used to sort the item

duplicateNodeComponent

protected void duplicateNodeComponent(NodeComponent original,
                                      boolean forceDuplicate)

Overrides:
duplicateNodeComponent in class NodeComponent

enableAutoFreeLocalData

public void enableAutoFreeLocalData()
This marks this Texture to free its local (RAM) texture-data after it has been sent to OpenGL.
In most cases this will be usefull, since we don't need the texture-data locally, since it will reside in the VRAM.


isMarkedAsLocalDataToBeFreed

public final boolean isMarkedAsLocalDataToBeFreed()

getOpenGLReferences

public final SceneGraphOpenGLReferences getOpenGLReferences()

finalize

protected void finalize()

Overrides:
finalize in class java.lang.Object

freeOpenGLResources

public void freeOpenGLResources(CanvasPeer canvasPeer)
This method frees OpenGL resources (names) for all this NodeComponent and all child-components.

Specified by:
freeOpenGLResources in class NodeComponent

setCacheKey

public void setCacheKey(java.lang.String cacheKey)

Specified by:
setCacheKey in interface org.jagatoo.loaders.textures.AbstractTexture

getCacheKey

public final java.lang.String getCacheKey()

Specified by:
getCacheKey in interface org.jagatoo.loaders.textures.AbstractTexture

removeFromCache

public final void removeFromCache()
Removes the Texture from the Cache, so that it can be deleted in OpenGL, if it is not used anymore anywhere else.


setResourceName

public void setResourceName(java.lang.String resName)

getResourceName

public final java.lang.String getResourceName()
Returns:
the name, this Texture has been loaded by.

toString

public java.lang.String toString()

Overrides:
toString in class SceneGraphObject