From Terry Welsh, .osg and .ive support for new Text boxes

This commit is contained in:
Robert Osfield 2009-07-28 06:00:03 +00:00
parent fcaec80dc9
commit 91f53369a3
3 changed files with 43 additions and 1 deletions

View File

@ -50,8 +50,9 @@
#define VERSION_0039 39
#define VERSION_0040 40
#define VERSION_0041 41
#define VERSION_0042 42
#define VERSION VERSION_0041
#define VERSION VERSION_0042
/* The BYTE_SEX tag is used to check the endian
of the IVE file being read in. The IVE format

View File

@ -75,6 +75,12 @@ void Text::write(DataOutputStream* out){
out->writeVec4(getColor());
out->writeUInt(getDrawMode());
if ( out->getVersion() >= VERSION_0041 )
{
out->writeFloat(getBoundingBoxMargin());
out->writeVec4(getBoundingBoxColor());
}
if ( out->getVersion() >= VERSION_0028 )
{
out->writeUInt(getBackdropType());
@ -189,6 +195,12 @@ void Text::read(DataInputStream* in){
setColor(in->readVec4());
setDrawMode(in->readUInt());
if ( in->getVersion() >= VERSION_0041 )
{
setBoundingBoxMargin(in->readFloat());
setBoundingBoxColor(in->readVec4());
}
if ( in->getVersion() >= VERSION_0028 )
{
setBackdropType((osgText::Text::BackdropType) in->readUInt());

View File

@ -192,6 +192,29 @@ bool TextBase_readLocalData(osg::Object &obj, osgDB::Input &fr)
}
}
// bounding box margin
if (fr[0].matchWord("BoundingBoxMargin"))
{
float margin;
if (fr[1].getFloat(margin)) {
text.setBoundingBoxMargin(margin);
fr += 2;
itAdvanced = true;
}
}
// bounding box color
if (fr[0].matchWord("BoundingBoxColor"))
{
osg::Vec4 c;
if (fr[1].getFloat(c.x()) && fr[2].getFloat(c.y()) && fr[3].getFloat(c.z()) && fr[4].getFloat(c.w()))
{
text.setBoundingBoxColor(c);
fr += 5;
itAdvanced = true;
}
}
// text
if (fr.matchSequence("text %s") && fr[1].getStr()) {
text.setText(std::string(fr[1].getStr()));
@ -346,6 +369,12 @@ bool TextBase_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
// draw mode
fw.indent() << "drawMode " << text.getDrawMode() << std::endl;
// bounding box margin
fw.indent() << "BoundingBoxMargin " << text.getBoundingBoxMargin() << std::endl;
// bounding box color
osg::Vec4 bbc = text.getBoundingBoxColor();
fw.indent() << "BoundingBoxColor " << bbc.x() << " " << bbc.y() << " " << bbc.z() << " " << bbc.w() << std::endl;
// text
const osgText::String& textstring = text.getText();