Detailed Description

Represents the location of an image on an atlas.

Inheritance diagram for Blaze.AtlasLocation:
Blaze.UVBlock

Public Member Functions

 AtlasLocation (TextureAtlas atlas, int x, int y, int width, int height)
 Creates a new location on the given atlas with the given size. More...
 
 AtlasLocation (int x, int y, int width, int height, float imageWidth, float imageHeight)
 Creates a new atlas location without an atlas. More...
 
 AtlasLocation (float imageWidth, float imageHeight)
 A fixed atlas location with 0->1 UV's. More...
 
void UpdateFixed (float imageWidth, float imageHeight)
 Updates a fixed image location. More...
 
void PreventDeallocation ()
 Blocks this location from ever getting deallocated from being no longer "in use". More...
 
bool DecreaseUsage ()
 Called when an instance of the image goes offscreen. More...
 
void Deselect ()
 Empties this location and frees it up for use by other textures. More...
 
void AddToEmptySet ()
 Adds this location to the set of empty locations on the atlas. This allows other textures to use this space on the atlas. More...
 
int FitFactor (int width, int height, int area)
 A value which represents how well the given image dimensions fit in this location. Select the location with this as close to zero as possible. It's essentially pixels wasted using this location. More...
 
void Select (AtlasEntity image, int width, int height, int spacing)
 This texture has selected this location to fit into. This adds it to the atlas. More...
 
void OptimiseSelect (AtlasLocation location)
 Used during the optimise process. This texture has selected this location to fit into. This adds it to the atlas. More...
 
float GetU (float atPixel)
 Gets the horizontal component of the UV co-ordinate of the given pixel. More...
 
float GetV (float atPixel)
 Gets the vertical component of the UV co-ordinate of the given pixel. More...
 
int BottomLeftPixel ()
 The index in the atlas of the pixel in the bottom left corner of this location. More...
 
int RowPixelDelta ()
 How many pixels should be gained to go up one row of pixels in the global atlas. More...
 
int AtlasIndex (int x, int y)
 Converts a local pixel coordinate into a global atlas pixel index. More...
 
void Flush ()
 Writes the texture to the pixels of the atlas. More...
 
void AtlasChanged ()
 
- Public Member Functions inherited from Blaze.UVBlock
 UVBlock ()
 
 UVBlock (UVBlock copy)
 
 UVBlock (float minX, float maxX, float minY, float maxY)
 
void Write (Vector2[] buffer, int index)
 Writes out this block of UV's to the given buffer. More...
 
override string ToString ()
 

Public Attributes

int UsageCount
 The number of times this location is in use. More...
 
AtlasLocation EmptyAfter
 If this location is empty (texture was removed), it's stored in a linked list. This is the element after this one in the list. More...
 
AtlasLocation EmptyBefore
 If this location is empty (texture was removed), it's stored in a linked list. This is the element before this one in the list. More...
 
int X
 The x coord in pixels of the left edge of the image from the left of the atlas. More...
 
int Y
 The y coord in pixels of the bottom edge of the image from the bottom of the atlas. More...
 
int Area
 The area of this image (width*height). More...
 
int Width
 The width of the image in pixels. More...
 
int Height
 The height of the image in pixels. More...
 
bool Empty
 True if the texture in this location has been removed and it is now empty. More...
 
AtlasEntity Image
 The image stored at this atlas location. More...
 
int AtlasID
 The ID of the entity stored in this location. Same as Image.GetAtlasID(). More...
 
TextureAtlas Atlas
 The atlas this location is on. More...
 
float InvertedSizeX
 1/the atlas width. More...
 
float InvertedSizeY
 1/the atlas height. More...
 
int Spacing
 Active spacing on this location. More...
 
- Public Attributes inherited from Blaze.UVBlock
float MinX
 The min UV x coordinate. More...
 
float MinY
 The min UV y coordinate. More...
 
float MaxX
 The max UV x coordinate. More...
 
float MaxY
 The max UV y coordinate. More...
 

Properties

override bool Shared [get]
 True if this UV block is a globally shared one. More...
 
- Properties inherited from Blaze.UVBlock
virtual bool Shared [get]
 True if this UV block is a globally shared one. More...
 

Private Member Functions

void BakeUV ()
 Figures out where the UV's are. Note: stored as Min and Max because it's most useful for rendering and memory usage. More...
 

Constructor & Destructor Documentation

Blaze.AtlasLocation.AtlasLocation ( TextureAtlas  atlas,
int  x,
int  y,
int  width,
int  height 
)
inline

Creates a new location on the given atlas with the given size.

Parameters
atlasThe atlas this location refers to.
xThe x coordinate of the left edge of this location in pixels from the left.
yThe y coordinate of the bototm edfe of this location in pixels from the bottom.
widthThe width of the location in pixels.
heightThe height of the location in pixels.
Blaze.AtlasLocation.AtlasLocation ( int  x,
int  y,
int  width,
int  height,
float  imageWidth,
float  imageHeight 
)
inline

Creates a new atlas location without an atlas.

