com.brackeen.javagamebook.graphics3D.texture
Class ShadedTexture

java.lang.Object
  extended bycom.brackeen.javagamebook.graphics3D.texture.Texture
      extended bycom.brackeen.javagamebook.graphics3D.texture.ShadedTexture

public final class ShadedTexture
extends Texture

The ShadedTexture class is a Texture that has multiple shades. The texture source image is stored as a 8-bit image with a palette for every shade.


Field Summary
static int MAX_LEVEL
           
static int NUM_SHADE_LEVELS
           
 
Constructor Summary
ShadedTexture(byte[] buffer, int widthBits, int heightBits, java.awt.image.IndexColorModel palette)
          Creates a new ShadedTexture from the specified 8-bit image buffer and palette.
ShadedTexture(byte[] buffer, int widthBits, int heightBits, java.awt.image.IndexColorModel palette, java.awt.Color targetShade)
          Creates a new ShadedTexture from the specified 8-bit image buffer, palette, and target shaded.
 
Method Summary
 short getColor(int x, int y)
          Gets the 16-bit color of this Texture at the specified (x,y) location, using the default shade level.
 short getColor(int x, int y, int shadeLevel)
          Gets the 16-bit color of this Texture at the specified (x,y) location, using the specified shade level.
 short getColorCurrRow(int x, int shadeLevel)
          Gets the color at the specified x location at the specified shade level.
 int getDefaultShadeLevel()
          Gets the default shade level that is used when getColor() is called.
 void makeShadeTable(java.awt.Color targetShade)
          Creates the shade table for this ShadedTexture.
 void setCurrRow(int y)
          Sets the current row for getColorCurrRow().
 void setDefaultShadeLevel(int level)
          Sets the default shade level that is used when getColor() is called.
 
Methods inherited from class com.brackeen.javagamebook.graphics3D.texture.Texture
countbits, createTexture, createTexture, createTexture, createTexture, getHeight, getWidth, isPowerOfTwo
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUM_SHADE_LEVELS

public static final int NUM_SHADE_LEVELS
See Also:
Constant Field Values

MAX_LEVEL

public static final int MAX_LEVEL
See Also:
Constant Field Values
Constructor Detail

ShadedTexture

public ShadedTexture(byte[] buffer,
                     int widthBits,
                     int heightBits,
                     java.awt.image.IndexColorModel palette)
Creates a new ShadedTexture from the specified 8-bit image buffer and palette. The width of the bitmap is 2 to the power of widthBits, or (1 << widthBits). Likewise, the height of the bitmap is 2 to the power of heightBits, or (1 << heightBits). The texture is shaded from it's original color to black.


ShadedTexture

public ShadedTexture(byte[] buffer,
                     int widthBits,
                     int heightBits,
                     java.awt.image.IndexColorModel palette,
                     java.awt.Color targetShade)
Creates a new ShadedTexture from the specified 8-bit image buffer, palette, and target shaded. The width of the bitmap is 2 to the power of widthBits, or (1 << widthBits). Likewise, the height of the bitmap is 2 to the power of heightBits, or (1 << heightBits). The texture is shaded from it's original color to the target shade.

Method Detail

makeShadeTable

public void makeShadeTable(java.awt.Color targetShade)
Creates the shade table for this ShadedTexture. Each entry in the palette is shaded from the original color to the specified target color.


setDefaultShadeLevel

public void setDefaultShadeLevel(int level)
Sets the default shade level that is used when getColor() is called.


getDefaultShadeLevel

public int getDefaultShadeLevel()
Gets the default shade level that is used when getColor() is called.


getColor

public short getColor(int x,
                      int y)
Gets the 16-bit color of this Texture at the specified (x,y) location, using the default shade level.

Specified by:
getColor in class Texture

getColor

public short getColor(int x,
                      int y,
                      int shadeLevel)
Gets the 16-bit color of this Texture at the specified (x,y) location, using the specified shade level.


setCurrRow

public void setCurrRow(int y)
Sets the current row for getColorCurrRow(). Pre-calculates the offset for this row.


getColorCurrRow

public short getColorCurrRow(int x,
                             int shadeLevel)
Gets the color at the specified x location at the specified shade level. The current row defined in setCurrRow is used.