Commit 84eeb0e6 authored by hybrid's avatar hybrid

Added 32bit support to some more of the mesh manipulator methods....

Added 32bit support to some more of the mesh manipulator methods. Unfortunately, the cloning methods (createXXX) will require huge code duplication, so I left them unchanged so far.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3765 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 1e321bc0
...@@ -44,6 +44,14 @@ namespace scene ...@@ -44,6 +44,14 @@ namespace scene
apply(scene::SVertexColorSetAlphaManipulator(alpha), mesh); apply(scene::SVertexColorSetAlphaManipulator(alpha), mesh);
} }
//! Sets the alpha vertex color value of the whole mesh to a new value.
/** \param buffer Meshbuffer on which the operation is performed.
\param alpha New alpha value. Must be a value between 0 and 255. */
void setVertexColorAlpha(IMeshBuffer* buffer, s32 alpha) const
{
apply(scene::SVertexColorSetAlphaManipulator(alpha), buffer);
}
//! Sets the colors of all vertices to one color //! Sets the colors of all vertices to one color
/** \param mesh Mesh on which the operation is performed. /** \param mesh Mesh on which the operation is performed.
\param color New color. */ \param color New color. */
...@@ -52,17 +60,27 @@ namespace scene ...@@ -52,17 +60,27 @@ namespace scene
apply(scene::SVertexColorSetManipulator(color), mesh); apply(scene::SVertexColorSetManipulator(color), mesh);
} }
//! Sets the colors of all vertices to one color
/** \param buffer Meshbuffer on which the operation is performed.
\param color New color. */
void setVertexColors(IMeshBuffer* buffer, video::SColor color) const
{
apply(scene::SVertexColorSetManipulator(color), buffer);
}
//! Recalculates all normals of the mesh. //! Recalculates all normals of the mesh.
/** \param mesh: Mesh on which the operation is performed. /** \param mesh: Mesh on which the operation is performed.
\param smooth: If the normals shall be smoothed. \param smooth: If the normals shall be smoothed.
\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(IMesh* mesh, bool smooth = false, bool angleWeighted = false) const = 0; virtual void recalculateNormals(IMesh* mesh, bool smooth = false,
bool angleWeighted = false) const=0;
//! Recalculates all normals of the mesh buffer. //! Recalculates all normals of the mesh buffer.
/** \param buffer: Mesh buffer on which the operation is performed. /** \param buffer: Mesh buffer on which the operation is performed.
\param smooth: If the normals shall be smoothed. \param smooth: If the normals shall be smoothed.
\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;
//! Recalculates tangents, requires a tangent mesh //! Recalculates tangents, requires a tangent mesh
/** \param mesh Mesh on which the operation is performed. /** \param mesh Mesh on which the operation is performed.
...@@ -74,6 +92,16 @@ namespace scene ...@@ -74,6 +92,16 @@ namespace scene
bool recalculateNormals=false, bool smooth=false, bool recalculateNormals=false, bool smooth=false,
bool angleWeighted=false) const=0; bool angleWeighted=false) const=0;
//! Recalculates tangents, requires a tangent mesh buffer
/** \param buffer Meshbuffer on which the operation is performed.
\param recalculateNormals If the normals shall be recalculated, otherwise original normals of the buffer are used unchanged.
\param smooth If the normals shall be smoothed.
\param angleWeighted If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision.
*/
virtual void recalculateTangents(IMeshBuffer* buffer,
bool recalculateNormals=false, bool smooth=false,
bool angleWeighted=false) const=0;
//! Scales the actual mesh, not a scene node. //! 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 factor Scale factor for each axis. */ \param factor Scale factor for each axis. */
...@@ -136,28 +164,31 @@ namespace scene ...@@ -136,28 +164,31 @@ namespace scene
\param m transformation matrix. */ \param m transformation matrix. */
_IRR_DEPRECATED_ virtual void transformMesh(IMesh* mesh, const core::matrix4& m) const {return transform(mesh,m);} _IRR_DEPRECATED_ 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
are of type SMeshBuffer or SMeshBufferLightMap.
\param mesh Mesh to copy.
\return Cloned mesh. If you no longer need the
cloned mesh, you should call SMesh::drop(). See
IReferenceCounted::drop() for more information. */
virtual SMesh* createMeshCopy(IMesh* mesh) const = 0;
//! 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 \param resolution: resolution of the planar mapping. This is
the value specifying which is the relation between world space the value specifying which is the relation between world space
and texture coordinate space. */ and texture coordinate space. */
virtual void makePlanarTextureMapping(IMesh* mesh, f32 resolution=0.001f) const =0; virtual void makePlanarTextureMapping(IMesh* mesh, f32 resolution=0.001f) const=0;
//! Creates a planar texture mapping on the meshbuffer //! Creates a planar texture mapping on the meshbuffer
/** \param meshbuffer: Buffer on which the operation is performed. /** \param meshbuffer: Buffer on which the operation is performed.
\param resolution: resolution of the planar mapping. This is \param resolution: resolution of the planar mapping. This is
the value specifying which is the relation between world space the value specifying which is the relation between world space
and texture coordinate space. */ and texture coordinate space. */
virtual void makePlanarTextureMapping(scene::IMeshBuffer* meshbuffer, f32 resolution=0.001f) const =0; virtual void makePlanarTextureMapping(scene::IMeshBuffer* meshbuffer, f32 resolution=0.001f) const=0;
//! Creates a planar texture mapping on the buffer
/** This method is currently implemented towards the LWO planar mapping. A more general biasing might be required.
\param mesh Mesh on which the operation is performed.
\param resolutionS Resolution of the planar mapping in horizontal direction. This is the ratio between object space and texture space.
\param resolutionT Resolution of the planar mapping in vertical direction. This is the ratio between object space and texture space.
\param axis The axis along which the texture is projected. The allowed values are 0 (X), 1(Y), and 2(Z).
\param offset Vector added to the vertex positions (in object coordinates).
*/
virtual void makePlanarTextureMapping(scene::IMesh* mesh,
f32 resolutionS, f32 resolutionT,
u8 axis, const core::vector3df& offset) const=0;
//! Creates a planar texture mapping on the meshbuffer //! Creates a planar texture mapping on the meshbuffer
/** This method is currently implemented towards the LWO planar mapping. A more general biasing might be required. /** This method is currently implemented towards the LWO planar mapping. A more general biasing might be required.
...@@ -167,7 +198,18 @@ namespace scene ...@@ -167,7 +198,18 @@ namespace scene
\param axis The axis along which the texture is projected. The allowed values are 0 (X), 1(Y), and 2(Z). \param axis The axis along which the texture is projected. The allowed values are 0 (X), 1(Y), and 2(Z).
\param offset Vector added to the vertex positions (in object coordinates). \param offset Vector added to the vertex positions (in object coordinates).
*/ */
virtual void makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) const =0; virtual void makePlanarTextureMapping(scene::IMeshBuffer* buffer,
f32 resolutionS, f32 resolutionT,
u8 axis, const core::vector3df& offset) const=0;
//! Clones a static IMesh into a modifiable SMesh.
/** All meshbuffers in the returned SMesh
are of type SMeshBuffer or SMeshBufferLightMap.
\param mesh Mesh to copy.
\return Cloned mesh. If you no longer need the
cloned mesh, you should call SMesh::drop(). See
IReferenceCounted::drop() for more information. */
virtual SMesh* createMeshCopy(IMesh* mesh) const = 0;
//! 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.
/** This is useful if you want to draw tangent space normal /** This is useful if you want to draw tangent space normal
...@@ -186,7 +228,9 @@ namespace scene ...@@ -186,7 +228,9 @@ namespace scene
you no longer need the cloned mesh, you should call you no longer need the cloned mesh, you should call
IMesh::drop(). See IReferenceCounted::drop() for more IMesh::drop(). See IReferenceCounted::drop() for more
information. */ information. */
virtual IMesh* createMeshWithTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false, bool recalculateTangents=true) const = 0; virtual IMesh* createMeshWithTangents(IMesh* mesh,
bool recalculateNormals=false, bool smooth=false,
bool angleWeighted=false, bool recalculateTangents=true) const=0;
//! Creates a copy of the mesh, which will only consist of S3DVertex2TCoord vertices. //! Creates a copy of the mesh, which will only consist of S3DVertex2TCoord vertices.
/** \param mesh Input mesh /** \param mesh Input mesh
......
This diff is collapsed.
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
\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=0.001f) const;
//! Creates a planar texture mapping on the meshbuffer //! Creates a planar texture mapping on the meshbuffer
virtual void makePlanarTextureMapping(scene::IMeshBuffer* meshbuffer, f32 resolution=0.001f) const; virtual void makePlanarTextureMapping(scene::IMeshBuffer* meshbuffer, f32 resolution=0.001f) const;
...@@ -51,6 +51,12 @@ public: ...@@ -51,6 +51,12 @@ public:
//! Creates a planar texture mapping on the meshbuffer //! Creates a planar texture mapping on the meshbuffer
void makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) const; void makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) const;
//! Creates a planar texture mapping on the mesh
void makePlanarTextureMapping(scene::IMesh* mesh, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) const;
//! Recalculates tangents, requires a tangent mesh buffer
virtual void recalculateTangents(IMeshBuffer* buffer, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const;
//! Recalculates tangents, requires a tangent mesh //! Recalculates tangents, requires a tangent mesh
virtual void recalculateTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const; virtual void recalculateTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const;
...@@ -77,14 +83,6 @@ public: ...@@ -77,14 +83,6 @@ public:
//! create a new AnimatedMesh and adds the mesh to it //! create a new AnimatedMesh and adds the mesh to it
virtual IAnimatedMesh * createAnimatedMesh(scene::IMesh* mesh,scene::E_ANIMATED_MESH_TYPE type) const; virtual IAnimatedMesh * createAnimatedMesh(scene::IMesh* mesh,scene::E_ANIMATED_MESH_TYPE type) const;
private:
static void calculateTangents(core::vector3df& normal,
core::vector3df& tangent,
core::vector3df& binormal,
const core::vector3df& vt1, const core::vector3df& vt2, const core::vector3df& vt3,
const core::vector2df& tc1, const core::vector2df& tc2, const core::vector2df& tc3);
}; };
} // end namespace scene } // end namespace scene
......
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