Commit 69389d0c authored by hybrid's avatar hybrid

Renamed scaleMesh to scale, added support for meshbuffer scaling.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1478 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 76547f8f
Changes in version 1.5 (... 2008) Changes in version 1.5 (... 2008)
- Enable use of other meshes for shadow mesh generation, can be used to speed up shadow generation and rendering for complex meshes. Patch based on a version by tonic.
- Fixed Software renderer color flicker, was a signed shift bug I believe.
- Fixed usage of SIrrCreationParameters struct, which dind't have copy constructor and assignment operator anymore, since the Irrlicht version string was made const.
- New glext.h (version 40)
- Added support for read-only locking of textures. Can speed up those calls. - Added support for read-only locking of textures. Can speed up those calls.
- Added support for locking RTTs under OpenGL. - Added support for locking RTTs under OpenGL.
...@@ -20,7 +28,8 @@ Changes in version 1.5 (... 2008) ...@@ -20,7 +28,8 @@ Changes in version 1.5 (... 2008)
- OpenGL clamp modes are now properly set. - OpenGL clamp modes are now properly set.
- transformMesh renamed to transform, also supports meshbuffers now. - IMeshManipulator::transformMesh renamed to transform, also supports meshbuffers now.
scaleMesh renamed to scale, supports meshbuffers as well.
- vector3d::rotationToDirection added. - vector3d::rotationToDirection added.
......
...@@ -59,10 +59,21 @@ namespace scene ...@@ -59,10 +59,21 @@ namespace scene
\param angleWeighted: If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision. */ \param angleWeighted: If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision. */
virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false, bool angleWeighted = false) const = 0; virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false, bool angleWeighted = false) const = 0;
//! Scales the whole mesh. //! Scales the actual mesh, not a scene node.
/** \param mesh Mesh on which the operation is performed. /** \param mesh Mesh on which the operation is performed.
\param scale Scale factor. */ \param factor Scale factor for each axis. */
virtual void scaleMesh(IMesh* mesh, const core::vector3df& scale) const = 0; virtual void scale(IMesh* mesh, const core::vector3df& factor) const = 0;
//! Scales the actual meshbuffer, not a scene node.
/** \param buffer Meshbuffer on which the operation is performed.
\param factor Scale factor for each axis. */
virtual void scale(IMeshBuffer* buffer, const core::vector3df& factor) const = 0;
//! Scales the actual mesh, not a scene node.
/** \deprecated
\param mesh Mesh on which the operation is performed.
\param factor Scale factor for each axis. */
virtual void scaleMesh(IMesh* mesh, const core::vector3df& factor) const {return scale(mesh,factor);}
//! Applies a transformation to a mesh //! Applies a transformation to a mesh
/** \param mesh Mesh on which the operation is performed. /** \param mesh Mesh on which the operation is performed.
......
...@@ -310,9 +310,8 @@ void CMeshManipulator::transform(scene::IMesh* mesh, const core::matrix4& m) con ...@@ -310,9 +310,8 @@ void CMeshManipulator::transform(scene::IMesh* mesh, const core::matrix4& m) con
} }
//! Scales the whole mesh. //! Scales the actual mesh, not a scene node.
//! \param mesh: Mesh on which the operation is performed. void CMeshManipulator::scale(scene::IMesh* mesh, const core::vector3df& factor) const
void CMeshManipulator::scaleMesh(scene::IMesh* mesh, const core::vector3df& scale) const
{ {
if (!mesh) if (!mesh)
return; return;
...@@ -323,28 +322,37 @@ void CMeshManipulator::scaleMesh(scene::IMesh* mesh, const core::vector3df& scal ...@@ -323,28 +322,37 @@ void CMeshManipulator::scaleMesh(scene::IMesh* mesh, const core::vector3df& scal
for ( u32 b=0; b<bcount; ++b) for ( u32 b=0; b<bcount; ++b)
{ {
IMeshBuffer* buffer = mesh->getMeshBuffer(b); IMeshBuffer* buffer = mesh->getMeshBuffer(b);
scale(buffer, factor);
if (b == 0)
meshbox.reset(buffer->getBoundingBox());
else
meshbox.addInternalBox(buffer->getBoundingBox());
}
mesh->setBoundingBox( meshbox );
}
//! Scales the actual meshbuffer, not a scene node.
void CMeshManipulator::scale(scene::IMeshBuffer* buffer, const core::vector3df& factor) const
{
if (!buffer)
return;
const u32 vtxcnt = buffer->getVertexCount(); const u32 vtxcnt = buffer->getVertexCount();
core::aabbox3df bufferbox; core::aabbox3df bufferbox;
u32 i;
if (vtxcnt != 0) if (vtxcnt != 0)
bufferbox.reset(buffer->getPosition(0) * scale); bufferbox.reset(buffer->getPosition(0) * factor);
for ( i=0; i<vtxcnt; ++i) for (u32 i=0; i<vtxcnt; ++i)
{ {
buffer->getPosition(i) *= scale; buffer->getPosition(i) *= factor;
bufferbox.addInternalPoint(buffer->getPosition(i)); bufferbox.addInternalPoint(buffer->getPosition(i));
} }
buffer->setBoundingBox( bufferbox ); buffer->setBoundingBox(bufferbox);
if (b == 0)
meshbox.reset(buffer->getBoundingBox());
else
meshbox.addInternalBox(buffer->getBoundingBox());
}
mesh->setBoundingBox( meshbox );
} }
......
...@@ -13,25 +13,21 @@ namespace scene ...@@ -13,25 +13,21 @@ namespace scene
{ {
//! An interface for easy manipulation of meshes. //! An interface for easy manipulation of meshes.
/** Scale, set alpha value, flip surfaces, and so on. This exists for fixing problems /** Scale, set alpha value, flip surfaces, and so on. This exists for fixing
with wrong imported or exported meshes quickly after loading. It is not intended for doing mesh problems with wrong imported or exported meshes quickly after loading. It is
modifications and/or animations during runtime. not intended for doing mesh modifications and/or animations during runtime.
*/ */
class CMeshManipulator : public IMeshManipulator class CMeshManipulator : public IMeshManipulator
{ {
public: public:
//! Flips the direction of surfaces.
//! destructor /** Changes backfacing triangles to frontfacing triangles and vice versa.
virtual ~CMeshManipulator() {} \param mesh: Mesh on which the operation is performed. */
//! Flips the direction of surfaces. Changes backfacing triangles to frontfacing
//! triangles and vice versa.
//! \param mesh: Mesh on which the operation is performed.
virtual void flipSurfaces(scene::IMesh* mesh) const; virtual void flipSurfaces(scene::IMesh* mesh) const;
//! Sets the alpha vertex color value of the whole mesh to a new value //! Sets the alpha vertex color value of the whole mesh to a new value
//! \param mesh: Mesh on which the operation is performed. /** \param mesh: Mesh on which the operation is performed.
//! \param alpha: New alpha for the vertex color. \param alpha: New alpha for the vertex color. */
virtual void setVertexColorAlpha(scene::IMesh* mesh, s32 alpha) const; virtual void setVertexColorAlpha(scene::IMesh* mesh, s32 alpha) const;
//! Sets the colors of all vertices to one color //! Sets the colors of all vertices to one color
...@@ -47,10 +43,15 @@ public: ...@@ -47,10 +43,15 @@ public:
\param smooth: Whether to use smoothed normals. */ \param smooth: Whether to use smoothed normals. */
virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false, bool angleWeighted = false) const; virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false, bool angleWeighted = false) const;
//! Scales the whole mesh. //! Scales the actual mesh, not the scene node.
//! \param mesh: Mesh on which the operation is performed. /** \param mesh Mesh on which the operation is performed.
//! \param scale: 3D Vector, defining the value, for each axis, to scale the mesh by. \param factor Vector which defines the scale for each axis. */
virtual void scaleMesh(scene::IMesh* mesh, const core::vector3df& scale) const; 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;
//! Applies a transformation to a meshbuffer //! Applies a transformation to a meshbuffer
/** \param buffer: Meshbuffer on which the operation is performed. /** \param buffer: Meshbuffer on which the operation is performed.
...@@ -66,10 +67,10 @@ public: ...@@ -66,10 +67,10 @@ public:
virtual SMesh* createMeshCopy(scene::IMesh* mesh) const; virtual SMesh* createMeshCopy(scene::IMesh* mesh) const;
//! Creates a planar texture mapping on the mesh //! Creates a planar texture mapping on the mesh
//! \param mesh: Mesh on which the operation is performed. /** \param mesh: Mesh on which the operation is performed.
//! \param resolution: resolution of the planar mapping. This is the value \param resolution: resolution of the planar mapping. This is the value
//! specifying which is the relation between world space and specifying which is the relation between world space and
//! texture coordinate space. texture coordinate space. */
virtual void makePlanarTextureMapping(scene::IMesh* mesh, f32 resolution) const; virtual void makePlanarTextureMapping(scene::IMesh* mesh, f32 resolution) const;
//! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices. //! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices.
......
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