com.jmex.bui
Class BImage

java.lang.Object
  extended by com.jme.scene.SceneElement
      extended by com.jme.scene.Spatial
          extended by com.jme.scene.Geometry
              extended by com.jme.scene.TriMesh
                  extended by com.jme.scene.shape.Quad
                      extended by com.jmex.bui.BImage
All Implemented Interfaces:
Savable, Serializable

public class BImage
extends Quad

Contains a texture, its dimensions and a texture state.

See Also:
Serialized Form

Nested Class Summary
static interface BImage.TexturePool
          An interface for pooling OpenGL textures.
 
Field Summary
protected  int _height
           
protected  int _referents
           
protected static boolean _supportsNonPowerOfTwo
           
protected static BImage.TexturePool _texturePool
           
protected  int _theight
           
protected  TextureState _tstate
           
protected  int _twidth
           
protected  int _width
           
static AlphaState blendState
          An alpha state that blends the source plus one minus destination.
 
Fields inherited from class com.jme.scene.Geometry
batchList
 
Fields inherited from class com.jme.scene.Spatial
geometricalControllers, localRotation, localScale, localTranslation, parent, worldRotation, worldScale, worldTranslation
 
Fields inherited from class com.jme.scene.SceneElement
COMPOSITE_MESH, CULL_ALWAYS, CULL_DYNAMIC, CULL_INHERIT, CULL_NEVER, cullMode, frustrumIntersects, GEOMBATCH, GEOMETRY, isCollidable, lightCombineMode, LOCKED_BOUNDS, LOCKED_BRANCH, LOCKED_MESH_DATA, LOCKED_NONE, LOCKED_SHADOWS, LOCKED_TRANSFORMS, lockedMode, name, NM_GL_NORMALIZE_IF_SCALED, NM_GL_NORMALIZE_PROVIDED, NM_INHERIT, NM_OFF, NM_USE_PROVIDED, NODE, normalsMode, QUADBATCH, queueDistance, renderQueueMode, renderStateList, SHARED_MESH, SHAREDBATCH, SKY_BOX, TERRAIN_BLOCK, TERRAIN_PAGE, textureCombineMode, TRIANGLEBATCH, TRIMESH, worldBound, zOrder
 
Constructor Summary
  BImage(Image image)
          Creates an image from the supplied source AWT image.
  BImage(Image image, boolean flip)
          Creates an image from the supplied source AWT image.
protected BImage(int width, int height)
          Helper constructor.
  BImage(int width, int height, Image image)
          Creates an image of the specified size, using the supplied JME image data.
  BImage(URL image)
          Creates an image from the supplied source URL.
 
Method Summary
protected  void acquireTexture()
           
 int getHeight()
          Returns the height of this image.
static BImage.TexturePool getTexturePool()
          Returns a reference to the configured texture pool.
 int getWidth()
          Returns the width of this image.
static void makeTransparent(Spatial target)
          Configures the supplied spatial with transparency in the standard user interface sense which is that transparent pixels show through to the background but non-transparent pixels are not blended with what is behind them.
protected static int nextPOT(int value)
          Rounds the supplied value up to a power of two.
 void reference()
          Notes that something is referencing this image and will subsequently call render(com.jme.renderer.Renderer, int, int, float) to render the image.
 void release()
          Unbinds our underlying texture from OpenGL, removing the data from graphics memory.
protected  void releaseTexture()
           
 void render(Renderer renderer, int tx, int ty, float alpha)
          Renders this image at the specified coordinates.
 void render(Renderer renderer, int tx, int ty, int twidth, int theight, float alpha)
          Renders this image at the specified coordinates, scaled to the specified size.
 void render(Renderer renderer, int sx, int sy, int swidth, int sheight, int tx, int ty, float alpha)
          Renders a region of this image at the specified coordinates.
 void render(Renderer renderer, int sx, int sy, int swidth, int sheight, int tx, int ty, int twidth, int theight, float alpha)
          Renders a region of this image at the specified coordinates, scaled to the specified size.
 void setImage(Image image)
          Configures the image data to be used by this image.
 void setTextureCoords(int sx, int sy, int swidth, int sheight)
          Configures our texture coordinates to the specified subimage.
static void setTexturePool(BImage.TexturePool pool)
          Sets the texture pool from which to acquire and release OpenGL texture objects.
 void setTransparent(boolean transparent)
          Configures this image to use transparency or not (true by default).
 
Methods inherited from class com.jme.scene.shape.Quad
getCenter, initialize, resize
 
Methods inherited from class com.jme.scene.TriMesh
clearBuffers, draw, findCollisions, findTriangleCollision, findTrianglePick, getBatch, getIndexBuffer, getMeshAsTriangles, getMeshAsTrianglesVertices, getTotalTriangles, getTriangle, getTriangle, getTriangle, getTriangle, getType, hasCollision, hasTriangleCollision, hasTriangleCollision, reconstruct, reconstruct, setIndexBuffer, setupBatchList, updateCollisionTree, updateCollisionTree
 
