2008-05-22 04:51:37 -07:00
|
|
|
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
2007-05-20 11:03:49 -07:00
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#ifndef __C_MESH_MANIPULATOR_H_INCLUDED__
|
|
|
|
#define __C_MESH_MANIPULATOR_H_INCLUDED__
|
|
|
|
|
|
|
|
#include "IMeshManipulator.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace scene
|
|
|
|
{
|
|
|
|
|
2007-06-02 05:10:39 -07:00
|
|
|
//! An interface for easy manipulation of meshes.
|
2008-08-09 03:34:58 -07:00
|
|
|
/** 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.
|
2007-05-20 11:03:49 -07:00
|
|
|
*/
|
|
|
|
class CMeshManipulator : public IMeshManipulator
|
|
|
|
{
|
|
|
|
public:
|
2008-08-09 03:34:58 -07:00
|
|
|
//! Flips the direction of surfaces.
|
|
|
|
/** Changes backfacing triangles to frontfacing triangles and vice versa.
|
|
|
|
\param mesh: Mesh on which the operation is performed. */
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual void flipSurfaces(scene::IMesh* mesh) const;
|
|
|
|
|
|
|
|
//! Sets the alpha vertex color value of the whole mesh to a new value
|
2008-08-09 03:34:58 -07:00
|
|
|
/** \param mesh: Mesh on which the operation is performed.
|
|
|
|
\param alpha: New alpha for the vertex color. */
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual void setVertexColorAlpha(scene::IMesh* mesh, s32 alpha) const;
|
|
|
|
|
|
|
|
//! Sets the colors of all vertices to one color
|
|
|
|
virtual void setVertexColors(IMesh* mesh, video::SColor color) const;
|
|
|
|
|
|
|
|
//! Recalculates all normals of the mesh.
|
|
|
|
/** \param mesh: Mesh on which the operation is performed.
|
|
|
|
\param smooth: Whether to use smoothed normals. */
|
2008-06-20 01:34:39 -07:00
|
|
|
virtual void recalculateNormals(scene::IMesh* mesh, bool smooth = false, bool angleWeighted = false) const;
|
2007-05-20 11:03:49 -07: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. */
|
2008-06-20 01:34:39 -07:00
|
|
|
virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false, bool angleWeighted = false) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2008-08-09 03:34:58 -07:00
|
|
|
//! Scales the actual mesh, not the scene node.
|
|
|
|
/** \param mesh Mesh on which the operation is performed.
|
|
|
|
\param factor Vector which defines the scale for each axis. */
|
|
|
|
virtual void scale(scene::IMesh* mesh, const core::vector3df& factor) const;
|
|
|
|
|
|
|
|
//! Scales the actual meshbuffer, not the scene node.
|
|
|
|
/** \param buffer MeshBuffer on which the operation is performed.
|
|
|
|
\param factor Vector which defines the scale for each axis. */
|
|
|
|
virtual void scale(scene::IMeshBuffer* buffer, const core::vector3df& factor) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2008-08-09 05:04:56 -07:00
|
|
|
//! Scale the texture coords of a mesh.
|
|
|
|
/** \param mesh Mesh on which the operation is performed.
|
|
|
|
\param factor Vector which defines the scale for each axis.
|
|
|
|
\param level Number of texture coord, starting from 1. Support for level 2 exists for LightMap buffers. */
|
|
|
|
virtual void scaleTCoords(scene::IMesh* mesh, const core::vector2df& factor, u32 layer=1) const;
|
|
|
|
|
|
|
|
//! Scale the texture coords of a meshbuffer.
|
|
|
|
/** \param mesh Mesh on which the operation is performed.
|
|
|
|
\param factor Vector which defines the scale for each axis.
|
|
|
|
\param level Number of texture coord, starting from 1. Support for level 2 exists for LightMap buffers. */
|
|
|
|
virtual void scaleTCoords(scene::IMeshBuffer* buffer, const core::vector2df& factor, u32 level=1) const;
|
|
|
|
|
2008-07-17 02:09:30 -07:00
|
|
|
//! Applies a transformation to a meshbuffer
|
|
|
|
/** \param buffer: Meshbuffer on which the operation is performed.
|
|
|
|
\param m: matrix. */
|
|
|
|
void transform(scene::IMeshBuffer* buffer, const core::matrix4& m) const;
|
|
|
|
|
|
|
|
//! Applies a transformation to a mesh
|
2007-05-20 11:03:49 -07:00
|
|
|
/** \param mesh: Mesh on which the operation is performed.
|
|
|
|
\param m: transformation matrix. */
|
2008-07-17 02:09:30 -07:00
|
|
|
virtual void transform(scene::IMesh* mesh, const core::matrix4& m) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Clones a static IMesh into a modifiable SMesh.
|
|
|
|
virtual SMesh* createMeshCopy(scene::IMesh* mesh) const;
|
|
|
|
|
|
|
|
//! Creates a planar texture mapping on the mesh
|
2008-08-09 03:34:58 -07:00
|
|
|
/** \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. */
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual void makePlanarTextureMapping(scene::IMesh* mesh, f32 resolution) const;
|
|
|
|
|
|
|
|
//! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices.
|
2008-06-20 05:45:05 -07:00
|
|
|
virtual IMesh* createMeshWithTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const;
|
2008-06-20 05:20:15 -07:00
|
|
|
|
|
|
|
//! Creates a copy of the mesh, which will only consist of S3D2TCoords vertices.
|
2007-09-28 14:11:30 -07:00
|
|
|
virtual IMesh* createMeshWith2TCoords(IMesh* mesh) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2008-06-20 05:20:15 -07:00
|
|
|
//! Creates a copy of the mesh, which will only consist of unique triangles, i.e. no vertices are shared.
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const;
|
|
|
|
|
2008-06-20 05:20:15 -07:00
|
|
|
//! Creates a copy of the mesh, which will have all duplicated vertices removed, i.e. maximal amount of vertices are shared via indexing.
|
2007-09-11 14:47:32 -07:00
|
|
|
virtual IMesh* createMeshWelded(IMesh *mesh, f32 tolerance=core::ROUNDING_ERROR_32) const;
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
//! Returns amount of polygons in mesh.
|
|
|
|
virtual s32 getPolyCount(scene::IMesh* mesh) const;
|
|
|
|
|
|
|
|
//! Returns amount of polygons in mesh.
|
|
|
|
virtual s32 getPolyCount(scene::IAnimatedMesh* mesh) const;
|
|
|
|
|
|
|
|
//! create a new AnimatedMesh and adds the mesh to it
|
|
|
|
virtual IAnimatedMesh * createAnimatedMesh(scene::IMesh* mesh,scene::E_ANIMATED_MESH_TYPE type) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
static void calculateTangents(core::vector3df& normal,
|
|
|
|
core::vector3df& tangent,
|
|
|
|
core::vector3df& binormal,
|
2007-08-08 09:30:10 -07:00
|
|
|
const core::vector3df& vt1, const core::vector3df& vt2, const core::vector3df& vt3,
|
|
|
|
const core::vector2df& tc1, const core::vector2df& tc2, const core::vector2df& tc3);
|
2007-05-20 11:03:49 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace scene
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|