Draw mesh normals
-
- Posts: 69
- Joined: Sun Oct 12, 2003 3:42 pm
- Location: Germany
Draw mesh normals
Is there an easy way to display a mesh´s normals? I have problems loading a Blender .obj file. The lighting is totally messed up, so I assumed the normals are not right. Thanks
Sure there is. Write a function to do it.
Code: Select all
void IMeshBuffer_drawNormals(scene::IMeshBuffer* mb, video::IVideoDriver* driver, video::SColor color)
{
if (mb->getVertexType() == video::EVT_STANDARD)
{
video::S3DVertex* v = (video::S3DVertex*)mb->getVertices();
s32 i;
for (i = 0; i < mb->getVertexCount(); ++i, ++v)
{
driver->draw3DLine(v->Pos, v->Pos + v->Normal, color);
}
}
}
// call it like this
// IAnimatedMeshSceneNode* node = /*...*/
// IMesh* mesh = /* the nodes mesh */
driver->setTransform(video::ETS_WORLD, node->getAbsoluteTransformation());
s32 b;
for (b = 0; b < mesh->getMeshBufferCount(); ++b)
{
if (node->isVisible())
IMeshBuffer_drawNormals( mesh->getMeshBuffer(b), driver, video::SColor(255, 255, 0, 0) );
}
Last edited by vitek on Sat Mar 25, 2006 6:36 pm, edited 1 time in total.
-
- Posts: 69
- Joined: Sun Oct 12, 2003 3:42 pm
- Location: Germany