Add method which draws the normals of a mesh buffer. Mainly for debug purposes.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4025 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2012-01-04 00:29:21 +00:00
parent ef473d9335
commit f1ec3dad93
3 changed files with 29 additions and 1 deletions

View File

@ -1015,9 +1015,16 @@ namespace video
video::SColor rightDownEdge = video::SColor(255,0,0,0)) =0;
//! Draws a mesh buffer
/** \param mb Buffer to draw; */
/** \param mb Buffer to draw */
virtual void drawMeshBuffer(const scene::IMeshBuffer* mb) =0;
//! Draws normals of a mesh buffer
/** \param mb Buffer to draw the normals of
\param length length scale factor of the normals
\param color Color the normals are rendered with
*/
virtual void drawMeshBufferNormals(const scene::IMeshBuffer* mb, f32 length=10.f, SColor color=0xffffffff) =0;
//! Sets the fog mode.
/** These are global values attached to each 3d object rendered,
which has the fog flag enabled in its material.

View File

@ -1520,6 +1520,24 @@ void CNullDriver::drawMeshBuffer(const scene::IMeshBuffer* mb)
}
//! Draws the normals of a mesh buffer
void CNullDriver::drawMeshBufferNormals(const scene::IMeshBuffer* mb, f32 length, SColor color)
{
const u32 count = mb->getVertexCount();
const bool normalize = mb->getMaterial().NormalizeNormals;
for (u32 i=0; i < count; ++i)
{
core::vector3df normalizedNormal = mb->getNormal(i);
if (normalize)
normalizedNormal.normalize();
const core::vector3df& pos = mb->getPosition(i);
draw3DLine(pos, pos + (normalizedNormal * length), color);
}
}
CNullDriver::SHWBufferLink *CNullDriver::getBufferLink(const scene::IMeshBuffer* mb)
{
if (!mb || !isHardwareBufferRecommend(mb))

View File

@ -372,6 +372,9 @@ namespace video
//! Draws a mesh buffer
virtual void drawMeshBuffer(const scene::IMeshBuffer* mb);
//! Draws the normals of a mesh buffer
virtual void drawMeshBufferNormals(const scene::IMeshBuffer* mb, f32 length=10.f, SColor color=0xffffffff);
protected:
struct SHWBufferLink
{