Hi Matrin,

On 24 February 2015 at 08:22, Martin Ferry <[email protected]> wrote:

> Hi, Robert
>
> I found another issue in code of LuaScriptEngine.
> Method LuaScriptEngine::pushValue(const osg::Matrixd& value) const has
> switched lua_pushnumber with lua_pushinteger. So if I sent matrix as input
> to method in lua script by input parameters, luascriptengine cast every
> value to int. Than I have in script numbers only 1 or 0. It's bad.
>

Well spotted.  Looks like I got the index and value assignment the wrong
way around.  I have fixed this and check it into svn/trunk.  The changes I
made are:

@@ -3869,7 +3869,7 @@
     {
         for(unsigned int c=0; c<4; ++c)
         {
-            lua_pushnumber(_lua, r*4+c); lua_pushinteger(_lua,
value(r,c)); lua_settable(_lua, -3);
+            lua_pushinteger(_lua, r*4+c); lua_pushnumber(_lua,
value(r,c)); lua_settable(_lua, -3);
         }
     }
 }




> I try your example of creating value objects. It works when I return
> objects like Vec3f to C++ code. In output parameter is mentioned vector.
> But how to do operation with objects as Vec3f, Matrixd in lua csript ?
>

The maths methods in Vec* and Matrix* don't have serializes for them so
they are accessible to the Lua script.  These classes aren't subclassed
from osg::Object so there isn't a any serialization mechanism that is built
for them so the Lua script integration has to provide special handling of
them.  To implement these methods we'd need to implement each of these
methods in the LuaScriptEngine.cpp.

In the project that help fund the development of lua plugin there was no
need for low level maths functions to be exposed so I haven't spent time
implementing stuff that isn't required.

Given going to/from C++ to lua isn't entirely free it may well be most
efficient to simply implement maths methods in Lua itself and use these as
a library.


Could you please write a small lua example how to create and add together 2
> vectors?
>

Or example with using simple matrix transformation (e.g
> osg::Matrix::rotate(osg::Vec3f) ) in Lua script?
>

No. I have other work to get on with.  While I can sympthize the desire
have everything work first time and everything documented in way that helps
you write your program I'm not on your payroll and I have plenty of other
important project to get on with.


> When I try this lua still claims , that called method (rotate) is nill.
>

Lua will report nil for methods that don't exist.

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

Reply via email to