Irrlicht 3D Engine: irr::scene::IMeshManipulator Class Reference

| Irrlicht 3D Engine |

Public Member Functions | Protected Member Functions
irr::scene::IMeshManipulator Class Reference

An interface for easy manipulation of meshes. More...

`#include <IMeshManipulator.h>`

Inheritance diagram for irr::scene::IMeshManipulator:

List of all members.

## Public Member Functions

- template<typename Functor > bool apply (const Functor &func, IMeshBuffer *buffer, bool boundingBoxUpdate=false) const
    Apply a manipulator on the Meshbuffer.
- template<typename Functor > bool apply (const Functor &func, IMesh *mesh, bool boundingBoxUpdate=false) const
    Apply a manipulator on the Mesh.
- virtual IAnimatedMesh * createAnimatedMesh (IMesh *mesh, scene::E_ANIMATED_MESH_TYPE type=scene::EAMT_UNKNOWN) const =0
    Create a new AnimatedMesh and adds the mesh to it.
- virtual IMesh * createForsythOptimizedMesh (const IMesh *mesh) const =0
    Vertex cache optimization according to the Forsyth paper.
- virtual SMesh * createMeshCopy (IMesh *mesh) const =0
    Clones a static IMesh into a modifiable SMesh.
- virtual IMesh * createMeshUniquePrimitives (IMesh *mesh) const =0
    Creates a copy of a mesh with all vertices unwelded.
- virtual IMesh * createMeshWelded (IMesh *mesh, f32 tolerance=core::ROUNDING_ERROR_f32) const =0
    Creates a copy of a mesh with vertices welded.
- virtual IMesh * createMeshWith1TCoords (IMesh *mesh) const =0
    Creates a copy of the mesh, which will only consist of S3DVertex vertices.
- virtual IMesh * createMeshWith2TCoords (IMesh *mesh) const =0
    Creates a copy of the mesh, which will only consist of S3DVertex2TCoord vertices.
- virtual IMesh * createMeshWithTangents (IMesh *mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false, bool recalculateTangents=true) const =0
    Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices.
- virtual void flipSurfaces (IMesh *mesh) const =0
    Flips the direction of surfaces.
- virtual s32 getPolyCount (IMesh *mesh) const =0
    Get amount of polygons in mesh.
- virtual s32 getPolyCount (IAnimatedMesh *mesh) const =0
    Get amount of polygons in mesh.
- virtual void makePlanarTextureMapping (IMesh *mesh, f32 resolution=0.001f) const =0
    Creates a planar texture mapping on the mesh.
- virtual void makePlanarTextureMapping (scene::IMeshBuffer *meshbuffer, f32 resolution=0.001f) const =0
    Creates a planar texture mapping on the meshbuffer.
- virtual void makePlanarTextureMapping (scene::IMesh *mesh, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df &offset) const =0
    Creates a planar texture mapping on the buffer.
- virtual void makePlanarTextureMapping (scene::IMeshBuffer *buffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df &offset) const =0
    Creates a planar texture mapping on the meshbuffer.
- virtual void recalculateNormals (IMesh *mesh, bool smooth=false, bool angleWeighted=false) const =0
    Recalculates all normals of the mesh.
- virtual void recalculateNormals (IMeshBuffer *buffer, bool smooth=false, bool angleWeighted=false) const =0
    Recalculates all normals of the mesh buffer.
