Commit 0f278fa5 authored by hybrid's avatar hybrid

Added a meshbuffer transform method and renamed the transformMesh method to transform.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1419 dfc29bdd-3216-0410-991c-e03cc46cb475
parent f66d9308
......@@ -64,10 +64,21 @@ namespace scene
\param scale Scale factor. */
virtual void scaleMesh(IMesh* mesh, const core::vector3df& scale) const = 0;
//! Applies a transformation
//! Applies a transformation to a mesh
/** \param mesh Mesh on which the operation is performed.
\param m transformation matrix. */
virtual void transformMesh(IMesh* mesh, const core::matrix4& m) const = 0;
virtual void transform(IMesh* mesh, const core::matrix4& m) const = 0;
//! Applies a transformation to a meshbuffer
/** \param buffer Meshbuffer on which the operation is performed.
\param m transformation matrix. */
virtual void transform(IMeshBuffer* buffer, const core::matrix4& m) const = 0;
//! Applies a transformation to a mesh
/** \deprecated
\param mesh Mesh on which the operation is performed.
\param m transformation matrix. */
virtual void transformMesh(IMesh* mesh, const core::matrix4& m) const {return transform(mesh,m);}
//! Clones a static IMesh into a modifiable SMesh.
/** All meshbuffers in the returned SMesh
......
......@@ -253,48 +253,52 @@ void CMeshManipulator::recalculateNormals(scene::IMesh* mesh, bool smooth, bool
//! Applies a transformation
/** \param mesh: Mesh on which the operation is performed.
/** \param buffer: Meshbuffer on which the operation is performed.
\param m: matrix. */
void CMeshManipulator::transformMesh(scene::IMesh* mesh, const core::matrix4& m) const
void CMeshManipulator::transform(scene::IMeshBuffer* buffer, const core::matrix4& m) const
{
if (!mesh)
const u32 vtxcnt = buffer->getVertexCount();
if (!vtxcnt)
return;
core::aabbox3df meshbox;
core::aabbox3df bufferbox;
u32 i;
const u32 bcount = mesh->getMeshBufferCount();
for ( u32 b=0; b<bcount; ++b)
// first transform
{
IMeshBuffer* buffer = mesh->getMeshBuffer(b);
m.transformVect(buffer->getPosition(0));
m.rotateVect(buffer->getNormal(0));
buffer->getNormal(0).normalize();
const u32 vtxcnt = buffer->getVertexCount();
const u32 vtxPitch = video::getVertexPitchFromType(buffer->getVertexType());
bufferbox.reset(buffer->getPosition(0));
}
video::S3DVertex* v = (video::S3DVertex*) buffer->getVertices();
for ( u32 i=1 ;i < vtxcnt; ++i)
{
m.transformVect(buffer->getPosition(i));
m.rotateVect(buffer->getNormal(i));
buffer->getNormal(i).normalize();
for ( i=0; i < 1; ++i)
{
m.transformVect ( v->Pos);
m.rotateVect ( v->Normal );
v->Normal.normalize();
bufferbox.addInternalPoint(buffer->getPosition(i));
}
bufferbox.reset( v->Pos);
v = (video::S3DVertex*) ((u8*) v + vtxPitch);
}
buffer->setBoundingBox(bufferbox);
}
for ( ;i < vtxcnt; ++i)
{
m.transformVect ( v->Pos);
m.rotateVect ( v->Normal );
v->Normal.normalize();
bufferbox.addInternalPoint( v->Pos);
v = (video::S3DVertex*) ((u8*) v + vtxPitch);
}
//! Applies a transformation
/** \param mesh: Mesh on which the operation is performed.
\param m: matrix. */
void CMeshManipulator::transform(scene::IMesh* mesh, const core::matrix4& m) const
{
if (!mesh)
return;
buffer->setBoundingBox(bufferbox);
core::aabbox3df meshbox;
const u32 bcount = mesh->getMeshBufferCount();
for ( u32 b=0; b<bcount; ++b)
{
IMeshBuffer* buffer = mesh->getMeshBuffer(b);
transform(buffer, m);
if (b == 0)
meshbox.reset(buffer->getBoundingBox());
......@@ -344,7 +348,6 @@ void CMeshManipulator::scaleMesh(scene::IMesh* mesh, const core::vector3df& scal
}
//! Clones a static IMesh into a modifyable SMesh.
SMesh* CMeshManipulator::createMeshCopy(scene::IMesh* mesh) const
{
......
......@@ -52,10 +52,15 @@ public:
//! \param scale: 3D Vector, defining the value, for each axis, to scale the mesh by.
virtual void scaleMesh(scene::IMesh* mesh, const core::vector3df& scale) const;
//! Applies a transformation
//! 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
/** \param mesh: Mesh on which the operation is performed.
\param m: transformation matrix. */
virtual void transformMesh(scene::IMesh* mesh, const core::matrix4& m) const;
virtual void transform(scene::IMesh* mesh, const core::matrix4& m) const;
//! Clones a static IMesh into a modifiable SMesh.
virtual SMesh* createMeshCopy(scene::IMesh* mesh) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment