zombie.core.textures
Class Texture

java.lang.Object
  extended by zombie.core.textures.Texture
All Implemented Interfaces:
java.io.Serializable, IDestroyable, IMaskerable, ITexture

public class Texture
extends java.lang.Object
implements IDestroyable, ITexture, java.io.Serializable

See Also:
Serialized Form

Nested Class Summary
static class Texture.PZFileformat
           
 
Field Summary
static boolean autoCreateMask
          indicates if all the texture will auto create the masks on load
The auto creation works only with the getTexture() methods
static boolean bDoingQuad
           
static int BindCount
           
 boolean flip
           
static float la
           
static float lb
           
static float lg
           
static float lr
           
 float offsetX
           
 float offsetY
           
static int renderQuadBatchCount
           
static int startStack
           
static boolean WarnFailFindTexture
           
 float xEnd
          internal texture coordinates
it's used to get the max border of texture...
 float xStart
          internal texture coordinates
it's used to get the max border of texture...
 float yEnd
          internal texture coordinates
it's used to get the max border of texture...
 float yStart
          internal texture coordinates
it's used to get the max border of texture...
 
Constructor Summary
Texture()
          creates an emptiy texture and adds it to the game engine's texture list
Texture(java.awt.image.BufferedImage bImage, java.lang.String name)
           
Texture(int width, int height)
          create a new empty texture.
Texture(int width, int height, java.lang.String name)
          create a new empty texture.
Texture(java.lang.String file)
          LOADS and crete a texture from a file
Texture(java.lang.String file, boolean useAlphaChannel)
          LOADS and crete a texture from a file
Texture(java.lang.String file, boolean bDelete, boolean bUseAlpha)
           
Texture(java.lang.String name, java.io.BufferedInputStream b, boolean bDoMask)
           
Texture(java.lang.String name, java.io.BufferedInputStream b, boolean bDoMask, Texture.PZFileformat format)
           
Texture(java.lang.String name, int[] palette)
           
Texture(java.lang.String file, int red, int green, int blue)
          loads and create a texture from a file and cretes as trasparent the section that have the color equal to the RGB valued spefied
Texture(java.lang.String name, java.lang.String palette)
           
Texture(Texture t)
          creates a copy of an existent texture
Texture(TextureID data, java.lang.String name)
           
 
Method Summary
 void bind()
          Blinds the image
 void bind(int unit)
          bind the current texture object in the specified texture unit
static void bindNone()
           
 void bindstrip(float a, float r, float g, float b)
           
 void bindstrip(int unit, float a, float r, float g, float b)
           
static void clearTextures()
           
 void copyMaskRegion(Texture from, int x, int y, int width, int height)
           
 void createMask()
          creates the mask of collisions
 void createMask(boolean[] mask)
           
 void createMask(WrappedBuffer buf)
           
 void destroy()
          destroys the image and release all resources
 boolean equals(Texture other)
           
 WrappedBuffer getData()
          returns the texture's pixel in a ByteBuffer EXAMPLE:
