Added osg::CallbackObject to be used to extend C++ class from scripting languages by providing callback objects assigned to the osg::Object UserDataContainer, with the CallbackObject's Name used to map the "method" provided by the CallbackObject. The CallbackObject is implemented by the script engine to provide the neccessary glue to invoking the script with the appropriate input parameters and handling the output parameters.

To the Lua plugin added support for assigned lua functions to C++ osg::Objects via the new osg::CallbackObject mechanism.  To invoke the scripts function from C++ one must get the CallbackObject and call run on it.

Renamed ScriptCallback to ScriptNodeCallback to avoid possibly confusion between osg::CallbackObject and the ScriptNodeCallback.
This commit is contained in:
Robert Osfield
2014-01-31 16:20:29 +00:00
parent 661f0e69ef
commit 5f8e2bda2f
5 changed files with 115 additions and 12 deletions

View File

@@ -58,7 +58,7 @@ int main(int argc, char** argv)
itr != scripts.end();
++itr)
{
model->addUpdateCallback(new osg::ScriptCallback(itr->get()));
model->addUpdateCallback(new osg::ScriptNodeCallback(itr->get()));
}
std::string str;
@@ -441,7 +441,7 @@ int main(int argc, char** argv)
osg::ref_ptr<osg::Script> script = osgDB::readFile<osg::Script>(str);
if (script.valid())
{
presentation->addUpdateCallback(new osg::ScriptCallback(script.get(),"update"));
presentation->addUpdateCallback(new osg::ScriptNodeCallback(script.get(),"update"));
}
}