Draw mesh normals

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Isometric God
Posts: 69
Joined: Sun Oct 12, 2003 3:42 pm
Location: Germany

Draw mesh normals

Post by Isometric God »

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
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

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.
Isometric God
Posts: 69
Joined: Sun Oct 12, 2003 3:42 pm
Location: Germany

Post by Isometric God »

arghs :shock:
but thanks :)
especially you vitek, you helped me many times 8)
Post Reply