shout3d.core
Class PixelBasedTexture

java.lang.Object
  |
  +--shout3d.core.Node
        |
        +--shout3d.core.Texture
              |
              +--shout3d.core.PixelBasedTexture
Direct Known Subclasses:
ImageTexture

public class PixelBasedTexture
extends Texture

An PixelBasedTexture


Field Summary
static int ALPHA
          These are the legal values for whichChannel in the getChannel() method.
static int BLUE
          These are the legal values for whichChannel in the getChannel() method.
static int GREEN
          These are the legal values for whichChannel in the getChannel() method.
static int RED
          These are the legal values for whichChannel in the getChannel() method.
 BooleanField repeatS
           
 BooleanField repeatT
           
 
Constructor Summary
PixelBasedTexture()
          Constructs a default PixelBasedTexture
PixelBasedTexture(Shout3DViewer viewer)
          Constructs that takes a viewer as an argument
 
Method Summary
 byte[][] getChannel(int whichChannel, boolean getCopy)
          Returns a reference to or copy of a channel of pixels in the texture.
 int getHeight()
          Returns the height of the texture.
 int getWidth()
          Returns the width of the texture.
 boolean setCustomPixels(int width, int height, byte[][] red, byte[][] green, byte[][] blue, byte[][] alpha)
          Specifies the pixels that will be used in this Texture.
 
Methods inherited from class shout3d.core.Node
cleanUp, getDEFName, getField, getFieldByIndex, getFieldName, getNumFields, getTypeName, getViewer, isOfType, setDEFName, setViewer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

repeatS

public final BooleanField repeatS

repeatT

public final BooleanField repeatT

RED

public static final int RED
These are the legal values for whichChannel in the getChannel() method.

GREEN

public static final int GREEN
These are the legal values for whichChannel in the getChannel() method.

BLUE

public static final int BLUE
These are the legal values for whichChannel in the getChannel() method.

ALPHA

public static final int ALPHA
These are the legal values for whichChannel in the getChannel() method.
Constructor Detail

PixelBasedTexture

public PixelBasedTexture()
Constructs a default PixelBasedTexture

PixelBasedTexture

public PixelBasedTexture(Shout3DViewer viewer)
Constructs that takes a viewer as an argument
Method Detail

getWidth

public int getWidth()
Returns the width of the texture. This may be any of: [a] 0 by default, [b] the width of a fetched texture from an url in an ImageTexture node [c] the width of a custom texture if setCustomPixels() has been called.
Returns:
the width of the texture

getHeight

public int getHeight()
Returns the height of the texture. This may be any of: [a] 0 by default, [b] the height of a fetched texture from an url in an ImageTexture node [c] the height of a custom texture if setCustomPixels() has been called.
Returns:
the height of the texture

getChannel

public byte[][] getChannel(int whichChannel,
                           boolean getCopy)
Returns a reference to or copy of a channel of pixels in the texture. This may be any of: [a] null by default, [b] the pixels of a fetched texture from an url in an ImageTexture node [c] the pixels of a custom texture if setCustomPixels() has been called. The whichChannel argument specifies which channel of pixel information is requested. Valid values are Texture.RED, Texture.GREEN, Texture.BLUE, and Texture.ALPHA. The getCopy argument is a boolean. If true, then a newly allocated copy of the requested channel is returned. If false, then a reference to the original is returned. NOTE: Care should be taken in requested an original reference. Editing this reference can have side effects. For example, different ImageTexture nodes with the same url may ALL change if you edit the original pixels of one of these nodes, even if they are not instances. Hence, when performing image processing of a texture it is best to get a copy, then manipulate the copy. The pixels are returned in a double-dimensioned array. The first dimension refers to the row and the second to the column, so the dimensions of the array are [getUrlTextureHeight()][getUrlTextureWidth()]. Each value in the arrays is a byte. Values may be assigned to the array by casting values in a range of [0..255] into a byte, for example: myRed[0][0] = (byte) 255; Values may be read from the array in the [0..255] range by &'ing the byte value with 255, for example: myZeroTo255 = (myRed[0][0] & 0x255);
Parameters:
whichChannel - the channel of information desired
getCopy - whether the value returned should be a copy or a reference
Returns:
the requested array of pixels

setCustomPixels

public boolean setCustomPixels(int width,
                               int height,
                               byte[][] red,
                               byte[][] green,
                               byte[][] blue,
                               byte[][] alpha)
Specifies the pixels that will be used in this Texture. Overrides any previously established pixels that may have been in use. Subsequent changes to the texture will replace these pixels. This occurs when later calls are made to this same method. It also occurs in the ImageTexture if the url, hasAlphaTexture, or loadASAP field is changed after this method is called -- such actions result in new fetching of textures from the url field and loading them to replace these pixels. The given height and width must be greater than 0 and apply to all of the elements in the texture. The red, green, and blue arrays must all be non-null, doubly-indexed, of dimensions [height][width]. The first index refers to the row number for a given pixel, and the second index refers to the column number. The alpha argument is the only one that may be null. If it is not null, it must be dimensioned the same as the other three arrays. If any of the above conditions are not met, then the texture will be initialized to no texture at all.
Parameters:
width - the width of the custom pixel arrays
height - the height of the custom pixel arrays
red - the double-array of red pixel values
green - the double-array of green pixel values
blue - the double-array of blue pixel values
alpha - the double-array of alpha pixel values
Returns:
true if the given pixels are used, false if intialized to no texture