org.xith3d.ui.hud.utils
Class HUDTextureUtils

java.lang.Object
  extended by org.xith3d.ui.hud.utils.HUDTextureUtils

public class HUDTextureUtils
extends java.lang.Object

HUDTextureUtils is a utility class that provides class methods to load and cache textures for your game.

Before you call one of the methods here, you need to have created a ResourceLocator with a folder as the base resource folder, which will be used as the relative location for further resources. You will make this new ResourceLocator globally accessible (which you will need later.) Then you need to create a TextureStreamLocator for each folder containing textures to be used.

Example:

ResourceLocator resLoc = ResourceLocator.create("resources/");
resLoc.useAsSingletonInstance();
resLoc.createAndAddTSL("textures");

See Also:
ResourceLocator, TextureStreamLocator

Constructor Summary
HUDTextureUtils()
           
 
Method Summary
static Texture2D getTexture(java.lang.String textureName)
          The HUDTextureUtils.getTexture() method is simply a wrapper for the org.xith3d.loaders.texture.TextureLoader.getTexture() method.
static Texture2D getTexture(java.lang.String textureName, boolean useCache)
          The HUDTextureUtils.getTexture() method is simply a wrapper for the org.xith3d.loaders.texture.TextureLoader.getTexture() method.
static int getTextureHeight(Texture2D texture)
          Returns the height (in pixels) of the specified texture.
static int getTextureHeight(TextureImage2D texture, boolean isDrawTexture)
          Returns the height (in pixels) of the specified texture image.
static Texture2D getTextureOrNull(java.lang.String textureName)
          The HUDTextureUtils.getTexture() method is simply a wrapper for the org.xith3d.loaders.texture.TextureLoader.getTexture() method.
static Texture2D getTextureOrNull(java.lang.String textureName, boolean useCache)
          The HUDTextureUtils.getTexture() method is simply a wrapper for the org.xith3d.loaders.texture.TextureLoader.getTexture() method.
static int getTextureWidth(Texture2D texture)
          Returns the width (in pixels) of the specified texture.
static int getTextureWidth(TextureImage2D texture, boolean isDrawTexture)
          Returns the width (in pixels) of the specified texture image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HUDTextureUtils

public HUDTextureUtils()
Method Detail

getTextureWidth

public static final int getTextureWidth(TextureImage2D texture,
                                        boolean isDrawTexture)
Returns the width (in pixels) of the specified texture image.

Parameters:
texture - org.xith3d.scenegraph.TextureImage2D - the texture image from which to get the width.
isDrawTexture - boolean - a flag to indicate whether to draw the texture.
Returns:
int - the width (in pixels) of the specified texture image.

getTextureHeight

public static final int getTextureHeight(TextureImage2D texture,
                                         boolean isDrawTexture)
Returns the height (in pixels) of the specified texture image.

Parameters:
texture - org.xith3d.scenegraph.TextureImage2D - the texture image from which to get the height.
isDrawTexture - boolean - a flag to indicate whether to draw the texture.
Returns:
int - the height (in pixels) of the specified texture image.

getTextureWidth

public static final int getTextureWidth(Texture2D texture)
Returns the width (in pixels) of the specified texture.

Parameters:
texture - org.xith3d.scenegraph.Texture2D - the texture from which to get the width.
Returns:
int - the width (in pixels) of the specified texture.

getTextureHeight

public static final int getTextureHeight(Texture2D texture)
Returns the height (in pixels) of the specified texture.

Parameters:
texture - org.xith3d.scenegraph.Texture2D - the texture from which to get the height.
Returns:
int - the height (in pixels) of the specified texture.

getTexture

public static final Texture2D getTexture(java.lang.String textureName,
                                         boolean useCache)
The HUDTextureUtils.getTexture() method is simply a wrapper for the org.xith3d.loaders.texture.TextureLoader.getTexture() method. Returns the Texture2D instance specified by the specified texture resource name.

Parameters:
textureName - java.lang.String - the resource name, that is searched in all the TextureStreamLocators, added to the TextureLoader.
useCache - boolean - a flag to indicate whether to retrieve the texture from the cache, if not the first time this texture is retrieved.
Returns:
org.xith3d.scenegraph.Texture2D - the texture to return. If the specified resource is not found, a default fallback texture is returned.

getTexture

public static final Texture2D getTexture(java.lang.String textureName)
The HUDTextureUtils.getTexture() method is simply a wrapper for the org.xith3d.loaders.texture.TextureLoader.getTexture() method. Returns the Texture2D instance specified by the specified texture resource name.

Parameters:
textureName - java.lang.String - the resource name, that is searched in all the TextureStreamLocators, added to the TextureLoader.
Returns:
org.xith3d.scenegraph.Texture2D - the texture to return (from the cache if any). If the specified resource is not found, a default fallback texture is returned.

getTextureOrNull

public static final Texture2D getTextureOrNull(java.lang.String textureName,
                                               boolean useCache)
The HUDTextureUtils.getTexture() method is simply a wrapper for the org.xith3d.loaders.texture.TextureLoader.getTexture() method. Returns the Texture2D instance specified by the specified texture resource name.

Parameters:
textureName - java.lang.String - the resource name, that is searched in all the TextureStreamLocators, added to the TextureLoader.
useCache - boolean - a flag to indicate whether to retrieve the texture from the cache, if not the first time this texture is retrieved.
Returns:
org.xith3d.scenegraph.Texture2D - the texture to return. If the specified resource is not found, null is returned.

getTextureOrNull

public static final Texture2D getTextureOrNull(java.lang.String textureName)
The HUDTextureUtils.getTexture() method is simply a wrapper for the org.xith3d.loaders.texture.TextureLoader.getTexture() method. Returns the Texture2D instance specified by the specified texture resource name.

Parameters:
textureName - java.lang.String - the resource name, that is searched in all the TextureStreamLocators, added to the TextureLoader.
Returns:
org.xith3d.scenegraph.Texture2D - the texture to return (from the cache if any). If the specified resource is not found, null is returned.