Moved Text3D across to using Style for character thickness.

Quitened down debug messages in 3D text geometry creation.
Improved the Text3D implementation of the new 3D text geometry.
This commit is contained in:
Robert Osfield 2010-09-27 17:11:12 +00:00
parent f8b44c3b33
commit 5af4884558
4 changed files with 19 additions and 17 deletions

View File

@ -165,8 +165,6 @@ protected:
osg::ref_ptr<Font> _font;
osg::ref_ptr<Style> _style;
float _characterDepth;
RenderMode _renderMode;
osg::ref_ptr<osg::StateSet> _wallStateSet;

View File

@ -511,12 +511,12 @@ GlyphGeometry* Glyph3D::getGlyphGeometry(const Style* style)
GlyphGeometry* glyphGeometry = itr->get();
if (glyphGeometry->match(style))
{
OSG_NOTICE<<"Glyph3D::getGlyphGeometry(Style* style) found matching GlyphGeometry."<<std::endl;
OSG_INFO<<"Glyph3D::getGlyphGeometry(Style* style) found matching GlyphGeometry."<<std::endl;
return glyphGeometry;
}
}
OSG_NOTICE<<"Glyph3D::getGlyphGeometry(Style* style) could not find matching GlyphGeometry, creating a new one."<<std::endl;
OSG_INFO<<"Glyph3D::getGlyphGeometry(Style* style) could not find matching GlyphGeometry, creating a new one."<<std::endl;
osg::ref_ptr<GlyphGeometry> glyphGeometry = new GlyphGeometry();
glyphGeometry->setup(this, style);
@ -543,22 +543,22 @@ void GlyphGeometry::setup(const Glyph3D* glyph, const Style* style)
if (!style)
{
OSG_NOTICE<<"GlyphGeometry::setup(const Glyph* glyph, NULL) creating default glyph geometry."<<std::endl;
OSG_INFO<<"GlyphGeometry::setup(const Glyph* glyph, NULL) creating default glyph geometry."<<std::endl;
float width = glyph->getFont()->getFontDepth();
float width = 0.1f;
_geometry = osgText::computeTextGeometry(glyph, width);
}
else
{
OSG_NOTICE<<"GlyphGeometry::setup(const Glyph* glyph, NULL) create glyph geometry with custom Style."<<std::endl;
OSG_INFO<<"GlyphGeometry::setup(const Glyph* glyph, NULL) create glyph geometry with custom Style."<<std::endl;
// record the style
_style = dynamic_cast<Style*>(style->clone(osg::CopyOp::DEEP_COPY_ALL));
const Bevel* bevel = style ? style->getBevel() : 0;
bool outline = style ? style->getOutlineRatio()>0.0f : false;
float width = glyph->getFont()->getFontDepth();//style->getThicknessRatio();
float width = style->getThicknessRatio();
if (bevel)
{
@ -577,7 +577,7 @@ void GlyphGeometry::setup(const Glyph3D* glyph, const Style* style)
if (!_geometry)
{
OSG_NOTICE<<"Warning: GlyphGeometry::setup(const Glyph* glyph, const Style* style) failed."<<std::endl;
OSG_INFO<<"Warning: GlyphGeometry::setup(const Glyph* glyph, const Style* style) failed."<<std::endl;
return;
}

View File

@ -117,7 +117,7 @@ public:
}
else
{
OSG_NOTICE<<" computeBisectorNormal(a=["<<a<<"], b=["<<b<<"], c=["<<c<<"], d=["<<d<<"]), nx="<<nx<<", ny="<<ny<<", denominator="<<denominator<<" need to swap!!!"<<std::endl;
OSG_INFO<<" computeBisectorNormal(a=["<<a<<"], b=["<<b<<"], c=["<<c<<"], d=["<<d<<"]), nx="<<nx<<", ny="<<ny<<", denominator="<<denominator<<" need to swap!!!"<<std::endl;
return osg::Vec3(-nx,-ny,0.0f);
}
}
@ -660,7 +660,7 @@ osg::Geometry* computeTextGeometry(osg::Geometry* glyphGeometry, const osgText::
osg::Vec3Array* orig_vertices = dynamic_cast<osg::Vec3Array*>(glyphGeometry->getVertexArray());
if (!orig_vertices)
{
OSG_NOTICE<<"computeTextGeometry(..): No vertices on glyphGeometry."<<std::endl;
OSG_INFO<<"computeTextGeometry(..): No vertices on glyphGeometry."<<std::endl;
return 0;
}

View File

@ -21,7 +21,6 @@ namespace osgText
Text3D::Text3D():
_font(0),
_style(0),
_characterDepth(1),
_renderMode(PER_GLYPH)
{
}
@ -30,7 +29,6 @@ Text3D::Text3D(const Text3D & text3D, const osg::CopyOp & copyop):
osgText::TextBase(text3D, copyop),
_font(text3D._font),
_style(text3D._style),
_characterDepth(text3D._characterDepth),
_renderMode(text3D._renderMode)
{
computeGlyphRepresentation();
@ -38,12 +36,15 @@ Text3D::Text3D(const Text3D & text3D, const osg::CopyOp & copyop):
float Text3D::getCharacterDepth() const
{
return _characterDepth;
if (!_style) return _characterHeight*0.1f;
else return _characterHeight * _style->getThicknessRatio();
}
void Text3D::setCharacterDepth(float characterDepth)
{
_characterDepth = characterDepth;
if (!_style) _style = new Style;
_style->setThicknessRatio(characterDepth / _characterHeight);
computeGlyphRepresentation();
}
@ -462,7 +463,9 @@ void Text3D::computeGlyphRepresentation()
++lineNumber;
}
_textBB.expandBy(0.0f,0.0f,-1);
float thickness = _style.valid() ? _style->getThicknessRatio() : 0.1f;
_textBB.zMin() = -thickness;
TextBase::computePositions();
}
@ -516,7 +519,8 @@ void Text3D::computePositions(unsigned int contextID) const
float scale = _font->getScale();
osg::Vec3 scaleVec(scale * _characterHeight, scale * _characterHeight / _characterAspectRatio, _characterDepth);
osg::Vec3 scaleVec(scale * _characterHeight, scale * _characterHeight / _characterAspectRatio, scale * _characterHeight);
matrix.makeTranslate(-_offset);
matrix.postMultScale(scaleVec);
matrix.postMultRotate(_rotation);