5#ifndef __I_MESH_MANIPULATOR_H_INCLUDED__
6#define __I_MESH_MANIPULATOR_H_INCLUDED__
8#include "IReferenceCounted.h"
12#include "CMeshBuffer.h"
157 virtual void recalculateTangents(
IMeshBuffer* meshBuffer,
bool recalculateNormals =
false,
bool smooth =
false,
bool angleWeighted =
false)
const = 0;
159 void recalculateTangents(
IMesh* mesh,
bool recNormals =
false,
bool smooth =
false,
bool angleWeighted =
false)
const
162 recalculateTangents(mesh->
getMeshBuffer(i), recNormals, smooth, angleWeighted);
202 f32 resolutionS,
f32 resolutionT,
220 bool check4Component =
true,
bool check3Component =
true,
bool check2Component =
true,
bool check1Component =
true)
const = 0;
227 !descriptor || descriptor->getVertexSize(0) !=
sizeof(T))
234 if (copyVertices(buffer->getVertexBuffer(0), 0, buffer->getVertexDescriptor(), vb, 0, descriptor,
false))
236 buffer->setVertexDescriptor(descriptor);
237 buffer->setVertexBuffer(vb, 0);
248 bool createTangents(IMeshBuffer* buffer, video::IVertexDescriptor* descriptor,
bool copyCustomAttribute =
false)
250 if (!convertVertices<T>(buffer, descriptor, copyCustomAttribute))
253 recalculateTangents(buffer,
false,
false,
false);
260 SMesh* createMeshCopy(IMesh* mesh, video::IVertexDescriptor* descriptor,
bool copyCustomAttribute =
false)
262 if (!mesh || mesh->getMeshBufferCount() == 0 || !descriptor || descriptor->getVertexSize(0) !=
sizeof(T))
265 const u32 mbCount = mesh->getMeshBufferCount();
267 for (
u32 i = 0; i < mbCount; ++i)
269 const IMeshBuffer*
const mb = mesh->getMeshBuffer(i);
271 if (!mb->isVertexBufferCompatible() || mb->getVertexBufferCount() > 1)
275 SMesh* dstMesh =
new SMesh();
277 for (
u32 i = 0; i < mbCount; ++i)
279 IMeshBuffer* srcBuffer = mesh->getMeshBuffer(i);
280 IIndexBuffer* srcIndexBuffer = srcBuffer->getIndexBuffer();
281 CMeshBuffer<T>* dstBuffer =
new CMeshBuffer<T>(descriptor, srcIndexBuffer->getType());
283 dstBuffer->getMaterial() = srcBuffer->getMaterial();
285 copyIndices(srcIndexBuffer, dstBuffer->getIndexBuffer());
286 copyVertices(srcBuffer->getVertexBuffer(0), 0, srcBuffer->getVertexDescriptor(), dstBuffer->getVertexBuffer(0), 0, dstBuffer->getVertexDescriptor(), copyCustomAttribute);
288 dstMesh->addMeshBuffer(dstBuffer);
292 dstMesh->BoundingBox = mesh->getBoundingBox();
bool drop() const
Drops the object. Decrements the reference counter by one.
Definition IReferenceCounted.h:126
IReferenceCounted()
Constructor.
Definition IReferenceCounted.h:50
void addInternalBox(const aabbox3d< T > &b)
Adds another bounding box.
Definition aabbox3d.h:82
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
Definition aabbox3d.h:50
Definition CVertexBuffer.h:17
Definition IIndexBuffer.h:25
Struct for holding a mesh with a single material.
Definition IMeshBuffer.h:42
bool isVertexBufferCompatible() const
Inform if stored vertex buffers have the same vertex descriptors.
Definition IMeshBuffer.h:66
virtual const core::aabbox3df & getBoundingBox() const =0
Get the axis aligned bounding box of this meshbuffer.
Class which holds the geometry of an object.
Definition IMesh.h:24
virtual void setBoundingBox(const core::aabbox3df &box)=0
Set user-defined axis aligned bounding box.
virtual u32 getMeshBufferCount() const =0
Get the amount of mesh buffers.
virtual IMeshBuffer * getMeshBuffer(u32 nr) const =0
Get pointer to a mesh buffer.
An interface for easy manipulation of meshes.
Definition IMeshManipulator.h:26
_IRR_DEPRECATED_ void scaleMesh(IMesh *mesh, const core::vector3df &factor) const
Scales the actual mesh, not a scene node.
Definition IMeshManipulator.h:92
virtual void scaleTCoords(IMeshBuffer *meshBuffer, const core::vector2df &factor, u32 level=0) const =0
Scale the texture coords of a meshbuffer.
virtual _IRR_DEPRECATED_ void transformMesh(IMesh *mesh, const core::matrix4 &m) const
Applies a transformation to a mesh.
Definition IMeshManipulator.h:139
virtual void makePlanarTextureMapping(IMeshBuffer *meshBuffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df &offset) const =0
Creates a planar texture mapping on the meshbuffer.
void recalculateNormals(IMesh *mesh, bool smooth=false, bool angleWeighted=false) const
Recalculates all normals of the mesh.
Definition IMeshManipulator.h:151
virtual void makePlanarTextureMapping(IMeshBuffer *meshBuffer, f32 resolution=0.001f) const =0
Creates a planar texture mapping on the meshbuffer.
virtual void flipSurfaces(IMesh *mesh) const =0
Flips the direction of surfaces.
void setVertexColors(IMesh *mesh, video::SColor color) const
Sets the colors of all vertices to one color.
Definition IMeshManipulator.h:57
void makePlanarTextureMapping(IMesh *mesh, f32 resolution=0.001f) const
Creates a planar texture mapping on the mesh.
Definition IMeshManipulator.h:177
virtual void transform(IMeshBuffer *meshBuffer, const core::matrix4 &mat) const =0
Applies a transformation to a meshbuffer.
virtual s32 getPolyCount(IMesh *mesh) const =0
Get amount of polygons in mesh.
void scaleTCoords(scene::IMesh *mesh, const core::vector2df &factor, u32 level=0) const
Scale the texture coords of a mesh.
Definition IMeshManipulator.h:104
void setVertexColorAlpha(IMesh *mesh, s32 alpha) const
Sets the alpha vertex color value of the whole mesh to a new value.
Definition IMeshManipulator.h:43
void transform(IMesh *mesh, const core::matrix4 &m) const
Applies a transformation to a mesh.
Definition IMeshManipulator.h:118
virtual void recalculateNormals(IMeshBuffer *meshBuffer, bool smooth=false, bool angleWeighted=false) const =0
Recalculates all normals of the mesh buffer.
void scale(IMesh *mesh, const core::vector3df &factor) const
Scales the actual mesh, not a scene node.
Definition IMeshManipulator.h:71
virtual void setVertexColorAlpha(IMeshBuffer *meshBuffer, s32 alpha) const =0
Sets the alpha vertex color value of the whole mesh to a new value.
virtual IMesh * createForsythOptimizedMesh(const IMesh *mesh) const =0
Vertex cache optimization according to the Forsyth paper.
virtual void setVertexColors(IMeshBuffer *meshBuffer, video::SColor color) const =0
Sets the colors of all vertices to one color.
void makePlanarTextureMapping(scene::IMesh *mesh, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df &offset) const
Creates a planar texture mapping on the buffer.
Definition IMeshManipulator.h:201
virtual void scale(IMeshBuffer *meshBuffer, const core::vector3df &factor) const =0
Scales the actual meshbuffer, not a scene node.
Definition IVertexBuffer.h:17
Definition IVertexDescriptor.h:154
Class representing a 32 bit ARGB color.
Definition SColor.h:285
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
vector2d< f32 > vector2df
Typedef for f32 2d vector.
Definition vector2d.h:323
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2241
aabbox3d< f32 > aabbox3df
Typedef for a f32 3d bounding box.
Definition aabbox3d.h:351
All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees a...
Definition CIndexBuffer.h:13
Everything in the Irrlicht Engine can be found in this namespace.
Definition Skylicht.h:33
float f32
32 bit floating point variable.
Definition irrTypes.h:104
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
unsigned char u8
8 bit unsigned variable.
Definition irrTypes.h:18
signed int s32
32 bit signed variable.
Definition irrTypes.h:66