Package zombie.core.textures
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
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static final class
Nested classes/interfaces inherited from class zombie.asset.Asset
Asset.ObserverCallback, Asset.State
-
Field Summary
Modifier and TypeFieldDescriptionstatic final AssetType
static boolean
boolean
static int
indicates if all the texture will auto create the masks on load
The auto creation works only with the getTexture() methodsboolean
static float
static int
static int
static float
static float
static float
float
float
static int
static boolean
float
internal texture coordinates
it's used to get the max border of texture...float
internal texture coordinates
it's used to get the max border of texture...float
internal texture coordinates
it's used to get the max border of texture...float
internal texture coordinates
it's used to get the max border of texture... -
Constructor Summary
ConstructorDescriptionTexture()
creates an emptiy texture and adds it to the game engine's texture listTexture
(int width, int height, int flags) create a new empty texture.create a new empty texture.LOADS and crete a texture from a fileLOADS and crete a texture from a fileloads and create a texture from a file and cretes as trasparent the section that have the color equal to the RGB valued spefiedTexture
(String name, BufferedInputStream b, boolean bDoMask) Texture
(String name, BufferedInputStream b, boolean bDoMask, Texture.PZFileformat format) Texture
(AssetPath path, AssetManager manager, Texture.TextureAssetParams params) creates a copy of an existent texture -
Method Summary
Modifier and TypeMethodDescriptionvoid
bind()
Blinds the imagevoid
bind
(int unit) bind the current texture object in the specified texture unitstatic void
bindNone()
static void
static void
void
copyMaskRegion
(Texture from, int x, int y, int width, int height) void
creates the mask of collisionsvoid
createMask
(boolean[] mask) void
createMask
(BooleanGrid mask) void
createMask
(WrappedBuffer buf) void
destroy()
destroys the image and release all resourcesboolean
static int[]
flipPixels
(int[] imgPixels, int imgw, int imgh) static void
forgetTexture
(String name) getData()
returns the texture's pixel in a ByteBufferstatic Texture
static Texture
int
returns the height of imageint
return the height hardware of imageint
int
getID()
returns the ID of image in the VramgetMask()
returns the mask of collisionsgetName()
float
float
int
int
static Texture
getSharedTexture
(String name) static Texture
getSharedTexture
(String name, int flags) static Texture
getSharedTexture
(String name, int[] palette, String paletteName) static Texture
getSharedTexture
(String name, String palette) static Texture
getSteamAvatar
(long steamID) static Texture
getTexture
(String name) gets a texture from it's name; If the texture isn't already loaded this method will load it.getType()
boolean
indicates if the image will use the alpha channel or notegetUVScale
(Vector2 uvScale) static Texture
getWhite()
int
getWidth()
returns the width of imageint
return the width Hardware of imageint
float
getXEnd()
returns the end X-coordinatefloat
returns the start X-coordinatefloat
getYEnd()
returns the end Y-coordinatefloat
returns the start Y-coordinateboolean
indicates if the texture has a mask of collisions or notboolean
returns if the texture is destroyed or notboolean
isSolid()
indicates if the texture is solid or not.
a non solid texture is a texture that containe an alpha channelboolean
isValid()
void
loadMaskRegion
(ByteBuffer cache) void
makeTransp
(int red, int green, int blue) sets transparent each pixel that it's equal to the red, green blue value specifiedvoid
static void
static String
processFilePath
(String filePath) static void
void
reloadFromFile
(String name) void
render
(float x, float y) void
render
(float x, float y, float width, float height) void
render
(float x, float y, float width, float height, float r, float g, float b, float a, Consumer<TextureDraw> texdModifier) void
render
(ObjectRenderEffects dr, float x, float y, float width, float height, float r, float g, float b, float a, Consumer<TextureDraw> texdModifier) void
renderdiamond
(float x, float y, float width, float height, int l, int u, int r, int d) 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) void
renderstrip
(int x, int y, int width, int height, float r, float g, float b, float a, Consumer<TextureDraw> texdModifier) void
renderwalln
(float x, float y, float width, float height, int u, int d, int u2, int d2) void
renderwallnw
(float x, float y, float width, float height, int u, int d, int u2, int d2, int r, int r2) void
renderwallw
(float x, float y, float width, float height, int u, int d, int u2, int d2) void
void
saveMaskRegion
(ByteBuffer cache) void
saveOnRenderThread
(String filename) void
saveToCurrentSavefileDirectory
(String filename) void
saveToZomboidDirectory
(String filename) 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 specifiedvoid
void
setData
(ByteBuffer data) sets the texture's pixel from a ByteBuffervoid
setHeight
(int height) void
sets the mask of collisionsvoid
void
setNameOnly
(String name) void
setOffsetX
(int offset) void
setOffsetY
(int offset) void
setRealHeight
(int realHeight) void
setRealWidth
(int realWidth) void
setRegion
(int x, int y, int width, int height) sets the region of the imagevoid
setUseAlphaChannel
(boolean value) indicates if the texture contains the alpha channel or notvoid
setWidth
(int width) 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) static void
steamAvatarChanged
(long steamID) toString()
static Texture
trygetTexture
(String name) Methods inherited from class zombie.asset.Asset
addDependency, getAssetManager, getObserverCb, getPath, getRefCount, getState, isEmpty, isFailure, isReady, onCreated, removeDependency, setAssetParams
-
Field Details
-
nullTextures
-
BindCount
public static int BindCountindicates 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 xEndinternal texture coordinates
it's used to get the max border of texture... -
yEnd
public float yEndinternal texture coordinates
it's used to get the max border of texture... -
xStart
public float xStartinternal texture coordinates
it's used to get the max border of texture... -
yStart
public float yStartinternal texture coordinates
it's used to get the max border of texture... -
assetParams
-
ASSET_TYPE
-
-
Constructor Details
-
Texture
-
Texture
-
Texture
LOADS and crete a texture from a file- Parameters:
file
- relative path- Throws:
Exception
-
Texture
-
Texture
- Throws:
Exception
-
Texture
- Throws:
Exception
-
Texture
-
Texture
-
Texture
LOADS and crete a texture from a file- Parameters:
file
- relative pathuseAlphaChannel
- indicates if the image should use or not the alpha channel- Throws:
Exception
-
Texture
create a new empty texture.- Parameters:
width
- size of textureheight
- size of texture
-
Texture
public Texture(int width, int height, int flags) create a new empty texture.- Parameters:
width
- size of textureheight
- size of texture
-
Texture
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 pathred
- red value to comparegreen
- green value to compareblue
- blue value to compare- Throws:
Exception
-
Texture
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
-
bindNone
public static void bindNone() -
getWhite
-
getErrorTexture
-
getEngineMipmapTexture
-
clearTextures
public static void clearTextures() -
trygetTexture
-
onTexturePacksChanged
public static void onTexturePacksChanged() -
getTexture
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
-
steamAvatarChanged
public static void steamAvatarChanged(long steamID) -
forgetTexture
-
reload
-
flipPixels
public static int[] flipPixels(int[] imgPixels, int imgw, int imgh) -
reloadFromFile
-
bind
public void bind()Blinds the image -
bind
public void bind(int unit) Description copied from interface:ITexture
bind the current texture object in the specified texture unit -
copyMaskRegion
-
createMask
public void createMask()creates the mask of collisions -
createMask
public void createMask(boolean[] mask) -
createMask
-
createMask
-
destroy
public void destroy()destroys the image and release all resources- Specified by:
destroy
in interfaceIDestroyable
-
equals
-
getData
returns the texture's pixel in a ByteBufferEXAMPLE:
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); -
setData
sets the texture's pixel from a ByteBufferEXAMPLE:
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); -
getHeight
public int getHeight()Description copied from 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 interfaceITexture
- Returns:
-
getHeightOrig
public int getHeightOrig() -
getID
public int getID()Description copied from interface:ITexture
returns the ID of image in the Vram -
getMask
returns the mask of collisions- Specified by:
getMask
in interfaceIMaskerable
- Returns:
- mask of collisions
-
setMask
sets the mask of collisions -
getName
-
setName
-
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 -
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 interfaceITexture
- Returns:
-
getWidthOrig
public int getWidthOrig() -
getXEnd
public float getXEnd()Description copied from interface:ITexture
returns the end X-coordinate -
getXStart
public float getXStart()Description copied from interface:ITexture
returns the start X-coordinate -
getYEnd
public float getYEnd()Description copied from interface:ITexture
returns the end Y-coordinate -
getYStart
public float getYStart()Description copied from 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 interfaceIDestroyable
-
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 -
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 interfaceITexture
- Parameters:
red
- color used in the testgreen
- color used in the testblue
- 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 interfaceITexture
- Parameters:
red
- color used in the testgreen
- color used in the testblue
- color used in the testalpha
- the alpha color that will be setted to the pixel that pass the test
-
setCustomizedTexture
public void setCustomizedTexture() -
setNameOnly
-
setRegion
public void setRegion(int x, int y, int width, int height) Description copied from interface:ITexture
sets the region of the image -
splitIcon
-
split
-
split
-
split
public Texture[] split(int xOffset, int yOffset, int row, int coloumn, int width, int height, int spaceX, int spaceY) -
split2D
-
toString
-
saveMask
-
saveToZomboidDirectory
-
saveToCurrentSavefileDirectory
-
saveOnRenderThread
-
loadMaskRegion
-
saveMaskRegion
-
getRealWidth
public int getRealWidth() -
setRealWidth
public void setRealWidth(int realWidth) -
getRealHeight
public int getRealHeight() -
setRealHeight
public void setRealHeight(int realHeight) -
getUVScale
-
getType
-
onBeforeReady
public void onBeforeReady() -
collectAllIcons
-