ByteBuffer bb = getData();
byte r, g, b;
bb.rewind(); //<-- IMPORTANT!!
try {
while (true) {
bb.mark();
r = bb.get();
g = bb.get();
b = bb.get();
bb.reset();
bb.put((byte)(r+red));
bb.put((byte)(g+green));
bb.put((byte)(b+blue));
bb.get(); // alpha

catch (Exception e) {

setData(bb);
 int getHeight()
          returns the height of image
 int getHeightHW()
          return the height hardware of image
 int getHeightOrig()
           
 int getID()
          returns the ID of image in the Vram
 Mask getMask()
          returns the mask of collisions
 java.lang.String getName()
           
static Texture getSharedTexture(java.lang.String name)
           
static Texture getSharedTexture(java.lang.String name, boolean bDeleteData)
           
static Texture getSharedTexture(java.lang.String name, int[] palette, java.lang.String paletteName)
           
static Texture getSharedTexture(java.lang.String name, java.lang.String palette)
           
static Texture getTexture(java.lang.String name)
          gets a texture from it's name; If the texture isn't already loaded this method will load it.
 TextureID getTextureId()
           
 boolean getUseAlphaChannel()
          indicates if the image will use the alpha channel or note
 int getWidth()
          returns the width of image
 int getWidthHW()
          return the width Hardware of image
 int getWidthOrig()
           
 float getXEnd()
          returns the end X-coordinate
 float getXStart()
          returns the start X-coordinate
 float getYEnd()
          returns the end Y-coordinate
 float getYStart()
          returns the start Y-coordinate
 boolean isCollisionable()
          indicates if the texture has a mask of collisions or not
 boolean isDestroyed()
          returns if the texture is destroyed or not
 boolean isSolid()
          indicates if the texture is solid or not.
a non solid texture is a texture that containe an alpha channel
 boolean isValid()
           
 void Load(java.awt.image.BufferedImage image)
           
 void loadMaskRegion(java.nio.ByteBuffer cache)
           
 void makeTransp(int red, int green, int blue)
          sets transparent each pixel that it's equal to the red, green blue value specified
 void render(int x, int y)
           
 void render(int x, int y, int width, int height)
           
 void render(int x, int y, int width, int height, float r, float g, float b, float a)
           
 void renderdiamond(int x, int y, int width, int height, float u, float d, float l, float r, float a)
           
 void renderdiamond(int x, int y, int width, int height, float ru, float gu, float bu, float au, float rd, float gd, float bd, float ad, float rl, float gl, float bl, float al, float rr, float gr, float br, float ar)
           
 void renderdiamond(int x, int y, int width, int height, int u, int d, int l, int r)
           
 void renderroofw(int x, int y, int width, int height, float ru, float gu, float bu, float au, float rd, float gd, float bd, float ad, float ru2, float gu2, float bu2, float au2, float rd2, float gd2, float bd2, float ad2)
           
 void rendershader(int x, int y, int width, int height, float r, float g, float b, float a)
           
 void renderstrip(int x, int y, int width, int height, float r, float g, float b, float a)
           
 void renderTest(int x, int y)
           
 void renderwalln(int x, int y, int width, int height, float ru, float gu, float bu, float au, float rd, float gd, float bd, float ad, float ru2, float gu2, float bu2, float au2, float rd2, float gd2, float bd2, float ad2)
           
 void renderwalln(int x, int y, int width, int height, int u, int d, int u2, int d2)
           
 void renderwallw(int x, int y, int width, int height, float ru, float gu, float bu, float au, float rd, float gd, float bd, float ad, float ru2, float gu2, float bu2, float au2, float rd2, float gd2, float bd2, float ad2)
           
 void renderwallw(int x, int y, int width, int height, int u, int d, int u2, int d2)
           
 void saveMask(java.lang.String name)
           
 void saveMaskRegion(java.nio.ByteBuffer cache)
           
 void setAlphaForeach(int red, int green, int blue, int alpha)
          sets the specified alpha for each pixel that it's equal to the red, green blue value specified
 void setCustomizedTexture()
           
 void setData(java.nio.ByteBuffer data)
          sets the texture's pixel from a ByteBuffer EXAMPLE:
ByteBuffer bb = getData();
byte r, g, b;
bb.rewind(); //<-- IMPORTANT!!
try {
while (true) {
bb.mark();
r = bb.get();
g = bb.get();
b = bb.get();
bb.reset();
bb.put((byte)(r+red));
bb.put((byte)(g+green));
bb.put((byte)(b+blue));
bb.get(); // alpha

catch (Exception e) {

setData(bb);
 void setMask(Mask mask)
          sets the mask of collisions
 void setName(java.lang.String name)
           
 void setRegion(int x, int y, int width, int height)
          sets the region of the image
 void setUseAlphaChannel(boolean value)
          indicates if the texture contains the alpha channel or not
 Texture split(int xOffset, int yOffset, int width, int height)
           
 Texture[] split(int xOffset, int yOffset, int row, int coloumn, int width, int height, int spaceX, int spaceY)
           
 Texture[][] split2D(int[] xstep, int[] ystep)
           
 java.lang.String toString()
           
static Texture trygetTexture(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

autoCreateMask

public static boolean autoCreateMask
indicates if all the texture will auto create the masks on load
The auto creation works only with the getTexture() methods


BindCount

public static int BindCount

renderQuadBatchCount

public static int renderQuadBatchCount

startStack

public static int startStack

bDoingQuad

public static boolean bDoingQuad

lr

public static float lr

lg

public static float lg

lb

public static float lb

la

public static float la

flip

public boolean flip

offsetX

public float offsetX

offsetY

public float offsetY

xEnd

public float xEnd
internal texture coordinates
it's used to get the max border of texture...


yEnd

public float yEnd
internal texture coordinates
it's used to get the max border of texture...


xStart

public float xStart
internal texture coordinates
it's used to get the max border of texture...


yStart

public float yStart
internal texture coordinates
it's used to get the max border of texture...


WarnFailFindTexture

public static boolean WarnFailFindTexture
Constructor Detail

Texture

public Texture(TextureID data,
               java.lang.String name)

Texture

public Texture(java.awt.image.BufferedImage bImage,
               java.lang.String name)

Texture

public Texture(java.lang.String file)
LOADS and crete a texture from a file

Parameters:
file - relative path

Texture

public Texture(java.lang.String name,
               java.io.BufferedInputStream b,
               boolean bDoMask,
               Texture.PZFileformat format)

Texture

public Texture(java.lang.String name,
               java.io.BufferedInputStream b,
               boolean bDoMask)

Texture

public Texture(java.lang.String file,
               boolean bDelete,
               boolean bUseAlpha)

Texture

public Texture(java.lang.String name,
               java.lang.String palette)

Texture

public Texture(java.lang.String name,
               int[] palette)

Texture

public Texture(java.lang.String file,
               boolean useAlphaChannel)
LOADS and crete a texture from a file

Parameters:
file - relative path
useAlphaChannel - indicates if the image should use or not the alpha channel

Texture

public Texture(int width,
               int height,
               java.lang.String name)
create a new empty texture.

Parameters:
width - size of texture
height - size of texture

Texture

public Texture(int width,
               int height)
create a new empty texture.

Parameters:
width - size of texture
height - size of texture

Texture

public Texture(java.lang.String file,
               int red,
               int green,
               int blue)
loads and create a texture from a file and cretes as trasparent the section that have the color equal to the RGB valued spefied

Parameters:
file - relative path
red - red value to compare
green - green value to compare
blue - blue value to compare

Texture

public Texture(Texture t)
creates a copy of an existent texture

Parameters:
t - original texture

Texture

public Texture()
creates an emptiy texture and adds it to the game engine's texture list

Method Detail

Load

public void Load(java.awt.image.BufferedImage image)

bindNone

public static void bindNone()

clearTextures

public static void clearTextures()

getSharedTexture

public static Texture getSharedTexture(java.lang.String name)

getSharedTexture

public static Texture getSharedTexture(java.lang.String name,
                                       boolean bDeleteData)

trygetTexture

public static Texture trygetTexture(java.lang.String name)

getSharedTexture

public static Texture getSharedTexture(java.lang.String name,
                                       java.lang.String palette)

getSharedTexture

public static Texture getSharedTexture(java.lang.String name,
                                       int[] palette,
                                       java.lang.String paletteName)

getTexture

public static Texture getTexture(java.lang.String name)
gets a texture from it's name; If the texture isn't already loaded this method will load it.

Parameters:
name - the name of texture
Returns:
returns the texture from the given name

bind

public void bind()
Blinds the image

Specified by:
bind in interface ITexture

bind

public void bind(int unit)
Description copied from interface: ITexture
bind the current texture object in the specified texture unit

Specified by:
bind in interface ITexture
Parameters:
unit - the texture unit in witch the current TextureObject will be binded

bindstrip

public void bindstrip(float a,
                      float r,
                      float g,
                      float b)

bindstrip

public void bindstrip(int unit,
                      float a,
                      float r,
                      float g,
                      float b)

copyMaskRegion

public void copyMaskRegion(Texture from,
                           int x,
                           int y,
                           int width,
                           int height)

createMask

public void createMask()
creates the mask of collisions


createMask

public void createMask(boolean[] mask)

createMask

public void createMask(WrappedBuffer buf)

destroy

public void destroy()
destroys the image and release all resources

Specified by:
destroy in interface IDestroyable

equals

public boolean equals(Texture other)

getData

public WrappedBuffer getData()
returns the texture's pixel in a ByteBuffer EXAMPLE:
ByteBuffer bb = getData();
byte r, g, b;
bb.rewind(); //<-- IMPORTANT!!
try {
while (true) {
bb.mark();
r = bb.get();
g = bb.get();
b = bb.get();
bb.reset();
bb.put((byte)(r+red));
bb.put((byte)(g+green));
bb.put((byte)(b+blue));
bb.get(); // alpha

catch (Exception e) {

setData(bb);

Specified by:
getData in interface ITexture

getHeight

public int getHeight()
Description copied from interface: ITexture
returns the height of image

Specified by:
getHeight in interface ITexture
Returns:
the height of image

getHeightHW

public int getHeightHW()
Description copied from interface: ITexture
return the height hardware of image

Specified by:
getHeightHW in interface ITexture
Returns:

getHeightOrig

public int getHeightOrig()

getID

public int getID()
Description copied from interface: ITexture
returns the ID of image in the Vram

Specified by:
getID in interface ITexture
Returns:
the ID of image in the Vram

getMask

public Mask getMask()
returns the mask of collisions

Specified by:
getMask in interface IMaskerable
Returns:
mask of collisions

getName

public java.lang.String getName()

getTextureId

public TextureID getTextureId()

getUseAlphaChannel

public boolean getUseAlphaChannel()
indicates if the image will use the alpha channel or note

Returns:
if the image will use the alpha channel or note

getWidth

public int getWidth()
Description copied from interface: ITexture
returns the width of image

Specified by:
getWidth in interface ITexture
Returns:
the width of image

getWidthHW

public int getWidthHW()
Description copied from interface: ITexture
return the width Hardware of image

Specified by:
getWidthHW in interface ITexture
Returns:

getWidthOrig

public int getWidthOrig()

getXEnd

public float getXEnd()
Description copied from interface: ITexture
returns the end X-coordinate

Specified by:
getXEnd in interface ITexture
Returns:
the end X-coordinate

getXStart

public float getXStart()
Description copied from interface: ITexture
returns the start X-coordinate

Specified by:
getXStart in interface ITexture
Returns:
the start X-coordinate

getYEnd

public float getYEnd()
Description copied from interface: ITexture
returns the end Y-coordinate

Specified by:
getYEnd in interface ITexture
Returns:
the end Y-coordinate

getYStart

public float getYStart()
Description copied from interface: ITexture
returns the start Y-coordinate

Specified by:
getYStart in interface ITexture
Returns:
the start Y-coordinate

isCollisionable

public boolean isCollisionable()
indicates if the texture has a mask of collisions or not


isDestroyed

public boolean isDestroyed()
returns if the texture is destroyed or not

Specified by:
isDestroyed in interface IDestroyable

isSolid

public boolean isSolid()
Description copied from interface: ITexture
indicates if the texture is solid or not.
a non solid texture is a texture that containe an alpha channel

Specified by:
isSolid in interface ITexture
Returns:
if the texture is solid or not.

isValid

public boolean isValid()

makeTransp

public void makeTransp(int red,
                       int green,
                       int blue)
Description copied from interface: ITexture
sets transparent each pixel that it's equal to the red, green blue value specified

Specified by:
makeTransp in interface ITexture
Parameters:
red - color used in the test
green - color used in the test
blue - color used in the test

render

public void render(int x,
                   int y,
                   int width,
                   int height)

render

public void render(int x,
                   int y)

render

public void render(int x,
                   int y,
                   int width,
                   int height,
                   float r,
                   float g,
                   float b,
                   float a)

rendershader

public void rendershader(int x,
                         int y,
                         int width,
                         int height,
                         float r,
                         float g,
                         float b,
                         float a)

renderdiamond

public void renderdiamond(int x,
                          int y,
                          int width,
                          int height,
                          float u,
                          float d,
                          float l,
                          float r,
                          float a)

renderdiamond

public void renderdiamond(int x,
                          int y,
                          int width,
                          int height,
                          float ru,
                          float gu,
                          float bu,
                          float au,
                          float rd,
                          float gd,
                          float bd,
                          float ad,
                          float rl,
                          float gl,
                          float bl,
                          float al,
                          float rr,
                          float gr,
                          float br,
                          float ar)

renderdiamond

public void renderdiamond(int x,
                          int y,
                          int width,
                          int height,
                          int u,
                          int d,
                          int l,
                          int r)

renderwallw

public void renderwallw(int x,
                        int y,
                        int width,
                        int height,
                        float ru,
                        float gu,
                        float bu,
                        float au,
                        float rd,
                        float gd,
                        float bd,
                        float ad,
                        float ru2,
                        float gu2,
                        float bu2,
                        float au2,
                        float rd2,
                        float gd2,
                        float bd2,
                        float ad2)

renderwallw

public void renderwallw(int x,
                        int y,
                        int width,
                        int height,
                        int u,
                        int d,
                        int u2,
                        int d2)

renderroofw

public void renderroofw(int x,
                        int y,
                        int width,
                        int height,
                        float ru,
                        float gu,
                        float bu,
                        float au,
                        float rd,
                        float gd,
                        float bd,
                        float ad,
                        float ru2,
                        float gu2,
                        float bu2,
                        float au2,
                        float rd2,
                        float gd2,
                        float bd2,
                        float ad2)

renderwalln

public void renderwalln(int x,
                        int y,
                        int width,
                        int height,
                        float ru,
                        float gu,
                        float bu,
                        float au,
                        float rd,
                        float gd,
                        float bd,
                        float ad,
                        float ru2,
                        float gu2,
                        float bu2,
                        float au2,
                        float rd2,
                        float gd2,
                        float bd2,
                        float ad2)

renderwalln

public void renderwalln(int x,
                        int y,
                        int width,
                        int height,
                        int u,
                        int d,
                        int u2,
                        int d2)

renderstrip

public void renderstrip(int x,
                        int y,
                        int width,
                        int height,
                        float r,
                        float g,
                        float b,
                        float a)

setAlphaForeach

public void setAlphaForeach(int red,
                            int green,
                            int blue,
                            int alpha)
Description copied from interface: ITexture
sets the specified alpha for each pixel that it's equal to the red, green blue value specified

Specified by:
setAlphaForeach in interface ITexture
Parameters:
red - color used in the test
green - color used in the test
blue - color used in the test
alpha - the alpha color that will be setted to the pixel that pass the test

setCustomizedTexture

public void setCustomizedTexture()

setData

public void setData(java.nio.ByteBuffer data)
sets the texture's pixel from a ByteBuffer EXAMPLE:
ByteBuffer bb = getData();
byte r, g, b;
bb.rewind(); //<-- IMPORTANT!!
try {
while (true) {
bb.mark();
r = bb.get();
g = bb.get();
b = bb.get();
bb.reset();
bb.put((byte)(r+red));
bb.put((byte)(g+green));
bb.put((byte)(b+blue));
bb.get(); // alpha

catch (Exception e) {

setData(bb);

Specified by:
setData in interface ITexture
Parameters:
data - texture's pixel data

setMask

public void setMask(Mask mask)
sets the mask of collisions

Specified by:
setMask in interface ITexture
Parameters:
mask - the mask of collisions to set

setName

public void setName(java.lang.String name)

setRegion

public void setRegion(int x,
                      int y,
                      int width,
                      int height)
Description copied from interface: ITexture
sets the region of the image

Specified by:
setRegion in interface ITexture
Parameters:
x - xstart position
y - ystart position
width - width of the region
height - height of the region

setUseAlphaChannel

public void setUseAlphaChannel(boolean value)
indicates if the texture contains the alpha channel or not

Parameters:
value - if true, the image will use the alpha channel

split

public Texture split(int xOffset,
                     int yOffset,
                     int width,
                     int height)

split

public Texture[] split(int xOffset,
                       int yOffset,
                       int row,
                       int coloumn,
                       int width,
                       int height,
                       int spaceX,
                       int spaceY)

split2D

public Texture[][] split2D(int[] xstep,
                           int[] ystep)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

renderTest

public void renderTest(int x,
                       int y)

saveMask

public void saveMask(java.lang.String name)

loadMaskRegion

public void loadMaskRegion(java.nio.ByteBuffer cache)

saveMaskRegion

public void saveMaskRegion(java.nio.ByteBuffer cache)