You need to sign in or sign up before continuing.
Commit 54340781 authored by hybrid's avatar hybrid

Added another parameter for the new planar mapping operator

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2189 dfc29bdd-3216-0410-991c-e03cc46cb475
parent b462a3e9
......@@ -132,8 +132,9 @@ namespace scene
\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::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis) const =0;
virtual void makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) 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
......
......@@ -444,7 +444,7 @@ 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
void CMeshManipulator::makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) const
{
u32 idxcnt = buffer->getIndexCount();
u16* idx = buffer->getIndices();
......@@ -456,24 +456,24 @@ void CMeshManipulator::makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32
{
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;
buffer->getTCoords(idx[i+o]).X = 0.5f+(buffer->getPosition(idx[i+o]).Z + offset.Z) * resolutionS;
buffer->getTCoords(idx[i+o]).Y = 0.5f-(buffer->getPosition(idx[i+o]).Y + offset.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;
buffer->getTCoords(idx[i+o]).X = 0.5f+(buffer->getPosition(idx[i+o]).X + offset.X) * resolutionS;
buffer->getTCoords(idx[i+o]).Y = 1.f-(buffer->getPosition(idx[i+o]).Z + offset.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;
buffer->getTCoords(idx[i+o]).X = 0.5f+(buffer->getPosition(idx[i+o]).X + offset.X) * resolutionS;
buffer->getTCoords(idx[i+o]).Y = 0.5f-(buffer->getPosition(idx[i+o]).Y + offset.Y) * resolutionT;
}
}
}
......
......@@ -89,7 +89,7 @@ public:
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;
void makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) 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;
......
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