Magnum::Trade::MeshData3D class

Three-dimensional mesh data.

Provides access to mesh data and additional information, such as primitive type.

It's possible to use MeshTools::transformPointsInPlace() and MeshTools::transformVectorsInPlace() to do transformations on the stored vertex data. For example, baking a particular translation + rotation directly to positions and normals:

Matrix4 transformation =
    Matrix4::translation({3.0f, 1.5f, -2.0f})*
    Matrix4::rotationX(45.0_degf);
MeshTools::transformPointsInPlace(transformation, data.positions(0));
MeshTools::transformVectorsInPlace(transformation, data.normals(0));

Constructors, destructors, conversion operators

MeshData3D(MeshPrimitive primitive, std::vector<UnsignedInt> indices, std::vector<std::vector<Vector3>> positions, std::vector<std::vector<Vector3>> normals, std::vector<std::vector<Vector2>> textureCoords2D, std::vector<std::vector<Color4>> colors, const void* importerState = nullptr) explicit
Constructor.
MeshData3D(const MeshData& other) deprecated in 2020.06
Construct from MeshData.
MeshData3D(const MeshData3D&) deleted
Copying is not allowed.
MeshData3D(MeshData3D&&) noexcept
Move constructor.

Public functions

auto operator=(const MeshData3D&) -> MeshData3D& deleted
Copying is not allowed.
auto operator=(MeshData3D&&) -> MeshData3D& noexcept
Move assignment.
auto primitive() const -> MeshPrimitive
Primitive.
auto isIndexed() const -> bool
Whether the mesh is indexed.
auto indices() -> std::vector<UnsignedInt>&
Indices.
auto indices() const -> const std::vector<UnsignedInt>&
auto positionArrayCount() const -> UnsignedInt
Count of position arrays.
auto positions(UnsignedInt id) -> std::vector<Vector3>&
Positions.
auto positions(UnsignedInt id) const -> const std::vector<Vector3>&
auto hasNormals() const -> bool
Whether the data contain any normals.
auto normalArrayCount() const -> UnsignedInt
Count of normal arrays.
auto normals(UnsignedInt id) -> std::vector<Vector3>&
Normals.
auto normals(UnsignedInt id) const -> const std::vector<Vector3>&
auto hasTextureCoords2D() const -> bool
Whether the data contain any 2D texture coordinates.
auto textureCoords2DArrayCount() const -> UnsignedInt
Count of 2D texture coordinate arrays.
auto textureCoords2D(UnsignedInt id) -> std::vector<Vector2>&
2D texture coordinates
auto textureCoords2D(UnsignedInt id) const -> const std::vector<Vector2>&
auto hasColors() const -> bool
Whether the data contain any vertex colors.
auto colorArrayCount() const -> UnsignedInt
Count of color arrays.
auto colors(UnsignedInt id) -> std::vector<Color4>&
Vertex colors.
auto colors(UnsignedInt id) const -> const std::vector<Color4>&
auto importerState() const -> const void*
Importer-specific state.

Function documentation

Magnum::Trade::MeshData3D::MeshData3D(MeshPrimitive primitive, std::vector<UnsignedInt> indices, std::vector<std::vector<Vector3>> positions, std::vector<std::vector<Vector3>> normals, std::vector<std::vector<Vector2>> textureCoords2D, std::vector<std::vector<Color4>> colors, const void* importerState = nullptr) explicit

Constructor.

Parameters
primitive Primitive
indices Index array or empty array, if the mesh is not indexed
positions Position arrays. At least one position array should be present.
normals Normal arrays, if present
textureCoords2D Two-dimensional texture coordinate arrays, if present
colors Vertex color arrays, if present
importerState Importer-specific state

Magnum::Trade::MeshData3D::MeshData3D(const MeshData& other)

Construct from MeshData.

std::vector<UnsignedInt>& Magnum::Trade::MeshData3D::indices()

Indices.

const std::vector<UnsignedInt>& Magnum::Trade::MeshData3D::indices() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

UnsignedInt Magnum::Trade::MeshData3D::positionArrayCount() const

Count of position arrays.

There is always at least one.

std::vector<Vector3>& Magnum::Trade::MeshData3D::positions(UnsignedInt id)

Positions.

Parameters
id Position array ID

const std::vector<Vector3>& Magnum::Trade::MeshData3D::positions(UnsignedInt id) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::vector<Vector3>& Magnum::Trade::MeshData3D::normals(UnsignedInt id)

Normals.

Parameters
id Normal array ID

const std::vector<Vector3>& Magnum::Trade::MeshData3D::normals(UnsignedInt id) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::vector<Vector2>& Magnum::Trade::MeshData3D::textureCoords2D(UnsignedInt id)

2D texture coordinates

Parameters
id Texture coordinate array ID

const std::vector<Vector2>& Magnum::Trade::MeshData3D::textureCoords2D(UnsignedInt id) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

std::vector<Color4>& Magnum::Trade::MeshData3D::colors(UnsignedInt id)

Vertex colors.

Parameters
id Vertex color array ID

const std::vector<Color4>& Magnum::Trade::MeshData3D::colors(UnsignedInt id) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const void* Magnum::Trade::MeshData3D::importerState() const

Importer-specific state.

See AbstractImporter::importerState() for more information.