Removed debug meshes rendering methods in irr_driver (these methods are now in abstract_renderer class)

This commit is contained in:
Elderme 2015-09-07 22:31:34 +02:00
parent 417bfb89e9
commit 44adc14cff
4 changed files with 17 additions and 203 deletions

View File

@ -23,12 +23,13 @@
using namespace irr;
#ifdef DEBUG
void AbstractRenderer::drawDebugMeshes()
void AbstractRenderer::drawDebugMeshes() const
{
for (unsigned int n=0; n<m_debug_meshes.size(); n++)
std::vector<irr::scene::IAnimatedMeshSceneNode*> debug_meshes = irr_driver->getDebugMeshes();
for (unsigned int n=0; n<debug_meshes.size(); n++)
{
scene::IMesh* mesh = m_debug_meshes[n]->getMesh();
scene::IMesh* mesh = debug_meshes[n]->getMesh();
scene::ISkinnedMesh* smesh = static_cast<scene::ISkinnedMesh*>(mesh);
const core::array< scene::ISkinnedMesh::SJoint * >& joints =
smesh->getAllJoints();
@ -50,9 +51,9 @@ void AbstractRenderer::drawDebugMeshes()
irr_driver->getVideoDriver()->setMaterial(material);
irr_driver->getVideoDriver()->setTransform(video::ETS_WORLD, core::IdentityMatrix);
for (unsigned int n=0; n<m_debug_meshes.size(); n++)
for (unsigned int n=0; n<debug_meshes.size(); n++)
{
scene::IMesh* mesh = m_debug_meshes[n]->getMesh();
scene::IMesh* mesh = debug_meshes[n]->getMesh();
scene::ISkinnedMesh* smesh = static_cast<scene::ISkinnedMesh*>(mesh);
@ -61,7 +62,7 @@ void AbstractRenderer::drawDebugMeshes()
for (unsigned int j=0; j<joints.size(); j++)
{
scene::IMesh* mesh = m_debug_meshes[n]->getMesh();
scene::IMesh* mesh = debug_meshes[n]->getMesh();
scene::ISkinnedMesh* smesh = static_cast<scene::ISkinnedMesh*>(mesh);
drawJoint(true, false, joints[j], smesh, j);
@ -80,7 +81,7 @@ void AbstractRenderer::drawDebugMeshes()
*/
void AbstractRenderer::drawJoint(bool drawline, bool drawname,
scene::ISkinnedMesh::SJoint* joint,
scene::ISkinnedMesh* mesh, int id)
scene::ISkinnedMesh* mesh, int id) const
{
scene::ISkinnedMesh::SJoint* parent = NULL;
const core::array< scene::ISkinnedMesh::SJoint * >& joints
@ -204,5 +205,4 @@ void AbstractRenderer::drawJoint(bool drawline, bool drawname,
}
} //drawJoint
#endif //DEBUG

View File

@ -25,19 +25,17 @@ class AbstractRenderer
{
protected:
/** Used to visualise skeletons. */
std::vector<irr::scene::IAnimatedMeshSceneNode*> m_debug_meshes;
#ifdef DEBUG
void drawDebugMeshes();
void drawDebugMeshes() const;
void drawJoint(bool drawline, bool drawname,
irr::scene::ISkinnedMesh::SJoint* joint,
irr::scene::ISkinnedMesh* mesh, int id);
irr::scene::ISkinnedMesh* mesh, int id) const;
#endif
public:
virtual ~AbstractRenderer(){}
virtual void render(float dt) = 0;
};

View File

@ -1860,189 +1860,6 @@ void IrrDriver::displayFPS()
font->draw( fpsString.c_str(), position, fpsColor, false );
} // updateFPS
// ----------------------------------------------------------------------------
#ifdef DEBUG
void IrrDriver::drawDebugMeshes()
{
for (unsigned int n=0; n<m_debug_meshes.size(); n++)
{
scene::IMesh* mesh = m_debug_meshes[n]->getMesh();
scene::ISkinnedMesh* smesh = static_cast<scene::ISkinnedMesh*>(mesh);
const core::array< scene::ISkinnedMesh::SJoint * >& joints =
smesh->getAllJoints();
for (unsigned int j=0; j<joints.size(); j++)
{
drawJoint( false, true, joints[j], smesh, j);
}
}
video::SColor color(255,255,255,255);
video::SMaterial material;
material.Thickness = 2;
material.AmbientColor = color;
material.DiffuseColor = color;
material.EmissiveColor= color;
material.BackfaceCulling = false;
material.setFlag(video::EMF_LIGHTING, false);
getVideoDriver()->setMaterial(material);
getVideoDriver()->setTransform(video::ETS_WORLD, core::IdentityMatrix);
for (unsigned int n=0; n<m_debug_meshes.size(); n++)
{
scene::IMesh* mesh = m_debug_meshes[n]->getMesh();
scene::ISkinnedMesh* smesh = static_cast<scene::ISkinnedMesh*>(mesh);
const core::array< scene::ISkinnedMesh::SJoint * >& joints =
smesh->getAllJoints();
for (unsigned int j=0; j<joints.size(); j++)
{
scene::IMesh* mesh = m_debug_meshes[n]->getMesh();
scene::ISkinnedMesh* smesh = static_cast<scene::ISkinnedMesh*>(mesh);
drawJoint(true, false, joints[j], smesh, j);
}
}
} // drawDebugMeshes
// ----------------------------------------------------------------------------
/** Draws a joing for debugging skeletons.
* \param drawline If true draw a line to the parent.
* \param drawname If true draw the name of the joint.
* \param joint The joint to draw.
* \param mesh The mesh whose skeleton is drawn (only used to get
* all joints to find the parent).
* \param id Index, which (%4) determines the color to use.
*/
void IrrDriver::drawJoint(bool drawline, bool drawname,
scene::ISkinnedMesh::SJoint* joint,
scene::ISkinnedMesh* mesh, int id)
{
scene::ISkinnedMesh::SJoint* parent = NULL;
const core::array< scene::ISkinnedMesh::SJoint * >& joints
= mesh->getAllJoints();
for (unsigned int j=0; j<joints.size(); j++)
{
if (joints[j]->Children.linear_search(joint) != -1)
{
parent = joints[j];
break;
}
}
core::vector3df jointpos = joint->GlobalMatrix.getTranslation();
video::SColor color(255, 255,255,255);
if (parent == NULL) color = video::SColor(255,0,255,0);
switch (id % 4)
{
case 0:
color = video::SColor(255,255,0,255);
break;
case 1:
color = video::SColor(255,255,0,0);
break;
case 2:
color = video::SColor(255,0,0,255);
break;
case 3:
color = video::SColor(255,0,255,255);
break;
}
if (parent)
{
core::vector3df parentpos = parent->GlobalMatrix.getTranslation();
jointpos = joint->GlobalMatrix.getTranslation();
if (drawline)
{
irr_driver->getVideoDriver()->draw3DLine(jointpos,
parentpos,
color);
}
}
else
{
/*
if (drawline)
{
irr_driver->getVideoDriver()->draw3DLine(jointpos,
core::vector3df(0,0,0),
color);
}
*/
}
if (joint->Children.size() == 0)
{
switch ((id + 1) % 4)
{
case 0:
color = video::SColor(255,255,0,255);
break;
case 1:
color = video::SColor(255,255,0,0);
break;
case 2:
color = video::SColor(255,0,0,255);
break;
case 3:
color = video::SColor(255,0,255,255);
break;
}
// This code doesn't quite work. 0.25 is used so that the bone is not
// way too long (not sure why I need to manually size it down)
// and the rotation of the bone is often rather off
core::vector3df v(0.0f, 0.25f, 0.0f);
//joint->GlobalMatrix.rotateVect(v);
joint->LocalMatrix.rotateVect(v);
v *= joint->LocalMatrix.getScale();
irr_driver->getVideoDriver()->draw3DLine(jointpos,
jointpos + v,
color);
}
switch ((id + 1) % 4)
{
case 0:
color = video::SColor(255,255,0,255);
break;
case 1:
color = video::SColor(255,255,0,0);
break;
case 2:
color = video::SColor(255,0,0,255);
break;
case 3:
color = video::SColor(255,0,255,255);
break;
}
if (drawname)
{
irr_driver->getVideoDriver()->setTransform(video::ETS_WORLD,
core::IdentityMatrix);
core::vector2di textpos =
irr_driver->getSceneManager()->getSceneCollisionManager()
->getScreenCoordinatesFrom3DPosition(jointpos);
GUIEngine::getSmallFont()->draw( stringw(joint->Name.c_str()),
core::rect<s32>(textpos,
core::dimension2d<s32>(500,50)),
color, false, false );
}
}
#endif
// ----------------------------------------------------------------------------
/** Requess a screenshot from irrlicht, and save it in a file.
*/

View File

@ -313,11 +313,6 @@ private:
#ifdef DEBUG
/** Used to visualise skeletons. */
std::vector<irr::scene::IAnimatedMeshSceneNode*> m_debug_meshes;
void drawDebugMeshes();
void drawJoint(bool drawline, bool drawname,
irr::scene::ISkinnedMesh::SJoint* joint,
irr::scene::ISkinnedMesh* mesh, int id);
#endif
void renderSolidFirstPass();
@ -743,6 +738,10 @@ public:
m_ssao_sigma = v;
}
#ifdef DEBUG
std::vector<scene::IAnimatedMeshSceneNode*> getDebugMeshes()
{
return m_debug_meshes;
}
/** Removes debug meshes. */
void clearDebugMesh() { m_debug_meshes.clear(); }
// ------------------------------------------------------------------------