Interface ITextureAtlasAPI
- Namespace
- Vintagestory.API.Client
- Assembly
- VintagestoryAPI.dll
Entity texture Atlas.
public interface ITextureAtlasAPI
- Extension Methods
Properties
AtlasTextures
Returns the list of currently loaded texture atlas ids
List<LoadedTexture> AtlasTextures { get; }
Property Value
this[AssetLocation]
TextureAtlasPosition this[AssetLocation textureLocation] { get; }
Parameters
textureLocation
AssetLocation
Property Value
Positions
Returns the default texture atlas position for all blocks, referenced by the texturesubid
TextureAtlasPosition[] Positions { get; }
Property Value
Size
Size of one block texture atlas
Size2i Size { get; }
Property Value
SubPixelPaddingX
As configured in the clientsettings.json divided by the texture atlas size
float SubPixelPaddingX { get; }
Property Value
SubPixelPaddingY
float SubPixelPaddingY { get; }
Property Value
UnknownTexturePosition
The texture atlas position of the "unknown.png" texture
TextureAtlasPosition UnknownTexturePosition { get; }
Property Value
Methods
AllocateTextureSpace(int, int, out int, out TextureAtlasPosition)
Reserves a spot on the texture atlas. Returns true if allocation was successful. Can be used to render onto it through the Render API
bool AllocateTextureSpace(int width, int height, out int textureSubId, out TextureAtlasPosition texPos)
Parameters
width
intheight
inttextureSubId
inttexPos
TextureAtlasPosition
Returns
FreeTextureSpace(int)
Deallocates a previously allocated texture space
void FreeTextureSpace(int textureSubId)
Parameters
textureSubId
int
GetAverageColor(int)
Returns you an average rgba value picked inside the texture subid
int GetAverageColor(int textureSubId)
Parameters
textureSubId
int
Returns
GetOrInsertTexture(CompositeTexture, out int, out TextureAtlasPosition, float)
bool GetOrInsertTexture(CompositeTexture ct, out int textureSubId, out TextureAtlasPosition texPos, float alphaTest = 0)
Parameters
ct
CompositeTexturetextureSubId
inttexPos
TextureAtlasPositionalphaTest
float
Returns
GetOrInsertTexture(AssetLocation, out int, out TextureAtlasPosition, CreateTextureDelegate, float)
Same as InsertTexture(IBitmap, out int, out TextureAtlasPosition, float) but this method remembers the inserted texure, which you can access using capi.TextureAtlas[path] A subsequent call to this method will update the texture, but retain the same texPos. Also a run-time texture reload will reload this texture automatically.
bool GetOrInsertTexture(AssetLocation path, out int textureSubId, out TextureAtlasPosition texPos, CreateTextureDelegate onCreate = null, float alphaTest = 0)
Parameters
path
AssetLocationUsed as reference for caching
textureSubId
inttexPos
TextureAtlasPositiononCreate
CreateTextureDelegateThe method that should load the bitmap, if required. Can be left null to simply attempt to load the bmp from
path
using method LoadCompositeBitmap(AssetLocationAndSource)alphaTest
float
Returns
- bool
False if the file was not found or the insert failed
GetOrInsertTexture(AssetLocationAndSource, out int, out TextureAtlasPosition, CreateTextureDelegate, float)
Same as InsertTexture(IBitmap, out int, out TextureAtlasPosition, float) but this method remembers the inserted texure, which you can access using capi.TextureAtlas[path] A subsequent call to this method will update the texture, but retain the same texPos. Also a run-time texture reload will reload this texture automatically.
bool GetOrInsertTexture(AssetLocationAndSource path, out int textureSubId, out TextureAtlasPosition texPos, CreateTextureDelegate onCreate = null, float alphaTest = 0)
Parameters
path
AssetLocationAndSourceUsed as reference for caching
textureSubId
inttexPos
TextureAtlasPositiononCreate
CreateTextureDelegateThe method that should load the bitmap, if required. Can be left null to simply attempt to load the bmp from
path
using method LoadCompositeBitmap(AssetLocationAndSource)alphaTest
float
Returns
- bool
False if the file was not found or the insert failed
GetRandomColor(int)
Returns an rgba value picked randomly inside the given texture (defined by its sub-id)
int GetRandomColor(int textureSubId)
Parameters
textureSubId
int
Returns
GetRandomColor(int, int)
Returns one of 30 random rgba values inside the given texture (defined by its sub-id)
int GetRandomColor(int textureSubId, int rndIndex)
Parameters
textureSubId
intrndIndex
int0..29 for a specific random pixel, or -1 to randomize, which is the same as calling GetRandomColor without the rndIndex argument
Returns
GetRandomColor(TextureAtlasPosition, int)
Returns one of 30 random rgba values inside the given texture (defined by its sub-id)
int GetRandomColor(TextureAtlasPosition texPos, int rndIndex)
Parameters
texPos
TextureAtlasPositionrndIndex
int0..29 for a specific random pixel, or -1 to randomize, which is the same as calling GetRandomColor without the rndIndex argument
Returns
GetRandomColors(TextureAtlasPosition)
Get the random colors array for the specified TextureAtlasPosition, creating it if necessary
int[] GetRandomColors(TextureAtlasPosition texPos)
Parameters
texPos
TextureAtlasPosition
Returns
- int[]
InsertTexture(byte[], out int, out TextureAtlasPosition, float)
Inserts a texture into the texture atlas after the atlas has been generated. Updates the in-ram texture atlas as well as the in-gpu-ram texture atlas. The textureSubId can be used to find the TextureAtlasPosition again in case you loose it ;-)
bool InsertTexture(byte[] pngBytes, out int textureSubId, out TextureAtlasPosition texPos, float alphaTest = 0)
Parameters
pngBytes
byte[]textureSubId
inttexPos
TextureAtlasPositionalphaTest
float
Returns
InsertTexture(IBitmap, out int, out TextureAtlasPosition, float)
Inserts a texture into the texture atlas after the atlas has been generated. Updates the in-ram texture atlas as well as the in-gpu-ram texture atlas. The textureSubId can be used to find the TextureAtlasPosition again in case you loose it ;-)
bool InsertTexture(IBitmap bmp, out int textureSubId, out TextureAtlasPosition texPos, float alphaTest = 0)
Parameters
bmp
IBitmaptextureSubId
inttexPos
TextureAtlasPositionalphaTest
float
Returns
InsertTextureCached(AssetLocation, byte[], out int, out TextureAtlasPosition, float)
Same as InsertTexture(IBitmap, out int, out TextureAtlasPosition, float) but this method remembers the inserted texure, which you can access using capi.TextureAtlas[path] A subsequent call to this method will update the texture, but retain the same texPos. Also a run-time texture reload will reload this texture automatically.
bool InsertTextureCached(AssetLocation path, byte[] pngBytes, out int textureSubId, out TextureAtlasPosition texPos, float alphaTest = 0)
Parameters
path
AssetLocationpngBytes
byte[]textureSubId
inttexPos
TextureAtlasPositionalphaTest
float
Returns
InsertTextureCached(AssetLocation, IBitmap, out int, out TextureAtlasPosition, float)
Same as InsertTexture(IBitmap, out int, out TextureAtlasPosition, float) but this method remembers the inserted texure, which you can access using capi.TextureAtlas[path] A subsequent call to this method will update the texture, but retain the same texPos. Also a run-time texture reload will reload this texture automatically.
[Obsolete("Use GetOrInsertTexture() instead. It's more efficient to load the bmp only if the texture was not found in the cache")]
bool InsertTextureCached(AssetLocation path, IBitmap bmp, out int textureSubId, out TextureAtlasPosition texPos, float alphaTest = 0)
Parameters
path
AssetLocationbmp
IBitmaptextureSubId
inttexPos
TextureAtlasPositionalphaTest
float
Returns
LoadCompositeBitmap(AssetLocationAndSource)
Loads a bitmap from given asset. Can use ++ syntax for texture overlay and @[int] for texture rotation
IBitmap LoadCompositeBitmap(AssetLocationAndSource path)
Parameters
Returns
RegenMipMaps(int)
Regenerates the mipmaps for one of the atlas textures, given by its array index
void RegenMipMaps(int atlasIndex)
Parameters
atlasIndex
int
RenderTextureIntoAtlas(int, LoadedTexture, float, float, float, float, float, float, float)
Renders given texture into the texture atlas at given location
void RenderTextureIntoAtlas(int intoAtlasTextureId, LoadedTexture fromTexture, float sourceX, float sourceY, float sourceWidth, float sourceHeight, float targetX, float targetY, float alphaTest = 0.005)