Debug Draw Text in 3D


#1

I found that the existing DebugDraw-class does not have any method which can draw text. However, the underlaying DrawHelper seems to offer that functionality. Can I somehow access it without implementing the boilerplate-code DebugDraw has again? Or could the DebugDraw-class be extended?


#2

I’d be happy to accept a PR extending debug draw with the ability to draw text. Other than that there is currently no other way to do it. Eventually I’ll be adding a specialized component for text drawing, along with support for distance fields for nicer font mi/mag-nification.


#3

I tried to add the method to debug draw class, however it didn’t worked for me. The text was not rendered on the screen. I followed this steps:

void DebugDraw::drawText(const Vector3& position, String& text, HFont& font, UINT32 size)
{
mDrawHelper->text(position, text, font, size);
}

added the method, and it definition to the .h

And then used it like this:

bs::DebugDraw::instance().setColor(bs::Color::Red);

bs::HFont fontGothicDefault = bs::gBuiltinResources().getDefaultFont();

for (HWaypoint from : allWaypoints())
{
bs::DebugDraw::instance().drawText(from->SO()->getTransform().pos(), bs::String(“THERE IS A WAYPOINT”),
fontGothicDefault, 8);
for (HWaypoint to : from->allPaths())
{
bs::DebugDraw::instance().drawLine(from->SO()->getTransform().pos(),
to->SO()->getTransform().pos());
}
}

The lines between the waypoints are showed correctly, but the text is not there.