Added support for set/getColor to ShapeDrawable.

This commit is contained in:
Robert Osfield
2003-04-16 20:02:15 +00:00
parent cad160fbe6
commit 0b0c6c4e60
3 changed files with 73 additions and 35 deletions

View File

@@ -11,41 +11,55 @@ using namespace osgDB;
bool ShapeDrawable_readLocalData(Object& obj, Input& fr);
bool ShapeDrawable_writeLocalData(const Object& obj, Output& fw);
//register the read and write functions with the osgDB::Registry.
RegisterDotOsgWrapperProxy g_ShapeDrawableFuncProxy
(
new osg::ShapeDrawable,
"ShapeDrawable",
"Object Drawable ShapeDrawable",
0,
0,
DotOsgWrapper::READ_AND_WRITE
);
// //register the read and write functions with the osgDB::Registry.
// RegisterDotOsgWrapperProxy g_ShapeDrawableFuncProxy
// (
// new osg::ShapeDrawable,
// "ShapeDrawable",
// "Object Drawable ShapeDrawable",
// &ShapeDrawable_readLocalData,
// &ShapeDrawable_writeLocalData,
// 0,
// 0,
// DotOsgWrapper::READ_AND_WRITE
// );
//
// bool ShapeDrawable_readLocalData(Object& obj, Input& fr)
// {
// bool iteratorAdvanced = false;
//
// ShapeDrawable& geom = static_cast<ShapeDrawable&>(obj);
//
// bool matchedFirst = false;
//
// return iteratorAdvanced;
// }
//
// bool ShapeDrawable_writeLocalData(const Object& obj, Output& fw)
// {
// const ShapeDrawable& geom = static_cast<const ShapeDrawable&>(obj);
//
// return true;
// }
RegisterDotOsgWrapperProxy g_ShapeDrawableFuncProxy
(
new osg::ShapeDrawable,
"ShapeDrawable",
"Object Drawable ShapeDrawable",
&ShapeDrawable_readLocalData,
&ShapeDrawable_writeLocalData,
DotOsgWrapper::READ_AND_WRITE
);
bool ShapeDrawable_readLocalData(Object& obj, Input& fr)
{
bool iteratorAdvanced = false;
ShapeDrawable& geom = static_cast<ShapeDrawable&>(obj);
if (fr.matchSequence("color %f %f %f %f"))
{
osg::Vec4 color;
fr[1].getFloat(color[0]);
fr[2].getFloat(color[1]);
fr[3].getFloat(color[2]);
fr[4].getFloat(color[3]);
geom.setColor(color);
fr+=5;
iteratorAdvanced = true;
}
return iteratorAdvanced;
}
bool ShapeDrawable_writeLocalData(const Object& obj, Output& fw)
{
const ShapeDrawable& geom = static_cast<const ShapeDrawable&>(obj);
fw.indent() << "color " << geom.getColor() << std::endl;
return true;
}