diff --git a/src/osgPlugins/lua/LuaScriptEngine.cpp b/src/osgPlugins/lua/LuaScriptEngine.cpp index a524b9169..349705673 100644 --- a/src/osgPlugins/lua/LuaScriptEngine.cpp +++ b/src/osgPlugins/lua/LuaScriptEngine.cpp @@ -97,7 +97,7 @@ static int callClassMethod(lua_State* _lua) for(int i=2; i<=n; ++i) { OSG_NOTICE<<" need to push parameter "<popParameterObject()); + inputParameters.insert(inputParameters.begin(), lse->popParameterObject()); } // if (osgDB::MethodsObjectManager::instance()->run(object, object->getCompoundClassName(), methodName, inputParameters, outputParameters)) diff --git a/src/osgWrappers/serializers/osg/Switch.cpp b/src/osgWrappers/serializers/osg/Switch.cpp index df2c53afe..961410ca2 100644 --- a/src/osgWrappers/serializers/osg/Switch.cpp +++ b/src/osgWrappers/serializers/osg/Switch.cpp @@ -1,8 +1,72 @@ #include +#include #include #include #include +struct SwitchGetValue : public osgDB::MethodObject +{ + virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const + { + if (inputParameters.empty()) return false; + + osg::Object* indexObject = inputParameters[0].get(); + OSG_NOTICE<<"SwitchGetValue "<className()<(indexObject); + if (dvo) index = static_cast(dvo->getValue()); + else + { + osg::UIntValueObject* uivo = dynamic_cast(indexObject); + if (uivo) index = uivo->getValue(); + } + + osg::Switch* sw = reinterpret_cast(objectPtr); + outputParameters.push_back(new osg::BoolValueObject("return", sw->getValue(index))); + + return true; + } +}; + + +struct SwitchSetValue : 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<<"SwitchSetValue "<className()<(indexObject); + if (dvo) index = static_cast(dvo->getValue()); + else + { + osg::UIntValueObject* uivo = dynamic_cast(indexObject); + if (uivo) index = uivo->getValue(); + } + + bool enabled = false; + indexObject = inputParameters[1].get(); + dvo = dynamic_cast(indexObject); + if (dvo) enabled = dvo->getValue()!=0.0; + else + { + osg::UIntValueObject* uivo = dynamic_cast(indexObject); + if (uivo) enabled = uivo->getValue()!=0; + } + + OSG_NOTICE<<"switch->setValue("<(objectPtr); + sw->setValue(index, enabled); + + return true; + } +}; + REGISTER_OBJECT_WRAPPER( Switch, new osg::Switch, osg::Switch, @@ -10,4 +74,7 @@ REGISTER_OBJECT_WRAPPER( Switch, { ADD_BOOL_SERIALIZER( NewChildDefaultValue, true ); // _newChildDefaultValue ADD_LIST_SERIALIZER( ValueList, osg::Switch::ValueList ); // _values + + ADD_METHOD_OBJECT( "getValue", SwitchGetValue ); + ADD_METHOD_OBJECT( "setValue", SwitchSetValue ); }