Methods inherited from class com.jme.scene.Geometry
addBatch, applyRenderState, clearBatches, copyTextureCoords, copyTextureCoords, findPick, getBatchCount, getBatchIndex, getColorBuffer, getNormalBuffer, getNumberOfUnits, getTextureBuffer, getTextureBuffers, getTotalVertices, getVBOInfo, getVertexBuffer, getWorldCoords, getWorldCoords, getWorldNormals, getWorldNormals, lockBounds, lockMeshes, lockShadows, lockTransforms, randomVertex, read, reconstruct, reconstruct, removeBatch, removeBatch, setColorBuffer, setDefaultColor, setModelBound, setNormalBuffer, setRandomColors, setSolidColor, setTextureBuffer, setTextureBuffer, setVBOInfo, setVBOInfo, setVertexBuffer, swapBatches, unlockBounds, unlockMeshes, unlockShadows, unlockTransforms, updateModelBound, updateWorldBound, updateWorldData, write
 
Methods inherited from class com.jme.scene.Spatial
addController, calculateCollisions, calculatePick, getController, getControllers, getCullMode, getLightCombineMode, getLocalRotation, getLocalScale, getLocalTranslation, getNormalsMode, getParent, getRenderQueueMode, getTextureCombineMode, getWorldRotation, getWorldScale, getWorldTranslation, localToWorld, lookAt, onDraw, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeFromParent, rotateUpTo, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setParent, updateGeometricState, updateWorldRotation, updateWorldScale, updateWorldTranslation, updateWorldVectors, worldToLocal
 
Methods inherited from class com.jme.scene.SceneElement
clearRenderState, getClassTag, getLastFrustumIntersection, getLocalCullMode, getLocalLightCombineMode, getLocalNormalsMode, getLocalRenderQueueMode, getLocalTextureCombineMode, getLocks, getName, getRenderState, getWorldBound, getZOrder, isCollidable, lock, lock, lockBranch, lockMeshes, setCullMode, setIsCollidable, setLastFrustumIntersection, setLightCombineMode, setLocks, setLocks, setName, setNormalsMode, setRenderQueueMode, setRenderState, setTextureCombineMode, setZOrder, toString, unlock, unlock, unlockBranch, unlockMeshes, updateRenderState, updateRenderState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.jme.util.export.Savable
getClassTag
 

Field Detail

blendState

public static AlphaState blendState
An alpha state that blends the source plus one minus destination.


_tstate

protected TextureState _tstate

_width

protected int _width

_height

protected int _height

_twidth

protected int _twidth

_theight

protected int _theight

_referents

protected int _referents

_supportsNonPowerOfTwo

protected static boolean _supportsNonPowerOfTwo

_texturePool

protected static BImage.TexturePool _texturePool
Constructor Detail

BImage

public BImage(URL image)
       throws IOException
Creates an image from the supplied source URL.

Throws:
IOException

BImage

public BImage(Image image)
Creates an image from the supplied source AWT image.


BImage

public BImage(Image image,
              boolean flip)
Creates an image from the supplied source AWT image.


BImage

public BImage(int width,
              int height,
              Image image)
Creates an image of the specified size, using the supplied JME image data. The image should be a power of two size if OpenGL requires it.

Parameters:
width - the width of the renderable image.
height - the height of the renderable image.
image - the image data.

BImage

protected BImage(int width,
                 int height)
Helper constructor.

Method Detail

makeTransparent

public static void makeTransparent(Spatial target)
Configures the supplied spatial with transparency in the standard user interface sense which is that transparent pixels show through to the background but non-transparent pixels are not blended with what is behind them.


setTexturePool

public static void setTexturePool(BImage.TexturePool pool)
Sets the texture pool from which to acquire and release OpenGL texture objects. Applications can provide a pool in order to avoid the rapid creation and destruction of OpenGL textures. The default pool always creates new textures and deletes released ones.


getTexturePool

public static BImage.TexturePool getTexturePool()
Returns a reference to the configured texture pool.


getWidth

public int getWidth()
Returns the width of this image.


getHeight

public int getHeight()
Returns the height of this image.


setTransparent

public void setTransparent(boolean transparent)
Configures this image to use transparency or not (true by default).


setImage

public void setImage(Image image)
Configures the image data to be used by this image.


setTextureCoords

public void setTextureCoords(int sx,
                             int sy,
                             int swidth,
                             int sheight)
Configures our texture coordinates to the specified subimage. This does not normally need to be called, but if one is stealthily using a BImage as a quad, then it does.


render

public void render(Renderer renderer,
                   int tx,
                   int ty,
                   float alpha)
Renders this image at the specified coordinates.


render

public void render(Renderer renderer,
                   int tx,
                   int ty,
                   int twidth,
                   int theight,
                   float alpha)
Renders this image at the specified coordinates, scaled to the specified size.


render

public void render(Renderer renderer,
                   int sx,
                   int sy,
                   int swidth,
                   int sheight,
                   int tx,
                   int ty,
                   float alpha)
Renders a region of this image at the specified coordinates.


render

public void render(Renderer renderer,
                   int sx,
                   int sy,
                   int swidth,
                   int sheight,
                   int tx,
                   int ty,
                   int twidth,
                   int theight,
                   float alpha)
Renders a region of this image at the specified coordinates, scaled to the specified size.


reference

public void reference()
Notes that something is referencing this image and will subsequently call render(com.jme.renderer.Renderer, int, int, float) to render the image. This must be paired with a call to release().


release

public void release()
Unbinds our underlying texture from OpenGL, removing the data from graphics memory. This should be done when the an image is no longer being displayed. The image will automatically rebind next time it is rendered.


acquireTexture

protected void acquireTexture()

releaseTexture

protected void releaseTexture()

nextPOT

protected static int nextPOT(int value)
Rounds the supplied value up to a power of two.



Copyright © 2008 Michael Bayne. All Rights Reserved.