2019-12-12 17:32:41 +01:00
|
|
|
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
2021-08-27 17:55:04 +02:00
|
|
|
#ifndef IRR_C_MESH_MANIPULATOR_H_INCLUDED
|
|
|
|
#define IRR_C_MESH_MANIPULATOR_H_INCLUDED
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
#include "IMeshManipulator.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace scene
|
|
|
|
{
|
|
|
|
|
|
|
|
//! 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.
|
|
|
|
*/
|
|
|
|
class CMeshManipulator : public IMeshManipulator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//! Flips the direction of surfaces.
|
|
|
|
/** Changes backfacing triangles to frontfacing triangles and vice versa.
|
|
|
|
\param mesh: Mesh on which the operation is performed. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void flipSurfaces(scene::IMesh* mesh) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Recalculates all normals of the mesh.
|
|
|
|
/** \param mesh: Mesh on which the operation is performed.
|
|
|
|
\param smooth: Whether to use smoothed normals. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void recalculateNormals(scene::IMesh* mesh, bool smooth = false, bool angleWeighted = false) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Recalculates all normals of the mesh buffer.
|
|
|
|
/** \param buffer: Mesh buffer on which the operation is performed.
|
|
|
|
\param smooth: Whether to use smoothed normals. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false, bool angleWeighted = false) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Clones a static IMesh into a modifiable SMesh.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual SMesh* createMeshCopy(scene::IMesh* mesh) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a planar texture mapping on the mesh
|
|
|
|
/** \param mesh: Mesh on which the operation is performed.
|
|
|
|
\param resolution: resolution of the planar mapping. This is the value
|
|
|
|
specifying which is the relation between world space and
|
|
|
|
texture coordinate space. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void makePlanarTextureMapping(scene::IMesh* mesh, f32 resolution=0.001f) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a planar texture mapping on the meshbuffer
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void makePlanarTextureMapping(scene::IMeshBuffer* meshbuffer, f32 resolution=0.001f) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a planar texture mapping on the meshbuffer
|
2021-08-27 14:55:10 +02:00
|
|
|
void makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a planar texture mapping on the mesh
|
2021-08-27 14:55:10 +02:00
|
|
|
void makePlanarTextureMapping(scene::IMesh* mesh, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Recalculates tangents, requires a tangent mesh buffer
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void recalculateTangents(IMeshBuffer* buffer, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Recalculates tangents, requires a tangent mesh
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void recalculateTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual IMesh* createMeshWithTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false, bool recalculateTangents=true) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a copy of the mesh, which will only consist of S3D2TCoords vertices.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual IMesh* createMeshWith2TCoords(IMesh* mesh) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a copy of the mesh, which will only consist of S3DVertex vertices.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual IMesh* createMeshWith1TCoords(IMesh* mesh) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a copy of the mesh, which will only consist of unique triangles, i.e. no vertices are shared.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a copy of the mesh, which will have all duplicated vertices removed, i.e. maximal amount of vertices are shared via indexing.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual IMesh* createMeshWelded(IMesh *mesh, f32 tolerance=core::ROUNDING_ERROR_f32) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns amount of polygons in mesh.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual s32 getPolyCount(scene::IMesh* mesh) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns amount of polygons in mesh.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual s32 getPolyCount(scene::IAnimatedMesh* mesh) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! create a new AnimatedMesh and adds the mesh to it
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual IAnimatedMesh * createAnimatedMesh(scene::IMesh* mesh,scene::E_ANIMATED_MESH_TYPE type) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! create a mesh optimized for the vertex cache
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual IMesh* createForsythOptimizedMesh(const scene::IMesh *mesh) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Optimizes the mesh using an algorithm tuned for heightmaps
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void heightmapOptimizeMesh(IMesh * const m, const f32 tolerance = core::ROUNDING_ERROR_f32) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Optimizes the mesh using an algorithm tuned for heightmaps
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void heightmapOptimizeMesh(IMeshBuffer * const m, const f32 tolerance = core::ROUNDING_ERROR_f32) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace scene
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif
|