Added new makePlanarMapping method with one major axis for the whole mesh buffer, and different resolutions in S and T.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2181 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2009-02-01 23:43:44 +00:00
parent e06d5090b2
commit 57c16f70d8
3 changed files with 51 additions and 2 deletions

View File

@ -117,14 +117,23 @@ namespace scene
\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(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
/** \param meshbuffer: Buffer 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::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 meshbuffer
/** This method is currently implemented towards the LWO planar mapping. A more general biasing might be required.
\param meshbuffer Buffer 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).
*/
virtual void makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis) const =0;
//! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices.
/** This is useful if you want to draw tangent space normal

View File

@ -443,6 +443,43 @@ void CMeshManipulator::makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32
}
//! Creates a planar texture mapping on the meshbuffer
void CMeshManipulator::makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis) const
{
u32 idxcnt = buffer->getIndexCount();
u16* idx = buffer->getIndices();
for (u32 i=0; i<idxcnt; i+=3)
{
// calculate planar mapping worldspace coordinates
if (axis==0)
{
for (u32 o=0; o!=3; ++o)
{
buffer->getTCoords(idx[i+o]).X = buffer->getPosition(idx[i+o]).Z * resolutionS;
buffer->getTCoords(idx[i+o]).Y = 0.5f+buffer->getPosition(idx[i+o]).Y * resolutionT;
}
}
else if (axis==1)
{
for (u32 o=0; o!=3; ++o)
{
buffer->getTCoords(idx[i+o]).X = 0.5f+buffer->getPosition(idx[i+o]).X * resolutionS;
buffer->getTCoords(idx[i+o]).Y = 0.5f+buffer->getPosition(idx[i+o]).Z * resolutionT;
}
}
else if (axis==2)
{
for (u32 o=0; o!=3; ++o)
{
buffer->getTCoords(idx[i+o]).X = 0.5f+buffer->getPosition(idx[i+o]).X * resolutionS;
buffer->getTCoords(idx[i+o]).Y = buffer->getPosition(idx[i+o]).Y * resolutionT;
}
}
}
}
//! Creates a copy of the mesh, which will only consist of unique primitives
IMesh* CMeshManipulator::createMeshUniquePrimitives(IMesh* mesh) const
{

View File

@ -88,6 +88,9 @@ public:
//! Creates a planar texture mapping on the meshbuffer
virtual void makePlanarTextureMapping(scene::IMeshBuffer* meshbuffer, f32 resolution=0.001f) const;
//! Creates a planar texture mapping on the meshbuffer
void makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis) const;
//! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices.
virtual IMesh* createMeshWithTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const;