Table of Contents

Class UniformTextureAtlas

Namespace
MLEM.Textures
Assembly
MLEM.dll

This class represents an atlas of TextureRegion objects that is uniform. Uniform, in this case, means that the texture atlas' size is not determined by the width and height of the texture, but instead by the amount of sub-regions that the atlas has in the x and y direction. Using a uniform texture atlas over a regular texture as an atlas allows for texture artists to create higher resolution textures without coordinates becoming off.

public class UniformTextureAtlas : GenericDataHolder, IGenericDataHolder
Inheritance
UniformTextureAtlas
Implements
Inherited Members

Constructors

UniformTextureAtlas(TextureRegion, int, int, int)

Creates a new uniform texture atlas with the given texture region and region amount. This atlas will only ever pull information from the given TextureRegion and never exit the region's bounds.

public UniformTextureAtlas(TextureRegion region, int regionAmountX, int regionAmountY, int regionPadding = 0)

Parameters

region TextureRegion

The texture region to use for this atlas

regionAmountX int

The amount of texture regions in the x direction

regionAmountY int

The amount of texture regions in the y direction

regionPadding int

The padding that each texture region has around itself, in pixels, which will be taken away from each side of TextureRegion objects created and returned by this texture atlas.

UniformTextureAtlas(Texture2D, int, int, int)

Creates a new uniform texture atlas with the given texture and region amount.

public UniformTextureAtlas(Texture2D texture, int regionAmountX, int regionAmountY, int regionPadding = 0)

Parameters

texture Texture2D

The texture to use for this atlas

regionAmountX int

The amount of texture regions in the x direction

regionAmountY int

The amount of texture regions in the y direction

regionPadding int

The padding that each texture region has around itself, in pixels, which will be taken away from each side of TextureRegion objects created and returned by this texture atlas.

Fields

Region

The TextureRegion that this uniform texture atlas uses as its basis. In most cases, Region has the full area of the underlying Texture.

public readonly TextureRegion Region

Field Value

TextureRegion

RegionAmountX

The amount of sub-regions this atlas has in the x direction

public readonly int RegionAmountX

Field Value

int

RegionAmountY

The amount of sub-regions this atlas has in the y direction

public readonly int RegionAmountY

Field Value

int

RegionHeight

The height of reach region, based on the texture's height and the amount of regions

public readonly int RegionHeight

Field Value

int

RegionPadding

The padding that each texture region has around itself, in pixels, which will be taken away from each side of TextureRegion objects created and returned by this texture atlas. Creating a texture atlas with padding can be useful if texture bleeding issues occur due to texture coordinate rounding.

public readonly int RegionPadding

Field Value

int

RegionWidth

The width of each region, based on the texture's width and the amount of regions

public readonly int RegionWidth

Field Value

int

Properties

this[Point]

Returns the TextureRegion at this texture atlas' given region position

public TextureRegion this[Point point] { get; }

Parameters

point Point

The region's x and y location

Property Value

TextureRegion

this[Rectangle]

Returns the TextureRegion at this texture atlas' given region position and size. Note that the region size is not in pixels, but in region units.

public TextureRegion this[Rectangle rect] { get; }

Parameters

rect Rectangle

The region's area

Property Value

TextureRegion

this[int]

Returns the TextureRegion at this texture atlas's given index. The index is zero-based, where rows come first and columns come second.

public TextureRegion this[int index] { get; }

Parameters

index int

The zero-based texture index

Property Value

TextureRegion

this[int, int]

Returns the TextureRegion at this texture atlas' given region position

public TextureRegion this[int x, int y] { get; }

Parameters

x int
y int

Property Value

TextureRegion

this[int, int, int, int]

Returns the TextureRegion at this texture atlas' given region position and size. Note that the region size is not in pixels, but in region units.

public TextureRegion this[int x, int y, int width, int height] { get; }

Parameters

x int
y int
width int
height int

Property Value

TextureRegion

Texture

The texture to use for this atlas. Note that Region stores the actual area that we depend on.

public Texture2D Texture { get; }

Property Value

Texture2D

Methods

ToDictionary()

Converts this uniform texture atlas to a Dictionary<TKey, TValue> and returns the result. The resulting dictionary will contain all square 1x1 regions that this uniform texture atlas contains, based on RegionAmountX and RegionAmountY, wich each key containing the TextureRegion at this[Point].

public Dictionary<Point, TextureRegion> ToDictionary()

Returns

Dictionary<Point, TextureRegion>

The dictionary representation of this uniform texture atlas.

ToList()

Converts this uniform texture atlas to a List<T> and returns the result. The resulting list will contain all square 1x1 regions that this uniform texture atlas contains, based on RegionAmountX and RegionAmountY, with each index containing the TextureRegion at this[int].

public List<TextureRegion> ToList()

Returns

List<TextureRegion>

The list representation of this uniform texture atlas.