add ScriptNodeCallback serializer

This commit is contained in:
mp3butcher 2017-03-28 22:37:34 +02:00
parent eb59590d77
commit 9d490bbf1c
3 changed files with 50 additions and 1 deletions

View File

@ -36,7 +36,7 @@ class Script : public osg::Object
META_Object(osg, Script)
void setLanguage(const std::string& language) { _language = language; dirty(); }
const std::string& getLanguage() { return _language; }
const std::string& getLanguage() const{ return _language; }
void setScript(const std::string& str) { _script = str; dirty(); }
const std::string& getScript() const { return _script; }
@ -75,6 +75,12 @@ class OSG_EXPORT ScriptNodeCallback : public osg::NodeCallback
/** Get the script to call.*/
const osg::Script* getScript() const { return _script.get(); }
/** Set the entry point to call.*/
void setEntryPoint(const std::string& script) { _entryPoint = script; }
/** Get the script to call.*/
const std::string& getEntryPoint() const { return _entryPoint; }
/** find the ScriptEngine from looking at the UserDataContainers of nodes in scene graph above the ScriptCallback.*/
osg::ScriptEngine* getScriptEngine(osg::NodePath& nodePath);

View File

@ -0,0 +1,20 @@
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
#include <osg/ScriptEngine>
REGISTER_OBJECT_WRAPPER( Script,
new osg::Script,
osg::Script,
"osg::Object osg::Script" )
{
ADD_STRING_SERIALIZER( Script, "" ); // _script
ADD_STRING_SERIALIZER( Language, "" ); // _script
}

View File

@ -0,0 +1,23 @@
#undef OBJECT_CAST
#define OBJECT_CAST dynamic_cast
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
#include <osg/ScriptEngine>
REGISTER_OBJECT_WRAPPER( ScriptNodeCallback,
new osg::ScriptNodeCallback,
osg::ScriptNodeCallback,
"osg::Object osg::Callback osg::CallbackObject osg::ScriptNodeCallback" )
{
ADD_OBJECT_SERIALIZER( Script, osg::Script, NULL ); // _script
ADD_STRING_SERIALIZER( EntryPoint, "" ); // _entrypoint
}
#undef OBJECT_CAST
#define OBJECT_CAST static_cast