Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class TextureComponent

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.NodeComponent
          extended by org.j3d.aviatrix3d.TextureComponent
All Implemented Interfaces:
TextureSource
Direct Known Subclasses:
TextureComponent1D, TextureComponent2D, TextureComponent3D

public abstract class TextureComponent
extends NodeComponent
implements TextureSource

Common representation of a component that contains source data to be used in textures.

Version:
$Revision: 1.10 $
Author:
Justin Couch, Alan Hudson

Field Summary
protected  byte[] copyBuffer
          Temp buffer used to transfer subimage updates to the listeners
protected  java.nio.ByteBuffer[] data
          Buffer to hold the data
protected  int format
          The format
protected  boolean invertY
          Flag describing whether the Y axis should be inverted before use.
protected  int numLevels
          The number of levels in this component.
protected  int size
          The size of the data buffer
protected  int type
          The type of the data
static int TYPE_BYTE
          Specifies the data is in byte format
static int TYPE_INT
          Specifies the data is in int format
protected  int width
          The width
 
Fields inherited from class org.j3d.aviatrix3d.NodeComponent
lastParent, liveCount, parentList
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler
 
Fields inherited from interface org.j3d.aviatrix3d.TextureSource
FORMAT_BGR, FORMAT_BGRA, FORMAT_INTENSITY_ALPHA, FORMAT_LUMINANCE_ALPHA, FORMAT_RGB, FORMAT_RGBA, FORMAT_SINGLE_COMPONENT
 
Constructor Summary
TextureComponent(int numLevels)
          Constructs an image with default values.
 
Method Summary
 void addUpdateListener(SubTextureUpdateListener l)
          Add a listener for subtexture change updates.
protected  int bytesPerPixel()
          Convenience method that looks at the user provided image format and returns the number of bytes per pixel
protected  void checkCopyBufferSize(int size)
          Ensure copyBuffer is large enough to hold the given number of pixels.
protected  void clearData(int level)
          Clear the storage used for this object.
abstract  void clearLocalData()
          Clear local data stored in this node.
protected abstract  java.nio.ByteBuffer convertImage(int level)
          Convenience method to convert a buffered image into a NIO array of the corresponding type.
protected  java.nio.ByteBuffer getData(int level)
          Get the underlying data object.
 int getFormat(int level)
          Get the format of this image at the given mipmap level.
 int getNumLevels()
          Get the number of levels in this component.
 int getWidth()
          Get the width of this image.
 boolean isYUp()
          Get the current value of the Y-axis inversion flag.
 void removeUpdateListener(SubTextureUpdateListener l)
          Remove a listener for subtexture change updates.
protected  void sendTextureUpdate(int x, int y, int z, int width, int height, int depth, int level, byte[] pixels)
          Send off a sub-image update event.
 
Methods inherited from class org.j3d.aviatrix3d.NodeComponent
addParent, getParents, numParents, removeParent
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, checkForCyclicParent, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setLive, setUpdateHandler, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_BYTE

public static final int TYPE_BYTE
Specifies the data is in byte format

See Also:
Constant Field Values

TYPE_INT

public static final int TYPE_INT
Specifies the data is in int format

See Also:
Constant Field Values

width

protected int width
The width


format

protected int format
The format


size

protected int size
The size of the data buffer


type

protected int type
The type of the data


data

protected java.nio.ByteBuffer[] data
Buffer to hold the data


invertY

protected boolean invertY
Flag describing whether the Y axis should be inverted before use. By default, yes


numLevels

protected int numLevels
The number of levels in this component.


copyBuffer

protected byte[] copyBuffer
Temp buffer used to transfer subimage updates to the listeners

Constructor Detail

TextureComponent

public TextureComponent(int numLevels)
Constructs an image with default values.

Parameters:
numLevels - The number of mipmap levels to create
Method Detail

getWidth

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

Specified by:
getWidth in interface TextureSource
Returns:
the width.

getNumLevels

public int getNumLevels()
Get the number of levels in this component.

Specified by:
getNumLevels in interface TextureSource
Returns:
The number of levels.

getFormat

public int getFormat(int level)
Get the format of this image at the given mipmap level.

Specified by:
getFormat in interface TextureSource
Parameters:
level - The mipmap level to get the format for
Returns:
the format.

addUpdateListener

public void addUpdateListener(SubTextureUpdateListener l)
Add a listener for subtexture change updates.

Parameters:
l - The listener instance to add

removeUpdateListener

public void removeUpdateListener(SubTextureUpdateListener l)
Remove a listener for subtexture change updates.

Parameters:
l - The listener instance to add

isYUp

public boolean isYUp()
Get the current value of the Y-axis inversion flag.

Returns:
true if the Y axis should be flipped

clearLocalData

public abstract void clearLocalData()
Clear local data stored in this node. Only data needed for OpenGL calls will be retained;


getData

protected java.nio.ByteBuffer getData(int level)
Get the underlying data object. This will be an array of the underlying data type.

Parameters:
level - Which image level needs to be converted
Returns:
A reference to the data.

clearData

protected void clearData(int level)
Clear the storage used for this object.

Parameters:
level - Which image level needs to be converted

convertImage

protected abstract java.nio.ByteBuffer convertImage(int level)
Convenience method to convert a buffered image into a NIO array of the corresponding type. Images typically need to be swapped when doing this by the Y axis is in the opposite direction to the one used by OpenGL.

Parameters:
level - Which image level needs to be converted
Returns:
an appropriate array type - either IntBuffer or ByteBuffer

checkCopyBufferSize

protected void checkCopyBufferSize(int size)
Ensure copyBuffer is large enough to hold the given number of pixels.

Parameters:
size - The number of bytes to hold

sendTextureUpdate

protected void sendTextureUpdate(int x,
                                 int y,
                                 int z,
                                 int width,
                                 int height,
                                 int depth,
                                 int level,
                                 byte[] pixels)
Send off a sub-image update event.

Parameters:
x - The start location x coordinate in texel space
y - The start location y coordinate in texel space
z - The start location z coordinate in texel space
width - The width of the update in texel space
height - The height of the update in texel space
depth - The depth of the update in texel space
level - The mipmap level that changed
pixels - Buffer of the data that has updated

bytesPerPixel

protected int bytesPerPixel()
Convenience method that looks at the user provided image format and returns the number of bytes per pixel

Returns:
A value between 1 and 4

Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org