diff -Nauwr Irrlicht/CMeshManipulator.cpp Irrlicht/CMeshManipulator.cpp --- Irrlicht/CMeshManipulator.cpp 2005-08-20 22:17:50.000000000 +0200 +++ Irrlicht/CMeshManipulator.cpp 2005-09-16 15:31:22.000000000 +0200 @@ -708,6 +708,87 @@ } +//! Returns a mesh copied from the mesh passed in, as a mesh with meshBuffers +//! with 2 texture coords. +//! \param mesh: base mesh to copy data from +IMesh* CMeshManipulator::createMeshWith2TCoords( IMesh* mesh ) const +{ + if (!mesh) + return 0; + + // copy mesh and fill data into SMeshBufferTangents + + SMesh* clone = new SMesh(); + s32 meshBufferCount = mesh->getMeshBufferCount(); + + s32 b = 0; + for ( ; bgetMeshBuffer( b )->getVertexCount(); + s32 idxCnt = mesh->getMeshBuffer( b )->getIndexCount(); + const u16* idx = mesh->getMeshBuffer( b )->getIndices(); + + SMeshBufferLightMap* buffer = new SMeshBufferLightMap(); + buffer->Material = mesh->getMeshBuffer( b )->getMaterial(); + + // copy vertices + s32 i; + + switch(mesh->getMeshBuffer( b )->getVertexType()) + { + case video::EVT_STANDARD: + { + video::S3DVertex* v = (video::S3DVertex*)mesh->getMeshBuffer( b )->getVertices(); + + for( i = 0; i < idxCnt; ++i ) + { + buffer->Vertices.push_back( + video::S3DVertex2TCoords( v[idx[i]].Pos, v[idx[i]].Color, v[idx[i]].TCoords, v[idx[i]].TCoords ) + ); + } + } + break; + case video::EVT_2TCOORDS: + { + video::S3DVertex2TCoords* v = (video::S3DVertex2TCoords*)mesh->getMeshBuffer(b)->getVertices(); + + for( i = 0; i < idxCnt; ++i ) + { + buffer->Vertices.push_back( *v ); + } + } + break; + case video::EVT_TANGENTS: + { + video::S3DVertexTangents* v = (video::S3DVertexTangents*)mesh->getMeshBuffer(b)->getVertices(); + + for( i = 0; i < idxCnt; ++i ) + { + buffer->Vertices.push_back( + video::S3DVertex2TCoords( v[idx[i]].Pos, v[idx[i]].Color, v[idx[i]].TCoords, v[idx[i]].TCoords ) + ); + } + } + break; + } + + // create new indices + + buffer->Indices.set_used( idxCnt ); + for( i = 0; i < idxCnt; ++i ) + { + buffer->Indices[i] = i; + } + + // add new buffer + clone->addMeshBuffer(buffer); + buffer->drop(); + } + + clone->BoundingBox = mesh->getBoundingBox(); + + return clone; +} } // end namespace scene diff -Nauwr Irrlicht/CMeshManipulator.h Irrlicht/CMeshManipulator.h --- Irrlicht/CMeshManipulator.h 2005-08-20 22:17:50.000000000 +0200 +++ Irrlicht/CMeshManipulator.h 2005-09-22 19:04:22.000000000 +0200 @@ -70,6 +70,11 @@ //! See IUnknown::drop() for more information. virtual IMesh* createMeshWithTangents(IMesh* mesh) const; + //! Returns a mesh copied from the mesh passed in, as a mesh with meshBuffers + //! with 2 texture coords. + //! \param mesh: base mesh to copy data from + virtual IMesh* createMeshWith2TCoords( IMesh* mesh ) const; + //! Recalculates the bounding box for a meshbuffer virtual void recalculateBoundingBox(scene::IMeshBuffer* buffer) const; diff -Nauwr Irrlicht/include/IMeshManipulator.h Irrlicht/include/IMeshManipulator.h --- Irrlicht/include/IMeshManipulator.h 2005-08-20 22:17:44.000000000 +0200 +++ Irrlicht/include/IMeshManipulator.h 2005-08-29 20:00:14.000000000 +0200 @@ -84,6 +84,11 @@ See IUnknown::drop() for more information. */ virtual IMesh* createMeshWithTangents(IMesh* mesh) const = 0; + //! Returns a mesh copied from the mesh passed in, as a mesh with meshBuffers + //! with 2 texture coords. + //! \param mesh: base mesh to copy data from + virtual IMesh* createMeshWith2TCoords( IMesh* mesh ) const = 0; + //! Recalculates the bounding box for a meshbuffer virtual void recalculateBoundingBox(scene::IMeshBuffer* buffer) const = 0;