Hi Martin,

Which version of the OSG are you using?  In svn/trunk and the recent
OSG-3.3.x dev series there is a lua plugin which provides the Lua source
code directly within the plugin as well as the glue to integrate the OSG
with Lua.  There won't be any need to use tools like Swig as the OSG's
serialization support is used to expose the OSG class properties and
methods for you.

As a test could you build OSG svn/trunk and OpenSceneGraph-Data svn/trunk,
put the OpenSceneGraph-Data directory on an OSG_FILE_PATH env var and then
run:

osgviewer ui/TabWidget.lua.90,0,0.rot cow.osgt

What you should get is a cow in the low left of widget with a tab panel in
it.  You can drag the panel around via the title area, and resize it using
the mouse scroll wheel in the title area.  Clicking on the tab will jump
you between the different elements.  Note, the 90,0,0.rot is simply there
to rotate the osgUI widget from being in the XY plane to the XZ plane.  The
cow.osgt isn't lua of course but should give a little 3d reference to it.

Now this example TabWidget.lua script is just what I've used for testing.
A more sophisticated usage of lua can be found with VolumeSettings.lua
script. This is designed to be used as part of Present3D along with volume
rendering.  These scripts are all examples of using .lua as a pseudo plugin
where the lua script creates scene graph objects, populates the scene graph
with lua callbacks and passes back the scene graph.

One can also create Lua scripts and assign these as callbacks to the scene
graph.  To do this you'd create your script/read it from a file (via
osgDB::readScriptFile("myscript.lua"); and then call this via creating
script engine and then passing in the script to be run via
ScriptEngine::run(..), or add as a callback to the scene graph by attaching
the osg::Script to an osg::ScriptNodeCallback.  Have a look at the
include/osg/ScriptEngine for all these classes.

The osgtransferfunction and osgpresentation examples are really just test
beds that I've used when developing this functionality so aren't written
for the purpose of education.  You might be able to glean a little from
these.  I'm afraid there aren't any examples written specifically for
teaching users how to use the scripting yet.  While this will be a bit of
hurdle it'll should be much easier to get to grips with than jumping
through all the hoops that a tool like Swig would introduce.

It's been quite a few months since last worked specifically on the lua code
so I'll be a little rusty but hopefully will be able to point you in the
right direction.  If you do have problems then if you can put together an
example that can be tested then it'll be easier for me to spot what might
be going wrong.

Good luck,
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to