namespace
MeshToolsMesh tools.
Tools for generating, optimizing and cleaning meshes.
This library is built if MAGNUM_WITH_MESHTOOLS
is enabled when building Magnum. To use this library with CMake, request the MeshTools
component of the Magnum
package and link to the Magnum::MeshTools
target:
find_package(Magnum REQUIRED MeshTools) # ... target_link_libraries(your-app PRIVATE Magnum::MeshTools)
Note that functionality depending on GL APIs is available only if Magnum is built with both MAGNUM_WITH_GL
and MAGNUM_TARGET_GL
enabled (which is done by default).
See Downloading and building and Usage with CMake for more information.
Enums
- enum class CompileFlag: UnsignedByte { GenerateFlatNormals = 1 << 0, GenerateSmoothNormals = 1 << 1, NoWarnOnCustomAttributes = 1 << 2 new in 2020.06 } new in 2019.10
- Mesh compilation flag.
- enum class InterleaveFlag: UnsignedInt { PreserveInterleavedAttributes = 1 << 0, PreserveStridedIndices = 1 << 1 } new in Git master
- Interleaving behavior flag.
Typedefs
-
using CompileFlags = Containers::
EnumSet<CompileFlag> new in 2019.10 - Mesh compilation flags.
-
using InterleaveFlags = Containers::
EnumSet<InterleaveFlag> new in Git master - Interleaving behavior flags.
Functions
-
auto boundingRange(const Containers::
StridedArrayView1D<const Vector3>& positions) -> Range3D new in Git master - Calculate a bounding range.
-
auto boundingSphereBouncingBubble(const Containers::
StridedArrayView1D<const Vector3>& positions) -> Containers:: Pair<Vector3, Float> new in Git master - Calculate an approximate bounding sphere using the Bouncing Bubble algorithm.
-
auto combineIndexedAttributes(const Containers::
Iterable<const Trade:: MeshData>& meshes) -> Trade:: MeshData new in 2020.06 - Combine differently indexed attributes into a single mesh.
-
auto combineFaceAttributes(const Trade::
MeshData& mesh, const Trade:: MeshData& faceAttributes) -> Trade:: MeshData new in 2020.06 - Combine per-face attributes into an existing mesh.
-
auto combineFaceAttributes(const Trade::
MeshData& mesh, Containers:: ArrayView<const Trade:: MeshAttributeData> faceAttributes) -> Trade:: MeshData new in 2020.06 -
auto combineFaceAttributes(const Trade::
MeshData& mesh, std:: initializer_list<Trade:: MeshAttributeData> faceAttributes) -> Trade:: MeshData new in 2020.06 -
auto combineIndexArrays(const std::
vector<std:: reference_wrapper<std:: vector<UnsignedInt>>>& arrays) -> std:: vector<UnsignedInt> deprecated in 2020.06 - Combine index arrays.
-
auto combineIndexArrays(std::
initializer_list<std:: reference_wrapper<std:: vector<UnsignedInt>>> arrays) -> std:: vector<UnsignedInt> deprecated in 2020.06 -
auto combineIndexArrays(const std::
vector<UnsignedInt>& interleavedArrays, UnsignedInt stride) -> std:: pair<std:: vector<UnsignedInt>, std:: vector<UnsignedInt>> deprecated in 2020.06 - Combine interleaved index arrays.
-
template<class ... T>auto combineIndexedArrays(const std::
pair<const std:: vector<UnsignedInt>&, std:: vector<T>&>&... indexedArrays) -> std:: vector<UnsignedInt> deprecated in 2020.06 - Combine indexed arrays.
-
auto compile(const Trade::
MeshData& mesh, CompileFlags flags) -> GL:: Mesh new in 2020.06 - Compile OpenGL mesh data.
-
auto compile(const Trade::
MeshData& mesh) -> GL:: Mesh new in 2020.06 -
auto compile(const Trade::
MeshData& mesh, GL:: Buffer& indices, GL:: Buffer& vertices) -> GL:: Mesh new in 2020.06 - Compile mesh data using external buffers.
-
auto compile(const Trade::
MeshData& mesh, GL:: Buffer& indices, GL:: Buffer&& vertices) -> GL:: Mesh new in 2020.06 -
auto compile(const Trade::
MeshData& mesh, GL:: Buffer&& indices, GL:: Buffer& vertices) -> GL:: Mesh new in 2020.06 -
auto compile(const Trade::
MeshData& mesh, GL:: Buffer&& indices, GL:: Buffer&& vertices) -> GL:: Mesh new in 2020.06 -
auto compile(const Trade::
MeshData2D& meshData) -> GL:: Mesh deprecated in 2020.06 - Compile 2D mesh data.
-
auto compile(const Trade::
MeshData3D& meshData, CompileFlags flags = {}) -> GL:: Mesh deprecated in 2020.06 - Compile 3D mesh data.
-
auto compiledPerVertexJointCount(const Trade::
MeshData& mesh) -> Containers:: Pair<UnsignedInt, UnsignedInt> new in Git master - Compiled per-vertex joint count for given mesh data.
-
auto compileLines(const Trade::
MeshData& mesh) -> GL:: Mesh new in Git master - Compile a line mesh for use with Shaders::
LineGL. -
auto compressIndices(const Containers::
StridedArrayView1D<const UnsignedInt>& indices, MeshIndexType atLeast = MeshIndexType:: UnsignedShort, Long offset = 0) -> Containers:: Pair<Containers:: Array<char>, MeshIndexType> new in 2020.06 - Compress an index array.
-
auto compressIndices(const Containers::
StridedArrayView1D<const UnsignedShort>& indices, MeshIndexType atLeast = MeshIndexType:: UnsignedShort, Long offset = 0) -> Containers:: Pair<Containers:: Array<char>, MeshIndexType> new in 2020.06 -
auto compressIndices(const Containers::
StridedArrayView1D<const UnsignedByte>& indices, MeshIndexType atLeast = MeshIndexType:: UnsignedShort, Long offset = 0) -> Containers:: Pair<Containers:: Array<char>, MeshIndexType> new in 2020.06 -
auto compressIndices(const Containers::
StridedArrayView1D<const UnsignedInt>& indices, Long offset) -> Containers:: Pair<Containers:: Array<char>, MeshIndexType> new in 2020.06 -
auto compressIndices(const Containers::
StridedArrayView1D<const UnsignedShort>& indices, Long offset) -> Containers:: Pair<Containers:: Array<char>, MeshIndexType> new in 2020.06 -
auto compressIndices(const Containers::
StridedArrayView1D<const UnsignedByte>& indices, Long offset) -> Containers:: Pair<Containers:: Array<char>, MeshIndexType> new in 2020.06 -
auto compressIndices(const Containers::
StridedArrayView2D<const char>& indices, MeshIndexType atLeast = MeshIndexType:: UnsignedShort, Long offset = 0) -> Containers:: Pair<Containers:: Array<char>, MeshIndexType> new in 2020.06 - Compress a type-erased index array.
-
auto compressIndices(const Containers::
StridedArrayView2D<const char>& indices, Long offset) -> Containers:: Pair<Containers:: Array<char>, MeshIndexType> new in 2020.06 -
auto compressIndices(const Trade::
MeshData& mesh, MeshIndexType atLeast = MeshIndexType:: UnsignedShort) -> Trade:: MeshData new in 2020.06 - Compress mesh data indices.
-
auto compressIndices(Trade::
MeshData&& mesh, MeshIndexType atLeast = MeshIndexType:: UnsignedShort) -> Trade:: MeshData new in 2020.06 - Compress mesh data indices.
-
auto compressIndices(const std::
vector<UnsignedInt>& indices) -> std:: tuple<Containers:: Array<char>, MeshIndexType, UnsignedInt, UnsignedInt> deprecated in 2020.06 - Compress vertex indices.
-
template<class T>auto compressIndicesAs(const std::
vector<UnsignedInt>& indices) -> Containers:: Array<T> deprecated in 2020.06 - Compress vertex indices as given type.
-
auto concatenate(const Containers::
Iterable<const Trade:: MeshData>& meshes, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in 2020.06 - Concatenate meshes together.
-
template<template<class> class Allocator = Containers::ArrayAllocator>void concatenateInto(Trade::
MeshData& destination, const Containers:: Iterable<const Trade:: MeshData>& meshes, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in 2020.06 - Concatenate a list of meshes into a pre-existing destination, enlarging it if necessary.
-
auto copy(const Trade::
MeshData& mesh) -> Trade:: MeshData new in Git master - Make an owned copy of the mesh.
-
auto copy(Trade::
MeshData&& mesh) -> Trade:: MeshData new in Git master - Make a mesh with owned data.
-
auto reference(const Trade::
MeshData& mesh) -> Trade:: MeshData new in 2020.06 - Create an immutable reference on a Trade::
MeshData. -
auto mutableReference(Trade::
MeshData& mesh) -> Trade:: MeshData new in 2020.06 - Create a mutable reference on a Trade::
MeshData. -
template<class IndexType, class T>auto duplicate(const Containers::
StridedArrayView1D<const IndexType>& indices, const Containers:: StridedArrayView1D<const T>& data) -> Containers:: Array<T> new in 2019.10 - Duplicate data using given index array.
-
template<class T>auto duplicate(const std::
vector<UnsignedInt>& indices, const std:: vector<T>& data) -> std:: vector<T> deprecated in 2020.06 - Duplicate data using given index array.
-
template<class IndexType, class T>void duplicateInto(const Containers::
StridedArrayView1D<const IndexType>& indices, const Containers:: StridedArrayView1D<const T>& data, const Containers:: StridedArrayView1D<T>& out) new in 2019.10 - Duplicate data using an index array into given output array.
-
void duplicateInto(const Containers::
StridedArrayView1D<const UnsignedInt>& indices, const Containers:: StridedArrayView2D<const char>& data, const Containers:: StridedArrayView2D<char>& out) new in 2020.06 - Duplicate type-erased data using an index array into given output array.
-
void duplicateInto(const Containers::
StridedArrayView1D<const UnsignedShort>& indices, const Containers:: StridedArrayView2D<const char>& data, const Containers:: StridedArrayView2D<char>& out) new in 2020.06 -
void duplicateInto(const Containers::
StridedArrayView1D<const UnsignedByte>& indices, const Containers:: StridedArrayView2D<const char>& data, const Containers:: StridedArrayView2D<char>& out) new in 2020.06 -
void duplicateInto(const Containers::
StridedArrayView2D<const char>& indices, const Containers:: StridedArrayView2D<const char>& data, const Containers:: StridedArrayView2D<char>& out) new in 2020.06 - Duplicate type-erased data using a type-erased index array into given output array.
-
auto duplicate(const Trade::
MeshData& mesh, Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}) -> Trade:: MeshData new in 2020.06 - Duplicate indexed mesh data.
-
auto duplicate(const Trade::
MeshData& mesh, std:: initializer_list<Trade:: MeshAttributeData> extra) -> Trade:: MeshData new in 2020.06 -
auto filterAttributes(const Trade::
MeshData& mesh, Containers:: BitArrayView attributesToKeep) -> Trade:: MeshData new in Git master - Filter a mesh to contain only the selected subset of attributes.
-
auto filterOnlyAttributes(const Trade::
MeshData& mesh, Containers:: ArrayView<const Trade:: MeshAttribute> attributes) -> Trade:: MeshData new in Git master - Filter a mesh to contain only the selected subset of named attributes.
-
auto filterOnlyAttributes(const Trade::
MeshData& mesh, std:: initializer_list<Trade:: MeshAttribute> attributes) -> Trade:: MeshData new in Git master -
auto filterExceptAttributes(const Trade::
MeshData& mesh, Containers:: ArrayView<const Trade:: MeshAttribute> attributes) -> Trade:: MeshData new in Git master - Filter a mesh to contain everything except the selected subset of named attributes.
-
auto filterExceptAttributes(const Trade::
MeshData& mesh, std:: initializer_list<Trade:: MeshAttribute> attributes) -> Trade:: MeshData new in Git master -
auto filterOnlyAttributes(const Trade::
MeshData& mesh, Containers:: ArrayView<const UnsignedInt> attributes) -> Trade:: MeshData deprecated in Git master - Filter a mesh to contain only the selected subset of attributes.
-
auto filterOnlyAttributes(const Trade::
MeshData& mesh, std:: initializer_list<UnsignedInt> attributes) -> Trade:: MeshData deprecated in Git master - Filter a mesh to contain only the selected subset of attributes.
-
auto filterExceptAttributes(const Trade::
MeshData& mesh, Containers:: ArrayView<const UnsignedInt> attributes) -> Trade:: MeshData deprecated in Git master - Filter a mesh to contain everything except the selected subset of attributes.
-
auto filterExceptAttributes(const Trade::
MeshData& mesh, std:: initializer_list<UnsignedInt> attributes) -> Trade:: MeshData deprecated in Git master - Filter a mesh to contain everything except the selected subset of attributes.
-
void flipNormalsInPlace(const Containers::
StridedArrayView1D<UnsignedInt>& indices, const Containers:: StridedArrayView1D<Vector3>& normals) new in 2020.06 - Flip mesh normals and face winding in-place.
-
void flipNormalsInPlace(const Containers::
StridedArrayView1D<UnsignedShort>& indices, const Containers:: StridedArrayView1D<Vector3>& normals) new in 2020.06 -
void flipNormalsInPlace(const Containers::
StridedArrayView1D<UnsignedByte>& indices, const Containers:: StridedArrayView1D<Vector3>& normals) new in 2020.06 -
void flipNormalsInPlace(const Containers::
StridedArrayView2D<char>& indices, const Containers:: StridedArrayView1D<Vector3>& normals) new in 2020.06 - Flip mesh normals and face winding in-place on a type-erased index array.
-
void flipNormals(std::
vector<UnsignedInt>& indices, std:: vector<Vector3>& normals) deprecated in 2020.06 - Flip mesh normals and face winding in-place.
-
void flipFaceWindingInPlace(const Containers::
StridedArrayView1D<UnsignedInt>& indices) new in 2020.06 - Flip face winding in-place.
-
void flipFaceWindingInPlace(const Containers::
StridedArrayView1D<UnsignedShort>& indices) new in 2020.06 -
void flipFaceWindingInPlace(const Containers::
StridedArrayView1D<UnsignedByte>& indices) new in 2020.06 -
void flipFaceWindingInPlace(const Containers::
StridedArrayView2D<char>& indices) new in 2020.06 - Flip face winding in-place on a type-erased index array.
-
void flipFaceWinding(std::
vector<UnsignedInt>& indices) deprecated in 2020.06 - Flip face winding in-place.
-
void flipNormalsInPlace(const Containers::
StridedArrayView1D<Vector3>& normals) - Flip mesh normals in-place.
-
void flipNormals(std::
vector<Vector3>& normals) deprecated in 2020.06 - Flip mesh normals in-place.
-
auto fullScreenTriangle(GL::
Version version) -> GL:: Mesh - Full screen triangle mesh.
-
auto fullScreenTriangle() -> GL::
Mesh - auto primitiveCount(MeshPrimitive primitive, UnsignedInt elementCount) -> UnsignedInt new in 2020.06
- Actual primitive count for given primitive type and element count.
-
auto generateTrivialIndices(UnsignedInt vertexCount) -> Containers::
Array<UnsignedInt> new in Git master - Create a trivial index buffer.
-
void generateTrivialIndicesInto(const Containers::
StridedArrayView1D<UnsignedInt>& output) new in Git master - Create a trivial index buffer into an existing array.
-
auto generateLineStripIndices(UnsignedInt vertexCount) -> Containers::
Array<UnsignedInt> new in 2020.06 - Create index buffer for a line strip primitive.
-
auto generateLineStripIndices(const Containers::
StridedArrayView1D<const UnsignedInt>& indices) -> Containers:: Array<UnsignedInt> new in Git master - Create index buffer for an indexed line strip primitive.
-
auto generateLineStripIndices(const Containers::
StridedArrayView1D<const UnsignedShort>& indices) -> Containers:: Array<UnsignedInt> new in Git master -
auto generateLineStripIndices(const Containers::
StridedArrayView1D<const UnsignedByte>& indices) -> Containers:: Array<UnsignedInt> new in Git master -
auto generateLineStripIndices(const Containers::
StridedArrayView2D<const char>& indices) -> Containers:: Array<UnsignedInt> new in Git master - Create index buffer for a line strip primitive with a type-erased index buffer.
-
void generateLineStripIndicesInto(UnsignedInt vertexCount,
const Containers::
StridedArrayView1D<UnsignedInt>& output) new in 2020.06 - Create index buffer for a line strip primitive into an existing array.
-
void generateLineStripIndicesInto(const Containers::
StridedArrayView1D<const UnsignedInt>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master - Create index buffer for an indexed line strip primitive into an existing array.
-
void generateLineStripIndicesInto(const Containers::
StridedArrayView1D<const UnsignedShort>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master -
void generateLineStripIndicesInto(const Containers::
StridedArrayView1D<const UnsignedByte>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master -
void generateLineStripIndicesInto(const Containers::
StridedArrayView2D<const char>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master - Create index buffer for a line strip primitive with a type-erased index buffer into an existing array.
-
auto generateLineLoopIndices(UnsignedInt vertexCount) -> Containers::
Array<UnsignedInt> new in 2020.06 - Create index buffer for a line loop primitive.
-
auto generateLineLoopIndices(const Containers::
StridedArrayView1D<const UnsignedInt>& indices) -> Containers:: Array<UnsignedInt> new in Git master - Create index buffer for an indexed line loop primitive.
-
auto generateLineLoopIndices(const Containers::
StridedArrayView1D<const UnsignedShort>& indices) -> Containers:: Array<UnsignedInt> new in Git master -
auto generateLineLoopIndices(const Containers::
StridedArrayView1D<const UnsignedByte>& indices) -> Containers:: Array<UnsignedInt> new in Git master -
auto generateLineLoopIndices(const Containers::
StridedArrayView2D<const char>& indices) -> Containers:: Array<UnsignedInt> new in Git master - Create index buffer for a line loop primitive with a type-erased index buffer.
-
void generateLineLoopIndicesInto(UnsignedInt vertexCount,
const Containers::
StridedArrayView1D<UnsignedInt>& output) new in 2020.06 - Create index buffer for a line loop primitive into an existing array.
-
void generateLineLoopIndicesInto(const Containers::
StridedArrayView1D<const UnsignedInt>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master - Create index buffer for an indexed line loop primitive into an existing array.
-
void generateLineLoopIndicesInto(const Containers::
StridedArrayView1D<const UnsignedShort>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master -
void generateLineLoopIndicesInto(const Containers::
StridedArrayView1D<const UnsignedByte>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master -
void generateLineLoopIndicesInto(const Containers::
StridedArrayView2D<const char>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master - Create index buffer for a line loop primitive with a type-erased index buffer into an existing array.
-
auto generateTriangleStripIndices(UnsignedInt vertexCount) -> Containers::
Array<UnsignedInt> new in 2020.06 - Create index buffer for a triangle strip primitive.
-
auto generateTriangleStripIndices(const Containers::
StridedArrayView1D<const UnsignedInt>& indices) -> Containers:: Array<UnsignedInt> new in Git master - Create index buffer for an indexed triangle strip primitive.
-
auto generateTriangleStripIndices(const Containers::
StridedArrayView1D<const UnsignedShort>& indices) -> Containers:: Array<UnsignedInt> new in Git master -
auto generateTriangleStripIndices(const Containers::
StridedArrayView1D<const UnsignedByte>& indices) -> Containers:: Array<UnsignedInt> new in Git master -
auto generateTriangleStripIndices(const Containers::
StridedArrayView2D<const char>& indices) -> Containers:: Array<UnsignedInt> new in Git master - Create index buffer for a triangle strip primitive with a type-erased index buffer.
-
void generateTriangleStripIndicesInto(UnsignedInt vertexCount,
const Containers::
StridedArrayView1D<UnsignedInt>& output) new in 2020.06 - Create index buffer for a triangle strip primitive into an existing array.
-
void generateTriangleStripIndicesInto(const Containers::
StridedArrayView1D<const UnsignedInt>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master - Create index buffer for an indexed triangle strip primitive into an existing array.
-
void generateTriangleStripIndicesInto(const Containers::
StridedArrayView1D<const UnsignedShort>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master -
void generateTriangleStripIndicesInto(const Containers::
StridedArrayView1D<const UnsignedByte>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master -
void generateTriangleStripIndicesInto(const Containers::
StridedArrayView2D<const char>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master - Create index buffer for a triangle strip primitive with a type-erased index buffer into an existing array.
-
auto generateTriangleFanIndices(UnsignedInt vertexCount) -> Containers::
Array<UnsignedInt> new in 2020.06 - Create index buffer for a triangle fan primitive.
-
auto generateTriangleFanIndices(const Containers::
StridedArrayView1D<const UnsignedInt>& indices) -> Containers:: Array<UnsignedInt> new in Git master - Create index buffer for an indexed triangle fan primitive.
-
auto generateTriangleFanIndices(const Containers::
StridedArrayView1D<const UnsignedShort>& indices) -> Containers:: Array<UnsignedInt> new in Git master -
auto generateTriangleFanIndices(const Containers::
StridedArrayView1D<const UnsignedByte>& indices) -> Containers:: Array<UnsignedInt> new in Git master -
auto generateTriangleFanIndices(const Containers::
StridedArrayView2D<const char>& indices) -> Containers:: Array<UnsignedInt> new in Git master - Create index buffer for a triangle fan primitive with a type-erased index buffer.
-
void generateTriangleFanIndicesInto(UnsignedInt vertexCount,
const Containers::
StridedArrayView1D<UnsignedInt>& output) new in 2020.06 - Create index buffer for a triangle fan primitive into an existing array.
-
void generateTriangleFanIndicesInto(const Containers::
StridedArrayView1D<const UnsignedInt>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master - Create index buffer for an indexed triangle fan primitive into an existing array.
-
void generateTriangleFanIndicesInto(const Containers::
StridedArrayView1D<const UnsignedShort>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master -
void generateTriangleFanIndicesInto(const Containers::
StridedArrayView1D<const UnsignedByte>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master -
void generateTriangleFanIndicesInto(const Containers::
StridedArrayView2D<const char>& indices, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master - Create index buffer for a triangle fan primitive with a type-erased index buffer into an existing array.
-
auto generateQuadIndices(const Containers::
StridedArrayView1D<const Vector3>& positions, const Containers:: StridedArrayView1D<const UnsignedInt>& quads) -> Containers:: Array<UnsignedInt> new in Git master - Create a triangle index buffer for quad primitives.
-
auto generateQuadIndices(const Containers::
StridedArrayView1D<const Vector3>& positions, const Containers:: StridedArrayView1D<const UnsignedShort>& quads) -> Containers:: Array<UnsignedInt> new in Git master -
auto generateQuadIndices(const Containers::
StridedArrayView1D<const Vector3>& positions, const Containers:: StridedArrayView1D<const UnsignedByte>& quads) -> Containers:: Array<UnsignedInt> new in Git master -
void generateQuadIndicesInto(const Containers::
StridedArrayView1D<const Vector3>& positions, const Containers:: StridedArrayView1D<const UnsignedInt>& quads, const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master - Create a triangle index buffer for quad primitives into an existing array.
-
void generateQuadIndicesInto(const Containers::
StridedArrayView1D<const Vector3>& positions, const Containers:: StridedArrayView1D<const UnsignedShort>& quads, const Containers:: StridedArrayView1D<UnsignedShort>& output) new in Git master -
void generateQuadIndicesInto(const Containers::
StridedArrayView1D<const Vector3>& positions, const Containers:: StridedArrayView1D<const UnsignedByte>& quads, const Containers:: StridedArrayView1D<UnsignedByte>& output) new in Git master -
auto generateIndices(const Trade::
MeshData& mesh) -> Trade:: MeshData new in 2020.06 - Convert a mesh to plain indexed lines or triangles.
-
auto generateIndices(Trade::
MeshData&& mesh) -> Trade:: MeshData new in 2020.06 - Convert a mesh to plain indexed lines or triangles.
-
auto generateLines(const Trade::
MeshData& lineMesh) -> Trade:: MeshData new in Git master - Generate a line mesh for use with Shaders::
LineGL. -
auto generateFlatNormals(const Containers::
StridedArrayView1D<const Vector3>& positions) -> Containers:: Array<Vector3> new in 2019.10 - Generate flat normals.
-
void generateFlatNormalsInto(const Containers::
StridedArrayView1D<const Vector3>& positions, const Containers:: StridedArrayView1D<Vector3>& normals) new in 2019.10 - Generate flat normals into an existing array.
-
auto generateFlatNormals(const std::
vector<UnsignedInt>& indices, const std:: vector<Vector3>& positions) -> std:: pair<std:: vector<UnsignedInt>, std:: vector<Vector3>> deprecated in 2019.10 - Generate flat normals.
-
auto generateSmoothNormals(const Containers::
StridedArrayView1D<const UnsignedInt>& indices, const Containers:: StridedArrayView1D<const Vector3>& positions) -> Containers:: Array<Vector3> new in 2019.10 - Generate smooth normals.
-
auto generateSmoothNormals(const Containers::
StridedArrayView1D<const UnsignedShort>& indices, const Containers:: StridedArrayView1D<const Vector3>& positions) -> Containers:: Array<Vector3> new in 2019.10 -
auto generateSmoothNormals(const Containers::
StridedArrayView1D<const UnsignedByte>& indices, const Containers:: StridedArrayView1D<const Vector3>& positions) -> Containers:: Array<Vector3> new in 2019.10 -
auto generateSmoothNormals(const Containers::
StridedArrayView2D<const char>& indices, const Containers:: StridedArrayView1D<const Vector3>& positions) -> Containers:: Array<Vector3> new in 2020.06 - Generate smooth normals using a type-erased index array.
-
void generateSmoothNormalsInto(const Containers::
StridedArrayView1D<const UnsignedInt>& indices, const Containers:: StridedArrayView1D<const Vector3>& positions, const Containers:: StridedArrayView1D<Vector3>& normals) new in 2019.10 - Generate smooth normals into an existing array.
-
void generateSmoothNormalsInto(const Containers::
StridedArrayView1D<const UnsignedShort>& indices, const Containers:: StridedArrayView1D<const Vector3>& positions, const Containers:: StridedArrayView1D<Vector3>& normals) new in 2019.10 -
void generateSmoothNormalsInto(const Containers::
StridedArrayView1D<const UnsignedByte>& indices, const Containers:: StridedArrayView1D<const Vector3>& positions, const Containers:: StridedArrayView1D<Vector3>& normals) new in 2019.10 -
void generateSmoothNormalsInto(const Containers::
StridedArrayView2D<const char>& indices, const Containers:: StridedArrayView1D<const Vector3>& positions, const Containers:: StridedArrayView1D<Vector3>& normals) new in 2020.06 - Generate smooth normals into an existing array using a type-erased index array.
-
template<class T, class ... U>auto interleave(const T& first, const U&... next) -> Containers::
Array<char> - Interleave vertex attributes.
-
template<class T, class ... U>void interleaveInto(Containers::
ArrayView<char> buffer, const T& first, const U&... next) - Interleave vertex attributes into existing buffer.
-
auto isInterleaved(const Trade::
MeshData& mesh) -> bool new in 2020.06 - If the mesh data is interleaved.
-
auto interleavedData(const Trade::
MeshData& mesh) -> Containers:: StridedArrayView2D<const char> new in 2020.06 - Type-erased view on interleaved mesh data.
-
auto interleavedMutableData(Trade::
MeshData& mesh) -> Containers:: StridedArrayView2D<char> new in 2020.06 - Mutable type-erased view on interleaved mesh data.
-
auto interleavedLayout(const Trade::
MeshData& mesh, UnsignedInt vertexCount, Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in 2020.06 - Create an interleaved mesh layout.
-
auto interleavedLayout(const Trade::
MeshData& mesh, UnsignedInt vertexCount, std:: initializer_list<Trade:: MeshAttributeData> extra, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in 2020.06 -
auto interleavedLayout(Trade::
MeshData&& mesh, UnsignedInt vertexCount, Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in 2020.06 - Create an interleaved mesh layout.
-
auto interleavedLayout(Trade::
MeshData&& mesh, UnsignedInt vertexCount, std:: initializer_list<Trade:: MeshAttributeData> extra, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in 2020.06 -
auto interleave(const Trade::
MeshData& mesh, Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in 2020.06 - Interleave mesh data.
-
auto interleave(const Trade::
MeshData& mesh, std:: initializer_list<Trade:: MeshAttributeData> extra, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in 2020.06 -
auto interleave(Trade::
MeshData&& mesh, Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in 2020.06 - Interleave mesh data.
-
auto interleave(Trade::
MeshData&& mesh, std:: initializer_list<Trade:: MeshAttributeData> extra, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in 2020.06 -
auto owned(const Trade::
MeshData& mesh) -> Trade:: MeshData deprecated in Git master - Create an owned Trade::
MeshData. -
auto owned(Trade::
MeshData&& mesh) -> Trade:: MeshData deprecated in Git master - Create an owned Trade::
MeshData, if not already. -
auto removeDuplicatesInPlace(const Containers::
StridedArrayView2D<char>& data) -> Containers:: Pair<Containers:: Array<UnsignedInt>, std:: size_t> new in 2020.06 - Remove duplicate data from given array in-place.
-
auto removeDuplicatesInPlaceInto(const Containers::
StridedArrayView2D<char>& data, const Containers:: StridedArrayView1D<UnsignedInt>& indices) -> std:: size_t new in 2020.06 - Remove duplicate data from given array in-place into given output index array.
-
auto removeDuplicates(const Containers::
StridedArrayView2D<const char>& data) -> Containers:: Pair<Containers:: Array<UnsignedInt>, std:: size_t> new in 2020.06 - Remove duplicate data from given array.
-
auto removeDuplicatesInto(const Containers::
StridedArrayView2D<const char>& data, const Containers:: StridedArrayView1D<UnsignedInt>& indices) -> std:: size_t new in 2020.06 - Remove duplicate data from given array into given output index array.
-
auto removeDuplicatesIndexedInPlace(const Containers::
StridedArrayView1D<UnsignedInt>& indices, const Containers:: StridedArrayView2D<char>& data) -> std:: size_t new in 2020.06 - Remove duplicates from indexed data in-place.
-
auto removeDuplicatesIndexedInPlace(const Containers::
StridedArrayView1D<UnsignedShort>& indices, const Containers:: StridedArrayView2D<char>& data) -> std:: size_t new in 2020.06 -
auto removeDuplicatesIndexedInPlace(const Containers::
StridedArrayView1D<UnsignedByte>& indices, const Containers:: StridedArrayView2D<char>& data) -> std:: size_t new in 2020.06 -
auto removeDuplicatesIndexedInPlace(const Containers::
StridedArrayView2D<char>& indices, const Containers:: StridedArrayView2D<char>& data) -> std:: size_t new in 2020.06 - Remove duplicates from indexed data in-place on a type-erased index array.
-
auto removeDuplicatesFuzzyInPlace(const Containers::
StridedArrayView2D<Float>& data, Float epsilon = Math:: TypeTraits<Float>::epsilon()) -> Containers:: Pair<Containers:: Array<UnsignedInt>, std:: size_t> new in 2020.06 - Remove duplicate data from given array using fuzzy comparison in-place.
-
auto removeDuplicatesFuzzyInPlace(const Containers::
StridedArrayView2D<Double>& data, Double epsilon = Math:: TypeTraits<Double>::epsilon()) -> Containers:: Pair<Containers:: Array<UnsignedInt>, std:: size_t> new in 2020.06 -
auto removeDuplicatesFuzzyInPlaceInto(const Containers::
StridedArrayView2D<Float>& data, const Containers:: StridedArrayView1D<UnsignedInt>& indices, Float epsilon = Math:: TypeTraits<Float>::epsilon()) -> std:: size_t new in 2020.06 - Remove duplicate data from given array using fuzzy comparison in-place into given output index array.
-
auto removeDuplicatesFuzzyInPlaceInto(const Containers::
StridedArrayView2D<Double>& data, const Containers:: StridedArrayView1D<UnsignedInt>& indices, Double epsilon = Math:: TypeTraits<Double>::epsilon()) -> std:: size_t new in 2020.06 -
template<class Vector>auto removeDuplicates(std::
vector<Vector>& data, typename Vector::Type epsilon = Math:: TypeTraits<typename Vector::Type>::epsilon()) -> std:: vector<UnsignedInt> deprecated in 2020.06 - Remove duplicate data from a STL vector using fuzzy comparison in-place.
-
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::
StridedArrayView1D<UnsignedInt>& indices, const Containers:: StridedArrayView2D<Float>& data, Float epsilon = Math:: TypeTraits<Float>::epsilon()) -> std:: size_t new in 2020.06 - Remove duplicates from indexed data using fuzzy comparison in-place.
-
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::
StridedArrayView1D<UnsignedShort>& indices, const Containers:: StridedArrayView2D<Float>& data, Float epsilon = Math:: TypeTraits<Float>::epsilon()) -> std:: size_t new in 2020.06 -
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::
StridedArrayView1D<UnsignedByte>& indices, const Containers:: StridedArrayView2D<Float>& data, Float epsilon = Math:: TypeTraits<Float>::epsilon()) -> std:: size_t new in 2020.06 -
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::
StridedArrayView1D<UnsignedInt>& indices, const Containers:: StridedArrayView2D<Double>& data, Double epsilon = Math:: TypeTraits<Double>::epsilon()) -> std:: size_t new in 2020.06 -
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::
StridedArrayView1D<UnsignedShort>& indices, const Containers:: StridedArrayView2D<Double>& data, Double epsilon = Math:: TypeTraits<Double>::epsilon()) -> std:: size_t new in 2020.06 -
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::
StridedArrayView1D<UnsignedByte>& indices, const Containers:: StridedArrayView2D<Double>& data, Double epsilon = Math:: TypeTraits<Double>::epsilon()) -> std:: size_t new in 2020.06 -
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::
StridedArrayView2D<char>& indices, const Containers:: StridedArrayView2D<Float>& data, Float epsilon = Math:: TypeTraits<Float>::epsilon()) -> std:: size_t new in 2020.06 - Remove duplicates from indexed data using fuzzy comparison in-place on a type-erased index array.
-
auto removeDuplicatesFuzzyIndexedInPlace(const Containers::
StridedArrayView2D<char>& indices, const Containers:: StridedArrayView2D<Double>& data, Double epsilon = Math:: TypeTraits<Double>::epsilon()) -> std:: size_t new in 2020.06 -
auto removeDuplicates(const Trade::
MeshData& mesh) -> Trade:: MeshData new in 2020.06 - Remove mesh data duplicates.
-
auto removeDuplicatesFuzzy(const Trade::
MeshData& mesh, Float floatEpsilon = Math:: TypeTraits<Float>::epsilon(), Double doubleEpsilon = Math:: TypeTraits<Double>::epsilon()) -> Trade:: MeshData new in 2020.06 - Remove mesh data duplicates with fuzzy comparison for floating-point attributes.
-
template<class IndexType, class Vertex, class Interpolator>void subdivide(Containers::
Array<IndexType>& indices, Containers:: Array<Vertex>& vertices, Interpolator interpolator) new in 2020.06 - Subdivide a mesh.
-
template<class Vertex, class Interpolator>void subdivide(std::
vector<UnsignedInt>& indices, std:: vector<Vertex>& vertices, Interpolator interpolator) deprecated in 2020.06 - Subdivide a mesh.
-
template<class IndexType, class Vertex, class Interpolator>void subdivideInPlace(const Containers::
StridedArrayView1D<IndexType>& indices, const Containers:: StridedArrayView1D<Vertex>& vertices, Interpolator interpolator) new in 2020.06 - Subdivide a mesh in-place.
-
template<class IndexType, class Vertex, class Interpolator>void subdivideInPlace(const Containers::
ArrayView<IndexType>& indices, const Containers:: StridedArrayView1D<Vertex>& vertices, Interpolator interpolator) new in 2020.06 -
void tipsifyInPlace(const Containers::
StridedArrayView1D<UnsignedInt>& indices, UnsignedInt vertexCount, std:: size_t cacheSize) - Tipsify the mesh in-place.
-
void tipsifyInPlace(const Containers::
StridedArrayView1D<UnsignedShort>& indices, UnsignedInt vertexCount, std:: size_t cacheSize) new in 2020.06 -
void tipsifyInPlace(const Containers::
StridedArrayView1D<UnsignedByte>& indices, UnsignedInt vertexCount, std:: size_t cacheSize) new in 2020.06 -
void tipsify(std::
vector<UnsignedInt>& indices, UnsignedInt vertexCount, std:: size_t cacheSize) deprecated in 2020.06 - Tipsify the mesh in-place.
-
template<class T, class U>void transformVectorsInPlace(const Math::
Matrix4<T>& matrix, U&& vectors) - Transform vectors in-place using given transformation.
-
template<class T, class U>void transformVectorsInPlace(const Math::
Matrix3<T>& matrix, U&& vectors) -
template<class T, class U>void transformVectorsInPlace(const Math::
Complex<T>& complex, U&& vectors) -
template<class T, class U>void transformVectorsInPlace(const Math::
Quaternion<T>& normalizedQuaternion, U&& vectors) -
template<class T, class U>auto transformVectors(const T& transformation, U vectors) -> U
- Transform vectors using given transformation.
-
template<class T, class U>void transformPointsInPlace(const Math::
Matrix4<T>& matrix, U&& points) - Transform points in-place using given transformation.
-
template<class T, class U>void transformPointsInPlace(const Math::
Matrix3<T>& matrix, U&& points) -
template<class T, class U>void transformPointsInPlace(const Math::
DualComplex<T>& dualComplex, U&& points) -
template<class T, class U>void transformPointsInPlace(const Math::
DualQuaternion<T>& normalizedDualQuaternion, U&& points) -
template<class T, class U>auto transformPoints(const T& transformation, U vectors) -> U
- Transform points using given transformation.
-
auto transform2D(const Trade::
MeshData& mesh, const Matrix3& transformation, UnsignedInt id = 0, Int morphTargetId = -1, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in Git master - Transform 2D positions in a mesh data.
-
auto transform2D(const Trade::
MeshData& mesh, const Matrix3& transformation, UnsignedInt id, InterleaveFlags flags) -> Trade:: MeshData deprecated in Git master - Transform 2D positions in a mesh data.
-
auto transform2D(Trade::
MeshData&& mesh, const Matrix3& transformation, UnsignedInt id = 0, Int morphTargetId = -1, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in Git master - Transform 2D positions in a mesh data.
-
auto transform2D(Trade::
MeshData&& mesh, const Matrix3& transformation, UnsignedInt id, InterleaveFlags flags) -> Trade:: MeshData deprecated in Git master - Transform 2D positions in a mesh data.
-
void transform2DInPlace(Trade::
MeshData& mesh, const Matrix3& transformation, UnsignedInt id = 0, Int morphTargetId = -1) new in Git master - Transform 2D positions in a mesh data in-place.
-
auto transform3D(const Trade::
MeshData& mesh, const Matrix4& transformation, UnsignedInt id = 0, Int morphTargetId = -1, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in Git master - Transform 3D positions, normals, tangents and bitangents in a mesh data.
-
auto transform3D(const Trade::
MeshData& mesh, const Matrix4& transformation, UnsignedInt id, InterleaveFlags flags) -> Trade:: MeshData deprecated in Git master - Transform 3D positions, normals, tangents and bitangents in a mesh data.
-
auto transform3D(Trade::
MeshData&& mesh, const Matrix4& transformation, UnsignedInt id = 0, Int morphTargetId = -1, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in Git master - Transform 3D positions, normals, tangenta and bitangents in a mesh data.
-
auto transform3D(Trade::
MeshData&& mesh, const Matrix4& transformation, UnsignedInt id, InterleaveFlags flags) -> Trade:: MeshData deprecated in Git master - Transform 3D positions, normals, tangenta and bitangents in a mesh data.
-
void transform3DInPlace(Trade::
MeshData& mesh, const Matrix4& transformation, UnsignedInt id = 0, Int morphTargetId = -1) new in Git master - Transform 3D positions, normals, tangents and bitangents in a mesh data in-place.
-
auto transformTextureCoordinates2D(const Trade::
MeshData& mesh, const Matrix3& transformation, UnsignedInt id = 0, Int morphTargetId = -1, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in Git master - Transform 2D texture coordinates in a mesh data.
-
auto transformTextureCoordinates2D(const Trade::
MeshData& mesh, const Matrix3& transformation, UnsignedInt id, InterleaveFlags flags) -> Trade:: MeshData deprecated in Git master - Transform 2D texture coordinates in a mesh data.
-
auto transformTextureCoordinates2D(Trade::
MeshData&& mesh, const Matrix3& transformation, UnsignedInt id = 0, Int morphTargetId = -1, InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) -> Trade:: MeshData new in Git master - Transform 2D texture coordinates in a mesh data.
-
auto transformTextureCoordinates2D(Trade::
MeshData&& mesh, const Matrix3& transformation, UnsignedInt id, InterleaveFlags flags) -> Trade:: MeshData deprecated in Git master - Transform 2D texture coordinates in a mesh data.
-
void transformTextureCoordinates2DInPlace(Trade::
MeshData& mesh, const Matrix3& transformation, UnsignedInt id = 0, Int morphTargetId = -1) new in Git master - Transform 2D texture coordinates in a mesh data in-place.
Enum documentation
enum class Magnum:: MeshTools:: CompileFlag: UnsignedByte new in 2019.10
#include <Magnum/MeshTools/Compile.h>
Mesh compilation flag.
Enumerators | |
---|---|
GenerateFlatNormals |
If the mesh is MeshPrimitive:: |
GenerateSmoothNormals |
If the mesh MeshPrimitive:: |
NoWarnOnCustomAttributes new in 2020.06 |
By default, compile() warns when it encounters custom attributes, morph target attributes and attributes with an implementation-specific format, as those get ignored by it. If you're binding those manually with compile(const Trade:: |
enum class Magnum:: MeshTools:: InterleaveFlag: UnsignedInt new in Git master
#include <Magnum/MeshTools/InterleaveFlags.h>
Interleaving behavior flag.
Enumerators | |
---|---|
PreserveInterleavedAttributes |
If the mesh is already interleaved, preserves existing layout of the attributes as well as any padding or aliasing among them, keeping the original stride and only removing the initial offset. This can also preserve attributes with an implementation-specific VertexFormat. If not set or if the mesh is not interleaved to begin with, a tightly packed stride is calculated from vertex format sizes of all attributes, removing all padding. In that case an implementation-specific VertexFormat can't be used for any attribute. |
PreserveStridedIndices |
If a mesh is indexed, makes interleave(const Trade:: If not set and the index buffer is strided, a tightly packed copy with the same index type is allocated for the output, dropping also any padding before or after the original index view. In such case however, the index type is not allowed to be implementation-specific. Has no effect when passed to interleavedLayout() as that function doesn't preserve the index buffer. Has no effect when passed to concatenate() as that function allocates a new combined index buffer anyway. |
Typedef documentation
typedef Containers:: EnumSet<CompileFlag> Magnum:: MeshTools:: CompileFlags new in 2019.10
#include <Magnum/MeshTools/Compile.h>
Mesh compilation flags.
typedef Containers:: EnumSet<InterleaveFlag> Magnum:: MeshTools:: InterleaveFlags new in Git master
#include <Magnum/MeshTools/InterleaveFlags.h>
Interleaving behavior flags.
Function documentation
Range3D Magnum:: MeshTools:: boundingRange(const Containers:: StridedArrayView1D<const Vector3>& positions) new in Git master
#include <Magnum/MeshTools/BoundingVolume.h>
Calculate a bounding range.
Parameters | |
---|---|
positions | Vertex positions |
Returns | Bounding range |
Same as Math::
Containers:: Pair<Vector3, Float> Magnum:: MeshTools:: boundingSphereBouncingBubble(const Containers:: StridedArrayView1D<const Vector3>& positions) new in Git master
#include <Magnum/MeshTools/BoundingVolume.h>
Calculate an approximate bounding sphere using the Bouncing Bubble algorithm.
Parameters | |
---|---|
positions | Vertex positions |
Returns | Sphere center and radius |
The resulting bounding sphere is not usually minimal. According to the author, a 1% to 2% error can be expected. Due to the nature of the algorithm, the radius is never below Math::
Trade:: MeshData Magnum:: MeshTools:: combineIndexedAttributes(const Containers:: Iterable<const Trade:: MeshData>& meshes) new in 2020.06
#include <Magnum/MeshTools/Combine.h>
Combine differently indexed attributes into a single mesh.
Assuming all meshes
contain only unique vertex data, creates an indexed mesh that contains all attributes from meshes
combined, with duplicate vertices removed. For example, when you have a position and a normal array, each indexed with separate indices like this:
{pA, pB, pC, pD, pE, pF} // positions {nA, nB, nC, nD, nE, nF, nG} // normals {0, 2, 5, 0, 0, 1, 3, 2, 2} // position indices {1, 3, 4, 1, 4, 6, 1, 3, 1} // normal indices
Then the first triangle in the mesh is defined as {pA, nB}, {pC, nD}, {pF, nE}
. When combined together using this function, the resulting mesh stays the same but there's just one index array, indexing both positions and normals:
{{pA, nB}, {pC, nD}, {pF, nE}, {pA, nE}, {pB, nG}, {pD, nB}, {pC, nB}} // unique pairs of positions and normals {0, 1, 2, 0, 3, 4, 5, 1, 6} // unified indices
The function preserves all attribute data including repeated or custom attributes. The resulting mesh is interleaved, with all attributes packed tightly together. If you need to add specific padding for alignment preservation, pass the result to interleave() and specify the paddings between attributes manually. Similarly, for simplicity the resulting mesh has always MeshIndexType::
Vertex data unreferenced by the index buffers are discarded. This means the function can be also called with just a single argument to compact a mesh with a sparse index buffer.
Expects that meshes
is non-empty and all data have the same primitive and index count. All inputs have to be indexed. For non-indexed attributes combining can be done much more efficiently using duplicate(const Trade::
Trade:: MeshData Magnum:: MeshTools:: combineFaceAttributes(const Trade:: MeshData& mesh,
const Trade:: MeshData& faceAttributes) new in 2020.06
#include <Magnum/MeshTools/Combine.h>
Combine per-face attributes into an existing mesh.
The resulting mesh will have all per-face attributes turned into per-vertex attributes, leaving only unique combinations and adjusting the index buffer accordingly. The resulting mesh has the same amount of indices, but likely more vertices.
Expects that mesh
is indexed MeshPrimitive::faceAttributes
is MeshPrimitive::faceAttributes
is indexed, it's assumed to have the data unique; if it's not indexed, it's first made unique using removeDuplicates() and in that case it's expected to be interleaved. Index buffers and attributes in both meshes are expected to not have an implementation-specific format.
Trade:: MeshData Magnum:: MeshTools:: combineFaceAttributes(const Trade:: MeshData& mesh,
Containers:: ArrayView<const Trade:: MeshAttributeData> faceAttributes) new in 2020.06
#include <Magnum/MeshTools/Combine.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Same as above with faceAttributes
wrapped in a Trade::faceAttributes
is expected to be interleaved. Note that offset-only Trade::faceAttributes
array.
Trade:: MeshData Magnum:: MeshTools:: combineFaceAttributes(const Trade:: MeshData& mesh,
std:: initializer_list<Trade:: MeshAttributeData> faceAttributes) new in 2020.06
#include <Magnum/MeshTools/Combine.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: vector<UnsignedInt> Magnum:: MeshTools:: combineIndexArrays(const std:: vector<std:: reference_wrapper<std:: vector<UnsignedInt>>>& arrays)
Combine index arrays.
Parameters | |
---|---|
arrays in/out | Index arrays to combine. These arrays are updated in-place to contain unique combinations of the original indices. |
Returns | Resulting combined index array |
Creates new combined index array and updates the original ones with translation to new ones. For example, when you have position and normal array, each indexed with separate indices and you want to index both of them with single index array:
a b c d e f // positions A B C D E F G // normals 0 2 5 0 0 1 3 2 2 // position indices 1 3 4 1 4 6 1 3 1 // normal indices
In particular, first triangle in the mesh will have positions a c f
and normals B D E
. You can see that not all combinations are unique and also that there are some vertices unused. When you pass the two index arrays above to this function, the following combined index array is returned:
0 1 2 0 3 4 5 1 6
And the original arrays are cleaned up to have only unique combinations:
0 2 5 0 1 3 2 1 3 4 4 6 1 1
You can use these as translation table to create new vertex and normal arrays which can be then indexed with the combined index array:
a c f a b d c B D E E G B B
Again, first triangle in the mesh will have positions a c f
and normals B D E
.
This function calls combineIndexArrays(const std::
std:: vector<UnsignedInt> Magnum:: MeshTools:: combineIndexArrays(std:: initializer_list<std:: reference_wrapper<std:: vector<UnsignedInt>>> arrays)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: pair<std:: vector<UnsignedInt>, std:: vector<UnsignedInt>> Magnum:: MeshTools:: combineIndexArrays(const std:: vector<UnsignedInt>& interleavedArrays,
UnsignedInt stride)
Combine interleaved index arrays.
Unlike above, this function takes one interleaved array instead of separate index arrays. Continuing with the above example, you would call this function with the following array (odd value is vertex index, even is normal index, stride
is thus 2):
0 1 2 3 5 4 0 1 0 4 1 6 3 1 2 3 2 1
Similarly to above this function will return the following combined index array as first pair value:
0 1 2 0 3 4 5 1 6
And second pair value is the cleaned up interleaved array:
0 1 2 3 5 4 0 4 1 6 3 1 2 1
template<class ... T>
std:: vector<UnsignedInt> Magnum:: MeshTools:: combineIndexedArrays(const std:: pair<const std:: vector<UnsignedInt>&, std:: vector<T>&>&... indexedArrays)
Combine indexed arrays.
Parameters | |
---|---|
indexedArrays in/out | Index and attribute arrays |
Returns | Array with resulting indices |
Creates new combined index array and reorders original attribute arrays so they can be indexed with the new single index array.
The index array must be passed as const reference (to avoid copying) and attribute array as reference, so it can be replaced with combined data. To avoid explicit verbose specification of tuple type, you can write it with help of some STL functions like shown below. Also if one index array is shared by more than one attribute array, just pass the index array more times. Example:
std::vector<UnsignedInt> vertexIndices; std::vector<Vector3> positions; std::vector<UnsignedInt> normalTextureIndices; std::vector<Vector3> normals; std::vector<Vector2> textureCoordinates; std::vector<UnsignedInt> indices = MeshTools::combineIndexedArrays( std::make_pair(std::cref(vertexIndices), std::ref(positions)), std::make_pair(std::cref(normalTextureIndices), std::ref(normals)), std::make_pair(std::cref(normalTextureIndices), std::ref(textureCoordinates)) );
See combineIndexArrays() documentation for more information about the procedure.
GL:: Mesh Magnum:: MeshTools:: compile(const Trade:: MeshData& mesh,
CompileFlags flags) new in 2020.06
#include <Magnum/MeshTools/Compile.h>
Compile OpenGL mesh data.
Configures a mesh for a Shaders::
- If the mesh contains Trade::
MeshAttribute:: Position, these are bound to the Shaders:: GenericGL2D:: Position attribute if they are 2D or to Shaders:: GenericGL3D:: Position if they are 3D. - If the mesh contains Trade::
MeshAttribute:: Tangent, these are bound to Shaders:: GenericGL3D:: Tangent4 or Shaders:: GenericGL3D:: Tangent based on their type. - If the mesh contains Trade::
MeshAttribute:: Bitangent, these are bound to Shaders:: GenericGL3D:: Bitangent. However, if the mesh contains a Trade:: MeshAttribute:: ObjectId as well, only the first appearing of the two is bound. The second is ignored with a warning as they share the same binding slot. - If the mesh contains Trade::
MeshAttribute:: Normal or if CompileFlag:: GenerateFlatNormals / CompileFlag:: GenerateSmoothNormals is set, these are bound to Shaders:: GenericGL3D:: Normal. - If the mesh contains Trade::
MeshAttribute:: TextureCoordinates, these are bound to Shaders:: GenericGL:: TextureCoordinates. - If the mesh contains Trade::
MeshAttribute:: Color, these are bound to Shaders:: GenericGL:: Color3 / Color4 based on their type. - If the mesh contains Trade::
MeshAttribute:: JointIds and Trade:: MeshAttribute:: Weights, these are bound to Shaders:: GenericGL:: JointIds / SecondaryJointIds and Weights / SecondaryWeights according to rules described in compiledPerVertexJointCount(). - If the mesh contains Trade::
MeshAttribute:: ObjectId, these are bound to Shaders:: GenericGL:: ObjectId. However, if the mesh contains a Trade:: MeshAttribute:: Bitangent as well, only the first appearing of the two is bound. The second is ignored with a warning as they share the same binding slot. - Custom attributes and known attributes of implementation-specific vertex formats are ignored with a warning. See compile(const Trade::
MeshData&, GL:: Buffer&, GL:: Buffer&) for an example showing how to bind them manually, and CompileFlag:: NoWarnOnCustomAttributes to suppress the warning. - Implementation-specific Magnum::
MeshPrimitive and Magnum:: MeshIndexType values are passed as-is with meshPrimitiveUnwrap() and meshIndexTypeUnwrap(). It's the user responsibility to ensure an implementation-specific value is valid in this context. - The index buffer is expected to be contiguous (size of the index type equal to Trade::
MeshData:: indexStride()). OpenGL doesn't support interleaved index buffers. In case the MeshIndexType is implementation-specific, this condition can't be checked and the buffer is assumed to be contiguous. - Stride of all attributes is expected to be positive. OpenGL doesn't support zero and negative strides.
If normal generation is not requested, Trade::
The generated mesh owns the index and vertex buffers and there's no possibility to access them afterwards. For alternative solutions see the compile(const Trade::
GL:: Mesh Magnum:: MeshTools:: compile(const Trade:: MeshData& mesh) new in 2020.06
#include <Magnum/MeshTools/Compile.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
GL:: Mesh Magnum:: MeshTools:: compile(const Trade:: MeshData& mesh,
GL:: Buffer& indices,
GL:: Buffer& vertices) new in 2020.06
#include <Magnum/MeshTools/Compile.h>
Compile mesh data using external buffers.
Assumes the whole vertex / index data are already uploaded to indices
/ vertices
and sets up the mesh using those. Can be used to have a single index/vertex buffer when multiple Trade::
GL::Buffer indices{meshData.indexData()}; GL::Buffer vertices{meshData.vertexData()}; GL::Mesh mesh = MeshTools::compile(meshData, indices, vertices);
Another use case is specifying additional vertex attributes that are not recognized by the function itself. You can choose among various r-value overloads depending on whether you want to have the index/vertex buffers owned by the mesh or not:
struct MyShader: GL::AbstractShaderProgram { typedef GL::Attribute<…> MyCustomAttribute; … }; Trade::MeshAttribute myCustomAttribute = …; GL::Buffer indices{meshData.indexData()}; GL::Buffer vertices{meshData.vertexData()}; /* Let compile() handle the usual attributes and configure custom ones after */ GL::Mesh mesh = MeshTools::compile(meshData, std::move(indices), vertices); mesh.addVertexBuffer(std::move(vertices), meshData.attributeOffset(myCustomAttribute), meshData.attributeStride(myCustomAttribute), GL::DynamicAttribute{ MyShader::MyCustomAttribute{}, meshData.attributeFormat(myCustomAttribute) });
If mesh
is not indexed, the indices
parameter is ignored — in that case you can pass a NoCreate-d instance to avoid allocating an unnecessary OpenGL buffer object.
Compared to compile(const Trade::
GL:: Mesh Magnum:: MeshTools:: compile(const Trade:: MeshData& mesh,
GL:: Buffer& indices,
GL:: Buffer&& vertices) new in 2020.06
#include <Magnum/MeshTools/Compile.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
GL:: Mesh Magnum:: MeshTools:: compile(const Trade:: MeshData& mesh,
GL:: Buffer&& indices,
GL:: Buffer& vertices) new in 2020.06
#include <Magnum/MeshTools/Compile.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
GL:: Mesh Magnum:: MeshTools:: compile(const Trade:: MeshData& mesh,
GL:: Buffer&& indices,
GL:: Buffer&& vertices) new in 2020.06
#include <Magnum/MeshTools/Compile.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
GL:: Mesh Magnum:: MeshTools:: compile(const Trade:: MeshData2D& meshData)
#include <Magnum/MeshTools/Compile.h>
Compile 2D mesh data.
Configures a mesh for Shaders::
This is just a convenience function for creating generic meshes, you might want to use interleave() and compressIndices() functions together with GL::
GL:: Mesh Magnum:: MeshTools:: compile(const Trade:: MeshData3D& meshData,
CompileFlags flags = {})
#include <Magnum/MeshTools/Compile.h>
Compile 3D mesh data.
Configures mesh for Shaders::
This is just a convenience function for creating generic meshes, you might want to use interleave() and compressIndices() functions together with GL::
Containers:: Pair<UnsignedInt, UnsignedInt> Magnum:: MeshTools:: compiledPerVertexJointCount(const Trade:: MeshData& mesh) new in Git master
#include <Magnum/MeshTools/Compile.h>
Compiled per-vertex joint count for given mesh data.
Returns the count of bound primary and secondary per-vertex joint IDs and weights that a mesh returned from compile(const Trade::
- If the mesh contains just one instance of joint ID and weight attributes and their Trade::
MeshData:: attributeArraySize() is not larger than 4, they occupy just the primary binding slot. The second returned value is 0
. - If the mesh contains more than one instance of joint ID and weight attributes and array size of the first instance is not larger than 4, the first instance goes to the primary binding slot and the first up to 4 array components of the second instance go to the secondary slot. Remaining array components of the second instance and all remaining instances of joint ID and weight attributes are ignored.
- If array size of the first instance of joint ID and weight attributes is larger than 4, the first slot uses the first 4 array components and the second the next up to 4 array components. Remaining array components of the first instance and all remaining instances of joint ID and weight attributes are ignored.
Useful to get subsequently fed to Shaders::
GL:: Mesh Magnum:: MeshTools:: compileLines(const Trade:: MeshData& mesh) new in Git master
#include <Magnum/MeshTools/CompileLines.h>
Compile a line mesh for use with Shaders::
Expects that the mesh
is returned from generateLines(), see its documentation for more information.
Containers:: Pair<Containers:: Array<char>, MeshIndexType> Magnum:: MeshTools:: compressIndices(const Containers:: StridedArrayView1D<const UnsignedInt>& indices,
MeshIndexType atLeast = MeshIndexType:: UnsignedShort,
Long offset = 0) new in 2020.06
#include <Magnum/MeshTools/CompressIndices.h>
Compress an index array.
Parameters | |
---|---|
indices | Index array |
atLeast | Smallest allowed type |
offset | Offset to subtract from each index |
Returns | Compressed index array and corresponding type |
This function compresses indices
to the smallest possible size. For example when your indices have the maximum vertex index 463, it's wasteful to store them in array of 32-bit integers, array of 16-bit integers is sufficient. The atLeast
parameter allows you to specify the smallest type to use and it defaults to MeshIndexType::
Containers::Array<UnsignedInt> indices; Containers::Pair<Containers::Array<char>, MeshIndexType> compressed = MeshTools::compressIndices(indices); GL::Buffer indexBuffer; indexBuffer.setData(compressed.first()); GL::Mesh mesh; mesh.setCount(indices.size()) .setIndexBuffer(indexBuffer, 0, compressed.second());
In case the indices all start from a large offset, the offset
parameter can be used to subtract it, allowing them to be compressed even further. For example, if all indices are in range (which fits only into a 32-bit type), subtracting 75000 makes them in range which fits into 16 bits. Note that you also need to update vertex attribute offsets accordingly. Example:
Containers::ArrayView<const UnsignedInt> indices; UnsignedInt offset = Math::min(indices); Containers::Pair<Containers::Array<char>, MeshIndexType> compressed = MeshTools::compressIndices(indices, offset); // use `offset` to adjust vertex attribute offset …
A negative offset
value will do an operation inverse to the above. See also compressIndices(const Trade::
The atLeast
parameter is expected to not be an implementation-specific type.
Containers:: Pair<Containers:: Array<char>, MeshIndexType> Magnum:: MeshTools:: compressIndices(const Containers:: StridedArrayView1D<const UnsignedShort>& indices,
MeshIndexType atLeast = MeshIndexType:: UnsignedShort,
Long offset = 0) new in 2020.06
#include <Magnum/MeshTools/CompressIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Containers:: Pair<Containers:: Array<char>, MeshIndexType> Magnum:: MeshTools:: compressIndices(const Containers:: StridedArrayView1D<const UnsignedByte>& indices,
MeshIndexType atLeast = MeshIndexType:: UnsignedShort,
Long offset = 0) new in 2020.06
#include <Magnum/MeshTools/CompressIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Containers:: Pair<Containers:: Array<char>, MeshIndexType> Magnum:: MeshTools:: compressIndices(const Containers:: StridedArrayView1D<const UnsignedInt>& indices,
Long offset) new in 2020.06
#include <Magnum/MeshTools/CompressIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Same as compressIndices(const Containers::atLeast
set to MeshIndexType::
Containers:: Pair<Containers:: Array<char>, MeshIndexType> Magnum:: MeshTools:: compressIndices(const Containers:: StridedArrayView1D<const UnsignedShort>& indices,
Long offset) new in 2020.06
#include <Magnum/MeshTools/CompressIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Same as compressIndices(const Containers::atLeast
set to MeshIndexType::
Containers:: Pair<Containers:: Array<char>, MeshIndexType> Magnum:: MeshTools:: compressIndices(const Containers:: StridedArrayView1D<const UnsignedByte>& indices,
Long offset) new in 2020.06
#include <Magnum/MeshTools/CompressIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Same as compressIndices(const Containers::atLeast
set to MeshIndexType::
Containers:: Pair<Containers:: Array<char>, MeshIndexType> Magnum:: MeshTools:: compressIndices(const Containers:: StridedArrayView2D<const char>& indices,
MeshIndexType atLeast = MeshIndexType:: UnsignedShort,
Long offset = 0) new in 2020.06
#include <Magnum/MeshTools/CompressIndices.h>
Compress a type-erased index array.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the compressIndices(const Containers::
The atLeast
parameter is expected to not be an implementation-specific type.
Containers:: Pair<Containers:: Array<char>, MeshIndexType> Magnum:: MeshTools:: compressIndices(const Containers:: StridedArrayView2D<const char>& indices,
Long offset) new in 2020.06
#include <Magnum/MeshTools/CompressIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Same as compressIndices(const Containers::atLeast
set to MeshIndexType::
Trade:: MeshData Magnum:: MeshTools:: compressIndices(const Trade:: MeshData& mesh,
MeshIndexType atLeast = MeshIndexType:: UnsignedShort) new in 2020.06
#include <Magnum/MeshTools/CompressIndices.h>
Compress mesh data indices.
Does the same as compressIndices(const Containers::
The mesh is expected to be indexed and the index type and the atLeast
parameter is expected to not be implementation-specific type.
Trade:: MeshData Magnum:: MeshTools:: compressIndices(Trade:: MeshData&& mesh,
MeshIndexType atLeast = MeshIndexType:: UnsignedShort) new in 2020.06
#include <Magnum/MeshTools/CompressIndices.h>
Compress mesh data indices.
Compared to compressIndices(const Trade::data
vertex buffer (in case it is owned) to the returned instance instead of making a copy of it. Index and attribute data are copied always.
std:: tuple<Containers:: Array<char>, MeshIndexType, UnsignedInt, UnsignedInt> Magnum:: MeshTools:: compressIndices(const std:: vector<UnsignedInt>& indices)
#include <Magnum/MeshTools/CompressIndices.h>
Compress vertex indices.
Parameters | |
---|---|
indices | Index array |
Returns | Index range, type and compressed index array |
This function takes index array and outputs them compressed to smallest possible size. For example when your indices have maximum number 463, it's wasteful to store them in array of 32bit integers, array of 16bit integers is sufficient.
Example usage:
std::vector<UnsignedInt> indices; Containers::Array<char> indexData; MeshIndexType indexType; UnsignedInt indexStart, indexEnd; std::tie(indexData, indexType, indexStart, indexEnd) = MeshTools::compressIndices(indices); GL::Buffer indexBuffer; indexBuffer.setData(indexData, GL::BufferUsage::StaticDraw); GL::Mesh mesh; mesh.setCount(indices.size()) .setIndexBuffer(indexBuffer, 0, indexType, indexStart, indexEnd);
#include <Magnum/MeshTools/CompressIndices.h>
template<class T>
Containers:: Array<T> Magnum:: MeshTools:: compressIndicesAs(const std:: vector<UnsignedInt>& indices)
Compress vertex indices as given type.
The type can be either UnsignedByte, UnsignedShort or UnsignedInt. Values in the index array are expected to be representable with given type.
Example usage:
std::vector<UnsignedInt> indices; Containers::Array<UnsignedShort> indexData = MeshTools::compressIndicesAs<UnsignedShort>(indices);
Trade:: MeshData Magnum:: MeshTools:: concatenate(const Containers:: Iterable<const Trade:: MeshData>& meshes,
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in 2020.06
#include <Magnum/MeshTools/Concatenate.h>
Concatenate meshes together.
Parameters | |
---|---|
meshes | Meshes to concatenate |
flags | Flags to pass to interleavedLayout() |
The returned mesh contains vertices from all meshes concatenated together. If any mesh is indexed (expected to not have an implementation-specific index type), the resulting mesh is indexed as well, with indices adjusted for vertex offsets of particular meshes. The behavior is undefined if any mesh has indices out of range for its particular vertex count. Meshes with MeshPrimitive::meshes
array is expected to have at least one item.
All attributes from the first mesh are taken, expected to not have an implementation-specific format. For each following mesh attributes present in the first are copied, superfluous attributes ignored and missing attributes zeroed out. Matching attributes are expected to have the same type, all meshes are expected to have the same primitive. In case of array attributes, attributes in subsequent meshes are expected to be arrays as well and have the same or smaller array size. Unused components at the end are zeroed out. The vertex data are concatenated in the same order as passed, with no duplicate removal. Returned instance vertex and index data flags always have both Trade::
The data layouting is done by interleavedLayout() with the flags
parameter propagated to it, see its documentation for detailed behavior description.
If an index buffer is needed, MeshIndexType::
#include <Magnum/MeshTools/Concatenate.h>
template<template<class> class Allocator = Containers::ArrayAllocator>
void Magnum:: MeshTools:: concatenateInto(Trade:: MeshData& destination,
const Containers:: Iterable<const Trade:: MeshData>& meshes,
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in 2020.06
Concatenate a list of meshes into a pre-existing destination, enlarging it if necessary.
Template parameters | |
---|---|
Allocator | Allocator to use |
Parameters | |
destination in/out | Destination mesh from which the output arrays as well as desired attribute layout is taken |
meshes in | Meshes to concatenate |
flags in | Flags to pass to interleavedLayout() |
Compared to concatenate(const Containers::destination
using Containers::allocator
, and reuses its atttribute data array instead of always allocating new ones. Only the attribute layout from destination
is used, all vertex/index data are taken from meshes
. Expects that meshes
contains at least one item.
Trade:: MeshData Magnum:: MeshTools:: copy(const Trade:: MeshData& mesh) new in Git master
#include <Magnum/MeshTools/Copy.h>
Make an owned copy of the mesh.
Allocates a copy of Trade::
Trade:: MeshData Magnum:: MeshTools:: copy(Trade:: MeshData&& mesh) new in Git master
#include <Magnum/MeshTools/Copy.h>
Make a mesh with owned data.
If Trade::
Trade:: MeshData Magnum:: MeshTools:: reference(const Trade:: MeshData& mesh) new in 2020.06
#include <Magnum/MeshTools/Copy.h>
Create an immutable reference on a Trade::
The returned instance has empty Trade::mesh
as well. The function performs no allocation or data copy. Use copy() for an inverse operation.
Trade:: MeshData Magnum:: MeshTools:: mutableReference(Trade:: MeshData& mesh) new in 2020.06
#include <Magnum/MeshTools/Copy.h>
Create a mutable reference on a Trade::
The returned instance has Trade::mesh
is mutable.
#include <Magnum/MeshTools/Duplicate.h>
template<class IndexType, class T>
Containers:: Array<T> Magnum:: MeshTools:: duplicate(const Containers:: StridedArrayView1D<const IndexType>& indices,
const Containers:: StridedArrayView1D<const T>& data) new in 2019.10
Duplicate data using given index array.
Converts indexed array to non-indexed, for example data {a, b, c, d}
with index array {1, 1, 0, 3, 2, 2}
will be converted to {b, b, a, d, c, c}
. The resulting array size is the same as size of indices
, expects that all indices are in range for the data
array.
If you want to fill an existing memory (or, for example a std::
#include <Magnum/MeshTools/Duplicate.h>
template<class T>
std:: vector<T> Magnum:: MeshTools:: duplicate(const std:: vector<UnsignedInt>& indices,
const std:: vector<T>& data)
Duplicate data using given index array.
#include <Magnum/MeshTools/Duplicate.h>
template<class IndexType, class T>
void Magnum:: MeshTools:: duplicateInto(const Containers:: StridedArrayView1D<const IndexType>& indices,
const Containers:: StridedArrayView1D<const T>& data,
const Containers:: StridedArrayView1D<T>& out) new in 2019.10
Duplicate data using an index array into given output array.
Parameters | |
---|---|
indices in | Index array to use |
data in | Input data |
out out | Where to store the output |
A variant of duplicate() that fills existing memory instead of allocating a new array. Expects that out
has the same size as indices
and all indices are in range for the data
array.
void Magnum:: MeshTools:: duplicateInto(const Containers:: StridedArrayView1D<const UnsignedInt>& indices,
const Containers:: StridedArrayView2D<const char>& data,
const Containers:: StridedArrayView2D<char>& out) new in 2020.06
#include <Magnum/MeshTools/Duplicate.h>
Duplicate type-erased data using an index array into given output array.
Parameters | |
---|---|
indices in | Index array to use |
data in | Input data |
out out | Where to store the output |
Compared to duplicateInto(const Containers::out
has the same size as indices
and all indices are in range for the data
array, and that the second dimension of both data
and out
is contiguous and has the same size.
void Magnum:: MeshTools:: duplicateInto(const Containers:: StridedArrayView1D<const UnsignedShort>& indices,
const Containers:: StridedArrayView2D<const char>& data,
const Containers:: StridedArrayView2D<char>& out) new in 2020.06
#include <Magnum/MeshTools/Duplicate.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: duplicateInto(const Containers:: StridedArrayView1D<const UnsignedByte>& indices,
const Containers:: StridedArrayView2D<const char>& data,
const Containers:: StridedArrayView2D<char>& out) new in 2020.06
#include <Magnum/MeshTools/Duplicate.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: duplicateInto(const Containers:: StridedArrayView2D<const char>& indices,
const Containers:: StridedArrayView2D<const char>& data,
const Containers:: StridedArrayView2D<char>& out) new in 2020.06
#include <Magnum/MeshTools/Duplicate.h>
Duplicate type-erased data using a type-erased index array into given output array.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the duplicateInto(const Containers::
Trade:: MeshData Magnum:: MeshTools:: duplicate(const Trade:: MeshData& mesh,
Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}) new in 2020.06
#include <Magnum/MeshTools/Duplicate.h>
Duplicate indexed mesh data.
Returns a copy of mesh
that's not indexed and has all attributes interleaved and duplicated according to mesh's
index buffer. The extra
attributes, if any, are duplicated and interleaved together with existing attributes (or, in case the attribute view is empty, only the corresponding space for given attribute type is reserved, with memory left uninitialized). The data layouting is done by interleavedLayout(), see its documentation for detailed behavior description. Note that offset-only Trade::extra
array.
Expects that mesh
is indexed with a non-implementation-specific index type and each attribute in extra
has either the same amount of elements as mesh
vertex count (not index count) or has none. All attributes are expected to not have an implementation-specific format.
Trade:: MeshData Magnum:: MeshTools:: duplicate(const Trade:: MeshData& mesh,
std:: initializer_list<Trade:: MeshAttributeData> extra) new in 2020.06
#include <Magnum/MeshTools/Duplicate.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Trade:: MeshData Magnum:: MeshTools:: filterAttributes(const Trade:: MeshData& mesh,
Containers:: BitArrayView attributesToKeep) new in Git master
#include <Magnum/MeshTools/Filter.h>
Filter a mesh to contain only the selected subset of attributes.
Returns a non-owning reference to the vertex and index buffer from mesh
with only the attributes for which the corresponding bit in attributesToKeep
was set. The index buffer, if present, is left untouched. The size of attributesToKeep
is expected to be equal to Trade::
This function only operates on the attribute metadata — if you'd like to have the vertex data repacked to contain just the remaining attributes as well, pass the output to interleave() without InterleaveFlag::
Trade:: MeshData Magnum:: MeshTools:: filterOnlyAttributes(const Trade:: MeshData& mesh,
Containers:: ArrayView<const Trade:: MeshAttribute> attributes) new in Git master
#include <Magnum/MeshTools/Filter.h>
Filter a mesh to contain only the selected subset of named attributes.
Returns a non-owning reference to the vertex and index buffer from mesh
with only the attributes that are listed in attributes
. The index buffer, if present, is left untouched. Attributes from the list that are not present in mesh
are skipped, duplicates in the list are treated the same as if given attribute was listed just once. If given attribute is present multiple times in the mesh (such as secondary colors or texture coordinates), all its occurences are kept — if you want a different behavior, use the filterOnlyAttributes(const Trade::
This function only operates on the attribute metadata — if you'd like to have the vertex data repacked to contain just the remaining attributes as well, pass the output to interleave() without InterleaveFlag::
Trade:: MeshData Magnum:: MeshTools:: filterOnlyAttributes(const Trade:: MeshData& mesh,
std:: initializer_list<Trade:: MeshAttribute> attributes) new in Git master
#include <Magnum/MeshTools/Filter.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Trade:: MeshData Magnum:: MeshTools:: filterExceptAttributes(const Trade:: MeshData& mesh,
Containers:: ArrayView<const Trade:: MeshAttribute> attributes) new in Git master
#include <Magnum/MeshTools/Filter.h>
Filter a mesh to contain everything except the selected subset of named attributes.
Returns a non-owning reference to the vertex and index buffer from mesh
with only the attributes that are not listed in attributes
. The index buffer, if present, is left untouched. Attributes from the list that are not present in mesh
are skipped, duplicates in the list are treated the same as if given attribute was listed just once. If given attribute is present multiple times in the mesh (such as secondary colors or texture coordinates), all its occurences are removed — if you want a different behavior, use the filterOnlyAttributes(const Trade::
This function only operates on the attribute metadata — if you'd like to have the vertex mesh repacked to contain just the remaining attributes as well, pass the output to interleave() without InterleaveFlag::
Trade:: MeshData Magnum:: MeshTools:: filterExceptAttributes(const Trade:: MeshData& mesh,
std:: initializer_list<Trade:: MeshAttribute> attributes) new in Git master
#include <Magnum/MeshTools/Filter.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Trade:: MeshData Magnum:: MeshTools:: filterOnlyAttributes(const Trade:: MeshData& mesh,
Containers:: ArrayView<const UnsignedInt> attributes)
Filter a mesh to contain only the selected subset of attributes.
Returns a non-owning reference to the vertex and index buffer from mesh
with only the attribute IDs listed in attributes
. IDs specified more than once don't result in given attribute being added multiple times. The index buffer, if present, is left untouched. All attribute IDs are expected to be smaller than Trade::
This function only operates on the attribute metadata — if you'd like to have the vertex data repacked to contain just the remaining attributes as well, pass the output to interleave() without InterleaveFlag::
Trade:: MeshData Magnum:: MeshTools:: filterOnlyAttributes(const Trade:: MeshData& mesh,
std:: initializer_list<UnsignedInt> attributes)
Filter a mesh to contain only the selected subset of attributes.
Trade:: MeshData Magnum:: MeshTools:: filterExceptAttributes(const Trade:: MeshData& mesh,
Containers:: ArrayView<const UnsignedInt> attributes)
Filter a mesh to contain everything except the selected subset of attributes.
Returns a non-owning reference to the vertex and index buffer from mesh
with only the attribute IDs that are not listed in attributes
. IDs specified multiple times behave like if specified just once. The index buffer, if present, is left untouched. All attribute IDs are expected to be smaller than Trade::attributes
is empty, the behavior is equivalent to reference().
This function only operates on the attribute metadata — if you'd like to have the vertex data repacked to contain just the remaining attributes as well, pass the output to interleave() without InterleaveFlag::
Trade:: MeshData Magnum:: MeshTools:: filterExceptAttributes(const Trade:: MeshData& mesh,
std:: initializer_list<UnsignedInt> attributes)
Filter a mesh to contain everything except the selected subset of attributes.
void Magnum:: MeshTools:: flipNormalsInPlace(const Containers:: StridedArrayView1D<UnsignedInt>& indices,
const Containers:: StridedArrayView1D<Vector3>& normals) new in 2020.06
#include <Magnum/MeshTools/FlipNormals.h>
Flip mesh normals and face winding in-place.
Parameters | |
---|---|
indices in/out | Index array to operate on |
normals in/out | Normal array to operate on |
Flips normal vectors and face winding in index array for face culling to work properly too. See also flipNormalsInPlace(const Containers::
void Magnum:: MeshTools:: flipNormalsInPlace(const Containers:: StridedArrayView1D<UnsignedShort>& indices,
const Containers:: StridedArrayView1D<Vector3>& normals) new in 2020.06
#include <Magnum/MeshTools/FlipNormals.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: flipNormalsInPlace(const Containers:: StridedArrayView1D<UnsignedByte>& indices,
const Containers:: StridedArrayView1D<Vector3>& normals) new in 2020.06
#include <Magnum/MeshTools/FlipNormals.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: flipNormalsInPlace(const Containers:: StridedArrayView2D<char>& indices,
const Containers:: StridedArrayView1D<Vector3>& normals) new in 2020.06
#include <Magnum/MeshTools/FlipNormals.h>
Flip mesh normals and face winding in-place on a type-erased index array.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the flipNormalsInPlace(const Containers::
void Magnum:: MeshTools:: flipNormals(std:: vector<UnsignedInt>& indices,
std:: vector<Vector3>& normals)
#include <Magnum/MeshTools/FlipNormals.h>
Flip mesh normals and face winding in-place.
void Magnum:: MeshTools:: flipFaceWindingInPlace(const Containers:: StridedArrayView1D<UnsignedInt>& indices) new in 2020.06
#include <Magnum/MeshTools/FlipNormals.h>
Flip face winding in-place.
Parameters | |
---|---|
indices in/out | Index array to operate on |
Same as flipNormalsInPlace(const Containers::
void Magnum:: MeshTools:: flipFaceWindingInPlace(const Containers:: StridedArrayView1D<UnsignedShort>& indices) new in 2020.06
#include <Magnum/MeshTools/FlipNormals.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: flipFaceWindingInPlace(const Containers:: StridedArrayView1D<UnsignedByte>& indices) new in 2020.06
#include <Magnum/MeshTools/FlipNormals.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: flipFaceWindingInPlace(const Containers:: StridedArrayView2D<char>& indices) new in 2020.06
#include <Magnum/MeshTools/FlipNormals.h>
Flip face winding in-place on a type-erased index array.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the flipFaceWindingInPlace(const Containers::
void Magnum:: MeshTools:: flipFaceWinding(std:: vector<UnsignedInt>& indices)
#include <Magnum/MeshTools/FlipNormals.h>
Flip face winding in-place.
void Magnum:: MeshTools:: flipNormalsInPlace(const Containers:: StridedArrayView1D<Vector3>& normals)
#include <Magnum/MeshTools/FlipNormals.h>
Flip mesh normals in-place.
Parameters | |
---|---|
normals in/out | Normal array to operate on |
Same as flipNormalsInPlace(const Containers::
void Magnum:: MeshTools:: flipNormals(std:: vector<Vector3>& normals)
#include <Magnum/MeshTools/FlipNormals.h>
Flip mesh normals in-place.
GL:: Mesh Magnum:: MeshTools:: fullScreenTriangle(GL:: Version version)
Full screen triangle mesh.
Returns a pre-configured mesh along with vertex buffer which can be used for full-screen post-processing effects. The mesh is a single triangle covering whole screen area ( in both dimensions) and provides only vertex positions, as other attributes (such as texture coordinates) can be calculated from them. The vertex positions are, in order:
Based on the version
parameter, on OpenGL 2.1, OpenGL ES 2.0 and WebGL 1 the vertex positions are passed explicitly as attribute 0
, contained in a vertex buffer owned by the mesh. On OpenGL 3.0+, OpenGL ES 3.0+ and WebGL 2 the mesh is attribute-less and the vertex positions can be calculated using the gl_VertexID
builtin shader variable.
Calculating positions in the shader in a portable way can be done like this. For OpenGL 2.1 and OpenGL ES 2.0 you then need to bind location of the position
attribute to 0
.
#if (!defined(GL_ES) && __VERSION__ >= 130) || (defined(GL_ES) && __VERSION__ >= 300) #define NEW_GLSL #endif #ifndef NEW_GLSL attribute lowp vec4 position; #endif void main() { #ifdef NEW_GLSL gl_Position = vec4((gl_VertexID == 2) ? 3.0 : -1.0, (gl_VertexID == 1) ? -3.0 : 1.0, 0.0, 1.0); #else gl_Position = position; #endif }
GL:: Mesh Magnum:: MeshTools:: fullScreenTriangle()
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This function implicitly uses current context version.
UnsignedInt Magnum:: MeshTools:: primitiveCount(MeshPrimitive primitive,
UnsignedInt elementCount) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Actual primitive count for given primitive type and element count.
Returns how many primitives is generated for given primitive
and elementCount
, for example for MeshPrimitive::elementCount/3
. Expects that primitive
is valid, elementCount
is either zero or at least 2
for a line-based primitive and at least 3
for a triangle-based primitive, is divisible by 2
for MeshPrimitive::3
for MeshPrimitive::
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateTrivialIndices(UnsignedInt vertexCount) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create a trivial index buffer.
Generates a 0, 1, 2, 3, 4, 5, ...
sequence, i.e. what std::
void Magnum:: MeshTools:: generateTrivialIndicesInto(const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create a trivial index buffer into an existing array.
A variant of generateTrivialIndices() that fills existing memory instead of allocating a new array.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateLineStripIndices(UnsignedInt vertexCount) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a line strip primitive.
Generates a 0, 1, 1, 2, 3, 4, ...
sequence. Can be used to convert a MeshPrimitive::vertexCount
is expected to be either 0
or at least 2
. Primitive restart is not supported. If the mesh is already indexed, use generateLineStripIndices(const Containers::
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateLineStripIndices(const Containers:: StridedArrayView1D<const UnsignedInt>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for an indexed line strip primitive.
Like generateLineStripIndices(UnsignedInt), but merges indices
into the generated line strip index buffer.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateLineStripIndices(const Containers:: StridedArrayView1D<const UnsignedShort>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateLineStripIndices(const Containers:: StridedArrayView1D<const UnsignedByte>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateLineStripIndices(const Containers:: StridedArrayView2D<const char>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a line strip primitive with a type-erased index buffer.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the generateLineStripIndices(const Containers::
void Magnum:: MeshTools:: generateLineStripIndicesInto(UnsignedInt vertexCount,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a line strip primitive into an existing array.
A variant of generateLineStripIndices() that fills existing memory instead of allocating a new array. The vertexCount
is expected to be either 0
or at least 2
, the output
array is expected to have a size of 2*(vertexCount - 1)
. Primitive restart is not supported. If the mesh is already indexed, use generateLineStripIndicesInto(const Containers::
void Magnum:: MeshTools:: generateLineStripIndicesInto(const Containers:: StridedArrayView1D<const UnsignedInt>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for an indexed line strip primitive into an existing array.
Like generateLineStripIndicesInto(UnsignedInt, const Containers::indices
into the generated line strip index buffer.
void Magnum:: MeshTools:: generateLineStripIndicesInto(const Containers:: StridedArrayView1D<const UnsignedShort>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: generateLineStripIndicesInto(const Containers:: StridedArrayView1D<const UnsignedByte>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: generateLineStripIndicesInto(const Containers:: StridedArrayView2D<const char>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a line strip primitive with a type-erased index buffer into an existing array.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the generateLineStripIndicesInto(const Containers::
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateLineLoopIndices(UnsignedInt vertexCount) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a line loop primitive.
Generates a 0, 1, 1, 2, 3, ..., 0
sequence. Can be used to convert a MeshPrimitive::vertexCount
is expected to be either 0
or at least 2
. Primitive restart is not supported. If the mesh is already indexed, use generateLineLoopIndices(const Containers::
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateLineLoopIndices(const Containers:: StridedArrayView1D<const UnsignedInt>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for an indexed line loop primitive.
Like generateLineLoopIndices(UnsignedInt), but merges indices
into the generated line loop index buffer.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateLineLoopIndices(const Containers:: StridedArrayView1D<const UnsignedShort>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateLineLoopIndices(const Containers:: StridedArrayView1D<const UnsignedByte>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateLineLoopIndices(const Containers:: StridedArrayView2D<const char>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a line loop primitive with a type-erased index buffer.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the generateLineLoopIndices(const Containers::
void Magnum:: MeshTools:: generateLineLoopIndicesInto(UnsignedInt vertexCount,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a line loop primitive into an existing array.
A variant of generateLineLoopIndices() that fills existing memory instead of allocating a new array. The vertexCount
is expected to be either 0
or at least 2
, the output
array is expected to have a size of 2*vertexCount
. Primitive restart is not supported.If the mesh is already indexed, use generateLineLoopIndicesInto(const Containers::
void Magnum:: MeshTools:: generateLineLoopIndicesInto(const Containers:: StridedArrayView1D<const UnsignedInt>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for an indexed line loop primitive into an existing array.
Like generateLineLoopIndicesInto(UnsignedInt, const Containers::indices
into the generated line loop index buffer.
void Magnum:: MeshTools:: generateLineLoopIndicesInto(const Containers:: StridedArrayView1D<const UnsignedShort>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: generateLineLoopIndicesInto(const Containers:: StridedArrayView1D<const UnsignedByte>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: generateLineLoopIndicesInto(const Containers:: StridedArrayView2D<const char>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a line loop primitive with a type-erased index buffer into an existing array.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the generateLineLoopIndicesInto(const Containers::
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateTriangleStripIndices(UnsignedInt vertexCount) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a triangle strip primitive.
Generates a 0, 1, 2, 2, 1, 3, 2, 3, 4, ...
sequence. Can be used to convert a MeshPrimitive::vertexCount
is expected to be either 0
or at least 3
. Primitive restart is not supported. If the mesh is already indexed, use generateTriangleStripIndices(const Containers::
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateTriangleStripIndices(const Containers:: StridedArrayView1D<const UnsignedInt>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for an indexed triangle strip primitive.
Like generateTriangleStripIndices(UnsignedInt), but merges indices
into the generated triangle strip index buffer.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateTriangleStripIndices(const Containers:: StridedArrayView1D<const UnsignedShort>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateTriangleStripIndices(const Containers:: StridedArrayView1D<const UnsignedByte>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateTriangleStripIndices(const Containers:: StridedArrayView2D<const char>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a triangle strip primitive with a type-erased index buffer.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the generateTriangleStripIndices(const Containers::
void Magnum:: MeshTools:: generateTriangleStripIndicesInto(UnsignedInt vertexCount,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a triangle strip primitive into an existing array.
A variant of generateTriangleStripIndices() that fills existing memory instead of allocating a new array. The vertexCount
is expected to be either 0
or at least 3
, the output
array is expected to have a size of 3*(vertexCount - 2)
. Primitive restart is not supported. If the mesh is already indexed, use generateTriangleStripIndicesInto(const Containers::
void Magnum:: MeshTools:: generateTriangleStripIndicesInto(const Containers:: StridedArrayView1D<const UnsignedInt>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for an indexed triangle strip primitive into an existing array.
Like generateTriangleStripIndicesInto(UnsignedInt, const Containers::indices
into the generated triangle strip index buffer.
void Magnum:: MeshTools:: generateTriangleStripIndicesInto(const Containers:: StridedArrayView1D<const UnsignedShort>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: generateTriangleStripIndicesInto(const Containers:: StridedArrayView1D<const UnsignedByte>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: generateTriangleStripIndicesInto(const Containers:: StridedArrayView2D<const char>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a triangle strip primitive with a type-erased index buffer into an existing array.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the generateTriangleStripIndicesInto(const Containers::
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateTriangleFanIndices(UnsignedInt vertexCount) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a triangle fan primitive.
Generates a 0, 1, 2, 0, 2, 3, 0, 3, 4, ...
sequence. Can be used to convert a MeshPrimitive::vertexCount
is expected to be either 0
or at least 3
. Primitive restart is not supported. If the mesh is already indexed, use generateTriangleFanIndices(const Containers::
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateTriangleFanIndices(const Containers:: StridedArrayView1D<const UnsignedInt>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for an indexed triangle fan primitive.
Like generateTriangleFanIndices(UnsignedInt), but merges indices
into the generated triangle fan index buffer.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateTriangleFanIndices(const Containers:: StridedArrayView1D<const UnsignedShort>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateTriangleFanIndices(const Containers:: StridedArrayView1D<const UnsignedByte>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateTriangleFanIndices(const Containers:: StridedArrayView2D<const char>& indices) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a triangle fan primitive with a type-erased index buffer.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the generateTriangleFanIndices(const Containers::
void Magnum:: MeshTools:: generateTriangleFanIndicesInto(UnsignedInt vertexCount,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a triangle fan primitive into an existing array.
A variant of generateTriangleFanIndices() that fills existing memory instead of allocating a new array. The vertexCount
is expected to be either 0
or at least 3
, the output
array is expected to have a size of 3*(vertexCount - 2)
. Primitive restart is not supported. If the mesh is already indexed, use generateTriangleFanIndicesInto(const Containers::
void Magnum:: MeshTools:: generateTriangleFanIndicesInto(const Containers:: StridedArrayView1D<const UnsignedInt>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for an indexed triangle fan primitive into an existing array.
Like generateTriangleFanIndicesInto(UnsignedInt, const Containers::indices
into the generated triangle fan index buffer.
void Magnum:: MeshTools:: generateTriangleFanIndicesInto(const Containers:: StridedArrayView1D<const UnsignedShort>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: generateTriangleFanIndicesInto(const Containers:: StridedArrayView1D<const UnsignedByte>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: generateTriangleFanIndicesInto(const Containers:: StridedArrayView2D<const char>& indices,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a triangle fan primitive with a type-erased index buffer into an existing array.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the generateTriangleFanIndicesInto(const Containers::
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateQuadIndices(const Containers:: StridedArrayView1D<const Vector3>& positions,
const Containers:: StridedArrayView1D<const UnsignedInt>& quads) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create a triangle index buffer for quad primitives.
For each quad ABCD
gives a pair of triangles that is either ABC ACD
or DAB DBC
, correctly handling cases of non-convex quads and avoiding thin triangles where possible. Loosely based on this SO question:
- If normals of triangles
ABC
andACD
point in opposite direction andDAB DBC
not (which is equivalent to pointsD
andB
being on the same side of a diagonalAC
in a two-dimensional case), split asDAB DBC
- Otherwise, if normals of triangles
DAB
andDBC
point in opposite direction andABC ACD
not (which is equivalent to pointsA
andC
being on the same side of a diagonalDB
in a two-dimensional case), split asABC ACD
- Otherwise the normals either point in the same direction in both cases or the quad is non-planar and ambiguous, pick the case where the diagonal is shorter
Size of quads
is expected to be divisible by 4
and all indices being in bounds of the positions
view.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateQuadIndices(const Containers:: StridedArrayView1D<const Vector3>& positions,
const Containers:: StridedArrayView1D<const UnsignedShort>& quads) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Containers:: Array<UnsignedInt> Magnum:: MeshTools:: generateQuadIndices(const Containers:: StridedArrayView1D<const Vector3>& positions,
const Containers:: StridedArrayView1D<const UnsignedByte>& quads) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: generateQuadIndicesInto(const Containers:: StridedArrayView1D<const Vector3>& positions,
const Containers:: StridedArrayView1D<const UnsignedInt>& quads,
const Containers:: StridedArrayView1D<UnsignedInt>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
Create a triangle index buffer for quad primitives into an existing array.
A variant of generateQuadIndices() that fills existing memory instead of allocating a new array. Size of quads
is expected to be divisible by 4
and output
should have a size that's quads.size()*6/4
.
void Magnum:: MeshTools:: generateQuadIndicesInto(const Containers:: StridedArrayView1D<const Vector3>& positions,
const Containers:: StridedArrayView1D<const UnsignedShort>& quads,
const Containers:: StridedArrayView1D<UnsignedShort>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: generateQuadIndicesInto(const Containers:: StridedArrayView1D<const Vector3>& positions,
const Containers:: StridedArrayView1D<const UnsignedByte>& quads,
const Containers:: StridedArrayView1D<UnsignedByte>& output) new in Git master
#include <Magnum/MeshTools/GenerateIndices.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Trade:: MeshData Magnum:: MeshTools:: generateIndices(const Trade:: MeshData& mesh) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Convert a mesh to plain indexed lines or triangles.
If mesh
is one of MeshPrimitive::0
vertices or at least 2
vertices for a line-based primitive and 3
vertices for a triangle-based primitive. If mesh
is a different MeshPrimitive, it's passed through unchanged if already indexed, and with indices generated using generateTrivialIndices() otherwise.
If mesh
is already indexed, the index type is expected to be non-implementation-specific.
The resulting mesh always has MeshIndexType::
Trade:: MeshData Magnum:: MeshTools:: generateIndices(Trade:: MeshData&& mesh) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Convert a mesh to plain indexed lines or triangles.
Compared to generateIndices(const Trade::mesh
vertex buffer (in case it is owned) to the returned instance instead of making a copy of it, and index buffer as well if it's owned, doesn't need expanding and is already with MeshIndexType::
Trade:: MeshData Magnum:: MeshTools:: generateLines(const Trade:: MeshData& lineMesh) new in Git master
#include <Magnum/MeshTools/GenerateLines.h>
Generate a line mesh for use with Shaders::
Creates a MeshPrimitive::
Each line segment in the input vertices is converted to a quad, with first two vertices inheriting vertex data from the first point of the segment and second two vertices inheriting data from the second point of the segment. If the input mesh is indexed, it's deindexed first. Neighbor information from a MeshPrimitive::
For compatibility with shaders other than Shaders::
Expects that the mesh contains at least a Trade::
The returned Trade::
Containers:: Array<Vector3> Magnum:: MeshTools:: generateFlatNormals(const Containers:: StridedArrayView1D<const Vector3>& positions) new in 2019.10
#include <Magnum/MeshTools/GenerateNormals.h>
Generate flat normals.
Parameters | |
---|---|
positions | Triangle vertex positions |
Returns | Per-vertex normals |
All vertices in each triangle face get the same normal vector. Expects that the position count is divisible by 3. If you need to generate flat normals for an indexed mesh, duplicate() the vertices first, after the operation you might want to remove the duplicates again using removeDuplicatesInPlace(). Example usage:
Containers::ArrayView<UnsignedInt> indices; Containers::ArrayView<Vector3> indexedPositions; Containers::Array<Vector3> positions = MeshTools::duplicate<UnsignedInt, Vector3>(indices, indexedPositions); Containers::Array<Vector3> normals = MeshTools::generateFlatNormals(positions);
void Magnum:: MeshTools:: generateFlatNormalsInto(const Containers:: StridedArrayView1D<const Vector3>& positions,
const Containers:: StridedArrayView1D<Vector3>& normals) new in 2019.10
#include <Magnum/MeshTools/GenerateNormals.h>
Generate flat normals into an existing array.
Parameters | |
---|---|
positions in | Triangle vertex positions |
normals out | Where to put the generated normals |
A variant of generateFlatNormals() that fills existing memory instead of allocating a new array. The normals
array is expected to have the same size as positions
.
Useful when you need to interface for example with STL containers — in that case #include
Corrade/
#include <Corrade/Containers/ArrayViewStl.h> // … std::vector<Vector3> positions; std::vector<Vector3> normals{positions.size()}; MeshTools::generateFlatNormalsInto(positions, normals);
std:: pair<std:: vector<UnsignedInt>, std:: vector<Vector3>> Magnum:: MeshTools:: generateFlatNormals(const std:: vector<UnsignedInt>& indices,
const std:: vector<Vector3>& positions)
#include <Magnum/MeshTools/GenerateNormals.h>
Generate flat normals.
Parameters | |
---|---|
indices | Triangle face indices |
positions | Triangle vertex positions |
Returns | Normal indices and vectors |
All vertices in each triangle face get the same normal vector. Removes duplicates before returning. Expects that the position count is divisible by 3.
Containers:: Array<Vector3> Magnum:: MeshTools:: generateSmoothNormals(const Containers:: StridedArrayView1D<const UnsignedInt>& indices,
const Containers:: StridedArrayView1D<const Vector3>& positions) new in 2019.10
#include <Magnum/MeshTools/GenerateNormals.h>
Generate smooth normals.
Parameters | |
---|---|
indices | Triangle face indices |
positions | Triangle vertex positions |
Returns | Per-vertex normals |
Uses the indices
array to discover adjacent triangles and then for each vertex position calculates a normal averaged from all triangles that share it. The normal is weighted according to adjacent triangle area and angle at given vertex; hard edges are preserved where adjacent triangles don't share vertices. Triangles with zero area or triangles containing invalid positions (NaNs) don't contribute to calculated vertex normals.
Implementation is based on the article Weighted Vertex Normals by Martijn Buijs.
Containers:: Array<Vector3> Magnum:: MeshTools:: generateSmoothNormals(const Containers:: StridedArrayView1D<const UnsignedShort>& indices,
const Containers:: StridedArrayView1D<const Vector3>& positions) new in 2019.10
#include <Magnum/MeshTools/GenerateNormals.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Containers:: Array<Vector3> Magnum:: MeshTools:: generateSmoothNormals(const Containers:: StridedArrayView1D<const UnsignedByte>& indices,
const Containers:: StridedArrayView1D<const Vector3>& positions) new in 2019.10
#include <Magnum/MeshTools/GenerateNormals.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Containers:: Array<Vector3> Magnum:: MeshTools:: generateSmoothNormals(const Containers:: StridedArrayView2D<const char>& indices,
const Containers:: StridedArrayView1D<const Vector3>& positions) new in 2020.06
#include <Magnum/MeshTools/GenerateNormals.h>
Generate smooth normals using a type-erased index array.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the generateSmoothNormals(const Containers::
void Magnum:: MeshTools:: generateSmoothNormalsInto(const Containers:: StridedArrayView1D<const UnsignedInt>& indices,
const Containers:: StridedArrayView1D<const Vector3>& positions,
const Containers:: StridedArrayView1D<Vector3>& normals) new in 2019.10
#include <Magnum/MeshTools/GenerateNormals.h>
Generate smooth normals into an existing array.
Parameters | |
---|---|
indices in | Triangle face indices |
positions in | Triangle vertex positions |
normals out | Where to put the generated normals |
A variant of generateSmoothNormals() that fills existing memory instead of allocating a new array. The normals
array is expected to have the same size as positions
. Note that even with the output array this function isn't fully allocation-free — it still allocates three additional internal arrays for adjacent face calculation.
Useful when you need to interface for example with STL containers — in that case #include
Corrade/
#include <Corrade/Containers/ArrayViewStl.h> // … std::vector<UnsignedInt> indices; std::vector<Vector3> positions; std::vector<Vector3> normals{positions.size()}; MeshTools::generateSmoothNormalsInto(indices, positions, normals);
void Magnum:: MeshTools:: generateSmoothNormalsInto(const Containers:: StridedArrayView1D<const UnsignedShort>& indices,
const Containers:: StridedArrayView1D<const Vector3>& positions,
const Containers:: StridedArrayView1D<Vector3>& normals) new in 2019.10
#include <Magnum/MeshTools/GenerateNormals.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: generateSmoothNormalsInto(const Containers:: StridedArrayView1D<const UnsignedByte>& indices,
const Containers:: StridedArrayView1D<const Vector3>& positions,
const Containers:: StridedArrayView1D<Vector3>& normals) new in 2019.10
#include <Magnum/MeshTools/GenerateNormals.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: generateSmoothNormalsInto(const Containers:: StridedArrayView2D<const char>& indices,
const Containers:: StridedArrayView1D<const Vector3>& positions,
const Containers:: StridedArrayView1D<Vector3>& normals) new in 2020.06
#include <Magnum/MeshTools/GenerateNormals.h>
Generate smooth normals into an existing array using a type-erased index array.
Expects that normals
has the same size as positions
and that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the generateSmoothNormalsInto(const Containers::
#include <Magnum/MeshTools/Interleave.h>
template<class T, class ... U>
Containers:: Array<char> Magnum:: MeshTools:: interleave(const T& first,
const U&... next)
Interleave vertex attributes.
This function takes list of attribute arrays and returns them interleaved, so data for each attribute are in continuous place in memory. Expects that all attributes have the same element count.
Example usage:
Containers::ArrayView<const Vector3> positions; Containers::ArrayView<const Vector2> textureCoordinates; GL::Buffer vertexBuffer; vertexBuffer.setData(MeshTools::interleave(positions, textureCoordinates)); GL::Mesh mesh; mesh.setCount(positions.size()) .addVertexBuffer(vertexBuffer, 0, MyShader::Position{}, MyShader::TextureCoordinates{});
It's often desirable to align data for one vertex on 32bit boundaries. To achieve that, you can specify gaps between the attributes:
Containers::ArrayView<const Vector4> positions; Containers::ArrayView<const UnsignedShort> weights; Containers::ArrayView<const Color3ub> vertexColors; auto data = MeshTools::interleave(positions, weights, 2, vertexColors, 1);
All gap bytes are set zero. This way vertex stride is 24 bytes, without gaps it would be 21 bytes, causing possible performance loss.
#include <Magnum/MeshTools/Interleave.h>
template<class T, class ... U>
void Magnum:: MeshTools:: interleaveInto(Containers:: ArrayView<char> buffer,
const T& first,
const U&... next)
Interleave vertex attributes into existing buffer.
Unlike interleave() this function interleaves the data into existing buffer and leaves gaps untouched instead of zero-initializing them. This function can thus be used for interleaving data depending on runtime parameters. Expects that all arrays have the same size and the passed buffer is large enough to contain the interleaved data.
bool Magnum:: MeshTools:: isInterleaved(const Trade:: MeshData& mesh) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
If the mesh data is interleaved.
Returns true
if all attributes have the same positive stride and the difference between minimal and maximal offset is not larger than the stride, false
otherwise. In particular, returns true
also if the mesh has just one or no attributes.
While interleaved layouts technically may also have zero or negative strides, this case is currently not implemented and such layouts are treated as non-interleaved.
Containers:: StridedArrayView2D<const char> Magnum:: MeshTools:: interleavedData(const Trade:: MeshData& mesh) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
Type-erased view on interleaved mesh data.
Returns a 2D view on Trade::
First dimension of the returned view has size equal to vertex count and stride equal to original stride, second dimension size is the smallest possible byte count to cover all interleaved attributes, including any padding between them but not before or after.
Containers:: StridedArrayView2D<char> Magnum:: MeshTools:: interleavedMutableData(Trade:: MeshData& mesh) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
Mutable type-erased view on interleaved mesh data.
Same as interleavedData(), but returns a mutable view. Expects that the mesh is interleaved and vertex data is mutable.
Trade:: MeshData Magnum:: MeshTools:: interleavedLayout(const Trade:: MeshData& mesh,
UnsignedInt vertexCount,
Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {},
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
Create an interleaved mesh layout.
Returns a Trade::vertexCount
vertices containing attributes from both mesh
and extra
interleaved together. No data is actually copied, only an interleaved layout is created. If mesh
is already interleaved according to isInterleaved() and InterleaveFlag::flags
, keeps the attributes in the same layout, potentially extending them with extra
. The extra
attributes, if any, are interleaved together with existing attributes. Returned instance vertex data flags have both Trade::
For greater control over the layout you can also pass an empty Trade::extra
with attributes cherry-picked using Trade::
Containers::ArrayView<const Trade::MeshAttributeData> attributes = data.attributeData(); /* Take just positions and normals and add a four-byte padding in between */ Trade::MeshData layout = MeshTools::interleavedLayout( Trade::MeshData{MeshPrimitive::Triangles, 0}, vertexCount, { attributes[data.attributeId(Trade::MeshAttribute::Position)], Trade::MeshAttributeData{4}, attributes[data.attributeId(Trade::MeshAttribute::Normal)] });
This function doesn't preserve index data information in any way, making the output non-indexed. If you want to preserve index data, create a new indexed instance with attribute and vertex data transferred from the returned instance:
Trade::MeshData layout = MeshTools::interleavedLayout(data, vertexCount, extraAttributes); Trade::MeshIndexData indices; Trade::MeshData indexed{data.primitive(), std::move(indexData), indices, layout.releaseVertexData(), layout.releaseAttributeData()};
This function will unconditionally allocate a new array to store all Trade::
All attributes in both mesh
and extra
are expected to not have an implementation-specific format, except for mesh
attributes in case mesh
is already interleaved, then the layout is untouched.
Trade:: MeshData Magnum:: MeshTools:: interleavedLayout(const Trade:: MeshData& mesh,
UnsignedInt vertexCount,
std:: initializer_list<Trade:: MeshAttributeData> extra,
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Trade:: MeshData Magnum:: MeshTools:: interleavedLayout(Trade:: MeshData&& mesh,
UnsignedInt vertexCount,
Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {},
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
Create an interleaved mesh layout.
Compared to interleavedLayout(const Trade::mesh
instead of allocating a new one if there are no attributes passed in extra
, the attribute array is owned by the mesh and InterleaveFlag::flags
.
Trade:: MeshData Magnum:: MeshTools:: interleavedLayout(Trade:: MeshData&& mesh,
UnsignedInt vertexCount,
std:: initializer_list<Trade:: MeshAttributeData> extra,
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Trade:: MeshData Magnum:: MeshTools:: interleave(const Trade:: MeshData& mesh,
Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {},
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
Interleave mesh data.
Returns a copy of mesh
with all attributes interleaved. The extra
attributes, if any, are interleaved together with existing attributes (or, in case the attribute view is empty, only the corresponding space for given attribute type is reserved, with memory left uninitialized). The data layouting is done by interleavedLayout() with the flags
parameter propagated to it, see its documentation for detailed behavior description. Note that offset-only Trade::extra
array.
Indices (if any) are kept as-is only if they're tightly packed and not with an implementation-specific type. Otherwise the behavior depends on presence of InterleaveFlag::
Expects that each attribute in extra
has either the same amount of elements as mesh
vertex count or has none. This function will unconditionally make a copy of all data even if mesh
is already interleaved and needs no change, use interleave(Trade::
All attributes in both mesh
and extra
are expected to not have an implementation-specific format, except for mesh
attributes in case data
is already interleaved, then the layout is untouched.
Trade:: MeshData Magnum:: MeshTools:: interleave(const Trade:: MeshData& mesh,
std:: initializer_list<Trade:: MeshAttributeData> extra,
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Trade:: MeshData Magnum:: MeshTools:: interleave(Trade:: MeshData&& mesh,
Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {},
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
Interleave mesh data.
Compared to interleave(const Trade::mesh
index buffer (in case it is owned) and vertex buffer (in case it is owned, already interleaved, there's no extra
attributes and InterleaveFlag::flags
) to the returned instance instead of making copies of them.
Trade:: MeshData Magnum:: MeshTools:: interleave(Trade:: MeshData&& mesh,
std:: initializer_list<Trade:: MeshAttributeData> extra,
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Trade:: MeshData Magnum:: MeshTools:: owned(const Trade:: MeshData& mesh)
#include <Magnum/MeshTools/Reference.h>
Create an owned Trade::
Trade:: MeshData Magnum:: MeshTools:: owned(Trade:: MeshData&& mesh)
#include <Magnum/MeshTools/Reference.h>
Create an owned Trade::
Containers:: Pair<Containers:: Array<UnsignedInt>, std:: size_t> Magnum:: MeshTools:: removeDuplicatesInPlace(const Containers:: StridedArrayView2D<char>& data) new in 2020.06
Remove duplicate data from given array in-place.
Parameters | |
---|---|
data in/out | Data array, duplicate items will be cut away with order preserved |
Returns | The resulting index array and size of unique prefix in the cleaned up data array |
Removes duplicate data from given array by comparing the second dimension of each item, the second dimension is expected to be contiguous. A plain bit-exact matching is used, if you need fuzzy comparison for floating-point data, use removeDuplicatesFuzzyInPlace() instead. If you want to remove duplicate data from an already indexed array, use removeDuplicatesIndexedInPlace(const Containers::
Containers::ArrayView<Vector3i> data; Containers::Pair<Containers::Array<UnsignedInt>, std::size_t> unique = MeshTools::removeDuplicatesInPlace(Containers::arrayCast<2, char>(data)); data = data.prefix(unique.second());
See removeDuplicates(const Containers::
std:: size_t Magnum:: MeshTools:: removeDuplicatesInPlaceInto(const Containers:: StridedArrayView2D<char>& data,
const Containers:: StridedArrayView1D<UnsignedInt>& indices) new in 2020.06
Remove duplicate data from given array in-place into given output index array.
Parameters | |
---|---|
data in/out | Data array, duplicate items will be cut away with order preserved |
indices out | Where to put the resulting index array |
Returns | Size of unique prefix in the cleaned up data array |
Same as above, except that the index array is not allocated but put into indices
instead. Expects that indices
has the same size as data
.
Containers:: Pair<Containers:: Array<UnsignedInt>, std:: size_t> Magnum:: MeshTools:: removeDuplicates(const Containers:: StridedArrayView2D<const char>& data) new in 2020.06
Remove duplicate data from given array.
Parameters | |
---|---|
data in | Data array |
Returns | The resulting index array and count of unique items in the original data array |
Compared to removeDuplicatesInPlace(const Containers::
std:: size_t Magnum:: MeshTools:: removeDuplicatesInto(const Containers:: StridedArrayView2D<const char>& data,
const Containers:: StridedArrayView1D<UnsignedInt>& indices) new in 2020.06
Remove duplicate data from given array into given output index array.
Parameters | |
---|---|
data in | Data array |
indices out | Where to put the resulting index array |
Returns | Count of unique items in the original data array |
Compared to removeDuplicatesInPlaceInto(const Containers::
std:: size_t Magnum:: MeshTools:: removeDuplicatesIndexedInPlace(const Containers:: StridedArrayView1D<UnsignedInt>& indices,
const Containers:: StridedArrayView2D<char>& data) new in 2020.06
Remove duplicates from indexed data in-place.
Parameters | |
---|---|
indices in/out | Index array, which will get remapped to list just unique data |
data in/out | Data array, duplicate items will be cut away with order preserved |
Returns | Size of unique prefix in the cleaned up data array |
Compared to removeDuplicatesInPlace(const Containers::
std:: size_t Magnum:: MeshTools:: removeDuplicatesIndexedInPlace(const Containers:: StridedArrayView1D<UnsignedShort>& indices,
const Containers:: StridedArrayView2D<char>& data) new in 2020.06
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: size_t Magnum:: MeshTools:: removeDuplicatesIndexedInPlace(const Containers:: StridedArrayView1D<UnsignedByte>& indices,
const Containers:: StridedArrayView2D<char>& data) new in 2020.06
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: size_t Magnum:: MeshTools:: removeDuplicatesIndexedInPlace(const Containers:: StridedArrayView2D<char>& indices,
const Containers:: StridedArrayView2D<char>& data) new in 2020.06
Remove duplicates from indexed data in-place on a type-erased index array.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls one of the removeDuplicatesIndexedInPlace(const Containers::
Containers:: Pair<Containers:: Array<UnsignedInt>, std:: size_t> Magnum:: MeshTools:: removeDuplicatesFuzzyInPlace(const Containers:: StridedArrayView2D<Float>& data,
Float epsilon = Math:: TypeTraits<Float>::epsilon()) new in 2020.06
Remove duplicate data from given array using fuzzy comparison in-place.
Parameters | |
---|---|
data in/out | Data array, duplicate items will be cut away with order preserved |
epsilon in | Epsilon value, data closer than this distance will be melt together |
Returns | Size of unique prefix in the cleaned up data array and the resulting index array |
Removes duplicate data from the array by collapsing them into buckets of size epsilon
. First vector in given bucket is used, other ones are thrown away, no interpolation is done. Note that this function is meant to be used for floating-point data (or generally with non-zero epsilon
), for data where bit-exact matching is sufficient use removeDuplicatesInPlace(const Containers::
If you want to remove duplicate data from an already indexed array, use removeDuplicatesFuzzyIndexedInPlace(const Containers::
If you want to remove duplicates in multiple incidental arrays, first remove duplicates in each array separately and then combine the resulting index arrays back into a single one using combineIndexedAttributes().
Containers:: Pair<Containers:: Array<UnsignedInt>, std:: size_t> Magnum:: MeshTools:: removeDuplicatesFuzzyInPlace(const Containers:: StridedArrayView2D<Double>& data,
Double epsilon = Math:: TypeTraits<Double>::epsilon()) new in 2020.06
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: size_t Magnum:: MeshTools:: removeDuplicatesFuzzyInPlaceInto(const Containers:: StridedArrayView2D<Float>& data,
const Containers:: StridedArrayView1D<UnsignedInt>& indices,
Float epsilon = Math:: TypeTraits<Float>::epsilon()) new in 2020.06
Remove duplicate data from given array using fuzzy comparison in-place into given output index array.
Parameters | |
---|---|
data in/out | Data array, duplicate items will be cut away with order preserved |
indices out | Where to put the resulting index array |
epsilon in | Epsilon value, data closer than this distance will be melt together |
Returns | Size of unique prefix in the cleaned up data array |
Same as above, except that the index array is not allocated but put into indices
instead. Expects that indices
has the same size as data
.
std:: size_t Magnum:: MeshTools:: removeDuplicatesFuzzyInPlaceInto(const Containers:: StridedArrayView2D<Double>& data,
const Containers:: StridedArrayView1D<UnsignedInt>& indices,
Double epsilon = Math:: TypeTraits<Double>::epsilon()) new in 2020.06
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class Vector>
std:: vector<UnsignedInt> Magnum:: MeshTools:: removeDuplicates(std:: vector<Vector>& data,
typename Vector::Type epsilon = Math:: TypeTraits<typename Vector::Type>::epsilon())
Remove duplicate data from a STL vector using fuzzy comparison in-place.
Parameters | |
---|---|
data in/out | Data array, duplicate items will be cut away with order preserved and the size shrunk to just the unique prefix |
epsilon in | Epsilon value, vertices closer than this distance will be melt together |
Returns | Resulting index array |
Similar to the above, except that it's operating on a std::
std::vector<Vector3> positions; std::vector<Vector2> texCoords; std::vector<UnsignedInt> positionIndices = MeshTools::removeDuplicates(positions); std::vector<UnsignedInt> texCoordIndices = MeshTools::removeDuplicates(texCoords); std::vector<UnsignedInt> indices = MeshTools::combineIndexedArrays( std::make_pair(std::cref(positionIndices), std::ref(positions)), std::make_pair(std::cref(texCoordIndices), std::ref(texCoords)) );
std:: size_t Magnum:: MeshTools:: removeDuplicatesFuzzyIndexedInPlace(const Containers:: StridedArrayView1D<UnsignedInt>& indices,
const Containers:: StridedArrayView2D<Float>& data,
Float epsilon = Math:: TypeTraits<Float>::epsilon()) new in 2020.06
Remove duplicates from indexed data using fuzzy comparison in-place.
Parameters | |
---|---|
indices in/out | Index array, which will get remapped to list just unique vertices |
data in/out | Data array, duplicate items will be cut away with order preserved |
epsilon in | Epsilon value, vertices closer than this distance will be melt together |
Returns | Size of unique prefix in the cleaned up data array |
Compared to removeDuplicatesFuzzyInPlace(const Containers::
std:: size_t Magnum:: MeshTools:: removeDuplicatesFuzzyIndexedInPlace(const Containers:: StridedArrayView1D<UnsignedShort>& indices,
const Containers:: StridedArrayView2D<Float>& data,
Float epsilon = Math:: TypeTraits<Float>::epsilon()) new in 2020.06
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: size_t Magnum:: MeshTools:: removeDuplicatesFuzzyIndexedInPlace(const Containers:: StridedArrayView1D<UnsignedByte>& indices,
const Containers:: StridedArrayView2D<Float>& data,
Float epsilon = Math:: TypeTraits<Float>::epsilon()) new in 2020.06
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: size_t Magnum:: MeshTools:: removeDuplicatesFuzzyIndexedInPlace(const Containers:: StridedArrayView1D<UnsignedInt>& indices,
const Containers:: StridedArrayView2D<Double>& data,
Double epsilon = Math:: TypeTraits<Double>::epsilon()) new in 2020.06
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: size_t Magnum:: MeshTools:: removeDuplicatesFuzzyIndexedInPlace(const Containers:: StridedArrayView1D<UnsignedShort>& indices,
const Containers:: StridedArrayView2D<Double>& data,
Double epsilon = Math:: TypeTraits<Double>::epsilon()) new in 2020.06
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: size_t Magnum:: MeshTools:: removeDuplicatesFuzzyIndexedInPlace(const Containers:: StridedArrayView1D<UnsignedByte>& indices,
const Containers:: StridedArrayView2D<Double>& data,
Double epsilon = Math:: TypeTraits<Double>::epsilon()) new in 2020.06
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: size_t Magnum:: MeshTools:: removeDuplicatesFuzzyIndexedInPlace(const Containers:: StridedArrayView2D<char>& indices,
const Containers:: StridedArrayView2D<Float>& data,
Float epsilon = Math:: TypeTraits<Float>::epsilon()) new in 2020.06
Remove duplicates from indexed data using fuzzy comparison in-place on a type-erased index array.
Expects that the second dimension of indices
is contiguous and represents the actual 1/2/4-byte index type. Based on its size then calls removeDuplicatesFuzzyIndexedInPlace(const Containers::
std:: size_t Magnum:: MeshTools:: removeDuplicatesFuzzyIndexedInPlace(const Containers:: StridedArrayView2D<char>& indices,
const Containers:: StridedArrayView2D<Double>& data,
Double epsilon = Math:: TypeTraits<Double>::epsilon()) new in 2020.06
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Trade:: MeshData Magnum:: MeshTools:: removeDuplicates(const Trade:: MeshData& mesh) new in 2020.06
Remove mesh data duplicates.
Equivalent to calling removeDuplicatesInPlace() (or removeDuplicatesIndexedInPlace(), in case the mesh is indexed) on a mutable copy of every attribute and then putting the unique prefix and newly generated index buffer into a new Trade::
In order to remove random padding values from the input and make the vertices suitable for fast in-place duplicate removal, this function unconditionally copies and interleaves the input vertex and index data.
Trade:: MeshData Magnum:: MeshTools:: removeDuplicatesFuzzy(const Trade:: MeshData& mesh,
Float floatEpsilon = Math:: TypeTraits<Float>::epsilon(),
Double doubleEpsilon = Math:: TypeTraits<Double>::epsilon()) new in 2020.06
Remove mesh data duplicates with fuzzy comparison for floating-point attributes.
Compared to removeDuplicates(const Trade::floatEpsilon
/ doubleEpsilon
is scaled appropriately, otherwise it's scaled to calculated value range.
#include <Magnum/MeshTools/Subdivide.h>
template<class IndexType, class Vertex, class Interpolator>
void Magnum:: MeshTools:: subdivide(Containers:: Array<IndexType>& indices,
Containers:: Array<Vertex>& vertices,
Interpolator interpolator) new in 2020.06
Subdivide a mesh.
Template parameters | |
---|---|
IndexType | |
Vertex | Vertex data type |
Interpolator | See the interpolator function parameter |
Parameters | |
indices in/out | Index array to operate on |
vertices in/out | Vertex array to operate on |
interpolator | Functor or function pointer which interpolates two adjacent vertices: Vertex interpolator(Vertex a, Vertex b) |
Goes through all triangle faces and subdivides them into four new, enlarging the indices
and vertices
arrays as appropriate. Removing duplicate vertices in the mesh is up to the user.
#include <Magnum/MeshTools/Subdivide.h>
template<class Vertex, class Interpolator>
void Magnum:: MeshTools:: subdivide(std:: vector<UnsignedInt>& indices,
std:: vector<Vertex>& vertices,
Interpolator interpolator)
Subdivide a mesh.
#include <Magnum/MeshTools/Subdivide.h>
template<class IndexType, class Vertex, class Interpolator>
void Magnum:: MeshTools:: subdivideInPlace(const Containers:: StridedArrayView1D<IndexType>& indices,
const Containers:: StridedArrayView1D<Vertex>& vertices,
Interpolator interpolator) new in 2020.06
Subdivide a mesh in-place.
Template parameters | |
---|---|
IndexType | |
Vertex | Vertex data type |
Interpolator | See the interpolator function parameter |
Parameters | |
indices in/out | Index array to operate on |
vertices in/out | Vertex array to operate on |
interpolator | Functor or function pointer which interpolates two adjacent vertices: Vertex interpolator(Vertex a, Vertex b) |
Assuming the original mesh has indices and vertices, expects the indices
array to have a size of (as every triangle face would be divided into four new), with the original indices being in the first quarter, and the vertices
array to have a size of (as every original triangle face will get three new vertices). Removing duplicate vertices in the mesh is up to the user.
Generally, for subsequent subdivisions, the resulting index and vertex array sizes and will be as following. To subdivide the mesh multiple times in-place, pass correctly sized prefix of the arrays to each step.
#include <Magnum/MeshTools/Subdivide.h>
template<class IndexType, class Vertex, class Interpolator>
void Magnum:: MeshTools:: subdivideInPlace(const Containers:: ArrayView<IndexType>& indices,
const Containers:: StridedArrayView1D<Vertex>& vertices,
Interpolator interpolator) new in 2020.06
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: tipsifyInPlace(const Containers:: StridedArrayView1D<UnsignedInt>& indices,
UnsignedInt vertexCount,
std:: size_t cacheSize)
#include <Magnum/MeshTools/Tipsify.h>
Tipsify the mesh in-place.
Parameters | |
---|---|
indices in/out | Indices array to operate on |
vertexCount in | Vertex count |
cacheSize in | Post-transform vertex cache size |
Optimizes the mesh for vertex-bound applications by rearranging its index array for beter usage of post-transform vertex cache. Algorithm used: Pedro V. Sander, Diego Nehab, and Joshua Barczak — Fast Triangle Reordering for Vertex Locality and Reduced Overdraw, SIGGRAPH 2007, https://gfx.cs.princeton.edu/pubs/Sander_
void Magnum:: MeshTools:: tipsifyInPlace(const Containers:: StridedArrayView1D<UnsignedShort>& indices,
UnsignedInt vertexCount,
std:: size_t cacheSize) new in 2020.06
#include <Magnum/MeshTools/Tipsify.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: tipsifyInPlace(const Containers:: StridedArrayView1D<UnsignedByte>& indices,
UnsignedInt vertexCount,
std:: size_t cacheSize) new in 2020.06
#include <Magnum/MeshTools/Tipsify.h>
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: MeshTools:: tipsify(std:: vector<UnsignedInt>& indices,
UnsignedInt vertexCount,
std:: size_t cacheSize)
#include <Magnum/MeshTools/Tipsify.h>
Tipsify the mesh in-place.
#include <Magnum/MeshTools/Transform.h>
template<class T, class U>
void Magnum:: MeshTools:: transformVectorsInPlace(const Math:: Matrix4<T>& matrix,
U&& vectors)
Transform vectors in-place using given transformation.
Usable for one-time mesh transformations that would otherwise negatively affect dependent objects, such as (uneven) scaling. Accepts any forward-iterable type with compatible vector type as vectors
. Expects that Quaternion is normalized, no further requirements are for other transformation representations.
Unlike in transformPointsInPlace(), the transformation does not involve translation.
Example usage:
std::vector<Vector3> vectors; auto transformation = Quaternion::rotation(35.0_degf, Vector3::yAxis()); MeshTools::transformVectorsInPlace(transformation, vectors);
#include <Magnum/MeshTools/Transform.h>
template<class T, class U>
void Magnum:: MeshTools:: transformVectorsInPlace(const Math:: Matrix3<T>& matrix,
U&& vectors)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
#include <Magnum/MeshTools/Transform.h>
template<class T, class U>
void Magnum:: MeshTools:: transformVectorsInPlace(const Math:: Complex<T>& complex,
U&& vectors)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
#include <Magnum/MeshTools/Transform.h>
template<class T, class U>
void Magnum:: MeshTools:: transformVectorsInPlace(const Math:: Quaternion<T>& normalizedQuaternion,
U&& vectors)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
#include <Magnum/MeshTools/Transform.h>
template<class T, class U>
U Magnum:: MeshTools:: transformVectors(const T& transformation,
U vectors)
Transform vectors using given transformation.
Returns transformed vectors instead of modifying them in-place. See transformVectorsInPlace() for more information.
#include <Magnum/MeshTools/Transform.h>
template<class T, class U>
void Magnum:: MeshTools:: transformPointsInPlace(const Math:: Matrix4<T>& matrix,
U&& points)
Transform points in-place using given transformation.
Usable for one-time mesh transformations that would otherwise negatively affect dependent objects, such as (uneven) scaling. Accepts any forward-iterable type with compatible vector type as vectors
. Expects that DualQuaternion is normalized, no further requirements are for other transformation representations.
Unlike in transformVectorsInPlace(), the transformation also involves translation.
Example usage:
std::vector<Vector3> points; auto transformation = DualQuaternion::rotation(35.0_degf, Vector3::yAxis())* DualQuaternion::translation({0.5f, -1.0f, 3.0f}); MeshTools::transformPointsInPlace(transformation, points);
#include <Magnum/MeshTools/Transform.h>
template<class T, class U>
void Magnum:: MeshTools:: transformPointsInPlace(const Math:: Matrix3<T>& matrix,
U&& points)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
#include <Magnum/MeshTools/Transform.h>
template<class T, class U>
void Magnum:: MeshTools:: transformPointsInPlace(const Math:: DualComplex<T>& dualComplex,
U&& points)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
#include <Magnum/MeshTools/Transform.h>
template<class T, class U>
void Magnum:: MeshTools:: transformPointsInPlace(const Math:: DualQuaternion<T>& normalizedDualQuaternion,
U&& points)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
#include <Magnum/MeshTools/Transform.h>
template<class T, class U>
U Magnum:: MeshTools:: transformPoints(const T& transformation,
U vectors)
Transform points using given transformation.
Returns transformed points instead of modifying them in-place. See transformPointsInPlace() for more information.
Trade:: MeshData Magnum:: MeshTools:: transform2D(const Trade:: MeshData& mesh,
const Matrix3& transformation,
UnsignedInt id = 0,
Int morphTargetId = -1,
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in Git master
#include <Magnum/MeshTools/Transform.h>
Transform 2D positions in a mesh data.
Expects that the mesh contains a two-dimensional Trade::id
(and in morph target morphTargetId
if not -1
) and that the attribute does not have an implementation-specific format. To avoid data loss with packed types, the positions are converted to VertexFormat::flags
parameter propagated to it, see its documentation for detailed behavior description. Other attributes, position attributes other than id
or with different morphTargetId
, and indices (if any) are passed through untouched.
See also transform2D(Trade::
Trade:: MeshData Magnum:: MeshTools:: transform2D(const Trade:: MeshData& mesh,
const Matrix3& transformation,
UnsignedInt id,
InterleaveFlags flags)
#include <Magnum/MeshTools/Transform.h>
Transform 2D positions in a mesh data.
Trade:: MeshData Magnum:: MeshTools:: transform2D(Trade:: MeshData&& mesh,
const Matrix3& transformation,
UnsignedInt id = 0,
Int morphTargetId = -1,
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in Git master
#include <Magnum/MeshTools/Transform.h>
Transform 2D positions in a mesh data.
Compared to transform2D(const Trade::id
in morphTargetId
are VertexFormat::
Trade:: MeshData Magnum:: MeshTools:: transform2D(Trade:: MeshData&& mesh,
const Matrix3& transformation,
UnsignedInt id,
InterleaveFlags flags)
#include <Magnum/MeshTools/Transform.h>
Transform 2D positions in a mesh data.
void Magnum:: MeshTools:: transform2DInPlace(Trade:: MeshData& mesh,
const Matrix3& transformation,
UnsignedInt id = 0,
Int morphTargetId = -1) new in Git master
#include <Magnum/MeshTools/Transform.h>
Transform 2D positions in a mesh data in-place.
Expects that the mesh has mutable vertex data and contains a two-dimensional Trade::id
(and in morph target morphTargetId
if not -1
). To avoid data loss with packed types, the in-place operation requires the position type to be VertexFormat::id
or with different morphTargetId
, and indices (if any) are left untouched.
Trade:: MeshData Magnum:: MeshTools:: transform3D(const Trade:: MeshData& mesh,
const Matrix4& transformation,
UnsignedInt id = 0,
Int morphTargetId = -1,
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in Git master
#include <Magnum/MeshTools/Transform.h>
Transform 3D positions, normals, tangents and bitangents in a mesh data.
Expects that the mesh contains a three-dimensional Trade::id
(and in morph target morphTargetId
if not -1
). If Trade::id
in morphTargetId
are present as well, those get transformed with Matrix4::transformation
. All these attributes are expected to not have an implementation-specific format. To avoid data loss with packed types, the positions, normals and bitangents are converted to VertexFormat::flags
parameter propagated to it, see its documentation for detailed behavior description. Other attributes, additional position/TBN attributes other than id
or with different morphTargetId
, and indices (if any) are passed through untouched.
See also transform3D(Trade::
Trade:: MeshData Magnum:: MeshTools:: transform3D(const Trade:: MeshData& mesh,
const Matrix4& transformation,
UnsignedInt id,
InterleaveFlags flags)
#include <Magnum/MeshTools/Transform.h>
Transform 3D positions, normals, tangents and bitangents in a mesh data.
Trade:: MeshData Magnum:: MeshTools:: transform3D(Trade:: MeshData&& mesh,
const Matrix4& transformation,
UnsignedInt id = 0,
Int morphTargetId = -1,
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in Git master
#include <Magnum/MeshTools/Transform.h>
Transform 3D positions, normals, tangenta and bitangents in a mesh data.
Compared to transform3D(const Trade::id
in morphTargetId
(if present) are VertexFormat::id
in morphTargetId
(if present) are either VertexFormat::
Trade:: MeshData Magnum:: MeshTools:: transform3D(Trade:: MeshData&& mesh,
const Matrix4& transformation,
UnsignedInt id,
InterleaveFlags flags)
#include <Magnum/MeshTools/Transform.h>
Transform 3D positions, normals, tangenta and bitangents in a mesh data.
void Magnum:: MeshTools:: transform3DInPlace(Trade:: MeshData& mesh,
const Matrix4& transformation,
UnsignedInt id = 0,
Int morphTargetId = -1) new in Git master
#include <Magnum/MeshTools/Transform.h>
Transform 3D positions, normals, tangents and bitangents in a mesh data in-place.
Expects that the mesh has mutable vertex data and contains at least a three-dimensional Trade::id
(and in morph target morphTargetId
if not -1
); optionally also Trade::id
in morphTargetId
, those get transformed with Matrix4::transformation
. To avoid data loss with packed types, the in-place operation requires the position, normal and bitangent types to be VertexFormat::id
or with different morphTargetId
, and indices (if any) are left untouched.
Trade:: MeshData Magnum:: MeshTools:: transformTextureCoordinates2D(const Trade:: MeshData& mesh,
const Matrix3& transformation,
UnsignedInt id = 0,
Int morphTargetId = -1,
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in Git master
#include <Magnum/MeshTools/Transform.h>
Transform 2D texture coordinates in a mesh data.
Expects that the mesh contains a Trade::id
(and in morph target morphTargetId
if not -1
). To avoid data loss with packed types, the coordinattes are converted to VertexFormat::flags
parameter propagated to it, see its documentation for detailed behavior description. Other attributes, texture coordinate attributes other than id
or with different morphTargetId
, and indices (if any) are passed through untouched.
See also transformTextureCoordinates2D(Trade::
Trade:: MeshData Magnum:: MeshTools:: transformTextureCoordinates2D(const Trade:: MeshData& mesh,
const Matrix3& transformation,
UnsignedInt id,
InterleaveFlags flags)
#include <Magnum/MeshTools/Transform.h>
Transform 2D texture coordinates in a mesh data.
Trade:: MeshData Magnum:: MeshTools:: transformTextureCoordinates2D(Trade:: MeshData&& mesh,
const Matrix3& transformation,
UnsignedInt id = 0,
Int morphTargetId = -1,
InterleaveFlags flags = InterleaveFlag:: PreserveInterleavedAttributes) new in Git master
#include <Magnum/MeshTools/Transform.h>
Transform 2D texture coordinates in a mesh data.
Compared to transformTextureCoordinates2D(const Trade::id
in morphTargetId
are VertexFormat::
Trade:: MeshData Magnum:: MeshTools:: transformTextureCoordinates2D(Trade:: MeshData&& mesh,
const Matrix3& transformation,
UnsignedInt id,
InterleaveFlags flags)
#include <Magnum/MeshTools/Transform.h>
Transform 2D texture coordinates in a mesh data.
void Magnum:: MeshTools:: transformTextureCoordinates2DInPlace(Trade:: MeshData& mesh,
const Matrix3& transformation,
UnsignedInt id = 0,
Int morphTargetId = -1) new in Git master
#include <Magnum/MeshTools/Transform.h>
Transform 2D texture coordinates in a mesh data in-place.
Expects that the mesh has mutable vertex data and contains a Trade::id
(and in morph target morphTargetId
if not -1
) and that the attribute does not have an implementation-specific format. To avoid data loss with packed types, the in-place operation requires the coordinate type to be VertexFormat::id
or with different morphTargetId
, and indices (if any) are passed through untouched.