From Terry Welsh, "Okay, here are the mods I wrote for drawing a filled bounding box

behind osgText::Text.  I made it so the box would get drawn using
whichever BackdropImplementation was selected.  However, I did not
implement STENCIL_BUFFER.  In that case it defaults to drawing the
bounding box using POLYGON_OFFSET instead.

Also made it so the BOUNDINGBOX and FILLEDBOUNDINGBOX are drawn with a
settable color and margin size.

While I was at it I tightened up the values applied with DEPTH_RANGE
and POLYGON_OFFSET, not just for drawing the bounding box but also for
drawing backdrop text (these values must be coupled since the bounding
box has to be drawn deeper in Z than the backdrop text).  The values
in use before seemed like overkill and I was seeing some z-clipping
with my background scenery in the case of DEPTH_RANGE.  If there was a
good reason for the large values please let me know...."
This commit is contained in:
Robert Osfield
2009-07-24 14:59:51 +00:00
parent 773ae51a45
commit 31a947fda6
4 changed files with 116 additions and 7 deletions

View File

@@ -44,6 +44,8 @@ TextBase::TextBase():
_autoRotateToScreen(false),
_layout(LEFT_TO_RIGHT),
_drawMode(TEXT),
_textBBMargin(0.0f),
_textBBColor(0.0, 0.0, 0.0, 0.5),
_kerningType(KERNING_DEFAULT),
_lineCount(0)
{
@@ -69,6 +71,8 @@ TextBase::TextBase(const TextBase& textBase,const osg::CopyOp& copyop):
_autoRotateToScreen(textBase._autoRotateToScreen),
_layout(textBase._layout),
_drawMode(textBase._drawMode),
_textBBMargin(textBase._textBBMargin),
_textBBColor(textBase._textBBColor),
_kerningType(textBase._kerningType),
_lineCount(textBase._lineCount)
{
@@ -225,6 +229,16 @@ void TextBase::setDrawMode(unsigned int mode)
}
void TextBase::setBoundingBoxMargin(float margin)
{
if (_textBBMargin == margin)
return;
_textBBMargin = margin;
computeGlyphRepresentation();
}
osg::BoundingBox TextBase::computeBound() const
{
osg::BoundingBox bbox;