class
Sprite
Generates geometry and contains information needed for rendering a two dimensional element.
Public
Constructors
Sprite
Methods
~Sprite
GetBounds
Returns clipped bounds of the sprite.
- offset
- Offset that will be added to the returned bounds.
- clipRect
- Local clip rect that is used for clipping the sprite bounds. (Clipping is done before the offset is applied). If clip rect width or height is zero, no clipping is done.
Returns: Clipped sprite bounds.
GetRenderElementCount
Returns the number of separate render elements in the sprite.
Normally this is 1, but some sprites may consist of multiple materials, in which case each will require its own mesh (render element)
Returns: The number render elements.
GetRenderElement
Copies the internal render element information into the provided object.
Note the pointers to vertex/index buffers continue to be owned by the Sprite. You must not manually free them. They will be valid until the sprite is destroyed, or until sprite is updated with new data or its mesh data is explicitly cleared, at which point you must no longer use them.
FillBuffer
Fill the pre-allocated vertex, uv and index buffers with the mesh data for the specified render element.
- outVertices
- Previously allocated buffer where to store the vertices.
- outUv
- Previously allocated buffer where to store the uv coordinates.
- outIndices
- Previously allocated buffer where to store the indices.
- vertexOffset
- At which vertex should the method start filling the buffer.
- indexOffset
- At which index should the method start filling the buffer.
- maxVertexCount
- Total number of vertices the buffers were allocated for. Used only for memory safety.
- maxIndexCount
- Total number of indices the buffers were allocated for. Used only for memory safety.
- vertexStride
- Number of bytes between of vertices in the provided vertex and uv data.
- indexStride
- Number of bytes between two indexes in the provided index data.
- renderElementIndex
- Zero-based index of the render element.
- offset
- Position offset to apply to all vertices, after clipping.
- clipRect
- Rectangle to clip the vertices to.
- clip
- Should the vertices be clipped to the provided .
staticClipQuadsToRect
Clips the provided 2D vertices to the provided clip rectangle.
The vertices must form axis aligned quads.
- outVertices
- Pointer to the start of the buffer containing vertex positions.
- outUv
- Pointer to the start of the buffer containing UV coordinates.
- quadCount
- Number of quads in the provided buffer pointers.
- vertexStride
- Number of bytes to skip when going to the next vertex. This assumes both position and uv coordinates have the same stride (as they are likely pointing to the same buffer).
- clipRect
- Rectangle to clip the geometry to.
staticClipQuadsToRectangle
Clips the provided 2D vertices to the provided clip rectangle.
The vertices must form axis aligned quads.
- vertices
- Buffer containing vertex positions to clip.
- uv
- Buffer containing UV positions to clip.
- quadCount
- Number of quads to clip.
- startVertexIndex
- Offset into vertex/uv buffers at which to start clipping.
- clipRectangle
- Rectangle to clip the geometry to.
staticClipTrianglesToRect
Clips the provided 2D vertices to the provided clip rectangle.
The vertices can be arbitrary triangles.
- vertices
- Pointer to the start of the buffer containing vertex positions.
- uv
- Pointer to the start of the buffer containing UV coordinates. Can be null if UV is not needed.
- triangleCount
- Number of triangles in the provided buffer pointers.
- vertexStride
- Number of bytes to skip when going to the next vertex. This assumes both position and uv coordinates have the same stride (as they are likely pointing to the same buffer).
- clipRect
- Rectangle to clip the geometry to.
- writeCallback
- Callback that will be triggered when clipped vertices and UV coordinates are generated and need to be stored. Vertices are always generate in tuples of three, forming a single triangle.
Protected
Methods
staticGetAnchorOffset
Returns the offset needed to move the sprite in order for it to respect the provided anchor.
UpdateBounds
Calculates the bounds of all sprite vertices.