Added support for automatic scaling of text to screen coords. Optimized

the text implementation to provide better speed, especially by using the
alignement to screen option.

Deprecated the Text::setFontSize(,) method, which is now being replaced
by setFontResolution(,)

Fixed typos in Texture*.cpp.

Removed old deprecated methods from osg headers.
This commit is contained in:
Robert Osfield
2003-04-30 11:40:17 +00:00
parent 821313d102
commit 0ab467483f
15 changed files with 366 additions and 225 deletions

View File

@@ -38,13 +38,13 @@ bool Text_readLocalData(osg::Object &obj, osgDB::Input &fr)
}
if (fr[0].matchWord("fontSize"))
if (fr[0].matchWord("fontResolution") || fr[0].matchWord("fontSize"))
{
unsigned int width;
unsigned int height;
if (fr[1].getUInt(width) && fr[2].getUInt(height))
{
text.setFontSize(width,height);
text.setFontResolution(width,height);
fr += 3;
itAdvanced = true;
}
@@ -127,6 +127,38 @@ bool Text_readLocalData(osg::Object &obj, osgDB::Input &fr)
}
}
if (fr.matchSequence("scale %f"))
{
float scale;
fr[1].getFloat(scale);
text.setScale(scale);
fr += 2;
itAdvanced = true;
}
if (fr.matchSequence("autoUpdateEyeMovementTolerance %f"))
{
float scale;
fr[1].getFloat(scale);
text.setAutoUpdateEyeMovementTolerance(scale);
fr += 2;
itAdvanced = true;
}
if (fr.matchSequence("autoRotateToScreen TRUE"))
{
text.setAutoRotateToScreen(true);
fr += 2;
itAdvanced = true;
}
if (fr.matchSequence("autoScaleToScreen TRUE"))
{
text.setAutoScaleToScreen(true);
fr += 2;
itAdvanced = true;
}
if (fr.matchSequence("layout %w"))
{
std::string str = fr[1].getStr();
@@ -226,7 +258,7 @@ bool Text_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
}
// font resolution
fw.indent() << "fontSize " << text.getFontWidth() << " " << text.getFontHeight() << std::endl;
fw.indent() << "fontResolution " << text.getFontWidth() << " " << text.getFontHeight() << std::endl;
// charater size.
fw.indent() << "characterSize " << text.getCharacterHeight() << " " << text.getCharacterAspectRatio() << std::endl;
@@ -264,21 +296,30 @@ bool Text_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
};
// axis alignment
fw.indent() << "axisAlignment ";
switch(text.getAxisAlignment())
{
case osgText::Text::XY_PLANE: fw << "XY_PLANE" << std::endl; break;
case osgText::Text::XZ_PLANE: fw << "XZ_PLANE" << std::endl; break;
case osgText::Text::YZ_PLANE: fw << "YZ_PLANE" << std::endl; break;
case osgText::Text::SCREEN: fw << "SCREEN" << std::endl; break;
};
if (!text.getRotation().zeroRotation())
{
fw.indent() << "rotation " << text.getRotation() << std::endl;
}
if (text.getScale()!=1.0f)
{
fw.indent() << "scale " << text.getScale() << std::endl;
}
if (text.getAutoUpdateEyeMovementTolerance()!=0.0f)
{
fw.indent() << "autoUpdateEyeMovementTolerance " << text.getAutoUpdateEyeMovementTolerance() << std::endl;
}
if (text.getAutoRotateToScreen())
{
fw.indent() << "autoRotateToScreen TRUE"<< std::endl;
}
if (text.getAutoScaleToScreen())
{
fw.indent() << "autoScaleToScreen TRUE"<< std::endl;
}
// layout
fw.indent() << "layout ";