- virtual void recalculateTangents (IMesh *mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const =0
    Recalculates tangents, requires a tangent mesh.
- virtual void recalculateTangents (IMeshBuffer *buffer, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const =0
    Recalculates tangents, requires a tangent mesh buffer.
- void scale (IMesh *mesh, const core::vector3df &factor) const
    Scales the actual mesh, not a scene node.
- void scale (IMeshBuffer *buffer, const core::vector3df &factor) const
    Scales the actual meshbuffer, not a scene node.
- _IRR_DEPRECATED_ void scaleMesh (IMesh *mesh, const core::vector3df &factor) const
    Scales the actual mesh, not a scene node.
- void scaleTCoords (scene::IMesh *mesh, const core::vector2df &factor, u32 level=1) const
    Scale the texture coords of a mesh.
- void scaleTCoords (scene::IMeshBuffer *buffer, const core::vector2df &factor, u32 level=1) const
    Scale the texture coords of a meshbuffer.
- void setVertexColorAlpha (IMesh *mesh, s32 alpha) const
    Sets the alpha vertex color value of the whole mesh to a new value.
- void setVertexColorAlpha (IMeshBuffer *buffer, s32 alpha) const
    Sets the alpha vertex color value of the whole mesh to a new value.
- void setVertexColors (IMesh *mesh, video::SColor color) const
    Sets the colors of all vertices to one color.
- void setVertexColors (IMeshBuffer *buffer, video::SColor color) const
    Sets the colors of all vertices to one color.
- void transform (IMesh *mesh, const core::matrix4 &m) const
    Applies a transformation to a mesh.
- void transform (IMeshBuffer *buffer, const core::matrix4 &m) const
    Applies a transformation to a meshbuffer.
- virtual _IRR_DEPRECATED_ void transformMesh (IMesh *mesh, const core::matrix4 &m) const
    Applies a transformation to a mesh.

## Protected Member Functions

- template<typename Functor > bool apply_ (const Functor &func, IMeshBuffer *buffer, bool boundingBoxUpdate, const IVertexManipulator &typeTest) const
    Apply a manipulator based on the type of the functor.

## Detailed Description

An interface for easy manipulation of meshes.

Scale, set alpha value, flip surfaces, and so on. This exists for fixing problems with wrong imported or exported meshes quickly after loading. It is not intended for doing mesh modifications and/or animations during runtime.

Definition at line 29 of file IMeshManipulator.h.

## Member Function Documentation

template<typename Functor >

bool irr::scene::IMeshManipulator::apply | ( | const Functor & | func,
|  | IMeshBuffer * | buffer,
|  | bool | boundingBoxUpdate = `false`
| ) |  | const`[inline]`

Apply a manipulator on the Meshbuffer.

Parameters:

  func | A functor defining the mesh manipulation.
  buffer | The Meshbuffer to apply the manipulator to.
  boundingBoxUpdate | Specifies if the bounding box should be updated during manipulation.

Returns:
  True if the functor was successfully applied, else false.

Definition at line 304 of file IMeshManipulator.h.

References apply_().

Referenced by apply(), scale(), scaleTCoords(), setVertexColorAlpha(), setVertexColors(), and transform().

template<typename Functor >

bool irr::scene::IMeshManipulator::apply | ( | const Functor & | func,
|  | IMesh * | mesh,
|  | bool | boundingBoxUpdate = `false`
| ) |  | const`[inline]`

Apply a manipulator on the Mesh.

Parameters:

  func | A functor defining the mesh manipulation.
  mesh | The Mesh to apply the manipulator to.
  boundingBoxUpdate | Specifies if the bounding box should be updated during manipulation.

Returns:
  True if the functor was successfully applied, else false.

Definition at line 316 of file IMeshManipulator.h.

References irr::core::aabbox3d< T >::addInternalBox(), apply(), irr::scene::IMeshBuffer::getBoundingBox(), irr::scene::IMesh::getMeshBuffer(), irr::scene::IMesh::getMeshBufferCount(), irr::core::aabbox3d< T >::reset(), and irr::scene::IMesh::setBoundingBox().

template<typename Functor >

bool irr::scene::IMeshManipulator::apply_ | ( | const Functor & | func,
|  | IMeshBuffer * | buffer,
|  | bool | boundingBoxUpdate,
|  | const IVertexManipulator & | typeTest
| ) |  | const`[inline, protected]`

Apply a manipulator based on the type of the functor.

Parameters:

  func | A functor defining the mesh manipulation.
  buffer | The Meshbuffer to apply the manipulator to.
  boundingBoxUpdate | Specifies if the bounding box should be updated during manipulation.
  typeTest | Unused parameter, which handles the proper call selection based on the type of the Functor which is passed in two times.

Returns:
  True if the functor was successfully applied, else false.

Definition at line 346 of file IMeshManipulator.h.

References irr::core::aabbox3d< T >::addInternalPoint(), irr::video::EVT_2TCOORDS, irr::video::EVT_STANDARD, irr::video::EVT_TANGENTS, irr::scene::IMeshBuffer::getPosition(), irr::scene::IMeshBuffer::getVertexCount(), irr::scene::IMeshBuffer::getVertexType(), irr::scene::IMeshBuffer::getVertices(), irr::core::aabbox3d< T >::reset(), and irr::scene::IMeshBuffer::setBoundingBox().

Referenced by apply().

virtual IAnimatedMesh* irr::scene::IMeshManipulator::createAnimatedMesh | ( | IMesh * | mesh,
|  | scene::E_ANIMATED_MESH_TYPE | type = `scene::EAMT_UNKNOWN`
| ) |  | const`[pure virtual]`

Create a new AnimatedMesh and adds the mesh to it.

Parameters:

  mesh | Input mesh
  type | The type of the animated mesh to create.

Returns:
  Newly created animated mesh with mesh as its only content. When you don't need the animated mesh anymore, you should call IAnimatedMesh::drop(). See IReferenceCounted::drop() for more information.

virtual IMesh* irr::scene::IMeshManipulator::createForsythOptimizedMesh | ( | const IMesh * | mesh | ) | const`[pure virtual]`

Vertex cache optimization according to the Forsyth paper.

More information can be found at http://home.comcast.net/~tom_forsyth/papers/fast_vert_cache_opt.html

The function is thread-safe (read: you can optimize several meshes in different threads).

Parameters:

  mesh | Source mesh for the operation.

Returns:
  A new mesh optimized for the vertex cache.

virtual SMesh* irr::scene::IMeshManipulator::createMeshCopy | ( | IMesh * | mesh | ) | const`[pure virtual]`

Clones a static IMesh into a modifiable SMesh.

All meshbuffers in the returned SMesh are of type SMeshBuffer or SMeshBufferLightMap.

Parameters:

  mesh | Mesh to copy.

Returns:
  Cloned mesh. If you no longer need the cloned mesh, you should call SMesh::drop(). See IReferenceCounted::drop() for more information.

virtual IMesh* irr::scene::IMeshManipulator::createMeshUniquePrimitives | ( | IMesh * | mesh | ) | const`[pure virtual]`

Creates a copy of a mesh with all vertices unwelded.

Parameters:

  mesh | Input mesh

Returns:
  Mesh consisting only of unique faces. All vertices which were previously shared are now duplicated. If you no longer need the cloned mesh, you should call IMesh::drop(). See IReferenceCounted::drop() for more information.

virtual IMesh* irr::scene::IMeshManipulator::createMeshWelded | ( | IMesh * | mesh,
|  | f32 | tolerance = `core::ROUNDING_ERROR_f32`
| ) |  | const`[pure virtual]`

Creates a copy of a mesh with vertices welded.

Parameters:

  mesh | Input mesh
  tolerance | The threshold for vertex comparisons.

Returns:
  Mesh without redundant vertices. If you no longer need the cloned mesh, you should call IMesh::drop(). See IReferenceCounted::drop() for more information.

virtual IMesh* irr::scene::IMeshManipulator::createMeshWith1TCoords | ( | IMesh * | mesh | ) | const`[pure virtual]`

Creates a copy of the mesh, which will only consist of S3DVertex vertices.

Parameters:

  mesh | Input mesh

Returns:
  Mesh consisting only of S3DVertex vertices. If you no longer need the cloned mesh, you should call IMesh::drop(). See IReferenceCounted::drop() for more information.

virtual IMesh* irr::scene::IMeshManipulator::createMeshWith2TCoords | ( | IMesh * | mesh | ) | const`[pure virtual]`

Creates a copy of the mesh, which will only consist of S3DVertex2TCoord vertices.

Parameters:

  mesh | Input mesh

Returns:
  Mesh consisting only of S3DVertex2TCoord vertices. If you no longer need the cloned mesh, you should call IMesh::drop(). See IReferenceCounted::drop() for more information.

virtual IMesh* irr::scene::IMeshManipulator::createMeshWithTangents | ( | IMesh * | mesh,
|  | bool | recalculateNormals = `false`,
|  | bool | smooth = `false`,
|  | bool | angleWeighted = `false`,
|  | bool | recalculateTangents = `true`
| ) |  | const`[pure virtual]`

Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices.

This is useful if you want to draw tangent space normal mapped geometry because it calculates the tangent and binormal data which is needed there.

Parameters:

  mesh | Input mesh
  recalculateNormals | The normals are recalculated if set, otherwise the original ones are kept. Note that keeping the normals may introduce inaccurate tangents if the normals are very different to those calculated from the faces.
  smooth | The normals/tangents are smoothed across the meshbuffer's faces if this flag is set.
  angleWeighted | Improved smoothing calculation used
  recalculateTangents | Whether are actually calculated, or just the mesh with proper type is created.

Returns:
  Mesh consisting only of S3DVertexTangents vertices. If you no longer need the cloned mesh, you should call IMesh::drop(). See IReferenceCounted::drop() for more information.

virtual void irr::scene::IMeshManipulator::flipSurfaces | ( | IMesh * | mesh | ) | const`[pure virtual]`

Flips the direction of surfaces.

Changes backfacing triangles to frontfacing triangles and vice versa.

Parameters:

  mesh | Mesh on which the operation is performed.

virtual s32 irr::scene::IMeshManipulator::getPolyCount | ( | IMesh * | mesh | ) | const`[pure virtual]`

Get amount of polygons in mesh.

Parameters:

  mesh | Input mesh

Returns:
  Number of polygons in mesh.

virtual s32 irr::scene::IMeshManipulator::getPolyCount | ( | IAnimatedMesh * | mesh | ) | const`[pure virtual]`

Get amount of polygons in mesh.

Parameters:

  mesh | Input mesh

Returns:
  Number of polygons in mesh.

virtual void irr::scene::IMeshManipulator::makePlanarTextureMapping | ( | IMesh * | mesh,
|  | f32 | resolution = `0.001f`
| ) |  | const`[pure virtual]`

Creates a planar texture mapping on the mesh.

Parameters:

  mesh,: | Mesh on which the operation is performed.
  resolution,: | resolution of the planar mapping. This is the value specifying which is the relation between world space and texture coordinate space.

virtual void irr::scene::IMeshManipulator::makePlanarTextureMapping | ( | scene::IMeshBuffer * | meshbuffer,
|  | f32 | resolution = `0.001f`
| ) |  | const`[pure virtual]`

Creates a planar texture mapping on the meshbuffer.

Parameters:

  meshbuffer,: | Buffer on which the operation is performed.
  resolution,: | resolution of the planar mapping. This is the value specifying which is the relation between world space and texture coordinate space.

virtual void irr::scene::IMeshManipulator::makePlanarTextureMapping | ( | scene::IMesh * | mesh,
|  | f32 | resolutionS,
|  | f32 | resolutionT,
|  | u8 | axis,
|  | const core::vector3df & | offset
| ) |  | const`[pure virtual]`

Creates a planar texture mapping on the buffer.

This method is currently implemented towards the LWO planar mapping. A more general biasing might be required.

Parameters:

  mesh | Mesh on which the operation is performed.
  resolutionS | Resolution of the planar mapping in horizontal direction. This is the ratio between object space and texture space.
  resolutionT | Resolution of the planar mapping in vertical direction. This is the ratio between object space and texture space.
  axis | The axis along which the texture is projected. The allowed values are 0 (X), 1(Y), and 2(Z).
  offset | Vector added to the vertex positions (in object coordinates).

virtual void irr::scene::IMeshManipulator::makePlanarTextureMapping | ( | scene::IMeshBuffer * | buffer,
|  | f32 | resolutionS,
|  | f32 | resolutionT,
|  | u8 | axis,
|  | const core::vector3df & | offset
| ) |  | const`[pure virtual]`

Creates a planar texture mapping on the meshbuffer.

This method is currently implemented towards the LWO planar mapping. A more general biasing might be required.

Parameters:

  buffer | Buffer on which the operation is performed.
  resolutionS | Resolution of the planar mapping in horizontal direction. This is the ratio between object space and texture space.
  resolutionT | Resolution of the planar mapping in vertical direction. This is the ratio between object space and texture space.
  axis | The axis along which the texture is projected. The allowed values are 0 (X), 1(Y), and 2(Z).
  offset | Vector added to the vertex positions (in object coordinates).

virtual void irr::scene::IMeshManipulator::recalculateNormals | ( | IMesh * | mesh,
|  | bool | smooth = `false`,
|  | bool | angleWeighted = `false`
| ) |  | const`[pure virtual]`

Recalculates all normals of the mesh.

Parameters:

  mesh,: | Mesh on which the operation is performed.
  smooth,: | If the normals shall be smoothed.
  angleWeighted,: | If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision.

virtual void irr::scene::IMeshManipulator::recalculateNormals | ( | IMeshBuffer * | buffer,
|  | bool | smooth = `false`,
|  | bool | angleWeighted = `false`
| ) |  | const`[pure virtual]`

Recalculates all normals of the mesh buffer.

Parameters:

  buffer,: | Mesh buffer on which the operation is performed.
  smooth,: | If the normals shall be smoothed.
  angleWeighted,: | If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision.

virtual void irr::scene::IMeshManipulator::recalculateTangents | ( | IMesh * | mesh,
|  | bool | recalculateNormals = `false`,
|  | bool | smooth = `false`,
|  | bool | angleWeighted = `false`
| ) |  | const`[pure virtual]`

Recalculates tangents, requires a tangent mesh.

Parameters:

  mesh | Mesh on which the operation is performed.
  recalculateNormals | If the normals shall be recalculated, otherwise original normals of the mesh are used unchanged.
  smooth | If the normals shall be smoothed.
  angleWeighted | If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision.

virtual void irr::scene::IMeshManipulator::recalculateTangents | ( | IMeshBuffer * | buffer,
|  | bool | recalculateNormals = `false`,
|  | bool | smooth = `false`,
|  | bool | angleWeighted = `false`
| ) |  | const`[pure virtual]`

Recalculates tangents, requires a tangent mesh buffer.

Parameters:

  buffer | Meshbuffer on which the operation is performed.
  recalculateNormals | If the normals shall be recalculated, otherwise original normals of the buffer are used unchanged.
  smooth | If the normals shall be smoothed.
  angleWeighted | If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision.

void irr::scene::IMeshManipulator::scale | ( | IMesh * | mesh,
|  | const core::vector3df & | factor
| ) |  | const`[inline]`

Scales the actual mesh, not a scene node.

Parameters:

  mesh | Mesh on which the operation is performed.
  factor | Scale factor for each axis.

Definition at line 108 of file IMeshManipulator.h.

References apply().

Referenced by scaleMesh().

void irr::scene::IMeshManipulator::scale | ( | IMeshBuffer * | buffer,
|  | const core::vector3df & | factor
| ) |  | const`[inline]`

Scales the actual meshbuffer, not a scene node.

Parameters:

  buffer | Meshbuffer on which the operation is performed.
  factor | Scale factor for each axis.

Definition at line 116 of file IMeshManipulator.h.

References apply().

_IRR_DEPRECATED_ void irr::scene::IMeshManipulator::scaleMesh | ( | IMesh * | mesh,
|  | const core::vector3df & | factor
| ) |  | const`[inline]`

Scales the actual mesh, not a scene node.

Deprecated:
  Use scale() instead. This method may be removed by Irrlicht 1.9

Parameters:

  mesh | Mesh on which the operation is performed.
  factor | Scale factor for each axis.

Definition at line 125 of file IMeshManipulator.h.

References scale().

void irr::scene::IMeshManipulator::scaleTCoords | ( | scene::IMesh * | mesh,
|  | const core::vector2df & | factor,
|  | u32 | level = `1`
| ) |  | const`[inline]`

Scale the texture coords of a mesh.

Parameters:

  mesh | Mesh on which the operation is performed.
  factor | Vector which defines the scale for each axis.
  level | Number of texture coord, starting from 1. Support for level 2 exists for LightMap buffers.

Definition at line 131 of file IMeshManipulator.h.

References apply().

void irr::scene::IMeshManipulator::scaleTCoords | ( | scene::IMeshBuffer * | buffer,
|  | const core::vector2df & | factor,
|  | u32 | level = `1`
| ) |  | const`[inline]`

Scale the texture coords of a meshbuffer.

Parameters:

  buffer | Meshbuffer on which the operation is performed.
  factor | Vector which defines the scale for each axis.
  level | Number of texture coord, starting from 1. Support for level 2 exists for LightMap buffers.

Definition at line 140 of file IMeshManipulator.h.

References apply().

void irr::scene::IMeshManipulator::setVertexColorAlpha | ( | IMesh * | mesh,
|  | s32 | alpha
| ) |  | const`[inline]`

Sets the alpha vertex color value of the whole mesh to a new value.

Parameters:

  mesh | Mesh on which the operation is performed.
  alpha | New alpha value. Must be a value between 0 and 255.

Definition at line 42 of file IMeshManipulator.h.

References apply().

void irr::scene::IMeshManipulator::setVertexColorAlpha | ( | IMeshBuffer * | buffer,
|  | s32 | alpha
| ) |  | const`[inline]`

Sets the alpha vertex color value of the whole mesh to a new value.

Parameters:

  buffer | Meshbuffer on which the operation is performed.
  alpha | New alpha value. Must be a value between 0 and 255.

Definition at line 50 of file IMeshManipulator.h.

References apply().

void irr::scene::IMeshManipulator::setVertexColors | ( | IMesh * | mesh,
|  | video::SColor | color
| ) |  | const`[inline]`

Sets the colors of all vertices to one color.

Parameters:

  mesh | Mesh on which the operation is performed.
  color | New color.

Definition at line 58 of file IMeshManipulator.h.

References apply().

void irr::scene::IMeshManipulator::setVertexColors | ( | IMeshBuffer * | buffer,
|  | video::SColor | color
| ) |  | const`[inline]`

Sets the colors of all vertices to one color.

Parameters:

  buffer | Meshbuffer on which the operation is performed.
  color | New color.

Definition at line 66 of file IMeshManipulator.h.

References apply().

void irr::scene::IMeshManipulator::transform | ( | IMesh * | mesh,
|  | const core::matrix4 & | m
| ) |  | const`[inline]`

Applies a transformation to a mesh.

Parameters:

  mesh | Mesh on which the operation is performed.
  m | transformation matrix.

Definition at line 148 of file IMeshManipulator.h.

References apply().

Referenced by transformMesh().

void irr::scene::IMeshManipulator::transform | ( | IMeshBuffer * | buffer,
|  | const core::matrix4 & | m
| ) |  | const`[inline]`

Applies a transformation to a meshbuffer.

Parameters:

  buffer | Meshbuffer on which the operation is performed.
  m | transformation matrix.

Definition at line 156 of file IMeshManipulator.h.

References apply().

virtual _IRR_DEPRECATED_ void irr::scene::IMeshManipulator::transformMesh | ( | IMesh * | mesh,
|  | const core::matrix4 & | m
| ) |  | const`[inline, virtual]`

Applies a transformation to a mesh.

Deprecated:
  Use transform() instead. This method may be removed by Irrlicht 1.9

Parameters:

  mesh | Mesh on which the operation is performed.
  m | transformation matrix.

Definition at line 165 of file IMeshManipulator.h.

References transform().

The documentation for this class was generated from the following file:

- IMeshManipulator.h