com.jmex.bui
Class BImage

java.lang.Object
  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:
com.jme.util.export.Savable, java.io.Serializable

public class BImage
extends com.jme.scene.shape.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.
 
Nested classes/interfaces inherited from class com.jme.scene.TriMesh
com.jme.scene.TriMesh.Mode
 
Nested classes/interfaces inherited from class com.jme.scene.Spatial
com.jme.scene.Spatial.CullHint, com.jme.scene.Spatial.LightCombineMode, com.jme.scene.Spatial.NormalsMode, com.jme.scene.Spatial.TextureCombineMode
 
Field Summary
protected  int _height
           
protected  int _referents
           
protected static boolean _supportsNonPowerOfTwo
           
protected static BImage.TexturePool _texturePool
           
protected  int _theight
           
protected  com.jme.scene.state.TextureState _tstate
           
protected  int _twidth
           
protected  int _width
           
static com.jme.scene.state.BlendState blendState
          An blend state that blends the source plus one minus destination.
 
Fields inherited from class com.jme.scene.shape.Quad
height, width
 
Fields inherited from class com.jme.scene.TriMesh
indexBuffer, mode, triangleQuantity
 
Fields inherited from class com.jme.scene.Geometry
binormalBuf, bound, castsShadows, colorBuf, compVect, defaultColor, displayListID, enabled, fogBuf, hasDirtyVertices, normBuf, states, tangentBuf, texBuf, vboInfo, vertBuf, vertQuantity
 
Fields inherited from class com.jme.scene.Spatial
cullHint, frustrumIntersects, geometricalControllers, isCollidable, lightCombineMode, localRotation, localScale, localTranslation, LOCKED_BOUNDS, LOCKED_BRANCH, LOCKED_MESH_DATA, LOCKED_NONE, LOCKED_SHADOWS, LOCKED_TRANSFORMS, lockedMode, name, normalsMode, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder
 
Constructor Summary
  BImage(java.awt.Image image)
          Creates an image from the supplied source AWT image.
  BImage(java.awt.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, com.jme.image.Image image)
          Creates an image of the specified size, using the supplied JME image data.
  BImage(java.net.URL image)
          Creates an image from the supplied source URL.
 
Method Summary
protected  void acquireTexture()
           
 java.lang.Class getClassTag()
           
 int getImageHeight()
          Returns the height of this image.
 int getImageWidth()
          Returns the width of this image.
static BImage.TexturePool getTexturePool()
          Returns a reference to the configured texture pool.
