Code: Select all
void CGame::DrawNormals(const scene::ISceneNode* parent)
{
scene::ISceneManager* smgr = g_Device->getSceneManager();
video::IVideoDriver* driver = g_Device->getVideoDriver();
if (parent == NULL)
parent = smgr->getRootSceneNode();
core::list<scene::ISceneNode*>::Iterator it;
video::SMaterial mat;
mat.Lighting = false;
driver->setMaterial(mat);
for (it = parent->getChildren().begin(); it != parent->getChildren().end(); ++it)
{
scene::IAnimatedMeshSceneNode* node = (scene::IAnimatedMeshSceneNode*)*it;
if (!node->isVisible())
continue; // no recursion
scene::IMesh* mesh = node->getMesh();
if (mesh)
{
driver->setTransform(video::ETS_WORLD, node->getAbsoluteTransformation());
for (s32 b = 0; b < mesh->getMeshBufferCount(); ++b)
{
scene::IMeshBuffer* mb = mesh->getMeshBuffer(b);
if (mb->getVertexType() == video::EVT_STANDARD)
{
video::S3DVertex* v = (video::S3DVertex*)mb->getVertices();
for (s32 i = 0; i < mb->getVertexCount(); ++i, ++v)
{
driver->draw3DLine(v->Pos, v->Pos + v->Normal, 0xFF0000FF);
}
}
}
}
DrawNormals(*it); // recursive call
}
}