Parameters
xThe x coordinate of the left edge of this location in pixels from the left.
yThe y coordinate of the bototm edfe of this location in pixels from the bottom.
widthThe width of the location in pixels.
heightThe height of the location in pixels.
imageWidthThe width of the atlas.
imageHeightThe height of the atlas.
Blaze.AtlasLocation.AtlasLocation ( float  imageWidth,
float  imageHeight 
)
inline

A fixed atlas location with 0->1 UV's.

Member Function Documentation

void Blaze.AtlasLocation.AddToEmptySet ( )
inline

Adds this location to the set of empty locations on the atlas. This allows other textures to use this space on the atlas.

void Blaze.AtlasLocation.AtlasChanged ( )
inline
int Blaze.AtlasLocation.AtlasIndex ( int  x,
int  y 
)
inline

Converts a local pixel coordinate into a global atlas pixel index.

Parameters
xThe x coordinate of the pixel in pixels from the left edge.
yThe y coordinate of the pixel in pixels from the bottom edge.
Returns
The index in the atlas.
void Blaze.AtlasLocation.BakeUV ( )
inlineprivate

Figures out where the UV's are. Note: stored as Min and Max because it's most useful for rendering and memory usage.

int Blaze.AtlasLocation.BottomLeftPixel ( )
inline

The index in the atlas of the pixel in the bottom left corner of this location.

Returns
The index in the atlas.
bool Blaze.AtlasLocation.DecreaseUsage ( )
inline

Called when an instance of the image goes offscreen.

Returns
True if this location is now completely unused.
void Blaze.AtlasLocation.Deselect ( )
inline

Empties this location and frees it up for use by other textures.

int Blaze.AtlasLocation.FitFactor ( int  width,
int  height,
int  area 
)
inline

A value which represents how well the given image dimensions fit in this location. Select the location with this as close to zero as possible. It's essentially pixels wasted using this location.

Parameters
widthThe width of what you want to fit in this location.
heightThe height of what you want to fit in this location.
areawidth*height.
Returns
A number that should be as close to zero as possible.
void Blaze.AtlasLocation.Flush ( )
inline

Writes the texture to the pixels of the atlas.

float Blaze.AtlasLocation.GetU ( float  atPixel)
inline

Gets the horizontal component of the UV co-ordinate of the given pixel.

Parameters
atPixelThe pixel on the atlas to use.
Returns
The value as a float from 0->1.
float Blaze.AtlasLocation.GetV ( float  atPixel)
inline

Gets the vertical component of the UV co-ordinate of the given pixel.

Parameters
atPixelThe pixel on the atlas to use.
Returns
The value as a float from 0->1.
void Blaze.AtlasLocation.OptimiseSelect ( AtlasLocation  location)
inline

Used during the optimise process. This texture has selected this location to fit into. This adds it to the atlas.

Parameters
locationThe new location to write this region to.
void Blaze.AtlasLocation.PreventDeallocation ( )
inline

Blocks this location from ever getting deallocated from being no longer "in use".

int Blaze.AtlasLocation.RowPixelDelta ( )
inline

How many pixels should be gained to go up one row of pixels in the global atlas.

Returns
The number of pixels.
void Blaze.AtlasLocation.Select ( AtlasEntity  image,
int  width,
int  height,
int  spacing 
)
inline

This texture has selected this location to fit into. This adds it to the atlas.

Parameters
textureThe texture that wants to go here.
widthThe width of the texture in pixels.
heightThe height of the texture in pixels.
void Blaze.AtlasLocation.UpdateFixed ( float  imageWidth,
float  imageHeight 
)
inline

Updates a fixed image location.

Member Data Documentation

int Blaze.AtlasLocation.Area

The area of this image (width*height).

TextureAtlas Blaze.AtlasLocation.Atlas

The atlas this location is on.

int Blaze.AtlasLocation.AtlasID

The ID of the entity stored in this location. Same as Image.GetAtlasID().

bool Blaze.AtlasLocation.Empty

True if the texture in this location has been removed and it is now empty.

AtlasLocation Blaze.AtlasLocation.EmptyAfter

If this location is empty (texture was removed), it's stored in a linked list. This is the element after this one in the list.

AtlasLocation Blaze.AtlasLocation.EmptyBefore

If this location is empty (texture was removed), it's stored in a linked list. This is the element before this one in the list.

int Blaze.AtlasLocation.Height

The height of the image in pixels.

AtlasEntity Blaze.AtlasLocation.Image

The image stored at this atlas location.

float Blaze.AtlasLocation.InvertedSizeX

1/the atlas width.

float Blaze.AtlasLocation.InvertedSizeY

1/the atlas height.

int Blaze.AtlasLocation.Spacing

Active spacing on this location.

int Blaze.AtlasLocation.UsageCount

The number of times this location is in use.

int Blaze.AtlasLocation.Width

The width of the image in pixels.

int Blaze.AtlasLocation.X

The x coord in pixels of the left edge of the image from the left of the atlas.

int Blaze.AtlasLocation.Y

The y coord in pixels of the bottom edge of the image from the bottom of the atlas.

Property Documentation

override bool Blaze.AtlasLocation.Shared
get

True if this UV block is a globally shared one.