Class Texture

java.lang.Object
zombie.asset.Asset
zombie.core.textures.Texture
All Implemented Interfaces:
Serializable, IDestroyable, IMaskerable, ITexture
Direct Known Subclasses:
AngelCodeFont.CharDefTexture, SmartTexture

public class Texture extends Asset implements IDestroyable, ITexture, Serializable
See Also:
  • Field Details

    • nullTextures

      public static final HashSet<String> nullTextures
    • BindCount

      public static int BindCount
      indicates if all the texture will auto create the masks on load
      The auto creation works only with the getTexture() methods
    • 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
    • lastlastTextureID

      public static int lastlastTextureID
    • totalTextureID

      public static int totalTextureID
    • lastTextureID

      public static int lastTextureID
    • WarnFailFindTexture

      public static boolean WarnFailFindTexture
    • flip

      public boolean flip
    • offsetX

      public float offsetX
    • offsetY

      public float offsetY
    • bindAlways

      public boolean bindAlways
    • 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...
    • assetParams

      public Texture.TextureAssetParams assetParams
    • ASSET_TYPE

      public static final AssetType ASSET_TYPE
  • Constructor Details

    • Texture

      public Texture(AssetPath path, AssetManager manager, Texture.TextureAssetParams params)
    • Texture

      public Texture(TextureID data, String name)
    • Texture

      public Texture(String file) throws Exception
      LOADS and crete a texture from a file
      Parameters:
      file - relative path
      Throws:
      Exception
    • Texture

      public Texture(String name, BufferedInputStream b, boolean bDoMask, Texture.PZFileformat format)
    • Texture

      public Texture(String name, BufferedInputStream b, boolean bDoMask) throws Exception
      Throws:
      Exception
    • Texture

      public Texture(String file, boolean bDelete, boolean bUseAlpha) throws Exception
      Throws:
      Exception
    • Texture

      public Texture(String name, String palette)
    • Texture

      public Texture(String name, int[] palette)
    • Texture

      public Texture(String file, boolean useAlphaChannel) throws Exception
      LOADS and crete a texture from a file
      Parameters:
      file - relative path
      useAlphaChannel - indicates if the image should use or not the alpha channel
      Throws:
      Exception
    • Texture

      public Texture(int width, int height, String name, int flags)
      create a new empty texture.
      Parameters:
      width - size of texture
      height - size of texture
    • Texture

      public Texture(int width, int height, int flags)
      create a new empty texture.
      Parameters:
      width - size of texture
      height - size of texture
    • Texture

      public Texture(String file, int red, int green, int blue) throws Exception
      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
      Throws:
      Exception
    • 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 Details

    • processFilePath

      public static String processFilePath(String filePath)
    • bindNone

      public static void bindNone()
    • getWhite

      public static Texture getWhite()
    • getErrorTexture

      public static Texture getErrorTexture()
    • getEngineMipmapTexture

      public static Texture getEngineMipmapTexture()
    • clearTextures

      public static void clearTextures()
    • getSharedTexture

      public static Texture getSharedTexture(String name)
    • getSharedTexture

      public static Texture getSharedTexture(String name, int flags)
    • trygetTexture

      public static Texture trygetTexture(String name)
    • onTexturePacksChanged

      public static void onTexturePacksChanged()
    • getSharedTexture

      public static Texture getSharedTexture(String name, String palette)
    • getSharedTexture

      public static Texture getSharedTexture(String name, int[] palette, String paletteName)
    • getTexture

      public static Texture getTexture(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
    • getSteamAvatar

      public static Texture getSteamAvatar(long steamID)
    • steamAvatarChanged

      public static void steamAvatarChanged(long steamID)
    • forgetTexture

      public static void forgetTexture(String name)
    • reload

      public static void reload(String name)
    • flipPixels

      public static int[] flipPixels(int[] imgPixels, int imgw, int imgh)
    • reloadFromFile

      public void reloadFromFile(String 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
    • 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(BooleanGrid 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
    • setData

      public void setData(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
    • 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
    • setHeight

      public void setHeight(int height)
    • 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
    • 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
    • getName

      public String getName()
    • setName

      public void setName(String name)
    • 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
    • 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
    • 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
    • setWidth

      public void setWidth(int width)
    • 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
    • getOffsetX

      public float getOffsetX()
    • setOffsetX

      public void setOffsetX(int offset)
    • getOffsetY

      public float getOffsetY()
    • setOffsetY

      public void setOffsetY(int offset)
    • 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(float x, float y, float width, float height)
    • render

      public void render(float x, float y)
    • render

      public void render(float x, float y, float width, float height, float r, float g, float b, float a, Consumer<TextureDraw> texdModifier)
    • render

      public void render(ObjectRenderEffects dr, float x, float y, float width, float height, float r, float g, float b, float a, Consumer<TextureDraw> texdModifier)
    • rendershader2

      public void rendershader2(float x, float y, float width, float height, int texx, int texy, int texWidth, int texHeight, float r, float g, float b, float a)
    • renderdiamond

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

      public void renderwallnw(float x, float y, float width, float height, int u, int d, int u2, int d2, int r, int r2)
    • renderwallw

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

      public void renderwalln(float x, float y, float width, float 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, Consumer<TextureDraw> texdModifier)
    • 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()
    • setNameOnly

      public void setNameOnly(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
    • splitIcon

      public Texture splitIcon()
    • split

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

      public Texture split(String name, 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 String toString()
      Overrides:
      toString in class Object
    • saveMask

      public void saveMask(String name)
    • saveToZomboidDirectory

      public void saveToZomboidDirectory(String filename)
    • saveToCurrentSavefileDirectory

      public void saveToCurrentSavefileDirectory(String filename)
    • saveOnRenderThread

      public void saveOnRenderThread(String filename)
    • loadMaskRegion

      public void loadMaskRegion(ByteBuffer cache)
    • saveMaskRegion

      public void saveMaskRegion(ByteBuffer cache)
    • getRealWidth

      public int getRealWidth()
    • setRealWidth

      public void setRealWidth(int realWidth)
    • getRealHeight

      public int getRealHeight()
    • setRealHeight

      public void setRealHeight(int realHeight)
    • getUVScale

      public Vector2 getUVScale(Vector2 uvScale)
    • getType

      public AssetType getType()
      Specified by:
      getType in class Asset
    • onBeforeReady

      public void onBeforeReady()
    • collectAllIcons

      public static void collectAllIcons(HashMap<String,String> map, HashMap<String,String> mapFull)