static void makeTransparent(com.jme.scene.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(com.jme.renderer.Renderer renderer, int tx, int ty, float alpha)
          Renders this image at the specified coordinates.
 void render(com.jme.renderer.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(com.jme.renderer.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(com.jme.renderer.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(com.jme.image.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, getHeight, getWidth, initialize, resize, updateGeometry
 
Methods inherited from class com.jme.scene.TriMesh
clearBuffers, draw, findCollisions, findTriangleCollision, findTrianglePick, getIndexBuffer, getMaxIndex, getMeshAsTriangles, getMeshAsTrianglesVertices, getMode, getTriangle, getTriangle, getTriangleCount, getTriangleIndices, getVertIndex, hasCollision, hasTriangleCollision, randomPointOnTriangles, read, recalcTriangleQuantity, reconstruct, setIndexBuffer, setMode, setTriangleQuantity, write
 
Methods inherited from class com.jme.scene.Geometry
addTextureCoordinates, addTextureCoordinates, applyRenderState, checkTextureCoordinates, clearTextureBuffers, copyTextureCoordinates, findPick, getBinormalBuffer, getColorBuffer, getDefaultColor, getDisplayListID, getFogBuffer, getLightState, getModelBound, getNormalBuffer, getNumberOfUnits, getTangentBuffer, getTextureCoords, getTextureCoords, getVBOInfo, getVertexBuffer, getVertexCount, getWorldCoords, getWorldNormals, hasDirtyVertices, isCastsShadows, lockMeshes, postdraw, predraw, randomVertex, reconstruct, resizeTextureIds, rotateNormals, rotatePoints, scaleTextureCoordinates, scaleTextureCoordinates, setBinormalBuffer, setCastsShadows, setColorBuffer, setDefaultColor, setDisplayListID, setFogCoordBuffer, setHasDirtyVertices, setLightState, setModelBound, setNormalBuffer, setRandomColors, setSolidColor, setTangentBuffer, setTextureCoords, setTextureCoords, setTextureCoords, setVBOInfo, setVertexBuffer, setVertexCount, sortLights, translatePoints, translatePoints, unlockMeshes, updateModelBound, updateWorldBound
 
Methods inherited from class com.jme.scene.Spatial
addController, calculateCollisions, calculatePick, clearControllers, clearRenderState, clearRenderState, getController, getControllerCount, getControllers, getCullHint, getLastFrustumIntersection, getLightCombineMode, getLocalCullHint, getLocalLightCombineMode, getLocalNormalsMode, getLocalRenderQueueMode, getLocalRotation, getLocalScale, getLocalTextureCombineMode, getLocalToWorldMatrix, getLocalTranslation, getLocks, getName, getNormalsMode, getParent, getRenderQueueMode, getRenderState, getRenderState, getTextureCombineMode, getUserData, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, hasAncestor, isCollidable, localToWorld, lock, lock, lockBounds, lockBranch, lockMeshes, lockShadows, lockTransforms, lookAt, onDraw, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeController, removeFromParent, removeUserData, rotateUpTo, setCullHint, setIsCollidable, setLastFrustumIntersection, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setLocalTranslation, setLocks, setLocks, setName, setNormalsMode, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setUserData, setZOrder, setZOrder, toString, unlock, unlock, unlockBounds, unlockBranch, unlockMeshes, unlockShadows, unlockTransforms, updateGeometricState, updateRenderState, updateRenderState, updateWorldData, updateWorldRotation, updateWorldScale, updateWorldTranslation, updateWorldVectors, updateWorldVectors, worldToLocal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

blendState

public static com.jme.scene.state.BlendState blendState
An blend state that blends the source plus one minus destination.


_tstate

protected com.jme.scene.state.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(java.net.URL image)
       throws java.io.IOException
Creates an image from the supplied source URL.

Parameters:
image - URL
Throws:
java.io.IOException - exception

BImage

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

Parameters:
image - Image

BImage

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

Parameters:
image - Image
flip - boolean

BImage

public BImage(int width,
              int height,
              com.jme.image.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.

Parameters:
width - int
height - int
Method Detail

getClassTag

public java.lang.Class getClassTag()
Specified by:
getClassTag in interface com.jme.util.export.Savable
Overrides:
getClassTag in class com.jme.scene.Spatial

makeTransparent

public static void makeTransparent(com.jme.scene.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.

Parameters:
target - Spatial

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.

Parameters:
pool - TexturePool

getTexturePool

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

Returns:
TexturePool

getImageWidth

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

Returns:
int

getImageHeight

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

Returns:
int

setTransparent

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

Parameters:
transparent - boolean

setImage

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

Parameters:
image - 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.

Parameters:
sx - int
sy - int
swidth - int
sheight - int

render

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

Parameters:
renderer - Renderer
tx - int
ty - int
alpha - float

render

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

Parameters:
renderer - Renderer
tx - int
ty - int
twidth - int
theight - int
alpha - float

render

public void render(com.jme.renderer.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.

Parameters:
renderer - Renderer
sx - int
sy - int
swidth - int
sheight - int
tx - int
ty - int
alpha - float

render

public void render(com.jme.renderer.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.

Parameters:
renderer - Renderer
sx - int
sy - int
swidth - int
sheight - int
tx - int
ty - int
twidth - int
theight - int
alpha - float

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.

Parameters:
value - int
Returns:
int


Copyright © 2011 Michael Bayne. All Rights Reserved.