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 ...@@ -64,10 +64,21 @@ namespace scene
\param scale Scale factor. */ \param scale Scale factor. */
virtual void scaleMesh(IMesh* mesh, const core::vector3df& scale) const = 0; 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 mesh Mesh on which the operation is performed.
\param m transformation matrix. */ \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. //! Clones a static IMesh into a modifiable SMesh.
/** All meshbuffers in the returned SMesh /** All meshbuffers in the returned SMesh
......
...@@ -253,48 +253,52 @@ void CMeshManipulator::recalculateNormals(scene::IMesh* mesh, bool smooth, bool ...@@ -253,48 +253,52 @@ void CMeshManipulator::recalculateNormals(scene::IMesh* mesh, bool smooth, bool
//! Applies a transformation //! Applies a transformation
/** \param mesh: Mesh on which the operation is performed. /** \param buffer: Meshbuffer on which the operation is performed.
\param m: matrix. */ \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; return;
core::aabbox3df meshbox;
core::aabbox3df bufferbox; core::aabbox3df bufferbox;
u32 i; // first transform
const u32 bcount = mesh->getMeshBufferCount();
for ( u32 b=0; b<bcount; ++b)
{ {
IMeshBuffer* buffer = mesh->getMeshBuffer(b); m.transformVect(buffer->getPosition(0));
m.rotateVect(buffer->getNormal(0));
buffer->getNormal(0).normalize();
const u32 vtxcnt = buffer->getVertexCount(); bufferbox.reset(buffer->getPosition(0));
const u32 vtxPitch = video::getVertexPitchFromType(buffer->getVertexType()); }
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) bufferbox.addInternalPoint(buffer->getPosition(i));
{ }
m.transformVect ( v->Pos);
m.rotateVect ( v->Normal );
v->Normal.normalize();
bufferbox.reset( v->Pos); buffer->setBoundingBox(bufferbox);
v = (video::S3DVertex*) ((u8*) v + vtxPitch); }
}
for ( ;i < vtxcnt; ++i)
{
m.transformVect ( v->Pos);
m.rotateVect ( v->Normal );
v->Normal.normalize();
bufferbox.addInternalPoint( v->Pos); //! Applies a transformation
v = (video::S3DVertex*) ((u8*) v + vtxPitch); /** \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) if (b == 0)
meshbox.reset(buffer->getBoundingBox()); meshbox.reset(buffer->getBoundingBox());
...@@ -344,7 +348,6 @@ void CMeshManipulator::scaleMesh(scene::IMesh* mesh, const core::vector3df& scal ...@@ -344,7 +348,6 @@ void CMeshManipulator::scaleMesh(scene::IMesh* mesh, const core::vector3df& scal
} }
//! Clones a static IMesh into a modifyable SMesh. //! Clones a static IMesh into a modifyable SMesh.
SMesh* CMeshManipulator::createMeshCopy(scene::IMesh* mesh) const SMesh* CMeshManipulator::createMeshCopy(scene::IMesh* mesh) const
{ {
......
...@@ -52,10 +52,15 @@ public: ...@@ -52,10 +52,15 @@ public:
//! \param scale: 3D Vector, defining the value, for each axis, to scale the mesh by. //! \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; 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 mesh: Mesh on which the operation is performed.
\param m: transformation matrix. */ \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. //! Clones a static IMesh into a modifiable SMesh.
virtual SMesh* createMeshCopy(scene::IMesh* mesh) const; 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