Text3D character/glyph size fixed
This commit is contained in:
parent
7e0a20b4ba
commit
b0ef9b0c42
@ -238,10 +238,22 @@ int main(int argc, char** argv)
|
|||||||
geode->addDrawable( osg::createTexturedQuadGeometry(osg::Vec3(0.0f,characterSize*thickness,0.0f),osg::Vec3(characterSize,0.0,0.0),osg::Vec3(0.0f,0.0,characterSize), 0.0, 0.0, 1.0, 1.0) );
|
geode->addDrawable( osg::createTexturedQuadGeometry(osg::Vec3(0.0f,characterSize*thickness,0.0f),osg::Vec3(characterSize,0.0,0.0),osg::Vec3(0.0f,0.0,characterSize), 0.0, 0.0, 1.0, 1.0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arguments.read("--add-axes"))
|
||||||
|
group->addChild(osgDB::readNodeFile("axes.osgt"));
|
||||||
|
|
||||||
|
std::string mode;
|
||||||
|
if (arguments.read("--character-size-mode", mode))
|
||||||
|
{
|
||||||
|
if (mode == "screen_coords")
|
||||||
|
{
|
||||||
|
text3D->setCharacterSizeMode(osgText::TextBase::SCREEN_COORDS);
|
||||||
|
text3D->setCharacterSize(1080/4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
viewer.addEventHandler(new Text3DAttributeHandler(text3D));
|
viewer.addEventHandler(new Text3DAttributeHandler(text3D));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
viewer.setSceneData(group);
|
viewer.setSceneData(group);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -325,12 +325,12 @@ protected:
|
|||||||
osg::Vec4 _textBBColor;
|
osg::Vec4 _textBBColor;
|
||||||
KerningType _kerningType;
|
KerningType _kerningType;
|
||||||
unsigned int _lineCount;
|
unsigned int _lineCount;
|
||||||
|
bool _glyphNormalized;
|
||||||
|
|
||||||
osg::Vec3 _offset;
|
osg::Vec3 _offset;
|
||||||
osg::Vec3 _normal;
|
osg::Vec3 _normal;
|
||||||
osg::BoundingBox _textBB;
|
osg::BoundingBox _textBB;
|
||||||
|
|
||||||
|
|
||||||
mutable osg::Matrix _matrix;
|
mutable osg::Matrix _matrix;
|
||||||
|
|
||||||
Primitives _decorationPrimitives;
|
Primitives _decorationPrimitives;
|
||||||
|
@ -21,12 +21,14 @@ namespace osgText
|
|||||||
Text3D::Text3D():
|
Text3D::Text3D():
|
||||||
_renderMode(PER_GLYPH)
|
_renderMode(PER_GLYPH)
|
||||||
{
|
{
|
||||||
|
_glyphNormalized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Text3D::Text3D(const Text3D & text3D, const osg::CopyOp & copyop):
|
Text3D::Text3D(const Text3D & text3D, const osg::CopyOp & copyop):
|
||||||
osgText::TextBase(text3D, copyop),
|
osgText::TextBase(text3D, copyop),
|
||||||
_renderMode(text3D._renderMode)
|
_renderMode(text3D._renderMode)
|
||||||
{
|
{
|
||||||
|
_glyphNormalized = text3D._glyphNormalized;
|
||||||
computeGlyphRepresentation();
|
computeGlyphRepresentation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,8 @@ TextBase::TextBase():
|
|||||||
_textBBMargin(0.0f),
|
_textBBMargin(0.0f),
|
||||||
_textBBColor(0.0, 0.0, 0.0, 0.5),
|
_textBBColor(0.0, 0.0, 0.0, 0.5),
|
||||||
_kerningType(KERNING_DEFAULT),
|
_kerningType(KERNING_DEFAULT),
|
||||||
_lineCount(0)
|
_lineCount(0),
|
||||||
|
_glyphNormalized(false)
|
||||||
{
|
{
|
||||||
setStateSet(Font::getDefaultFont()->getStateSet());
|
setStateSet(Font::getDefaultFont()->getStateSet());
|
||||||
setUseDisplayList(false);
|
setUseDisplayList(false);
|
||||||
@ -78,7 +79,8 @@ TextBase::TextBase(const TextBase& textBase,const osg::CopyOp& copyop):
|
|||||||
_textBBMargin(textBase._textBBMargin),
|
_textBBMargin(textBase._textBBMargin),
|
||||||
_textBBColor(textBase._textBBColor),
|
_textBBColor(textBase._textBBColor),
|
||||||
_kerningType(textBase._kerningType),
|
_kerningType(textBase._kerningType),
|
||||||
_lineCount(textBase._lineCount)
|
_lineCount(textBase._lineCount),
|
||||||
|
_glyphNormalized(textBase._glyphNormalized)
|
||||||
{
|
{
|
||||||
initArraysAndBuffers();
|
initArraysAndBuffers();
|
||||||
}
|
}
|
||||||
@ -537,6 +539,12 @@ bool TextBase::computeMatrix(osg::Matrix& matrix, osg::State* state) const
|
|||||||
if (pixelSizeHori == 0.0f)
|
if (pixelSizeHori == 0.0f)
|
||||||
pixelSizeHori= 1.0f;
|
pixelSizeHori= 1.0f;
|
||||||
|
|
||||||
|
if (_glyphNormalized)
|
||||||
|
{
|
||||||
|
osg::Vec3 scaleVec(_characterHeight/getCharacterAspectRatio(), _characterHeight, _characterHeight);
|
||||||
|
matrix.postMultScale(scaleVec);
|
||||||
|
}
|
||||||
|
|
||||||
if (_characterSizeMode==SCREEN_COORDS)
|
if (_characterSizeMode==SCREEN_COORDS)
|
||||||
{
|
{
|
||||||
float scale_font_vert=_characterHeight/pixelSizeVert;
|
float scale_font_vert=_characterHeight/pixelSizeVert;
|
||||||
@ -544,12 +552,12 @@ bool TextBase::computeMatrix(osg::Matrix& matrix, osg::State* state) const
|
|||||||
|
|
||||||
if (P10<0)
|
if (P10<0)
|
||||||
scale_font_vert=-scale_font_vert;
|
scale_font_vert=-scale_font_vert;
|
||||||
matrix.postMultScale(osg::Vec3f(scale_font_hori, scale_font_vert,1.0f));
|
matrix.postMultScale(osg::Vec3f(scale_font_hori, scale_font_vert, scale_font_hori));
|
||||||
}
|
}
|
||||||
else if (pixelSizeVert>getFontHeight())
|
else if (pixelSizeVert>getFontHeight())
|
||||||
{
|
{
|
||||||
float scale_font = getFontHeight()/pixelSizeVert;
|
float scale_font = getFontHeight()/pixelSizeVert;
|
||||||
matrix.postMultScale(osg::Vec3f(scale_font, scale_font,1.0f));
|
matrix.postMultScale(osg::Vec3f(scale_font, scale_font, scale_font));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -560,17 +568,29 @@ bool TextBase::computeMatrix(osg::Matrix& matrix, osg::State* state) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
matrix.postMultTranslate(_position);
|
matrix.postMultTranslate(_position);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!_rotation.zeroRotation())
|
else if (!_rotation.zeroRotation())
|
||||||
{
|
{
|
||||||
matrix.makeRotate(_rotation);
|
matrix.makeTranslate(-_offset);
|
||||||
matrix.preMultTranslate(-_offset);
|
if (_glyphNormalized)
|
||||||
|
{
|
||||||
|
osg::Vec3 scaleVec(_characterHeight/getCharacterAspectRatio(), _characterHeight, _characterHeight);
|
||||||
|
matrix.postMultScale(scaleVec);
|
||||||
|
}
|
||||||
|
matrix.postMultRotate(_rotation);
|
||||||
matrix.postMultTranslate(_position);
|
matrix.postMultTranslate(_position);
|
||||||
// OSG_NOTICE<<"New Need to rotate "<<matrix<<std::endl;
|
// OSG_NOTICE<<"New Need to rotate "<<matrix<<std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
matrix.makeTranslate(_position-_offset);
|
matrix.makeTranslate(-_offset);
|
||||||
|
if (_glyphNormalized)
|
||||||
|
{
|
||||||
|
osg::Vec3 scaleVec(_characterHeight/getCharacterAspectRatio(), _characterHeight, _characterHeight);
|
||||||
|
matrix.postMultScale(scaleVec);
|
||||||
|
}
|
||||||
|
matrix.postMultTranslate(_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_matrix!=matrix)
|
if (_matrix!=matrix)
|
||||||
|
Loading…
Reference in New Issue
Block a user