Renamed scaleMesh to scale, added support for meshbuffer scaling.

git-svn-id: http://svn.code.sf.net/p/irrlicht/code/trunk@1478 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
hybrid 2008-08-09 10:34:58 +00:00
parent e0168a9a89
commit 98e7b49aed
4 changed files with 70 additions and 41 deletions

View File

@ -1,5 +1,13 @@
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 locking RTTs under OpenGL.
@ -20,7 +28,8 @@ Changes in version 1.5 (... 2008)
- 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.

View File

@ -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. */
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 scale Scale factor. */
virtual void scaleMesh(IMesh* mesh, const core::vector3df& scale) const = 0;
\param factor Scale factor for each axis. */
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
/** \param mesh Mesh on which the operation is performed.

View File

@ -310,9 +310,8 @@ void CMeshManipulator::transform(scene::IMesh* mesh, const core::matrix4& m) con
}
//! Scales the whole mesh.
//! \param mesh: Mesh on which the operation is performed.
void CMeshManipulator::scaleMesh(scene::IMesh* mesh, const core::vector3df& scale) const
//! Scales the actual mesh, not a scene node.
void CMeshManipulator::scale(scene::IMesh* mesh, const core::vector3df& factor) const
{
if (!mesh)
return;
@ -323,20 +322,7 @@ void CMeshManipulator::scaleMesh(scene::IMesh* mesh, const core::vector3df& scal
for ( u32 b=0; b<bcount; ++b)
{
IMeshBuffer* buffer = mesh->getMeshBuffer(b);
const u32 vtxcnt = buffer->getVertexCount();
core::aabbox3df bufferbox;
u32 i;
if (vtxcnt != 0)
bufferbox.reset(buffer->getPosition(0) * scale);
for ( i=0; i<vtxcnt; ++i)
{
buffer->getPosition(i) *= scale;
bufferbox.addInternalPoint(buffer->getPosition(i));
}
buffer->setBoundingBox( bufferbox );
scale(buffer, factor);
if (b == 0)
meshbox.reset(buffer->getBoundingBox());
@ -348,6 +334,28 @@ void CMeshManipulator::scaleMesh(scene::IMesh* mesh, const core::vector3df& scal
}
//! 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();
core::aabbox3df bufferbox;
if (vtxcnt != 0)
bufferbox.reset(buffer->getPosition(0) * factor);
for (u32 i=0; i<vtxcnt; ++i)
{
buffer->getPosition(i) *= factor;
bufferbox.addInternalPoint(buffer->getPosition(i));
}
buffer->setBoundingBox(bufferbox);
}
//! Clones a static IMesh into a modifyable SMesh.
SMesh* CMeshManipulator::createMeshCopy(scene::IMesh* mesh) const
{

View File

@ -13,25 +13,21 @@ namespace scene
{
//! An interface for easy manipulation of meshes.
/** Scale, set alpha value, flip surfaces, and so on. This exists for fixing problems
with wrong imported or exported meshes quickly after loading. It is not intended for doing mesh
modifications and/or animations during runtime.
/** Scale, set alpha value, flip surfaces, and so on. This exists for fixing
problems with wrong imported or exported meshes quickly after loading. It is
not intended for doing mesh modifications and/or animations during runtime.
*/
class CMeshManipulator : public IMeshManipulator
{
public:
//! destructor
virtual ~CMeshManipulator() {}
//! Flips the direction of surfaces. Changes backfacing triangles to frontfacing
//! triangles and vice versa.
//! \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;
//! Sets the alpha vertex color value of the whole mesh to a new value
//! \param mesh: Mesh on which the operation is performed.
//! \param alpha: New alpha for the vertex color.
/** \param mesh: Mesh on which the operation is performed.
\param alpha: New alpha for the vertex color. */
virtual void setVertexColorAlpha(scene::IMesh* mesh, s32 alpha) const;
//! Sets the colors of all vertices to one color
@ -47,10 +43,15 @@ public:
\param smooth: Whether to use smoothed normals. */
virtual void recalculateNormals(IMeshBuffer* buffer, bool smooth = false, bool angleWeighted = false) const;
//! Scales the whole mesh.
//! \param mesh: Mesh on which the operation is performed.
//! \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;
//! Scales the actual mesh, not the scene node.
/** \param mesh Mesh on which the operation is performed.
\param factor Vector which defines the scale for each axis. */
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
/** \param buffer: Meshbuffer on which the operation is performed.
@ -66,10 +67,10 @@ public:
virtual SMesh* createMeshCopy(scene::IMesh* mesh) const;
//! Creates a planar texture mapping on the mesh
//! \param mesh: Mesh on which the operation is performed.
//! \param resolution: resolution of the planar mapping. This is the value
//! specifying which is the relation between world space and
//! texture coordinate space.
/** \param mesh: Mesh on which the operation is performed.
\param resolution: resolution of the planar mapping. This is the value
specifying which is the relation between world space and
texture coordinate space. */
virtual void makePlanarTextureMapping(scene::IMesh* mesh, f32 resolution) const;
//! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices.