Moved the IO support for the osgText and osgParticle libraries into seperate

plugin libraries.
This commit is contained in:
Robert Osfield
2002-08-20 11:27:08 +00:00
parent 05573d553d
commit df9a899d9e
34 changed files with 498 additions and 1637 deletions

View File

@@ -1,205 +0,0 @@
#include <osgText/Font>
#include <osgText/Font>
#include <iostream>
#include <string>
#include <osg/Vec3>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
/////////////////////////////////////////////////////////////////////////////
// class Font
/////////////////////////////////////////////////////////////////////////////
bool Font_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy Font_Proxy
(
0,
"Font",
"Object Font",
0,
Font_writeLocalData
);
bool Font_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgText::Font &myobj = static_cast<const osgText::Font &>(obj);
fw.indent() << "parameters ";
fw << myobj.getPointSize() << " " << myobj.getTextureSize() << " ";
fw << "\"" << myobj.getFontName() << "\"" << std::endl;
return true;
}
/////////////////////////////////////////////////////////////////////////////
// class BitmapFont
/////////////////////////////////////////////////////////////////////////////
bool BitmapFont_readLocalData(osg::Object &obj, osgDB::Input &fr);
osgDB::RegisterDotOsgWrapperProxy BitmapFont_Proxy
(
osgNew osgText::BitmapFont,
"BitmapFont",
"Object Font RasterFont BitmapFont",
BitmapFont_readLocalData,
0
);
bool BitmapFont_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgText::BitmapFont &myobj = static_cast<osgText::BitmapFont &>(obj);
bool itAdvanced = false;
if (fr[0].matchWord("parameters")) {
int psize;
if (fr[1].getInt(psize) && fr[2].isInt() && fr[3].isString()) {
osgText::BitmapFont *temp = osgNew osgText::BitmapFont(std::string(fr[3].getStr()), psize);
temp->copyAndInvalidate(myobj);
fr += 4;
itAdvanced = true;
}
}
return itAdvanced;
}
/////////////////////////////////////////////////////////////////////////////
// class PixmapFont
/////////////////////////////////////////////////////////////////////////////
bool PixmapFont_readLocalData(osg::Object &obj, osgDB::Input &fr);
osgDB::RegisterDotOsgWrapperProxy PixmapFont_Proxy
(
osgNew osgText::PixmapFont,
"PixmapFont",
"Object Font RasterFont PixmapFont",
PixmapFont_readLocalData,
0
);
bool PixmapFont_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgText::PixmapFont &myobj = static_cast<osgText::PixmapFont &>(obj);
bool itAdvanced = false;
if (fr[0].matchWord("parameters")) {
int psize;
if (fr[1].getInt(psize) && fr[2].isInt() && fr[3].isString()) {
osgText::PixmapFont *temp = osgNew osgText::PixmapFont(std::string(fr[3].getStr()), psize);
temp->copyAndInvalidate(myobj);
fr += 4;
itAdvanced = true;
}
}
return itAdvanced;
}
/////////////////////////////////////////////////////////////////////////////
// class TextureFont
/////////////////////////////////////////////////////////////////////////////
bool TextureFont_readLocalData(osg::Object &obj, osgDB::Input &fr);
osgDB::RegisterDotOsgWrapperProxy TextureFont_Proxy
(
osgNew osgText::TextureFont,
"TextureFont",
"Object Font RasterFont TextureFont",
TextureFont_readLocalData,
0
);
bool TextureFont_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgText::TextureFont &myobj = static_cast<osgText::TextureFont &>(obj);
bool itAdvanced = false;
if (fr[0].matchWord("parameters")) {
int psize, txsize;
if (fr[1].getInt(psize) && fr[2].getInt(txsize) && fr[3].isString()) {
osgText::TextureFont *temp = osgNew osgText::TextureFont(std::string(fr[3].getStr()), psize, txsize);
temp->copyAndInvalidate(myobj);
fr += 4;
itAdvanced = true;
}
}
return itAdvanced;
}
/////////////////////////////////////////////////////////////////////////////
// class OutlineFont
/////////////////////////////////////////////////////////////////////////////
bool OutlineFont_readLocalData(osg::Object &obj, osgDB::Input &fr);
osgDB::RegisterDotOsgWrapperProxy OutlineFont_Proxy
(
osgNew osgText::OutlineFont,
"OutlineFont",
"Object Font VectorFont OutlineFont",
OutlineFont_readLocalData,
0
);
bool OutlineFont_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgText::OutlineFont &myobj = static_cast<osgText::OutlineFont &>(obj);
bool itAdvanced = false;
if (fr[0].matchWord("parameters")) {
int psize;
if (fr[1].getInt(psize) && fr[2].isInt() && fr[3].isString()) {
osgText::OutlineFont *temp = osgNew osgText::OutlineFont(std::string(fr[3].getStr()), psize, 1);
temp->copyAndInvalidate(myobj);
fr += 4;
itAdvanced = true;
}
}
return itAdvanced;
}
/////////////////////////////////////////////////////////////////////////////
// class PolygonFont
/////////////////////////////////////////////////////////////////////////////
bool PolygonFont_readLocalData(osg::Object &obj, osgDB::Input &fr);
osgDB::RegisterDotOsgWrapperProxy PolygonFont_Proxy
(
osgNew osgText::PolygonFont,
"PolygonFont",
"Object Font VectorFont PolygonFont",
PolygonFont_readLocalData,
0
);
bool PolygonFont_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgText::PolygonFont &myobj = static_cast<osgText::PolygonFont &>(obj);
bool itAdvanced = false;
if (fr[0].matchWord("parameters")) {
int psize;
if (fr[1].getInt(psize) && fr[2].isInt() && fr[3].isString()) {
osgText::PolygonFont *temp = osgNew osgText::PolygonFont(std::string(fr[3].getStr()), psize, 1);
temp->copyAndInvalidate(myobj);
fr += 4;
itAdvanced = true;
}
}
return itAdvanced;
}

View File

@@ -1,100 +0,0 @@
#include <osgText/Paragraph>
#include <osgText/Font>
#include <iostream>
#include <string>
#include <osg/Vec3>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
bool Paragraph_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool Paragraph_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
// osgDB::RegisterDotOsgWrapperProxy Paragraph_Proxy
// (
// osgNew osgText::Paragraph,
// "Paragraph",
// "Object Node Geode Paragraph",
// Paragraph_readLocalData,
// Paragraph_writeLocalData
// );
//
bool Paragraph_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgText::Paragraph &myobj = static_cast<osgText::Paragraph &>(obj);
bool itAdvanced = false;
// font
osgText::Font *font = dynamic_cast<osgText::Font *>(fr.readObject());
if (font) {
myobj.setFont(font);
itAdvanced = true;
}
// maximum chars
if (fr[0].matchWord("maximumNoCharactersPerLine")) {
int i;
if (fr[1].getInt(i)) {
myobj.setMaximumNoCharactersPerLine(i);
fr += 2;
itAdvanced = true;
}
}
// text
if (fr[0].matchWord("text") && fr[1].isString()) {
myobj.setText(std::string(fr[1].getStr()));
fr += 2;
itAdvanced = true;
}
// position
if (fr[0].matchWord("position")) {
osg::Vec3 p;
if (fr[1].getFloat(p.x()) && fr[2].getFloat(p.y()) && fr[3].getFloat(p.z())) {
myobj.setPosition(p);
fr += 4;
itAdvanced = true;
}
}
// alignment
if (fr[0].matchWord("alignment")) {
int i;
if (fr[1].getInt(i)) {
myobj.setAlignment(i);
fr += 2;
itAdvanced = true;
}
}
return itAdvanced;
}
bool Paragraph_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgText::Paragraph &myobj = static_cast<const osgText::Paragraph &>(obj);
// font
fw.writeObject(*myobj.getFont());
// maximum chars
fw.indent() << "maximumNoCharactersPerLine " << myobj.getMaximumNoCharactersPerLine() << std::endl;
// text
fw.indent() << "text " << myobj.getText() << std::endl;
// position
osg::Vec3 p = myobj.getPosition();
fw.indent() << "position " << p.x() << " " << p.y() << " " << p.z() << std::endl;
// alignment
fw.indent() << "alignment " << myobj.getAlignment() << std::endl;
return true;
}

View File

@@ -1,128 +0,0 @@
#include <osgText/Text>
#include <osgText/Font>
#include <iostream>
#include <string>
#include <osg/Vec3>
#include <osg/Vec4>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
bool Text_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool Text_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy Text_Proxy
(
osgNew osgText::Text,
"Text",
"Object Drawable Text",
Text_readLocalData,
Text_writeLocalData
);
bool Text_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osgText::Text &myobj = static_cast<osgText::Text &>(obj);
bool itAdvanced = false;
// position
if (fr[0].matchWord("position")) {
osg::Vec3 p;
if (fr[1].getFloat(p.x()) && fr[2].getFloat(p.y()) && fr[3].getFloat(p.z())) {
myobj.setPosition(p);
fr += 4;
itAdvanced = true;
}
}
// color
if (fr[0].matchWord("color")) {
osg::Vec4 c;
if (fr[1].getFloat(c.x()) && fr[2].getFloat(c.y()) && fr[3].getFloat(c.z()) && fr[4].getFloat(c.w())) {
myobj.setColor(c);
fr += 4;
itAdvanced = true;
}
}
// draw mode
if (fr[0].matchWord("drawMode")) {
int i;
if (fr[1].getInt(i)) {
myobj.setDrawMode(i);
fr += 2;
itAdvanced = true;
}
}
// bounding box
if (fr[0].matchWord("boundingBox")) {
int i;
if (fr[1].getInt(i)) {
myobj.setBoundingBox(i);
fr += 2;
itAdvanced = true;
}
}
// alignment
if (fr[0].matchWord("alignment")) {
int i;
if (fr[1].getInt(i)) {
myobj.setAlignment(i);
fr += 2;
itAdvanced = true;
}
}
// font
osgText::Font *font = dynamic_cast<osgText::Font *>(fr.readObject());
if (font) {
myobj.setFont(font);
itAdvanced = true;
}
// text
if (fr.matchSequence("text %s")) {
myobj.setText(std::string(fr[1].getStr()));
fr += 2;
itAdvanced = true;
}
return itAdvanced;
}
bool Text_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const osgText::Text &myobj = static_cast<const osgText::Text &>(obj);
// position
osg::Vec3 p = myobj.getPosition();
fw.indent() << "position " << p.x() << " " << p.y() << " " << p.z() << std::endl;
// color
osg::Vec4 c = myobj.getColor();
fw.indent() << "color " << c.x() << " " << c.y() << " " << c.z() << " " << c.w() << std::endl;
// draw mode
fw.indent() << "drawMode " << myobj.getDrawMode() << std::endl;
// bounding box
fw.indent() << "boundingBox " << myobj.getBoundingBox() << std::endl;
// alignment
fw.indent() << "alignment " << myobj.getAlignment() << std::endl;
// font
fw.writeObject(*myobj.getFont());
// text
fw.indent() << "text \"" << myobj.getText() << "\"" << std::endl;
return true;
}

View File

@@ -23,9 +23,6 @@ CXXFILES =\
Font.cpp \
Paragraph.cpp \
Text.cpp \
IO_Text.cpp \
IO_Font.cpp \
IO_Paragraph.cpp \
Version.cpp