Loading...
Searching...
No Matches
IMeshManipulator.h
Go to the documentation of this file.
// 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
#ifndef __I_MESH_MANIPULATOR_H_INCLUDED__
#define __I_MESH_MANIPULATOR_H_INCLUDED__
#include "IReferenceCounted.h"
#include "vector3d.h"
#include "aabbox3d.h"
#include "matrix4.h"
#include "IAnimatedMesh.h"
#include "IMeshBuffer.h"
#include "SVertexManipulator.h"
namespace irr
{
namespace scene
{
struct SMesh;
class IMeshManipulator : public virtual IReferenceCounted
{
public:
virtual void flipSurfaces(IMesh* mesh) const = 0;
void setVertexColorAlpha(IMesh* mesh, s32 alpha) const
{
apply(scene::SVertexColorSetAlphaManipulator(alpha), mesh);
}
void setVertexColorAlpha(IMeshBuffer* buffer, s32 alpha) const
{
apply(scene::SVertexColorSetAlphaManipulator(alpha), buffer);
}
void setVertexColors(IMesh* mesh, video::SColor color) const
{
apply(scene::SVertexColorSetManipulator(color), mesh);
}
void setVertexColors(IMeshBuffer* buffer, video::SColor color) const
{
apply(scene::SVertexColorSetManipulator(color), buffer);
}
virtual void recalculateNormals(IMesh* mesh, bool smooth = false,
bool angleWeighted = false) const=0;
virtual void recalculateNormals(IMeshBuffer* buffer,
bool smooth = false, bool angleWeighted = false) const=0;
virtual void recalculateTangents(IMesh* mesh,
bool recalculateNormals=false, bool smooth=false,
bool angleWeighted=false) const=0;
virtual void recalculateTangents(IMeshBuffer* buffer,
bool recalculateNormals=false, bool smooth=false,
bool angleWeighted=false) const=0;
void scale(IMesh* mesh, const core::vector3df& factor) const
{
apply(SVertexPositionScaleManipulator(factor), mesh, true);
}
void scale(IMeshBuffer* buffer, const core::vector3df& factor) const
{
apply(SVertexPositionScaleManipulator(factor), buffer, true);
}
_IRR_DEPRECATED_ void scaleMesh(IMesh* mesh, const core::vector3df& factor) const {return scale(mesh,factor);}
void scaleTCoords(scene::IMesh* mesh, const core::vector2df& factor, u32 level=1) const
{
apply(SVertexTCoordsScaleManipulator(factor, level), mesh);
}
void scaleTCoords(scene::IMeshBuffer* buffer, const core::vector2df& factor, u32 level=1) const
{
apply(SVertexTCoordsScaleManipulator(factor, level), buffer);
}
void transform(IMesh* mesh, const core::matrix4& m) const
{
apply(SVertexPositionTransformManipulator(m), mesh, true);
}
void transform(IMeshBuffer* buffer, const core::matrix4& m) const
{
apply(SVertexPositionTransformManipulator(m), buffer, true);
}
_IRR_DEPRECATED_ virtual void transformMesh(IMesh* mesh, const core::matrix4& m) const {return transform(mesh,m);}
virtual void makePlanarTextureMapping(IMesh* mesh, f32 resolution=0.001f) const=0;
virtual void makePlanarTextureMapping(scene::IMeshBuffer* meshbuffer, f32 resolution=0.001f) const=0;
virtual void makePlanarTextureMapping(scene::IMesh* mesh,
f32 resolutionS, f32 resolutionT,
u8 axis, const core::vector3df& offset) const=0;
virtual void makePlanarTextureMapping(scene::IMeshBuffer* buffer,
f32 resolutionS, f32 resolutionT,
u8 axis, const core::vector3df& offset) const=0;
virtual SMesh* createMeshCopy(IMesh* mesh) const = 0;
virtual IMesh* createMeshWithTangents(IMesh* mesh,
bool recalculateNormals=false, bool smooth=false,
bool angleWeighted=false, bool recalculateTangents=true) const=0;
virtual IMesh* createMeshWith2TCoords(IMesh* mesh) const = 0;
virtual IMesh* createMeshWith1TCoords(IMesh* mesh) const = 0;
virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const = 0;
virtual IMesh* createMeshWelded(IMesh* mesh, f32 tolerance=core::ROUNDING_ERROR_f32) const = 0;
virtual s32 getPolyCount(IMesh* mesh) const = 0;
virtual s32 getPolyCount(IAnimatedMesh* mesh) const = 0;
virtual IAnimatedMesh * createAnimatedMesh(IMesh* mesh,
scene::E_ANIMATED_MESH_TYPE type = scene::EAMT_UNKNOWN) const = 0;
virtual IMesh* createForsythOptimizedMesh(const IMesh *mesh) const = 0;
template <typename Functor>
bool apply(const Functor& func, IMeshBuffer* buffer, bool boundingBoxUpdate=false) const
{
return apply_(func, buffer, boundingBoxUpdate, func);
}
template <typename Functor>
bool apply(const Functor& func, IMesh* mesh, bool boundingBoxUpdate=false) const
{
if (!mesh)
return true;
bool result = true;
core::aabbox3df bufferbox;
for (u32 i=0; i<mesh->getMeshBufferCount(); ++i)
{
result &= apply(func, mesh->getMeshBuffer(i), boundingBoxUpdate);
if (boundingBoxUpdate)
{
if (0==i)
bufferbox.reset(mesh->getMeshBuffer(i)->getBoundingBox());
else
bufferbox.addInternalBox(mesh->getMeshBuffer(i)->getBoundingBox());
}
}
if (boundingBoxUpdate)
mesh->setBoundingBox(bufferbox);
return result;
}
protected:
template <typename Functor>
bool apply_(const Functor& func, IMeshBuffer* buffer, bool boundingBoxUpdate, const IVertexManipulator& typeTest) const
{
if (!buffer)
return true;
core::aabbox3df bufferbox;
for (u32 i=0; i<buffer->getVertexCount(); ++i)
{
switch (buffer->getVertexType())
{
case video::EVT_STANDARD:
{
video::S3DVertex* verts = (video::S3DVertex*)buffer->getVertices();
func(verts[i]);
}
break;
case video::EVT_2TCOORDS:
{
video::S3DVertex2TCoords* verts = (video::S3DVertex2TCoords*)buffer->getVertices();
func(verts[i]);
}
break;
case video::EVT_TANGENTS:
{
video::S3DVertexTangents* verts = (video::S3DVertexTangents*)buffer->getVertices();
func(verts[i]);
}
break;
}
if (boundingBoxUpdate)
{
if (0==i)
bufferbox.reset(buffer->getPosition(0));
else
bufferbox.addInternalPoint(buffer->getPosition(i));
}
}
if (boundingBoxUpdate)
buffer->setBoundingBox(bufferbox);
return true;
}
};
} // end namespace scene
} // end namespace irr
#endif
IAnimatedMesh.h
IMeshBuffer.h
IReferenceCounted.h
SVertexManipulator.h
aabbox3d.h
irr::IReferenceCounted::IReferenceCounted
IReferenceCounted()
Constructor.
Definition IReferenceCounted.h:46
irr::core::aabbox3d::addInternalPoint
void addInternalPoint(const vector3d< T > &p)
Adds a point to the bounding box.
Definition aabbox3d.h:74
irr::core::aabbox3d::addInternalBox
void addInternalBox(const aabbox3d< T > &b)
Adds another bounding box.
Definition aabbox3d.h:82
irr::core::aabbox3d::reset
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
Definition aabbox3d.h:50
irr::scene::IAnimatedMesh
Interface for an animated mesh.
Definition IAnimatedMesh.h:63
irr::scene::IMeshBuffer
Struct for holding a mesh with a single material.
Definition IMeshBuffer.h:40
irr::scene::IMeshBuffer::getPosition
virtual const core::vector3df & getPosition(u32 i) const =0
returns position of vertex i
irr::scene::IMeshBuffer::getVertexType
virtual video::E_VERTEX_TYPE getVertexType() const =0
Get type of vertex data which is stored in this meshbuffer.
irr::scene::IMeshBuffer::getVertexCount
virtual u32 getVertexCount() const =0
Get amount of vertices in meshbuffer.
irr::scene::IMeshBuffer::getVertices
virtual const void * getVertices() const =0
Get access to vertex data. The data is an array of vertices.
irr::scene::IMeshBuffer::getBoundingBox
virtual const core::aabbox3df & getBoundingBox() const =0
Get the axis aligned bounding box of this meshbuffer.
irr::scene::IMeshBuffer::setBoundingBox
virtual void setBoundingBox(const core::aabbox3df &box)=0
Set axis aligned bounding box.
irr::scene::IMesh
Class which holds the geometry of an object.
Definition IMesh.h:24
irr::scene::IMesh::setBoundingBox
virtual void setBoundingBox(const core::aabbox3df &box)=0
Set user-defined axis aligned bounding box.
irr::scene::IMesh::getMeshBufferCount
virtual u32 getMeshBufferCount() const =0
Get the amount of mesh buffers.
irr::scene::IMesh::getMeshBuffer
virtual IMeshBuffer * getMeshBuffer(u32 nr) const =0
Get pointer to a mesh buffer.
irr::scene::IMeshManipulator
An interface for easy manipulation of meshes.
Definition IMeshManipulator.h:30
irr::scene::IMeshManipulator::scaleMesh
_IRR_DEPRECATED_ void scaleMesh(IMesh *mesh, const core::vector3df &factor) const
Scales the actual mesh, not a scene node.
Definition IMeshManipulator.h:125
irr::scene::IMeshManipulator::createMeshWelded
virtual IMesh * createMeshWelded(IMesh *mesh, f32 tolerance=core::ROUNDING_ERROR_f32) const =0
Creates a copy of a mesh with vertices welded.
irr::scene::IMeshManipulator::recalculateTangents
virtual void recalculateTangents(IMesh *mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const =0
Recalculates tangents, requires a tangent mesh.
irr::scene::IMeshManipulator::transformMesh
virtual _IRR_DEPRECATED_ void transformMesh(IMesh *mesh, const core::matrix4 &m) const
Applies a transformation to a mesh.
Definition IMeshManipulator.h:165
irr::scene::IMeshManipulator::transform
void transform(IMeshBuffer *buffer, const core::matrix4 &m) const
Applies a transformation to a meshbuffer.
Definition IMeshManipulator.h:156
irr::scene::IMeshManipulator::createMeshUniquePrimitives
virtual IMesh * createMeshUniquePrimitives(IMesh *mesh) const =0
Creates a copy of a mesh with all vertices unwelded.
irr::scene::IMeshManipulator::makePlanarTextureMapping
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.
irr::scene::IMeshManipulator::scaleTCoords
void scaleTCoords(scene::IMesh *mesh, const core::vector2df &factor, u32 level=1) const
Scale the texture coords of a mesh.
Definition IMeshManipulator.h:131
irr::scene::IMeshManipulator::apply
bool apply(const Functor &func, IMesh *mesh, bool boundingBoxUpdate=false) const
Apply a manipulator on the Mesh.
Definition IMeshManipulator.h:316
irr::scene::IMeshManipulator::scale
void scale(IMeshBuffer *buffer, const core::vector3df &factor) const
Scales the actual meshbuffer, not a scene node.
Definition IMeshManipulator.h:116
irr::scene::IMeshManipulator::recalculateTangents
virtual void recalculateTangents(IMeshBuffer *buffer, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const =0
Recalculates tangents, requires a tangent mesh buffer.
irr::scene::IMeshManipulator::apply
bool apply(const Functor &func, IMeshBuffer *buffer, bool boundingBoxUpdate=false) const
Apply a manipulator on the Meshbuffer.
Definition IMeshManipulator.h:304
irr::scene::IMeshManipulator::flipSurfaces
virtual void flipSurfaces(IMesh *mesh) const =0
Flips the direction of surfaces.
irr::scene::IMeshManipulator::setVertexColors
void setVertexColors(IMesh *mesh, video::SColor color) const
Sets the colors of all vertices to one color.
Definition IMeshManipulator.h:58
irr::scene::IMeshManipulator::makePlanarTextureMapping
virtual void makePlanarTextureMapping(scene::IMeshBuffer *meshbuffer, f32 resolution=0.001f) const =0
Creates a planar texture mapping on the meshbuffer.
irr::scene::IMeshManipulator::createAnimatedMesh
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.
irr::scene::IMeshManipulator::apply_
bool apply_(const Functor &func, IMeshBuffer *buffer, bool boundingBoxUpdate, const IVertexManipulator &typeTest) const
Apply a manipulator based on the type of the functor.
Definition IMeshManipulator.h:346
irr::scene::IMeshManipulator::makePlanarTextureMapping
virtual void makePlanarTextureMapping(IMesh *mesh, f32 resolution=0.001f) const =0
Creates a planar texture mapping on the mesh.
irr::scene::IMeshManipulator::recalculateNormals
virtual void recalculateNormals(IMesh *mesh, bool smooth=false, bool angleWeighted=false) const =0
Recalculates all normals of the mesh.
irr::scene::IMeshManipulator::createMeshCopy
virtual SMesh * createMeshCopy(IMesh *mesh) const =0
Clones a static IMesh into a modifiable SMesh.
irr::scene::IMeshManipulator::getPolyCount
virtual s32 getPolyCount(IMesh *mesh) const =0
Get amount of polygons in mesh.
irr::scene::IMeshManipulator::recalculateNormals
virtual void recalculateNormals(IMeshBuffer *buffer, bool smooth=false, bool angleWeighted=false) const =0
Recalculates all normals of the mesh buffer.
irr::scene::IMeshManipulator::setVertexColorAlpha
void setVertexColorAlpha(IMesh *mesh, s32 alpha) const
Sets the alpha vertex color value of the whole mesh to a new value.
Definition IMeshManipulator.h:42
irr::scene::IMeshManipulator::transform
void transform(IMesh *mesh, const core::matrix4 &m) const
Applies a transformation to a mesh.
Definition IMeshManipulator.h:148
irr::scene::IMeshManipulator::createMeshWithTangents
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.
irr::scene::IMeshManipulator::setVertexColors
void setVertexColors(IMeshBuffer *buffer, video::SColor color) const
Sets the colors of all vertices to one color.
Definition IMeshManipulator.h:66
irr::scene::IMeshManipulator::makePlanarTextureMapping
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.
irr::scene::IMeshManipulator::scale
void scale(IMesh *mesh, const core::vector3df &factor) const
Scales the actual mesh, not a scene node.
Definition IMeshManipulator.h:108
irr::scene::IMeshManipulator::createMeshWith2TCoords
virtual IMesh * createMeshWith2TCoords(IMesh *mesh) const =0
Creates a copy of the mesh, which will only consist of S3DVertex2TCoord vertices.
irr::scene::IMeshManipulator::scaleTCoords
void scaleTCoords(scene::IMeshBuffer *buffer, const core::vector2df &factor, u32 level=1) const
Scale the texture coords of a meshbuffer.
Definition IMeshManipulator.h:140
irr::scene::IMeshManipulator::createForsythOptimizedMesh
virtual IMesh * createForsythOptimizedMesh(const IMesh *mesh) const =0
Vertex cache optimization according to the Forsyth paper.
irr::scene::IMeshManipulator::getPolyCount
virtual s32 getPolyCount(IAnimatedMesh *mesh) const =0
Get amount of polygons in mesh.
irr::scene::IMeshManipulator::createMeshWith1TCoords
virtual IMesh * createMeshWith1TCoords(IMesh *mesh) const =0
Creates a copy of the mesh, which will only consist of S3DVertex vertices.
irr::scene::IMeshManipulator::setVertexColorAlpha
void setVertexColorAlpha(IMeshBuffer *buffer, s32 alpha) const
Sets the alpha vertex color value of the whole mesh to a new value.
Definition IMeshManipulator.h:50
irr::scene::SVertexColorSetAlphaManipulator
Vertex manipulator to set the alpha value of the vertex color to a fixed value.
Definition SVertexManipulator.h:40
irr::scene::SVertexColorSetManipulator
Vertex manipulator to set color to a fixed color for all vertices.
Definition SVertexManipulator.h:28
irr::scene::SVertexPositionScaleManipulator
Vertex manipulator which scales the position of the vertex.
Definition SVertexManipulator.h:222
irr::scene::SVertexPositionTransformManipulator
Vertex manipulator which transforms the position of the vertex.
Definition SVertexManipulator.h:253
irr::scene::SVertexTCoordsScaleManipulator
Vertex manipulator which scales the TCoords of the vertex.
Definition SVertexManipulator.h:267
irr::video::SColor
Class representing a 32 bit ARGB color.
Definition SColor.h:202
_IRR_DEPRECATED_
#define _IRR_DEPRECATED_
Defines a deprecated macro which generates a warning at compile time.
Definition irrTypes.h:195
matrix4.h
irr::core::vector3df
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
irr::core::vector2df
vector2d< f32 > vector2df
Typedef for f32 2d vector.
Definition vector2d.h:323
irr::core::matrix4
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2235
irr::core::ROUNDING_ERROR_f32
const f32 ROUNDING_ERROR_f32
Definition irrMath.h:49
irr::core::aabbox3df
aabbox3d< f32 > aabbox3df
Typedef for a f32 3d bounding box.
Definition aabbox3d.h:324
irr::scene
All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees a...
Definition CDynamicMeshBuffer.h:16
irr::scene::E_ANIMATED_MESH_TYPE
E_ANIMATED_MESH_TYPE
Possible types of (animated) meshes.
Definition IAnimatedMesh.h:17
irr::scene::EAMT_UNKNOWN
@ EAMT_UNKNOWN
Unknown animated mesh type.
Definition IAnimatedMesh.h:19
irr::video::EVT_2TCOORDS
@ EVT_2TCOORDS
Vertex with two texture coordinates, video::S3DVertex2TCoords.
Definition S3DVertex.h:25
irr::video::EVT_TANGENTS
@ EVT_TANGENTS
Vertex with a tangent and binormal vector, video::S3DVertexTangents.
Definition S3DVertex.h:29
irr::video::EVT_STANDARD
@ EVT_STANDARD
Standard vertex type used by the Irrlicht engine, video::S3DVertex.
Definition S3DVertex.h:21
irr
Everything in the Irrlicht Engine can be found in this namespace.
Definition aabbox3d.h:13
irr::f32
float f32
32 bit floating point variable.
Definition irrTypes.h:104
irr::u32
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
irr::u8
unsigned char u8
8 bit unsigned variable.
Definition irrTypes.h:18
irr::s32
signed int s32
32 bit signed variable.
Definition irrTypes.h:66
irr::scene::IVertexManipulator
Interface for vertex manipulators.
Definition SVertexManipulator.h:24
irr::scene::SMesh
Simple implementation of the IMesh interface.
Definition SMesh.h:19
irr::video::S3DVertex2TCoords
Vertex with two texture coordinates.
Definition S3DVertex.h:110
irr::video::S3DVertex
standard vertex used by the Irrlicht engine.
Definition S3DVertex.h:43
irr::video::S3DVertexTangents
Vertex with a tangent and binormal vector.
Definition S3DVertex.h:188
vector3d.h
- Irrlicht Engine Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on for Irrlicht 3D Engine by Doxygen 1.15.0