namespace
MeshToolsMesh tools.
Tools for generating, optimizing and cleaning meshes.
This library is built if 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 WITH_GL
and 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.
Typedefs
-
using CompileFlags = Containers::
EnumSet<CompileFlag> new in 2019.10 - Mesh compilation flags.
Functions
-
auto combineIndexedAttributes(const Containers::
ArrayView<const Containers:: Reference<const Trade:: MeshData>> data) -> Trade:: MeshData new in 2020.06 - Combine differently indexed attributes into a single mesh.
-
auto combineIndexedAttributes(std::
initializer_list<Containers:: Reference<const Trade:: MeshData>> data) -> Trade:: MeshData new in 2020.06 -
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& meshData, CompileFlags flags) -> GL:: Mesh new in 2020.06 - Compile mesh data.
-
auto compile(const Trade::
MeshData& meshData) -> GL:: Mesh new in 2020.06 -
auto compile(const Trade::
MeshData& meshData, GL:: Buffer& indices, GL:: Buffer& vertices) -> GL:: Mesh new in 2020.06 - Compile mesh data using external buffers.
-
auto compile(const Trade::
MeshData& meshData, GL:: Buffer& indices, GL:: Buffer&& vertices) -> GL:: Mesh new in 2020.06 -
auto compile(const Trade::
MeshData& meshData, GL:: Buffer&& indices, GL:: Buffer& vertices) -> GL:: Mesh new in 2020.06 -
auto compile(const Trade::
MeshData& meshData, 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 compressIndices(const Containers::
StridedArrayView1D<const UnsignedInt>& indices, MeshIndexType atLeast = MeshIndexType:: UnsignedShort, Long offset = 0) -> std:: 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) -> std:: pair<Containers:: Array<char>, MeshIndexType> new in 2020.06 -
auto compressIndices(const Containers::
StridedArrayView1D<const UnsignedByte>& indices, MeshIndexType atLeast = MeshIndexType:: UnsignedShort, Long offset = 0) -> std:: pair<Containers:: Array<char>, MeshIndexType> new in 2020.06 -
auto compressIndices(const Containers::
StridedArrayView1D<const UnsignedInt>& indices, Long offset) -> std:: pair<Containers:: Array<char>, MeshIndexType> new in 2020.06 -
auto compressIndices(const Containers::
StridedArrayView1D<const UnsignedShort>& indices, Long offset) -> std:: pair<Containers:: Array<char>, MeshIndexType> new in 2020.06 -
auto compressIndices(const Containers::
StridedArrayView1D<const UnsignedByte>& indices, Long offset) -> std:: pair<Containers:: Array<char>, MeshIndexType> new in 2020.06 -
auto compressIndices(const Containers::
StridedArrayView2D<const char>& indices, MeshIndexType atLeast = MeshIndexType:: UnsignedShort, Long offset = 0) -> std:: 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) -> std:: pair<Containers:: Array<char>, MeshIndexType> new in 2020.06 -
auto compressIndices(const Trade::
MeshData& data, MeshIndexType atLeast = MeshIndexType:: UnsignedShort) -> Trade:: MeshData new in 2020.06 - Compress mesh data indices.
-
auto compressIndices(Trade::
MeshData&& data, 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(Containers::
ArrayView<const Containers:: Reference<const Trade:: MeshData>> meshes) -> Trade:: MeshData new in 2020.06 - Concatenate meshes together.
-
auto concatenate(std::
initializer_list<Containers:: Reference<const Trade:: MeshData>> meshes) -> Trade:: MeshData new in 2020.06 -
template<template<class> class Allocator = Containers::ArrayAllocator>void concatenateInto(Trade::
MeshData& destination, const Containers:: ArrayView<const Containers:: Reference<const Trade:: MeshData>> meshes) new in 2020.06 - Concatenate a list of meshes into a pre-existing destination, enlarging it if necessary.
-
template<template<class> class Allocator = Containers::ArrayAllocator>void concatenateInto(Trade::
MeshData& destination, const std:: initializer_list<Containers:: Reference<const Trade:: MeshData>> meshes) new in 2020.06 -
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& data, Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}) -> Trade:: MeshData new in 2020.06 - Duplicate indexed mesh data.
-
auto duplicate(const Trade::
MeshData& data, std:: initializer_list<Trade:: MeshAttributeData> extra) -> Trade:: MeshData new in 2020.06 -
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 generateLineStripIndices(UnsignedInt vertexCount) -> Containers::
Array<UnsignedInt> new in 2020.06 - Create index buffer for a line strip primitive.
-
void generateLineStripIndicesInto(UnsignedInt vertexCount,
const Containers::
StridedArrayView1D<UnsignedInt>& indices) new in 2020.06 - Create index buffer for a line strip primitive into an existing array.
-
auto generateLineLoopIndices(UnsignedInt vertexCount) -> Containers::
Array<UnsignedInt> new in 2020.06 - Create index buffer for a line loop primitive.
-
void generateLineLoopIndicesInto(UnsignedInt vertexCount,
const Containers::
StridedArrayView1D<UnsignedInt>& into) new in 2020.06 - Create index buffer for a line loop primitive into an existing array.
-
auto generateTriangleStripIndices(UnsignedInt vertexCount) -> Containers::
Array<UnsignedInt> new in 2020.06 - Create index buffer for a triangle strip primitive.
-
void generateTriangleStripIndicesInto(UnsignedInt vertexCount,
const Containers::
StridedArrayView1D<UnsignedInt>& into) new in 2020.06 - Create index buffer for a triangle strip primitive into an existing array.
-
auto generateTriangleFanIndices(UnsignedInt vertexCount) -> Containers::
Array<UnsignedInt> new in 2020.06 - Create index buffer for a triangle fan primitive.
-
void generateTriangleFanIndicesInto(UnsignedInt vertexCount,
const Containers::
StridedArrayView1D<UnsignedInt>& into) new in 2020.06 - Create index buffer for a triangle fan primitive 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>& into) 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>& into) new in Git master -
void generateQuadIndicesInto(const Containers::
StridedArrayView1D<const Vector3>& positions, const Containers:: StridedArrayView1D<const UnsignedByte>& quads, const Containers:: StridedArrayView1D<UnsignedByte>& into) 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&& data) -> Trade:: MeshData new in 2020.06 - Convert a mesh to plain indexed lines or triangles.
-
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& data) -> bool new in 2020.06 - If the mesh data is interleaved.
-
auto interleavedData(const Trade::
MeshData& data) -> Containers:: StridedArrayView2D<const char> new in 2020.06 - Type-erased view on interleaved mesh data.
-
auto interleavedMutableData(Trade::
MeshData& data) -> Containers:: StridedArrayView2D<char> new in 2020.06 - Mutable type-erased view on interleaved mesh data.
-
auto interleavedLayout(const Trade::
MeshData& data, UnsignedInt vertexCount, Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}) -> Trade:: MeshData new in 2020.06 - Create an interleaved mesh layout.
-
auto interleavedLayout(const Trade::
MeshData& data, UnsignedInt vertexCount, std:: initializer_list<Trade:: MeshAttributeData> extra) -> Trade:: MeshData new in 2020.06 -
auto interleavedLayout(Trade::
MeshData&& data, UnsignedInt vertexCount, Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}) -> Trade:: MeshData new in 2020.06 - Create an interleaved mesh layout.
-
auto interleavedLayout(Trade::
MeshData&& data, UnsignedInt vertexCount, std:: initializer_list<Trade:: MeshAttributeData> extra) -> Trade:: MeshData new in 2020.06 -
auto interleave(const Trade::
MeshData& data, Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}) -> Trade:: MeshData new in 2020.06 - Interleave mesh data.
-
auto interleave(const Trade::
MeshData& data, std:: initializer_list<Trade:: MeshAttributeData> extra) -> Trade:: MeshData new in 2020.06 -
auto interleave(Trade::
MeshData&& data, Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}) -> Trade:: MeshData new in 2020.06 - Interleave mesh data.
-
auto interleave(Trade::
MeshData&& data, std:: initializer_list<Trade:: MeshAttributeData> extra) -> Trade:: MeshData new in 2020.06 -
auto reference(const Trade::
MeshData& data) -> Trade:: MeshData new in 2020.06 - Create an immutable reference on a Trade::
MeshData. -
auto mutableReference(Trade::
MeshData& data) -> Trade:: MeshData new in 2020.06 - Create a mutable reference on a Trade::
MeshData. -
auto owned(const Trade::
MeshData& data) -> Trade:: MeshData new in 2020.06 - Create an owned Trade::
MeshData. -
auto owned(Trade::
MeshData&& data) -> Trade:: MeshData new in 2020.06 - Create an owned Trade::
MeshData, if not already. -
auto removeDuplicatesInPlace(const Containers::
StridedArrayView2D<char>& data) -> std:: 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) -> std:: 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()) -> std:: 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()) -> std:: 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& data) -> Trade:: MeshData new in 2020.06 - Remove mesh data duplicates.
-
auto removeDuplicates(Trade::
MeshData&& data) -> Trade:: MeshData new in 2020.06 - Remove mesh data duplicates.
-
auto removeDuplicatesFuzzy(const Trade::
MeshData& data, 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.
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 and attributes with implementation-specific format, as those get ignored by it. If you're binding those manually with compile(const Trade:: |
Typedef documentation
typedef Containers:: EnumSet<CompileFlag> Magnum:: MeshTools:: CompileFlags new in 2019.10
#include <Magnum/MeshTools/Compile.h>
Mesh compilation flags.
Function documentation
Trade:: MeshData Magnum:: MeshTools:: combineIndexedAttributes(const Containers:: ArrayView<const Containers:: Reference<const Trade:: MeshData>> data) new in 2020.06
#include <Magnum/MeshTools/Combine.h>
Combine differently indexed attributes into a single mesh.
Assuming each data
contains only unique vertex data, creates an indexed mesh that contains all attributes from data
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 data
is non-empty and all data have the same primitive and index count. All inputs have to be indexed, although the particular MeshIndexType doesn't matter. For non-indexed attributes combining can be done much more efficiently using duplicate(const Trade::
Trade:: MeshData Magnum:: MeshTools:: combineIndexedAttributes(std:: initializer_list<Containers:: Reference<const Trade:: MeshData>> data) 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.
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.
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& meshData,
CompileFlags flags) new in 2020.06
#include <Magnum/MeshTools/Compile.h>
Compile mesh data.
Configures a mesh for a Shaders::
- If the mesh contains positions, these are bound to the Shaders::
Generic2D:: Position attribute if they are 2D or to Shaders:: Generic3D:: Position if they are 3D. - If the mesh contains normals or if CompileFlag::
GenerateFlatNormals / CompileFlag:: GenerateSmoothNormals is set, these are bound to Shaders:: Generic3D:: Normal. - If the mesh contains texture coordinates, these are bound to Shaders::
Generic:: TextureCoordinates. - If the mesh contains colors, these are bound to Shaders::
Generic:: Color3 / Shaders:: Generic:: Color4 based on their type. - Custom attributes and known attributes of implementation-specific types are ignored with a warning. See the compile(const Trade::
MeshData&, GL:: Buffer&, GL:: Buffer&) for an example showing how to bind them manually, and CompileFlag:: NoWarnOnCustomAttributes to suppress the warning.
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& meshData) 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& meshData,
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, vertices; indices.setData(meshData.indexData()); vertices.setData(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:
GL::Buffer indices, vertices; indices.setData(meshData.indexData()); vertices.setData(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{ GL::DynamicAttribute::Kind::Generic, 7, GL::DynamicAttribute::Components::One, GL::DynamicAttribute::DataType::Float});
If meshData
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& meshData,
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& meshData,
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& meshData,
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::
std:: 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::Array<char> indexData; MeshIndexType indexType; std::tie(indexData, indexType) = MeshTools::compressIndices(indices); GL::Buffer indexBuffer; indexBuffer.setData(indexData); GL::Mesh mesh; mesh.setCount(indices.size()) .setIndexBuffer(indexBuffer, 0, indexType);
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); std::pair<Containers::Array<char>, MeshIndexType> result = 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::
std:: 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.
std:: 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.
std:: 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::
std:: 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::
std:: 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::
std:: 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::
std:: 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& data,
MeshIndexType atLeast = MeshIndexType:: UnsignedShort) new in 2020.06
#include <Magnum/MeshTools/CompressIndices.h>
Compress mesh data indices.
Does the same as compressIndices(const Containers::
Trade:: MeshData Magnum:: MeshTools:: compressIndices(Trade:: MeshData&& data,
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(Containers:: ArrayView<const Containers:: Reference<const Trade:: MeshData>> meshes) new in 2020.06
#include <Magnum/MeshTools/Concatenate.h>
Concatenate meshes together.
The returned mesh contains vertices from all meshes concatenated together. If any mesh is indexed, 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 bounds 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; 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. 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::
If an index buffer is needed, MeshIndexType::
Trade:: MeshData Magnum:: MeshTools:: concatenate(std:: initializer_list<Containers:: Reference<const Trade:: MeshData>> meshes) new in 2020.06
#include <Magnum/MeshTools/Concatenate.h>
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/Concatenate.h>
template<template<class> class Allocator = Containers::ArrayAllocator>
void Magnum:: MeshTools:: concatenateInto(Trade:: MeshData& destination,
const Containers:: ArrayView<const Containers:: Reference<const Trade:: MeshData>> meshes) 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 |
Compared to concatenate(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.
#include <Magnum/MeshTools/Concatenate.h>
template<template<class> class Allocator = Containers::ArrayAllocator>
void Magnum:: MeshTools:: concatenateInto(Trade:: MeshData& destination,
const std:: initializer_list<Containers:: Reference<const Trade:: MeshData>> meshes) 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.
#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& data,
Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}) new in 2020.06
#include <Magnum/MeshTools/Duplicate.h>
Duplicate indexed mesh data.
Returns a copy of data
that's not indexed and has all attributes interleaved and duplicated according to data'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 data
is indexed and each attribute in extra
has either the same amount of elements as data
vertex count (not index count) or has none.
Trade:: MeshData Magnum:: MeshTools:: duplicate(const Trade:: MeshData& data,
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.
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, return value is rounded down if there's not enough elements for given primitive type (so for 14 vertices you get just 4 triangles, for example).
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.
Can be used to convert a MeshPrimitive::vertexCount
is expected to be at least 2
. Primitive restart is not supported.
void Magnum:: MeshTools:: generateLineStripIndicesInto(UnsignedInt vertexCount,
const Containers:: StridedArrayView1D<UnsignedInt>& indices) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a line strip primitive into an existing array.
A variant of generateLineStripIndicesInto() that fills existing memory instead of allocating a new array. The vertexCount
is expected to be at least 2
, the indices
array is expected to have a size of 2*(vertexCount - 1)
. Primitive restart is not supported.
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.
Can be used to convert a MeshPrimitive::vertexCount
is expected to be at least 2
. Primitive restart is not supported.
void Magnum:: MeshTools:: generateLineLoopIndicesInto(UnsignedInt vertexCount,
const Containers:: StridedArrayView1D<UnsignedInt>& into) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a line loop primitive into an existing array.
A variant of generateLineLoopIndicesInto() that fills existing memory instead of allocating a new array. The vertexCount
is expected to be at least 2
, the indices
array is expected to have a size of 2*vertexCount
. Primitive restart is not supported.
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.
Can be used to convert a MeshPrimitive::vertexCount
is expected to be at least 3
. Primitive restart is not supported.
void Magnum:: MeshTools:: generateTriangleStripIndicesInto(UnsignedInt vertexCount,
const Containers:: StridedArrayView1D<UnsignedInt>& into) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a triangle strip primitive into an existing array.
A variant of generateTriangleStripIndicesInto() that fills existing memory instead of allocating a new array. The vertexCount
is expected to be at least 3
, the indices
array is expected to have a size of 3*(vertexCount - 2)
. Primitive restart is not supported.
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.
Can be used to convert a MeshPrimitive::vertexCount
is expected to be at least 3
. Primitive restart is not supported.
void Magnum:: MeshTools:: generateTriangleFanIndicesInto(UnsignedInt vertexCount,
const Containers:: StridedArrayView1D<UnsignedInt>& into) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Create index buffer for a triangle fan primitive into an existing array.
A variant of generateTriangleFanIndicesInto() that fills existing memory instead of allocating a new array. The vertexCount
is expected to be at least 3
, the indices
array is expected to have a size of 3*(vertexCount - 2)
. Primitive restart is not supported.
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>& into) 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 into
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>& into) 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>& into) 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.
Expects that mesh
is not indexed and is one of MeshPrimitive::
The resulting mesh always has MeshIndexType::
Trade:: MeshData Magnum:: MeshTools:: generateIndices(Trade:: MeshData&& data) new in 2020.06
#include <Magnum/MeshTools/GenerateIndices.h>
Convert a mesh to plain indexed lines or triangles.
Compared to generateIndices(const Trade::data
vertex buffer (in case it is owned) to the returned instance instead of making a copy of it. Attribute data is copied always.
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& data) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
If the mesh data is interleaved.
Returns true
if all attributes have the same 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.
Containers:: StridedArrayView2D<const char> Magnum:: MeshTools:: interleavedData(const Trade:: MeshData& data) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
Type-erased view on interleaved mesh data.
Returns a 2D view on Trade::
Containers:: StridedArrayView2D<char> Magnum:: MeshTools:: interleavedMutableData(Trade:: MeshData& data) 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& data,
UnsignedInt vertexCount,
Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
Create an interleaved mesh layout.
Returns a Trade::vertexCount
vertices containing attributes from both data
and extra
interleaved together. No data is actually copied, only an interleaved layout is created. If data
is already interleaved, 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 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::
Trade:: MeshData Magnum:: MeshTools:: interleavedLayout(const Trade:: MeshData& data,
UnsignedInt vertexCount,
std:: initializer_list<Trade:: MeshAttributeData> extra) 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&& data,
UnsignedInt vertexCount,
Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
Create an interleaved mesh layout.
Compared to interleavedLayout(const Trade::data
instead of allocating a new one if there are no attributes passed in extra
and the attribute array is owned by the mesh.
Trade:: MeshData Magnum:: MeshTools:: interleavedLayout(Trade:: MeshData&& data,
UnsignedInt vertexCount,
std:: initializer_list<Trade:: MeshAttributeData> extra) 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& data,
Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
Interleave mesh data.
Returns a copy of data
with all attributes interleaved. Indices (if any) are kept as-is. 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(), see its documentation for detailed behavior description. Note that offset-only Trade::extra
array.
Expects that each attribute in extra
has either the same amount of elements as data
vertex count or has none. This function will unconditionally make a copy of all data even if data
is already interleaved and needs no change, use interleave(Trade::
Trade:: MeshData Magnum:: MeshTools:: interleave(const Trade:: MeshData& data,
std:: initializer_list<Trade:: MeshAttributeData> extra) 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&& data,
Containers:: ArrayView<const Trade:: MeshAttributeData> extra = {}) new in 2020.06
#include <Magnum/MeshTools/Interleave.h>
Interleave mesh data.
Compared to interleave(const Trade::data
index buffer (in case it is owned) and vertex buffer (in case it is owned, already interleaved and there's no extra
attributes) to the returned instance instead of making copies of them.
Trade:: MeshData Magnum:: MeshTools:: interleave(Trade:: MeshData&& data,
std:: initializer_list<Trade:: MeshAttributeData> extra) 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:: reference(const Trade:: MeshData& data) new in 2020.06
#include <Magnum/MeshTools/Reference.h>
Create an immutable reference on a Trade::
The returned instance has empty Trade::data
as well. The function performs no allocation or data copy. Use owned() for an inverse operation.
Trade:: MeshData Magnum:: MeshTools:: mutableReference(Trade:: MeshData& data) new in 2020.06
#include <Magnum/MeshTools/Reference.h>
Create a mutable reference on a Trade::
The returned instance has Trade::data
is mutable.
Trade:: MeshData Magnum:: MeshTools:: owned(const Trade:: MeshData& data) new in 2020.06
#include <Magnum/MeshTools/Reference.h>
Create an owned Trade::
The returned instance owns its index, vertex and attribute data — both Trade::data
is already owned, use owned(Trade::
Trade:: MeshData Magnum:: MeshTools:: owned(Trade:: MeshData&& data) new in 2020.06
#include <Magnum/MeshTools/Reference.h>
Create an owned Trade::
The returned instance owns its index, vertex and attribute data — both Trade::
std:: 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; std::size_t size; Containers::Array<UnsignedInt> indices; std::tie(indices, size) = MeshTools::removeDuplicatesInPlace( Containers::arrayCast<2, char>(data)); data = data.prefix(size);
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
.
std:: 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::
std:: 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().
std:: 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& data) 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::
This function unconditionally copies and interleaves passed vertex and index data in order to operate on them in-place. If your data is interleaved and owned by the instance and you don't need the original data after the process, call removeDuplicates(Trade::
Trade:: MeshData Magnum:: MeshTools:: removeDuplicates(Trade:: MeshData&& data) new in 2020.06
Remove mesh data duplicates.
Same as removeDuplicates(const Trade::
Trade:: MeshData Magnum:: MeshTools:: removeDuplicatesFuzzy(const Trade:: MeshData& data,
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, http://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.