nCine::MeshSprite class

A scene node representing a mesh with vertices and UVs.

Base classes

class BaseSprite
Base class for sprites.

Public types

struct Vertex
Vertex data for the mesh.
struct VertexNoTexture
Vertex data for the mesh when no texture is specified.
enum class TextureCutMode { RESIZE, CROP }

Public static variables

static const std::uint32_t VertexBytes
static const std::uint32_t VertexFloats
static const std::uint32_t VertexNoTextureBytes
static const std::uint32_t VertexNoTextureFloats

Public static functions

static auto sType() -> ObjectType

Constructors, destructors, conversion operators

MeshSprite()
Default constructor for a sprite with no parent and no texture, positioned in the origin.
MeshSprite(SceneNode* parent, Texture* texture)
Constructor for a sprite with a parent and texture, positioned in the relative origin.
MeshSprite(Texture* texture) explicit
Constructor for a sprite with a texture but no parent, positioned in the origin.
MeshSprite(SceneNode* parent, Texture* texture, float xx, float yy)
Constructor for a sprite with a parent, a texture and a specified relative position.
MeshSprite(SceneNode* parent, Texture* texture, Vector2f position)
Constructor for a sprite with a parent, a texture and a specified relative position as a vector.
MeshSprite(Texture* texture, float xx, float yy)
Constructor for a sprite with a texture and a specified position but no parent.
MeshSprite(Texture* texture, Vector2f position)
Constructor for a sprite with a texture and a specified position as a vector but no parent.
MeshSprite(MeshSprite&&) defaulted
MeshSprite(const MeshSprite& other) protected
Protected copy constructor used to clone objects.

Public functions

auto operator=(const MeshSprite&) -> MeshSprite& deleted
auto operator=(MeshSprite&&) -> MeshSprite& defaulted
auto clone() const -> MeshSprite
Returns a copy of this object.
auto bytesPerVertex() const -> std::uint32_t
Returns the number of bytes used by each vertex.
auto numVertices() const -> std::uint32_t
Returns the number of vertices of the sprite mesh.
auto numBytes() const -> std::uint32_t
Returns the total number of bytes used by all sprite's vertices.
auto vertices() const -> const float*
Returns the vertices data of the sprite mesh.
auto uniqueVertices() const -> bool
Returns true if the vertices belong to the sprite and are not stored externally.
void copyVertices(std::uint32_t numVertices, std::uint32_t bytesPerVertex, const void* vertexData)
Copies the vertices data with a custom format from a pointer into the sprite.
void copyVertices(std::uint32_t numVertices, const Vertex* vertices)
Copies the vertices data from a pointer into the sprite.
void copyVertices(std::uint32_t numVertices, const VertexNoTexture* vertices)
Copies the vertices data from a pointer into the sprite (no texture version)
void copyVertices(const MeshSprite& meshSprite)
Copies the vertices data from another sprite and sets the same size.
void setVertices(std::uint32_t numVertices, std::uint32_t bytesPerVertex, const void* vertexData)
Sets the vertices data to point to an external array with a custom format.
void setVertices(std::uint32_t numVertices, const Vertex* vertices)
Sets the vertices data to point to an external array.
void setVertices(std::uint32_t numVertices, const VertexNoTexture* vertices)
Sets the vertices data to point to an external array (no texture version)
void setVertices(const MeshSprite& meshSprite)
Sets the vertices data to the data used by another sprite and sets the same size.
auto emplaceVertices(std::uint32_t numElements, std::uint32_t bytesPerVertex) -> float*
Returns the internal vertices data, cleared and set to the required size (custom format version)
auto emplaceVertices(std::uint32_t numElements) -> float*
Returns the internal vertices data, cleared and set to the required size.
void createVerticesFromTexels(std::uint32_t numVertices, const Vector2f* points, TextureCutMode cutMode)
Creates an internal set of vertices from an external array of points in texture space, with optional texture cut mode.
void createVerticesFromTexels(std::uint32_t numVertices, const Vector2f* points)
Creates an internal set of vertices from an external array of points in texture space.
auto numIndices() const -> std::uint32_t
Returns the number of indices used to draw the sprite mesh.
auto indices() const -> const std::uint16_t*
Returns the indices used to draw the sprite mesh.
auto uniqueIndices() const -> bool
Returns true if the indices belong to the sprite and are not stored externally.
void copyIndices(std::uint32_t numIndices, const std::uint16_t* indices)
Copies the indices from a pointer into the sprite.
void copyIndices(const MeshSprite& meshSprite)
Copies the indices from another sprite.
void setIndices(std::uint32_t numIndices, const std::uint16_t* indices)
Sets the indices data to point to an external array.
void setIndices(const MeshSprite& meshSprite)
Sets the indices data to the data used by another sprite.
auto emplaceIndices(std::uint32_t numIndices) -> std::uint16_t*
Returns the internal indices data, cleared and set to the required size.

Private functions

void shaderHasChanged() override
Performs the required tasks upon a change to the shader.
void textureHasChanged(Texture* newTexture) override
Performs the required tasks upon a change to the texture.