Description
Operations on meshes.
Functions and classes for the creation (e.g. MeshUtils::MeshBuilder ) or modification (e.g. MeshUtils::calculateNormals ) of meshes.
Author: Claudius Jaehn
Author: Ralf Petring
Author: Benjamin Eikel
Author: Stefan Arens
Author: Paul Justus
Namespaces
namespace | Rendering::MeshUtils::MarchingCubesMeshBuilder |
namespace | Rendering::MeshUtils::PlatonicSolids |
namespace | Rendering::MeshUtils::Simplification |
namespace | Rendering::MeshUtils::WireShapes |
Classes
class | Rendering::MeshUtils::ConnectivityAccessor |
class | Rendering::MeshUtils::LocalMeshDataHolder Class to ensure that the data of a mesh stays in local memory. |
class | Rendering::MeshUtils::MeshBuilder |
class | Rendering::MeshUtils::QuadtreeMeshBuilder |
class | Rendering::MeshUtils::TriangleAccessor |
Functions
Geometry::Sphere_f | calculateBoundingSphere( Mesh * mesh) Compute a tight bounding sphere for the vertex positions of the given mesh. |
Geometry::Sphere_f | calculateBoundingSphere(const std::vector< std::pair< Mesh *, Geometry::Matrix4x4 » & meshesAndTransformations) |
uint32_t | calculateHash( Mesh * mesh) Calculate a hash value for the given mesh. |
uint32_t | calculateHash(const VertexDescription & vd) Calculate a hash value for the given vertex description. |
void | calculateNormals( Mesh * m) |
void | calculateTangentVectors( Mesh * mesh, const Util::StringIdentifier uvName, const Util::StringIdentifier tangentVecName) |
void | calculateTextureCoordinates_projection( Mesh * mesh, Util::StringIdentifier attribName, const Geometry::Matrix4x4 & projection) Create texture coordinates by projecting the vertices with the given projection matrix. |
Mesh * | combineMeshes(const std::deque< Mesh * > & meshArray) |
Mesh * | combineMeshes(const std::deque< Mesh * > & meshArray, const std::deque< Geometry::Matrix4x4 > & transformations) |
std::deque< MeshVertexData > | splitVertexData( Mesh * mesh, uint32_t chunkSize) |
MeshVertexData * | extractVertexData( Mesh * mesh, uint32_t begin, uint32_t length) |
bool | compareMeshes( Mesh * mesh1, Mesh * mesh2) Return true iff the given two meshes contain the same data - only the glIds and the filenames are not compared. |
MeshVertexData * | convertVertices(const MeshVertexData & vertices, const VertexDescription & newVertexDescription) |
void | copyVertexAttribute( Mesh * mesh, Util::StringIdentifier from, Util::StringIdentifier to) Copy data from one vertex attribute to another. Create, or modify the target attribute. |
void | eliminateDuplicateVertices( Mesh * mesh) |
Mesh * | eliminateUnusedVertices( Mesh * mesh) |
Mesh * | eliminateLongTriangles( Mesh * mesh, float ratio) |
Mesh * | eliminateTrianglesBehindPlane( Mesh * mesh, const Geometry::Plane & plane) |
Mesh * | eliminateZeroAreaTriangles( Mesh * m) |
float | getLongestSideLength( Mesh * m) |
void | optimizeIndices( Mesh * mesh, const uint_fast8_t cacheSize) |
void | removeColorData( Mesh * m) |
Mesh * | removeSkinsWithHoleCovering( Mesh * mesh, float maxNormalZ, float coveringMovement) |
void | reverseWinding( Mesh * mesh) |
void | splitLargeTriangles( Mesh * m, float maxSideLength) |
void | setColor( Mesh * mesh, const Util::Color4f & color) |
void | setMaterial( Mesh * mesh, const Util::Color4f & ambient, const Util::Color4f & diffuse, const Util::Color4f & specular, float shininess) |
void | shrinkMesh( Mesh * m, bool shrinkPosition) |
void | transform( MeshVertexData & vd, const Geometry::Matrix4x4 & transMat) |
void | transformCoordinates( MeshVertexData & vd, Util::StringIdentifier attrName, const Geometry::Matrix4x4 & transMat, uint32_t begin, uint32_t numVerts) Transforms one specific vertexAttribute of the vertexData according to the given matrix. |
void | transformNormals( MeshVertexData & vd, Util::StringIdentifier attrName, const Geometry::Matrix4x4 & transMat, uint32_t begin, uint32_t numVerts) |
VertexDescription | uniteVertexDescriptions(const std::deque< VertexDescription > & vertexDescs) |
void | cutMesh( Mesh * m, const Geometry::Plane & plane, const std::set< uint32_t > tIndices, float tolerance) |
void | extrudeTriangles( Mesh * m, const Geometry::Vec3 & dir, const std::set< uint32_t > tIndices) |
int32_t | getFirstTriangleIntersectingRay( Mesh * m, const Geometry::Ray3 & ray) |
uint32_t | mergeCloseVertices( Mesh * mesh, float tolerance) |
std::deque< Mesh * > | splitIntoConnectedComponents( Mesh * mesh, float relDistance) |
void | applyDisplacementMap( Mesh * mesh, Util::PixelAccessor * displaceAcc, float scale, bool clampToEdge) |
void | applyNoise( Mesh * mesh, float noiseScale, const Geometry::Matrix4x4 & transform, uint32_t seed) |
void | flattenMesh( Mesh * mesh, const Geometry::Vec3 & pos, float radius, float falloff) |
float | computeSurfaceArea( Mesh * mesh) |
Rendering::MeshVertexData * | extractVertices( Rendering::Mesh * mesh, const std::vector< uint32_t > & indices) |
void | copyVertices( Rendering::Mesh * source, Rendering::Mesh * target, uint32_t sourceOffset, uint32_t targetOffset, uint32_t count) |
Mesh * | createBox(const VertexDescription & vd, const Geometry::Box & box) |
void | addBox( MeshBuilder & mb, const Geometry::Box & box) Adds a box to the given meshBuilder. |
Mesh * | createDome(const VertexDescription & vd, const double radius, const int horiRes, const int vertRes, const double halfSphereFraction, const double imagePercentage) |
void | addDome( MeshBuilder & mb, const double radius, const int horiRes, const int vertRes, const double halfSphereFraction, const double imagePercentage) Adds a dome to the given meshBuilder. |
Mesh * | createSphere(const VertexDescription & vd, const Geometry::Sphere_f & sphere, uint32_t inclinationSegments, uint32_t azimuthSegments) |
void | addSphere( MeshBuilder & mb, const Geometry::Sphere_f & sphere, uint32_t inclinationSegments, uint32_t azimuthSegments) Adds a shere to the given meshBuilder. |
Mesh * | createDiscSector(const VertexDescription & vd, float radius, uint8_t numSegments, float angle) |
void | addDiscSector( MeshBuilder & mb, float radius, uint8_t numSegments, float angle) Adds a disc sector to the given meshBuilder. |
Mesh * | createRingSector(const VertexDescription & vd, float innerRadius, float outerRadius, uint8_t numSegments, float angle) |
void | addRingSector( MeshBuilder & mb, float innerRadius, float outerRadius, uint8_t numSegments, float angle) Adds a ring sector to the given meshBuilder. |
Mesh * | createCone(const VertexDescription & vd, float radius, float height, uint8_t numSegments) |
void | addCone( MeshBuilder & mb, float radius, float height, uint8_t numSegments) Adds a cone to the given meshBuilder. |
Mesh * | createConicalFrustum(const VertexDescription & vd, float radiusBottom, float radiusTop, float height, uint8_t numSegments) |
void | addConicalFrustum( MeshBuilder & mb, float radiusBottom, float radiusTop, float height, uint8_t numSegments) Adds a conical frustum to the given meshBuilder. |
Mesh * | createArrow(const VertexDescription & vd, float radius, float length) |
void | addArrow( MeshBuilder & mb, float radius, float length) Adds an arrow to the given meshBuilder. |
Mesh * | createRectangle(const VertexDescription & vd, const Geometry::Rect_f & rect) |
Mesh * | createRectangle(const VertexDescription & vd, float width, float height) |
void | addRectangle( MeshBuilder & mb, const Geometry::Rect_f & rect) Adds an rectangle to the given meshBuilder. |
void | addRectangle( MeshBuilder & mb, float width, float height) Adds an rectangle to the given meshBuilder. |
Mesh * | createGrid(const VertexDescription & vd, float width, float height, uint32_t rows, uint32_t columns) |
void | addGrid( MeshBuilder & mb, float width, float height, uint32_t rows, uint32_t columns) Adds a rectangular grid to the given meshBuilder. |
Mesh * | createHexGrid(const VertexDescription & vd, float width, float height, uint32_t rows, uint32_t columns) |
void | addHexGrid( MeshBuilder & mb, float width, float height, uint32_t rows, uint32_t columns) Adds a hexagonal grid to the given meshBuilder. |
Mesh * | createVoxelMesh(const VertexDescription & vd, const Util::PixelAccessor & colorAcc, uint32_t depth) |
void | addVoxelMesh( MeshBuilder & mb, const Util::PixelAccessor & colorAcc, uint32_t depth) Adds a voxel mesh to the given meshBuilder. |
Mesh * | createTorus(const VertexDescription & vd, float innerRadius, float outerRadius, uint32_t majorSegments, uint32_t minorSegments) |
void | addTorus( MeshBuilder & mb, float innerRadius, float outerRadius, uint32_t majorSegments, uint32_t minorSegments) Adds a torus to the MeshBuilder . |
Mesh * | createMeshFromBitmaps(const VertexDescription & vd, Util::Reference < Util::PixelAccessor > depth, Util::Reference < Util::PixelAccessor > color, Util::Reference < Util::PixelAccessor > normals) |
void | addMeshFromBitmaps( MeshBuilder & mb, Util::Reference < Util::PixelAccessor > depth, Util::Reference < Util::PixelAccessor > color, Util::Reference < Util::PixelAccessor > normals) Adds a mesh from bitmap to the given meshBuilder. |
Documentation
function
Rendering::MeshUtils::calculateBoundingSphere
public |
Geometry::Sphere_f calculateBoundingSphere( | Mesh * | mesh ) |
Compute a tight bounding sphere for the vertex positions of the given mesh.
Defined in Rendering/MeshUtils/MeshUtils.h:63
function
Rendering::MeshUtils::calculateBoundingSphere
public |
Geometry::Sphere_f calculateBoundingSphere( | const std::vector< std::pair< Mesh *, Geometry::Matrix4x4 » & | meshesAndTransformations ) |
Compute a tight bounding sphere for the vertex positions of the given meshes after applying the corresponding transformations to the positions.
Defined in Rendering/MeshUtils/MeshUtils.h:69
function
Rendering::MeshUtils::calculateHash
public |
uint32_t calculateHash( | Mesh * | mesh ) |
Calculate a hash value for the given mesh.
Defined in Rendering/MeshUtils/MeshUtils.h:72
function
Rendering::MeshUtils::calculateHash
public |
uint32_t calculateHash( | const VertexDescription & | vd ) |
Calculate a hash value for the given vertex description.
Defined in Rendering/MeshUtils/MeshUtils.h:75
function
Rendering::MeshUtils::calculateNormals
public |
void calculateNormals( | Mesh * | m ) |
calulates vertex normals for a given mesh calculation is done by
-
first calculating face normals
-
second calculating the unweighted average of the adjacent face normals for all vertices
Note: if the mesh has already normals these are ignored and recalculated
Parameters
- m
- the mesh to be modified
Author: Ralf Petring
Defined in Rendering/MeshUtils/MeshUtils.h:85
function
Rendering::MeshUtils::calculateTangentVectors
public |
void calculateTangentVectors( | Mesh * | mesh, |
const Util::StringIdentifier | uvName, | |
const Util::StringIdentifier | tangentVecName | |
) |
Calculate and add tangent space vectors from the normals and uv-coordinates of the given mesh.
Note: based on: Lengyel, Eric. “Computing Tangent Space Basis Vectors for an Arbitrary Mesh”. Terathon Software 3D Graphics Library, 2001.http://www.terathon.com/code/tangent.htmlThe bitangent can be calculated in the shader by: float3 bitangent = cross(normal, tangent.xyz) * tangent.w;
Defined in Rendering/MeshUtils/MeshUtils.h:94
function
Rendering::MeshUtils::calculateTextureCoordinates_projection
public |
void calculateTextureCoordinates_projection( | Mesh * | mesh, |
Util::StringIdentifier | attribName, | |
const Geometry::Matrix4x4 & | projection | |
) |
Create texture coordinates by projecting the vertices with the given projection matrix.
Defined in Rendering/MeshUtils/MeshUtils.h:99
function
Rendering::MeshUtils::combineMeshes
public |
Mesh * combineMeshes( | const std::deque< Mesh * > & | meshArray ) |
Combine several meshes into a single mesh.
Note: All meshes must have the same VertexDescription .
Author: Claudius Jaehn
Author: Stefan Arens
Author: Paul Justus
Defined in Rendering/MeshUtils/MeshUtils.h:109
function
Rendering::MeshUtils::combineMeshes
public |
Mesh * combineMeshes( | const std::deque< Mesh * > & | meshArray, |
const std::deque< Geometry::Matrix4x4 > & | transformations | |
) |
Defined in Rendering/MeshUtils/MeshUtils.h:110
function
Rendering::MeshUtils::splitVertexData
public |
std::deque< MeshVertexData > splitVertexData( | Mesh * | mesh, |
uint32_t | chunkSize | |
) |
Splits the vertex data of a given mesh into multiple blocks of vertex data each containingchunkSizemany vertices.
Note: The last block only contains MeshVertexCount % chunkSize many vertices.
Author: Sascha Brauer
Defined in Rendering/MeshUtils/MeshUtils.h:118
function
Rendering::MeshUtils::extractVertexData
public |
MeshVertexData * extractVertexData( | Mesh * | mesh, |
uint32_t | begin, | |
uint32_t | length | |
) |
Extracts a range of vertices from the given mesh.
Parameters
- mesh
- The mesh to extract the vertex data from
- begin
- Start of the range of extracted vertices
- length
- The number of vertices to extract
Author: Sascha Brauer
Defined in Rendering/MeshUtils/MeshUtils.h:129
function
Rendering::MeshUtils::compareMeshes
public |
bool compareMeshes( | Mesh * | mesh1, |
Mesh * | mesh2 | |
) |
Returntrue
iff the given two meshes contain the same data - only the glIds and the filenames are not compared.
Defined in Rendering/MeshUtils/MeshUtils.h:132
function
Rendering::MeshUtils::convertVertices
public |
MeshVertexData * convertVertices( | const MeshVertexData & | vertices, |
const VertexDescription & | newVertexDescription | |
) |
allocates the memory for storing old vertices in new format and copies the old values to the correct position in the new memory
Note: missing values are initialized with 0
Note: values which do not fit into the new format get lost
Author: Ralf Petring
Defined in Rendering/MeshUtils/MeshUtils.h:140
function
Rendering::MeshUtils::copyVertexAttribute
public |
void copyVertexAttribute( | Mesh * | mesh, |
Util::StringIdentifier | from, | |
Util::StringIdentifier | to | |
) |
Copy data from one vertex attribute to another. Create, or modify the target attribute.
Defined in Rendering/MeshUtils/MeshUtils.h:144
function
Rendering::MeshUtils::eliminateDuplicateVertices
public |
void eliminateDuplicateVertices( | Mesh * | mesh ) |
Remove vertices which are equal to each other from the mesh and store them only once. The indices to the vertices are adjusted. This function has runtime O(n * log(n)) where n is the number of vertices inmesh.
Parameters
- mesh
- Mesh to do the elimination on.
Author: Benjamin Eikel
Defined in Rendering/MeshUtils/MeshUtils.h:157
function
Rendering::MeshUtils::eliminateUnusedVertices
public |
Mesh * eliminateUnusedVertices( | Mesh * | mesh ) |
Clone the given mesh but remove all vertices which are never referenced.
Defined in Rendering/MeshUtils/MeshUtils.h:163
function
Rendering::MeshUtils::eliminateLongTriangles
public |
Mesh * eliminateLongTriangles( | Mesh * | mesh, |
float | ratio | |
) |
Deletes long triangles (whose ratio between the longest side and the corresponding height is > ratio).
Note: Calls eliminateUnusedVertices to remove unused vertices.
Defined in Rendering/MeshUtils/MeshUtils.h:170
function
Rendering::MeshUtils::eliminateTrianglesBehindPlane
public |
Mesh * eliminateTrianglesBehindPlane( | Mesh * | mesh, |
const Geometry::Plane & | plane | |
) |
Delete triangles that have at least one vertex lying behind the given plane.
Parameters
- mesh
- Source mesh. The mesh is not changed.
- plane
- Plane that is used for cutting off vertices.
Returns
New mesh
Defined in Rendering/MeshUtils/MeshUtils.h:179
function
Rendering::MeshUtils::eliminateZeroAreaTriangles
public |
Mesh * eliminateZeroAreaTriangles( | Mesh * | m ) |
Delete triangles that have (nearly) zero area.
Parameters
- mesh
- Source mesh. The mesh is not changed.
Returns
New mesh
Defined in Rendering/MeshUtils/MeshUtils.h:187
function
Rendering::MeshUtils::getLongestSideLength
public |
float getLongestSideLength( | Mesh * | m ) |
Estimate the max. side length of the polygon in the mesh m
Defined in Rendering/MeshUtils/MeshUtils.h:193
function
Rendering::MeshUtils::optimizeIndices
public |
void optimizeIndices( | Mesh * | mesh, |
const uint_fast8_t | cacheSize | |
) |
Take the given mesh and optimize the indices stored there for vertex cache optimality. The implementation is based on the algorithm described by Sander, Nehab and Barczak. This function has runtime O(n) where n is the number of indices inmesh.
Parameters
- mesh
- Mesh whose indices will be optimized.
- cacheSize
- Post-transform vertex cache size to optimize for. This parameter is called
k
in the article.
See also: http://doi.acm.org/10.1145/1276377.1276489
Author: Benjamin Eikel
Defined in Rendering/MeshUtils/MeshUtils.h:209
function
Rendering::MeshUtils::removeColorData
public |
void removeColorData( | Mesh * | m ) |
removes the color information from a mesh
Parameters
- m
- the mesh to be modified
Author: Ralf Petring
Defined in Rendering/MeshUtils/MeshUtils.h:216
function
Rendering::MeshUtils::removeSkinsWithHoleCovering
public |
Mesh * removeSkinsWithHoleCovering( | Mesh * | mesh, |
float | maxNormalZ, | |
float | coveringMovement | |
) |
Identify triangles that span large depth ranges by calculating their normals. Remove those triangles and move the adjacent vertices in the background a little bit to cover the arising hole.
Note: The calculation assumes that z values represent depth, x values represent horizontal direction, and y values represent vertical direction. This holds for meshes generated from depth textures.
Parameters
- mesh
- Source mesh. The mesh is not changed.
- maxNormalZ
- Maximum absolute z coordinate of the triangle’s normal so that the triangle is removed.
- coveringMovement
- Ratio of the depth range of the removed triangle that the background vertices are moved in normal direction of this triangle.
Returns
New mesh
Note: maxNormalZ = 0.6f and coveringMovement = 0.1f are good starting points.
Defined in Rendering/MeshUtils/MeshUtils.h:230
function
Rendering::MeshUtils::reverseWinding
public |
void reverseWinding( | Mesh * | mesh ) |
Change the order of the vertices of each triangle.
Parameters
- mesh
- Input and output mesh (the given mesh is changed).
Note: This function only works for meshes with a triangle list. If the mesh uses another mode, then the mesh is not changed.
Author: Benjamin Eikel
Defined in Rendering/MeshUtils/MeshUtils.h:240
function
Rendering::MeshUtils::splitLargeTriangles
public |
void splitLargeTriangles( | Mesh * | m, |
float | maxSideLength | |
) |
splits all triangles in the mesh which have at least one side longer than specified
Parameters
- m
- the mesh to deal with
- maxSideLength
- the maximum length of a triangles edge, if this value is exceeded the triangle will be split up
Returns
the modified mesh
Author: Ralf Petring
Defined in Rendering/MeshUtils/MeshUtils.h:249
function
Rendering::MeshUtils::setColor
public |
void setColor( | Mesh * | mesh, |
const Util::Color4f & | color | |
) |
Apply color information to each vertex of the mesh
Parameters
- mesh
- the mesh to be midified
- color
- the color to be set
Author: Ralf Petring
Defined in Rendering/MeshUtils/MeshUtils.h:257
function
Rendering::MeshUtils::setMaterial
public |
void setMaterial( | Mesh * | mesh, |
const Util::Color4f & | ambient, | |
const Util::Color4f & | diffuse, | |
const Util::Color4f & | specular, | |
float | shininess | |
) |
Apply material information to each vertex of the mesh
Parameters
- mesh
- the mesh to be midified
- ambient
- the ambient color to be set
- diffuse
- the diffuse color to be set
- specular
- the specular color to be set
- shininess
- the shininess value to be set
Author: Ralf Petring
Defined in Rendering/MeshUtils/MeshUtils.h:268
function
Rendering::MeshUtils::shrinkMesh
public |
void shrinkMesh( | Mesh * | m, |
bool | shrinkPosition | |
) |
converts normals from 3 * GL_FLOAT to 4 * GL_BYTE if present converts colors from (3 or 4) * GL_FLOAT to 4 * GL_UNSIGNED_BYTE if present optionally converts position from (3 or 4) * GL_FLOAT to 4 * GL_HALF_FLOAT
Parameters
- m
- the mesh to be shrinked
Defined in Rendering/MeshUtils/MeshUtils.h:279
function
Rendering::MeshUtils::transform
public |
void transform( | MeshVertexData & | vd, |
const Geometry::Matrix4x4 & | transMat | |
) |
transforms the position and the normals of the vertices of the vertex data by the given matrix
Parameters
- mesh
- the vertex data to be modified
- transMat
- the matrix to be used for transformation
Author: Claudius Jaehn
Defined in Rendering/MeshUtils/MeshUtils.h:288
function
Rendering::MeshUtils::transformCoordinates
public |
void transformCoordinates( | MeshVertexData & | vd, |
Util::StringIdentifier | attrName, | |
const Geometry::Matrix4x4 & | transMat, | |
uint32_t | begin, | |
uint32_t | numVerts | |
) |
Transforms one specific vertexAttribute of the vertexData according to the given matrix.
Defined in Rendering/MeshUtils/MeshUtils.h:291
function
Rendering::MeshUtils::transformNormals
public |
void transformNormals( | MeshVertexData & | vd, |
Util::StringIdentifier | attrName, | |
const Geometry::Matrix4x4 & | transMat, | |
uint32_t | begin, | |
uint32_t | numVerts | |
) |
Defined in Rendering/MeshUtils/MeshUtils.h:292
function
Rendering::MeshUtils::uniteVertexDescriptions
public |
VertexDescription uniteVertexDescriptions( | const std::deque< VertexDescription > & | vertexDescs ) |
Return a new VertexDescription that contains the union of all VertexAttributes of the given VertexDescriptions.
Parameters
- vertexDescs
- Container with VertexDescriptions that will be analysed.
Returns
New VertexDescription that is able to hold all VertexAttributes.
Author: Benjamin Eikel
Defined in Rendering/MeshUtils/MeshUtils.h:301
function
Rendering::MeshUtils::cutMesh
public |
void cutMesh( | Mesh * | m, |
const Geometry::Plane & | plane, | |
const std::set< uint32_t > | tIndices, | |
float | tolerance | |
) |
Cuts the given mesh along the given plane.
Parameters
- m
- the mesh to be cut
- plane
- the cutting plane
- tIndices
- list of triangle indices to cut. If empty, the whole mesh is cut.
- tolerance
- if a vertex lies on the plane with the given tolerance, no new vertex is created
Author: Sascha Brandt
Defined in Rendering/MeshUtils/MeshUtils.h:312
function
Rendering::MeshUtils::extrudeTriangles
public |
void extrudeTriangles( | Mesh * | m, |
const Geometry::Vec3 & | dir, | |
const std::set< uint32_t > | tIndices | |
) |
Extrudes the specified triangles of the given mesh.
Parameters
- m
- the mesh
- dir
- extrusion direction
- tIndices
- set of triangle indices to extrude
Author: Sascha Brandt
Defined in Rendering/MeshUtils/MeshUtils.h:322
function
Rendering::MeshUtils::getFirstTriangleIntersectingRay
public |
int32_t getFirstTriangleIntersectingRay( | Mesh * | m, |
const Geometry::Ray3 & | ray | |
) |
Slow method for finding the first triangle in a mesh that intersects the given ray.
Parameters
- m
- the mesh
- ray
- the ray
Returns
-1 if no intersecting triangle was found, the triangle index otherwise.
Author: Sascha Brandt
Defined in Rendering/MeshUtils/MeshUtils.h:331
function
Rendering::MeshUtils::mergeCloseVertices
public |
uint32_t mergeCloseVertices( | Mesh * | mesh, |
float | tolerance | |
) |
Remove vertices which are close to each other from the mesh and store them only once. The indices to the vertices are adjusted. This function has runtime O(n * log(n)) where n is the number of vertices inmesh.
Parameters
- mesh
- Mesh to do the elimination on.
Returns
number of merged vertices
Author: Sascha Brandt
Defined in Rendering/MeshUtils/MeshUtils.h:343
function
Rendering::MeshUtils::splitIntoConnectedComponents
public |
std::deque< Mesh * > splitIntoConnectedComponents( | Mesh * | mesh, |
float | relDistance | |
) |
Splits a mesh into its connected components.
Parameters
- mesh
- Mesh to split into connected components
- relDistance
- relative distance (w.r.t. mesh’s bounding box) between vertices that are considered as connected.
Returns
connected components of the mesh
Author: Sascha Brandt
Defined in Rendering/MeshUtils/MeshUtils.h:353
function
Rendering::MeshUtils::applyDisplacementMap
public |
void applyDisplacementMap( | Mesh * | mesh, |
Util::PixelAccessor * | displaceAcc, | |
float | scale, | |
bool | clampToEdge | |
) |
Moves every vertex along their normal according to the given texture (using its u,v coordinates).
Parameters
- mesh
- The mesh
- displaceAcc
- pixel accessor of the displacement map
- scale
- scale factor multiplied with the value of the texture
- clampToEdge
- clamp to texture borders (true) or wrap around (false)
Author: Sascha Brandt
Defined in Rendering/MeshUtils/MeshUtils.h:364
function
Rendering::MeshUtils::applyNoise
public |
void applyNoise( | Mesh * | mesh, |
float | noiseScale, | |
const Geometry::Matrix4x4 & | transform, | |
uint32_t | seed | |
) |
Moves every vertex along their normal using the value of a 3D perlin noise function.
Parameters
- mesh
- The mesh
- seed
- The seed for the noise generator
- noiseScale
- scale factor multiplied with the noise value
- transform
- transformation matrix applied on each position
Author: Sascha Brandt
Defined in Rendering/MeshUtils/MeshUtils.h:376
function
Rendering::MeshUtils::flattenMesh
public |
void flattenMesh( | Mesh * | mesh, |
const Geometry::Vec3 & | pos, | |
float | radius, | |
float | falloff | |
) |
Sets the y-coordinates of all vertices in a radius around a given 3d position to it’s y-coordinate (with cubic bezier falloff)
Parameters
- mesh
- The mesh
- pos
- the 3d position
- radius
- radius around the 3d position to flatten vertices
- falloff
- blend falloff for vertices beyond the radius
Author: Sascha Brandt
Defined in Rendering/MeshUtils/MeshUtils.h:387
function
Rendering::MeshUtils::computeSurfaceArea
public |
float computeSurfaceArea( | Mesh * | mesh ) |
Computes the combined surface area of all triangles in a mesh
Parameters
- mesh
- The mesh
Returns
the surface area
Author: Sascha Brandt
Defined in Rendering/MeshUtils/MeshUtils.h:396
function
Rendering::MeshUtils::extractVertices
public |
Rendering::MeshVertexData * extractVertices( | Rendering::Mesh * | mesh, |
const std::vector< uint32_t > & | indices | |
) |
Extracts the vertices of a mesh with corresponding indices and moves them to a new mesh
Parameters
- mesh
- Mesh to extract vertices from
- indices
- array of indices of the vertices to be extracted
Returns
new mesh
Author: Sascha Brandt
Defined in Rendering/MeshUtils/MeshUtils.h:406
function
Rendering::MeshUtils::copyVertices
public |
void copyVertices( | Rendering::Mesh * | source, |
Rendering::Mesh * | target, | |
uint32_t | sourceOffset, | |
uint32_t | targetOffset, | |
uint32_t | count | |
) |
Copies vertices from one mesh to another. If both meshes are uploaded, it directly copies using the buffers.
Parameters
- source
- Mesh to copy vertices from
- target
- Mesh to copy vertices to
- sourceOffset
- vertex offset of the source mesh
- targetOffset
- vertex offset of the target mesh
- count
- number of vertices to copy
Author: Sascha Brandt
Defined in Rendering/MeshUtils/MeshUtils.h:419
function
Rendering::MeshUtils::createBox
public |
Mesh * createBox( | const VertexDescription & | vd, |
const Geometry::Box & | box | |
) |
Return the mesh of a three-dimensional, axis-aligned box. Positions, and normals are supported.
Parameters
- vd
- Vertex description specifying the vertex information to generate
- box
- Geometric specification of the box
Returns
Mesh of the box
Defined in Rendering/MeshUtils/PrimitiveShapes.h:62
function
Rendering::MeshUtils::addBox
public |
void addBox( | MeshBuilder & | mb, |
const Geometry::Box & | box | |
) |
Adds a box to the given meshBuilder.
See also: createBox (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:65
function
Rendering::MeshUtils::createDome
public |
Mesh * createDome( | const VertexDescription & | vd, |
const double | radius, | |
const int | horiRes, | |
const int | vertRes, | |
const double | halfSphereFraction, | |
const double | imagePercentage | |
) |
Creates a mesh for a sky dome with texture coordinates.
Note: adapted from [alc]http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=13887&sid=25788d2b93c73294fd7abe76db6fab1e
Defined in Rendering/MeshUtils/PrimitiveShapes.h:69
function
Rendering::MeshUtils::addDome
public |
void addDome( | MeshBuilder & | mb, |
const double | radius, | |
const int | horiRes, | |
const int | vertRes, | |
const double | halfSphereFraction, | |
const double | imagePercentage | |
) |
Adds a dome to the given meshBuilder.
See also: createDome (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:72
function
Rendering::MeshUtils::createSphere
public |
Mesh * createSphere( | const VertexDescription & | vd, |
const Geometry::Sphere_f & | sphere, | |
uint32_t | inclinationSegments, | |
uint32_t | azimuthSegments | |
) |
Return a sphere, which is generated by subdividing the sphere surface into segements. The surface is subdivided into the given number of subdivisions of the inclination angle and the azimuth angle, respectively. The sphere is centered at the origin and the vertices are lying on the unit sphere. The given vertex description specifies which information is generated for every vertex. Positions, normals, colors, and texture coordinates are supported.
Parameters
- vd
- Vertex description specifying the vertex information to generate
- inclinationSegments
- Number of subdivisions of the inclination angle
- azimuthSegments
- Number of subdivisions of the azimuth angle
Returns
Sphere Mesh
Defined in Rendering/MeshUtils/PrimitiveShapes.h:87
function
Rendering::MeshUtils::addSphere
public |
void addSphere( | MeshBuilder & | mb, |
const Geometry::Sphere_f & | sphere, | |
uint32_t | inclinationSegments, | |
uint32_t | azimuthSegments | |
) |
Adds a shere to the given meshBuilder.
See also: createSphere (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:90
function
Rendering::MeshUtils::createDiscSector
public |
Mesh * createDiscSector( | const VertexDescription & | vd, |
float | radius, | |
uint8_t | numSegments, | |
float | angle | |
) |
Return a sector of a disc. The center of the disc is the origin. The disc is aligned with the y-z plane and the normals are pointing into negative x direction. Positions and normals for the vertices are generated.
Parameters
- vd
- Vertex description specifying the vertex information to generate
- radius
- Radius of the disc
- numSegments
- Number of segments for the disc
- angle
- Central angle of the sector in degrees
Returns
Disc Mesh ornullptr
if the number of segments is smaller than two.
Defined in Rendering/MeshUtils/PrimitiveShapes.h:104
function
Rendering::MeshUtils::addDiscSector
public |
void addDiscSector( | MeshBuilder & | mb, |
float | radius, | |
uint8_t | numSegments, | |
float | angle | |
) |
Adds a disc sector to the given meshBuilder.
See also: createDiscSector (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:107
function
Rendering::MeshUtils::createRingSector
public |
Mesh * createRingSector( | const VertexDescription & | vd, |
float | innerRadius, | |
float | outerRadius, | |
uint8_t | numSegments, | |
float | angle | |
) |
Return a sector of a ring. The center of the disc is the origin. The disc is aligned with the y-z plane and the normals are pointing into negative x direction. Positions and normals for the vertices are generated.
Parameters
- vd
- Vertex description specifying the vertex information to generate
- innerRadius
- inner radius of the ring
- outerRadius
- outer radius of the ring
- numSegments
- Number of segments for the disc
- angle
- Central angle of the sector in degrees
Returns
Disc Mesh ornullptr
if the number of segments is smaller than two or innerRadius >= outerRadius
Defined in Rendering/MeshUtils/PrimitiveShapes.h:122
function
Rendering::MeshUtils::addRingSector
public |
void addRingSector( | MeshBuilder & | mb, |
float | innerRadius, | |
float | outerRadius, | |
uint8_t | numSegments, | |
float | angle | |
) |
Adds a ring sector to the given meshBuilder.
See also: createRingSector (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:125
function
Rendering::MeshUtils::createCone
public |
Mesh * createCone( | const VertexDescription & | vd, |
float | radius, | |
float | height, | |
uint8_t | numSegments | |
) |
Return a cone with the radius given. The cap end is not created. The center of the base is the origin. The apex lies on the x-axis at distanceheightfrom the origin. Positions and normals for the vertices are generated.
Parameters
- vd
- Vertex description specifying the vertex information to generate
- radius
- Radius of the base
- height
- Distance between the base and the apex
- numSegments
- Number of segments for the circle at the base and the lateral surface
Returns
Cone Mesh ornullptr
if the number of segments is smaller than two
See also: createDisc() for creation of a cap end
Defined in Rendering/MeshUtils/PrimitiveShapes.h:141
function
Rendering::MeshUtils::addCone
public |
void addCone( | MeshBuilder & | mb, |
float | radius, | |
float | height, | |
uint8_t | numSegments | |
) |
Adds a cone to the given meshBuilder.
See also: createCone (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:144
function
Rendering::MeshUtils::createConicalFrustum
public |
Mesh * createConicalFrustum( | const VertexDescription & | vd, |
float | radiusBottom, | |
float | radiusTop, | |
float | height, | |
uint8_t | numSegments | |
) |
Return a conical frustum with the radii given. The cap ends are not created. The center of the bottom circle is the origin. The center of the top circle lies on the x-axis at distanceheightfrom the origin. If both radii have the same value, a cylinder is created. Positions and normals for the vertices are generated.
Parameters
- vd
- Vertex description specifying the vertex information to generate
- radiusBottom
- Radius of the bottom circle
- radiusTop
- Radius of the top circle
- height
- Distance between both circles
- numSegments
- Number of segments for the circles and the lateral surface
Returns
Conical frustum Mesh ornullptr
if the number of segments is smaller than two
See also: createDisc() for creation of cap ends
Defined in Rendering/MeshUtils/PrimitiveShapes.h:162
function
Rendering::MeshUtils::addConicalFrustum
public |
void addConicalFrustum( | MeshBuilder & | mb, |
float | radiusBottom, | |
float | radiusTop, | |
float | height, | |
uint8_t | numSegments | |
) |
Adds a conical frustum to the given meshBuilder.
See also: createConicalFrustum (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:165
function
Rendering::MeshUtils::createArrow
public |
Mesh * createArrow( | const VertexDescription & | vd, |
float | radius, | |
float | length | |
) |
Returns an arrow which consists of a ConicalFrustum and 2 Cones at one end.
Parameters
- vd
- Vertex description specifying the vertex information to generate
- radius
- Radius of the arrow
- length
- Overall length of the arrow
Returns
Arrow Mesh
Defined in Rendering/MeshUtils/PrimitiveShapes.h:175
function
Rendering::MeshUtils::addArrow
public |
void addArrow( | MeshBuilder & | mb, |
float | radius, | |
float | length | |
) |
Adds an arrow to the given meshBuilder.
See also: createArrow (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:178
function
Rendering::MeshUtils::createRectangle
public |
Mesh * createRectangle( | const VertexDescription & | vd, |
const Geometry::Rect_f & | rect | |
) |
Returns a Rectangle consisting of 2 triangles (oriented in x-y-plane)
Parameters
- vd
- Vertex description specifying the vertex information to generate
- rect
- the rectangle
Returns
Rectangle Mesh
Defined in Rendering/MeshUtils/PrimitiveShapes.h:187
function
Rendering::MeshUtils::createRectangle
public | inline |
Mesh * createRectangle( | const VertexDescription & | vd, |
float | width, | |
float | height | |
) |
Returns a Rectangle consisting of 2 triangles with origin in the center (oriented in x-y-plane)
Parameters
- vd
- Vertex description specifying the vertex information to generate
- width
- The width of the rectangle
- height
- The height of the rectangle
Returns
Rectangle Mesh
Defined in Rendering/MeshUtils/PrimitiveShapes.h:197
function
Rendering::MeshUtils::addRectangle
public |
void addRectangle( | MeshBuilder & | mb, |
const Geometry::Rect_f & | rect | |
) |
Adds an rectangle to the given meshBuilder.
See also: createRectangle (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:202
function
Rendering::MeshUtils::addRectangle
public | inline |
void addRectangle( | MeshBuilder & | mb, |
float | width, | |
float | height | |
) |
Adds an rectangle to the given meshBuilder.
See also: createRectangle (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:204
function
Rendering::MeshUtils::createGrid
public |
Mesh * createGrid( | const VertexDescription & | vd, |
float | width, | |
float | height, | |
uint32_t | rows, | |
uint32_t | columns | |
) |
Creates a rectangular grid in the x-z-plane.
Parameters
- vd
- Vertex description specifying the vertex information to generate
- width
- The width of the grid
- height
- The height of the grid
- rows
- number of rows
- columns
- number of columns
Defined in Rendering/MeshUtils/PrimitiveShapes.h:217
function
Rendering::MeshUtils::addGrid
public |
void addGrid( | MeshBuilder & | mb, |
float | width, | |
float | height, | |
uint32_t | rows, | |
uint32_t | columns | |
) |
Adds a rectangular grid to the given meshBuilder.
See also: createGrid (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:220
function
Rendering::MeshUtils::createHexGrid
public |
Mesh * createHexGrid( | const VertexDescription & | vd, |
float | width, | |
float | height, | |
uint32_t | rows, | |
uint32_t | columns | |
) |
Creates a hexagonal grid in the x-z-plane.
Parameters
- vd
- Vertex description specifying the vertex information to generate
- width
- The width of the grid
- height
- The height of the grid
- rows
- number of rows. Needs to be at least 3
- columns
- number of columns. Needs to be at least 4
Defined in Rendering/MeshUtils/PrimitiveShapes.h:231
function
Rendering::MeshUtils::addHexGrid
public |
void addHexGrid( | MeshBuilder & | mb, |
float | width, | |
float | height, | |
uint32_t | rows, | |
uint32_t | columns | |
) |
Adds a hexagonal grid to the given meshBuilder.
See also: createHexGrid (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:234
function
Rendering::MeshUtils::createVoxelMesh
public |
Mesh * createVoxelMesh( | const VertexDescription & | vd, |
const Util::PixelAccessor & | colorAcc, | |
uint32_t | depth | |
) |
Creates a mesh from a voxel bitmap as exported from a 3D Texture . The bitmap should have a height of depth*heiht, i.e., each depth layer is stored from top to bottom in the vertical direction of the bitmap. The height and width of the voxel grid is derived from the bitmap width and height. The actual height of the voxel grid is bitmap-height/depth. A voxel box of size 1^3 is created for every pixel with a positive alpha value. The local point (0,0,0) in the resulting mesh corresponds to the (0,0,0) coordinate in the voxel bitmap. To scale the mesh afterwards, use MeshUtils::transform
Parameters
- vd
- Vertex description specifying the vertex information to generate
- colorAcc
- the bitmap that defines the voxel grid. Every pixel with non-zero alpha value defines a voxel.
- the
- depth of the voxel grid. The height of the bitmap should be divisible by this value
Defined in Rendering/MeshUtils/PrimitiveShapes.h:248
function
Rendering::MeshUtils::addVoxelMesh
public |
void addVoxelMesh( | MeshBuilder & | mb, |
const Util::PixelAccessor & | colorAcc, | |
uint32_t | depth | |
) |
Adds a voxel mesh to the given meshBuilder.
See also: createHexGrid (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:251
function
Rendering::MeshUtils::createTorus
public |
Mesh * createTorus( | const VertexDescription & | vd, |
float | innerRadius, | |
float | outerRadius, | |
uint32_t | majorSegments, | |
uint32_t | minorSegments | |
) |
Creates a torus mesh. The center of the torus is located at the origin. The aligned is aligned with the x-z plane.
Parameters
- vd
- Vertex description specifying the vertex information to generate
- innerRadius
- inner radius of the torus. Should be greater than or equal 0.
- outerRadius
- outer radius of the torus. Should be greater than inner radius.
- majorSegments
- Number of major segments. Minimum is 3.
- minorSegments
- Number of minor segments. Minimum is 3.
Returns
The mesh
Defined in Rendering/MeshUtils/PrimitiveShapes.h:265
function
Rendering::MeshUtils::addTorus
public |
void addTorus( | MeshBuilder & | mb, |
float | innerRadius, | |
float | outerRadius, | |
uint32_t | majorSegments, | |
uint32_t | minorSegments | |
) |
Adds a torus to the MeshBuilder .
See also: addTorus (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:268
function
Rendering::MeshUtils::createMeshFromBitmaps
public |
Mesh * createMeshFromBitmaps( | const VertexDescription & | vd, |
Util::Reference < Util::PixelAccessor > | depth, | |
Util::Reference < Util::PixelAccessor > | color, | |
Util::Reference < Util::PixelAccessor > | normals | |
) |
Creates a mesh from the input bitmap.
Parameters
- vd
- Vertex description specifying the vertex information to generate
- depth
- Bitmap with depth values. Translates to the y-values of the mesh.
- color
- Bitmap with colors.
- normals
- Bitmap with normals.
Returns
The mesh
Defined in Rendering/MeshUtils/PrimitiveShapes.h:280
function
Rendering::MeshUtils::addMeshFromBitmaps
public |
void addMeshFromBitmaps( | MeshBuilder & | mb, |
Util::Reference < Util::PixelAccessor > | depth, | |
Util::Reference < Util::PixelAccessor > | color, | |
Util::Reference < Util::PixelAccessor > | normals | |
) |
Adds a mesh from bitmap to the given meshBuilder.
See also: createMeshFromBitmaps (…)
Defined in Rendering/MeshUtils/PrimitiveShapes.h:283