Class Atlas

java.lang.Object
org.xjge.graphics.Atlas

public final class Atlas
extends java.lang.Object
Represents a texture atlas (or sprite sheet) that will provide the texture coordinates of sub-images within a larger Texture.

More specifically the data provided by this object includes:

  • The number of rows and columns the texture image was divided into.
  • The number of sub-images (or cells) the atlas contains.
  • The dimensions of a single sub-image cell as texture coordinates.
  • A collection containing the texture coordinates of every sub-image cell.
Since:
2.0.0
  • Field Summary

    Fields
    Modifier and Type Field Description
    int cellHeight  
    int cellWidth  
    int columns  
    int rows  
    int subImageCount  
    float subImageHeight
    The size (in texture coordinates) of a single sub-image cell.
    java.util.Map<org.joml.Vector2i,​org.joml.Vector2f> subImageOffsets
    A collection that couples the cell locations of sub-images to their corresponding coordinates within the texture.
    float subImageWidth
    The size (in texture coordinates) of a single sub-image cell.
    org.joml.Vector2f texCoords  
  • Constructor Summary

    Constructors
    Constructor Description
    Atlas​(Texture texture, int cellWidth, int cellHeight)
    Supplies the data generated from a texture and cell dimensions as a texture atlas.
  • Method Summary

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • cellWidth

      public final int cellWidth
    • cellHeight

      public final int cellHeight
    • rows

      public final int rows
    • columns

      public final int columns
    • subImageCount

      public final int subImageCount
    • subImageWidth

      public final float subImageWidth
      The size (in texture coordinates) of a single sub-image cell. This information is useful in the event the atlas is used in a SpriteAnimation where consecutive frames are placed next to one another.
    • subImageHeight

      public final float subImageHeight
      The size (in texture coordinates) of a single sub-image cell. This information is useful in the event the atlas is used in a SpriteAnimation where consecutive frames are placed next to one another.
    • texCoords

      public final org.joml.Vector2f texCoords
    • subImageOffsets

      public final java.util.Map<org.joml.Vector2i,​org.joml.Vector2f> subImageOffsets
      A collection that couples the cell locations of sub-images to their corresponding coordinates within the texture.
  • Constructor Details

    • Atlas

      public Atlas​(Texture texture, int cellWidth, int cellHeight)
      Supplies the data generated from a texture and cell dimensions as a texture atlas.

      NOTE: The dimensions of the texture should be evenly divisible by the cell width and height.

      Parameters:
      texture - the texture image to use
      cellWidth - the width of each sub-image cell in pixels
      cellHeight - the height of each sub-image cell in pixels