Added Group::setChild(..) and Geode::setDrawable(..) MethodObjects
This commit is contained in:
@@ -36,6 +36,7 @@ static bool writeDrawables( osgDB::OutputStream& os, const osg::Geode& node )
|
||||
os << os.END_BRACKET << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
struct GeodeGetNumDrawables : public osgDB::MethodObject
|
||||
{
|
||||
virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const
|
||||
@@ -64,6 +65,35 @@ struct GeodeGetDrawable : public osgDB::MethodObject
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct GeodeSetDrawable : public osgDB::MethodObject
|
||||
{
|
||||
virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const
|
||||
{
|
||||
if (inputParameters.size()<2) return false;
|
||||
|
||||
osg::Object* indexObject = inputParameters[0].get();
|
||||
OSG_NOTICE<<"GeodeSetChild "<<indexObject->className()<<std::endl;
|
||||
|
||||
unsigned int index = 0;
|
||||
osg::DoubleValueObject* dvo = dynamic_cast<osg::DoubleValueObject*>(indexObject);
|
||||
if (dvo) index = static_cast<unsigned int>(dvo->getValue());
|
||||
else
|
||||
{
|
||||
osg::UIntValueObject* uivo = dynamic_cast<osg::UIntValueObject*>(indexObject);
|
||||
if (uivo) index = uivo->getValue();
|
||||
}
|
||||
|
||||
osg::Drawable* child = dynamic_cast<osg::Drawable*>(inputParameters[1].get());
|
||||
if (!child) return false;
|
||||
|
||||
osg::Geode* geode = reinterpret_cast<osg::Geode*>(objectPtr);
|
||||
geode->setDrawable(index, child);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct GeodeAddDrawable : public osgDB::MethodObject
|
||||
{
|
||||
virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const
|
||||
@@ -106,6 +136,7 @@ REGISTER_OBJECT_WRAPPER( Geode,
|
||||
|
||||
ADD_METHOD_OBJECT( "getNumDrawables", GeodeGetNumDrawables );
|
||||
ADD_METHOD_OBJECT( "getDrawable", GeodeGetDrawable );
|
||||
ADD_METHOD_OBJECT( "setDrawable", GeodeSetDrawable );
|
||||
ADD_METHOD_OBJECT( "addDrawable", GeodeAddDrawable );
|
||||
ADD_METHOD_OBJECT( "removeDrawable", GeodeRemoveDrawable );
|
||||
}
|
||||
|
||||
@@ -68,6 +68,34 @@ struct GroupGetChild : public osgDB::MethodObject
|
||||
}
|
||||
};
|
||||
|
||||
struct GroupSetChild : public osgDB::MethodObject
|
||||
{
|
||||
virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const
|
||||
{
|
||||
if (inputParameters.size()<2) return false;
|
||||
|
||||
osg::Object* indexObject = inputParameters[0].get();
|
||||
OSG_NOTICE<<"GroupSetChild "<<indexObject->className()<<std::endl;
|
||||
|
||||
unsigned int index = 0;
|
||||
osg::DoubleValueObject* dvo = dynamic_cast<osg::DoubleValueObject*>(indexObject);
|
||||
if (dvo) index = static_cast<unsigned int>(dvo->getValue());
|
||||
else
|
||||
{
|
||||
osg::UIntValueObject* uivo = dynamic_cast<osg::UIntValueObject*>(indexObject);
|
||||
if (uivo) index = uivo->getValue();
|
||||
}
|
||||
|
||||
osg::Node* child = dynamic_cast<osg::Node*>(inputParameters[1].get());
|
||||
if (!child) return false;
|
||||
|
||||
osg::Group* group = reinterpret_cast<osg::Group*>(objectPtr);
|
||||
group->setChild(index, child);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct GroupAddChild : public osgDB::MethodObject
|
||||
{
|
||||
virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const
|
||||
@@ -110,6 +138,7 @@ REGISTER_OBJECT_WRAPPER( Group,
|
||||
|
||||
ADD_METHOD_OBJECT( "getNumChildren", GroupGetNumChildren );
|
||||
ADD_METHOD_OBJECT( "getChild", GroupGetChild );
|
||||
ADD_METHOD_OBJECT( "setChild", GroupSetChild );
|
||||
ADD_METHOD_OBJECT( "addChild", GroupAddChild );
|
||||
ADD_METHOD_OBJECT( "removeChild", GroupRemoveChild );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user