diff --git a/include/osgDB/OutputStream b/include/osgDB/OutputStream index 5e9cf1e00..24a55bd4b 100644 --- a/include/osgDB/OutputStream +++ b/include/osgDB/OutputStream @@ -168,6 +168,7 @@ public: void writeImage( const osg::Image* img ); void writeObject( const osg::Object* obj ); void writeObjectFields( const osg::Object* obj ); + void writeObjectFields( const osg::Object* obj, const std::string& compoundName ); /// set an output iterator, used directly when not using OutputStream with a traditional file releated stream. void setOutputIterator( OutputIterator* oi ) { _out = oi; } diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 61ef2d3ef..c2ee771ea 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -747,7 +747,7 @@ unsigned int Image::computeBlockSize(GLenum pixelFormat, GLenum packing) case(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2): case(GL_COMPRESSED_R11_EAC): case(GL_COMPRESSED_SIGNED_R11_EAC): - return osg::maximum(8u,packing); // block size of 8 + return osg::maximum(8u,packing); // block size of 8 case(GL_COMPRESSED_RGBA8_ETC2_EAC): case(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC): @@ -1912,6 +1912,7 @@ Vec4 Image::getColor(unsigned int s,unsigned t,unsigned r) const case(GL_INT): return _readColor(_pixelFormat, (int*)ptr, 1.0f/2147483648.0f); case(GL_UNSIGNED_INT): return _readColor(_pixelFormat, (unsigned int*)ptr, 1.0f/4294967295.0f); case(GL_FLOAT): return _readColor(_pixelFormat, (float*)ptr, 1.0f); + case(GL_DOUBLE): return _readColor(_pixelFormat, (double*)ptr, 1.0f); } return Vec4(1.0f,1.0f,1.0f,1.0f); } diff --git a/src/osgDB/InputStream.cpp b/src/osgDB/InputStream.cpp index 4ef207dce..0bf4dcd64 100644 --- a/src/osgDB/InputStream.cpp +++ b/src/osgDB/InputStream.cpp @@ -778,7 +778,7 @@ osg::Image* InputStream::readImage(bool readFromExternal) if ( !image && _forceReadingImage ) image = new osg::Image; } - image = static_cast( readObjectFields(className, id, image.get()) ); + image = static_cast( readObjectFields("osg::Object", id, image.get()) ); if ( image.valid() ) { image->setFileName( name ); diff --git a/src/osgDB/OutputStream.cpp b/src/osgDB/OutputStream.cpp index 7e12105fa..c93fb0d10 100644 --- a/src/osgDB/OutputStream.cpp +++ b/src/osgDB/OutputStream.cpp @@ -569,7 +569,7 @@ void OutputStream::writeImage( const osg::Image* img ) break; } - writeObjectFields( img ); + writeObjectFields( img, "osg::Object" ); } // *this << END_BRACKET << std::endl; @@ -601,6 +601,12 @@ void OutputStream::writeObjectFields( const osg::Object* obj ) { std::string name = obj->libraryName(); name += std::string("::") + obj->className(); + writeObjectFields(obj, name); +} + +void OutputStream::writeObjectFields( const osg::Object* obj, const std::string& name ) +{ + // OSG_NOTICE<<"OutputStream::writeObjectFields("<className()<<", name="<getObjectWrapperManager()->findWrapper( name ); if ( !wrapper ) diff --git a/src/osgDB/PropertyInterface.cpp b/src/osgDB/PropertyInterface.cpp index 50374e0a1..43e567254 100644 --- a/src/osgDB/PropertyInterface.cpp +++ b/src/osgDB/PropertyInterface.cpp @@ -301,7 +301,7 @@ osg::Object* PropertyInterface::createObject(const std::string& compoundClassNam if (ow) { osg::Object* object = ow->createInstance(); - OSG_NOTICE<<"PropertyInterface::createObject("<=2 && lua_isnumber(_lua, 2)) s = static_cast(lua_tonumber(_lua, 2)); + if (n>=3 && lua_isnumber(_lua, 3)) t = static_cast(lua_tonumber(_lua, 3)); + if (n>=4 && lua_isnumber(_lua, 4)) r = static_cast(lua_tonumber(_lua, 4)); + + if (n>=5) + { + if (lua_isnumber(_lua, 5)) pixelFormat = static_cast(lua_tonumber(_lua, 5)); + else if (lua_isstring(_lua, 5)) + { + pixelFormat = lse->lookUpGLenumValue(lua_tostring(_lua,5)); + } + } + + if (n>=6) + { + if (lua_isnumber(_lua, 6)) dataType = static_cast(lua_tonumber(_lua, 6)); + else if (lua_isstring(_lua, 6)) + { + dataType = lse->lookUpGLenumValue(lua_tostring(_lua,6)); + } + } + + if (n>=7) + { + if (lua_isnumber(_lua, 7)) packing = static_cast(lua_tonumber(_lua, 7)); + } + + + if (s<=0 || t<=0 || r<=0 || pixelFormat==0 || dataType==0) + { + OSG_NOTICE<<"Warning: Cannot not image:allocator("<allocateImage(s,t,r,pixelFormat,dataType,packing); + + return 0; +} + +static int callImageS(lua_State* _lua) +{ + const LuaScriptEngine* lse = reinterpret_cast(lua_topointer(_lua, lua_upvalueindex(1))); + int n = lua_gettop(_lua); /* number of arguments */ + if (n<1 || lua_type(_lua, 1)!=LUA_TTABLE) return 0; + + osg::Image* image = lse->getObjectFromTable(1); + if (!image) + { + OSG_NOTICE<<"Warning: Image:s() can only be called on a Image"<s()); + + return 1; +} + +static int callImageT(lua_State* _lua) +{ + const LuaScriptEngine* lse = reinterpret_cast(lua_topointer(_lua, lua_upvalueindex(1))); + int n = lua_gettop(_lua); /* number of arguments */ + if (n<1 || lua_type(_lua, 1)!=LUA_TTABLE) return 0; + + osg::Image* image = lse->getObjectFromTable(1); + if (!image) + { + OSG_NOTICE<<"Warning: Image:t() can only be called on a Image"<t()); + + return 1; +} + +static int callImageR(lua_State* _lua) +{ + const LuaScriptEngine* lse = reinterpret_cast(lua_topointer(_lua, lua_upvalueindex(1))); + int n = lua_gettop(_lua); /* number of arguments */ + if (n<1 || lua_type(_lua, 1)!=LUA_TTABLE) return 0; + + osg::Image* image = lse->getObjectFromTable(1); + if (!image) + { + OSG_NOTICE<<"Warning: Image:r() can only be called on a Image"<r()); + + return 1; +} + +// conversion of a lua value/table to a std::string, supports recursion when tables contain tables +static std::string cpp_tostring(lua_State* _lua, int index) +{ + if (!lua_istable(_lua, index)) + { + const char* str = lua_tostring(_lua, index); + if (str) + { + return str; + } + else + { + return "value-cannot-be-converted-to-string"; + } + } + + // Push another reference to the table on top of the stack (so we know + // where it is, and this function can work for negative, positive and + // pseudo indices + lua_pushvalue(_lua, index); + // stack now contains: -1 => table + lua_pushnil(_lua); + // stack now contains: -1 => nil; -2 => table + bool first = true; + std::string str("{"); + while (lua_next(_lua, -2)) + { + if (!first) str.append(", "); + else first = false; + + // stack now contains: -1 => value; -2 => key; -3 => table + // copy the key so that lua_tostring does not modify the original + lua_pushvalue(_lua, -2); + // stack now contains: -1 => key; -2 => value; -3 => key; -4 => table + + // handle key + if (lua_isstring(_lua, -1)) + { + const char *key = lua_tostring(_lua, -1); + if (key) + { + str.append(key); + str.append("="); + } + } + + // handle value + if (lua_istable(_lua, -2)) + { + str.append(cpp_tostring(_lua,-2)); + } + else if (lua_isfunction(_lua, -2)) + { + str.append("function"); + } + else if (lua_isnil(_lua, -2)) + { + str.append("nil"); + } + else if (lua_isstring(_lua,-2)) + { + const char *value = lua_tostring(_lua, -2); + str.append("\""); + if (value) + { + str.append(value); + } + str.append("\""); + } + else + { + const char *value = lua_tostring(_lua, -2); + if (value) + { + str.append(value); + } + } + + // pop value + copy of key, leaving original key + lua_pop(_lua, 2); + // stack now contains: -1 => key; -2 => table + } + str.append("}"); + + // stack now contains: -1 => table (when lua_next returns 0 it pops the key + // but does not push anything.) + // Pop table + lua_pop(_lua, 1); + // Stack is now the same as it was on entry to this function + + return str; +} + +static int tostring(lua_State* _lua) +{ + lua_pushstring(_lua, cpp_tostring(_lua,-1) .c_str()); + return 1; +} + +static int callImageGet(lua_State* _lua) +{ + const LuaScriptEngine* lse = reinterpret_cast(lua_topointer(_lua, lua_upvalueindex(1))); + int n = lua_gettop(_lua); /* number of arguments */ + if (n<2 || lua_type(_lua, 1)!=LUA_TTABLE) return 0; + + osg::Image* image = lse->getObjectFromTable(1); + if (!image) + { + OSG_NOTICE<<"Warning: Image:get() can only be called on a Image"<=2 && lua_isnumber(_lua, 2)) i = static_cast(lua_tonumber(_lua, 2)); + if (n>=3 && lua_isnumber(_lua, 3)) j = static_cast(lua_tonumber(_lua, 3)); + if (n>=4 && lua_isnumber(_lua, 4)) k = static_cast(lua_tonumber(_lua, 4)); + + const unsigned char* ptr = image->data(i,j,k); + unsigned int numComponents = osg::Image::computeNumComponents(image->getPixelFormat()); + + // OSG_NOTICE<<"Need to implement Image::get("<getPixelFormat()) + { + case(GL_INTENSITY): lua_pushnumber(_lua, colour[0]); return 1; + case(GL_LUMINANCE): lua_pushnumber(_lua, colour[0]); return 1; + case(GL_ALPHA): lua_pushnumber(_lua, colour[0]); return 1; + case(GL_LUMINANCE_ALPHA): + { + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); + lua_pushstring(_lua, "luminance"); lua_pushnumber(_lua, colour[0]); lua_settable(_lua, -3); + lua_pushstring(_lua, "alpha"); lua_pushnumber(_lua, colour[1]); lua_settable(_lua, -3); + return 1; + } + case(GL_RGB): + { + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); + lua_pushstring(_lua, "red"); lua_pushnumber(_lua, colour[0]); lua_settable(_lua, -3); + lua_pushstring(_lua, "green"); lua_pushnumber(_lua, colour[1]); lua_settable(_lua, -3); + lua_pushstring(_lua, "blue"); lua_pushnumber(_lua, colour[2]); lua_settable(_lua, -3); + return 1; + } + case(GL_RGBA): + { + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); + lua_pushstring(_lua, "red"); lua_pushnumber(_lua, colour[0]); lua_settable(_lua, -3); + lua_pushstring(_lua, "green"); lua_pushnumber(_lua, colour[1]); lua_settable(_lua, -3); + lua_pushstring(_lua, "blue"); lua_pushnumber(_lua, colour[2]); lua_settable(_lua, -3); + lua_pushstring(_lua, "alpha"); lua_pushnumber(_lua, colour[3]); lua_settable(_lua, -3); + return 1; + } + case(GL_BGR): + { + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); + lua_pushstring(_lua, "red"); lua_pushnumber(_lua, colour[2]); lua_settable(_lua, -3); + lua_pushstring(_lua, "green"); lua_pushnumber(_lua, colour[1]); lua_settable(_lua, -3); + lua_pushstring(_lua, "blue"); lua_pushnumber(_lua, colour[0]); lua_settable(_lua, -3); + return 1; + } + case(GL_BGRA): + { + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); + lua_pushstring(_lua, "red"); lua_pushnumber(_lua, colour[2]); lua_settable(_lua, -3); + lua_pushstring(_lua, "green"); lua_pushnumber(_lua, colour[1]); lua_settable(_lua, -3); + lua_pushstring(_lua, "blue"); lua_pushnumber(_lua, colour[0]); lua_settable(_lua, -3); + lua_pushstring(_lua, "alpha"); lua_pushnumber(_lua, colour[3]); lua_settable(_lua, -3); + return 1; + } + } + + OSG_NOTICE<<"Warning: Image:get() unsupported PixelFormat"<=image->s() || j>=image->t() || k>=image->r()) + { + OSG_NOTICE<<"Warning: Image::set("<data(i,j,k); + unsigned int numComponents = osg::Image::computeNumComponents(image->getPixelFormat()); + + switch(image->getDataType()) + { + case(GL_BYTE): for(unsigned int i=0; i(ptr)+i) = static_cast(colourToWrite[i]); } break; + case(GL_UNSIGNED_BYTE): for(unsigned int i=0; i(ptr)+i) = static_cast(colourToWrite[i]); } break; + case(GL_SHORT): for(unsigned int i=0; i(ptr)+i) = static_cast(colourToWrite[i]); } break; + case(GL_UNSIGNED_SHORT): for(unsigned int i=0; i(ptr)+i) = static_cast(colourToWrite[i]); } break; + case(GL_INT): for(unsigned int i=0; i(ptr)+i) = static_cast(colourToWrite[i]); } break; + case(GL_UNSIGNED_INT): for(unsigned int i=0; i(ptr)+i) = static_cast(colourToWrite[i]); } break; + case(GL_FLOAT): for(unsigned int i=0; i(ptr)+i) = static_cast(colourToWrite[i]); } break; + case(GL_DOUBLE): for(unsigned int i=0; i(ptr)+i) = static_cast(colourToWrite[i]); } break; + default: + OSG_NOTICE<<"Warning: Unsupported DataType in Image::set()"<(lua_topointer(_lua, lua_upvalueindex(1))); + int n = lua_gettop(_lua); /* number of arguments */ + if (n<2 || lua_type(_lua, 1)!=LUA_TTABLE) return 0; + + osg::Image* image = lse->getObjectFromTable(1); + if (!image) + { + OSG_NOTICE<<"Warning: Image:set() can only be called on a Image"<=3 && lua_isnumber(_lua, 2)) { i = static_cast(lua_tonumber(_lua, 2)); positionSet = true; } + if (n>=4 && lua_isnumber(_lua, 3)) { j = static_cast(lua_tonumber(_lua, 3)); positionSet = true; } + if (n>=5 && lua_isnumber(_lua, 4)) { k = static_cast(lua_tonumber(_lua, 4)); positionSet = true; } + + osg::Vec4d colour(1.0,1.0,1.0,1.0); + if (lua_isnumber(_lua, n)) + { + colour[0] = colour[1] = colour[2] = colour[3] = lua_tonumber(_lua, n); + } + else if (lua_istable(_lua, n)) + { + lua_getfield(_lua, n, "intensity"); + if (lua_isnumber(_lua, -1)) { double i = lua_tonumber(_lua, -1); colour[0] = i; colour[1] = i; colour[2] = i; colour[3] = i; } + lua_pop(_lua, 1); + + lua_getfield(_lua, n, "i"); + if (lua_isnumber(_lua, -1)) { double i = lua_tonumber(_lua, -1); colour[0] = i; colour[1] = i; colour[2] = i; colour[3] = i; } + lua_pop(_lua, 1); + + + lua_getfield(_lua, n, "luminance"); + if (lua_isnumber(_lua, -1)) { double l = lua_tonumber(_lua, -1); colour[0] = l; colour[1] = l; colour[2] = l; } + lua_pop(_lua, 1); + + lua_getfield(_lua, n, "l"); + if (lua_isnumber(_lua, -1)) { double l = lua_tonumber(_lua, -1); colour[0] = l; colour[1] = l; colour[2] = l; } + lua_pop(_lua, 1); + + + lua_getfield(_lua, n, "alpha"); + if (lua_isnumber(_lua, -1)) { double a = lua_tonumber(_lua, -1); colour[3] = a; } + lua_pop(_lua, 1); + + lua_getfield(_lua, n, "a"); + if (lua_isnumber(_lua, -1)) { double a = lua_tonumber(_lua, -1); colour[3] = a; } + lua_pop(_lua, 1); + + + lua_getfield(_lua, n, "red"); + if (lua_isnumber(_lua, -1)) { double r = lua_tonumber(_lua, -1); colour[0] = r; } + lua_pop(_lua, 1); + + lua_getfield(_lua, n, "r"); + if (lua_isnumber(_lua, -1)) { double r = lua_tonumber(_lua, -1); colour[0] = r; } + lua_pop(_lua, 1); + + + lua_getfield(_lua, n, "green"); + if (lua_isnumber(_lua, -1)) { double g = lua_tonumber(_lua, -1); colour[1] = g; } + lua_pop(_lua, 1); + + lua_getfield(_lua, n, "g"); + if (lua_isnumber(_lua, -1)) { double g = lua_tonumber(_lua, -1); colour[1] = g; } + lua_pop(_lua, 1); + + + lua_getfield(_lua, n, "blue"); + if (lua_isnumber(_lua, -1)) { double b = lua_tonumber(_lua, -1); colour[2] = b; } + lua_pop(_lua, 1); + + lua_getfield(_lua, n, "b"); + if (lua_isnumber(_lua, -1)) { double b = lua_tonumber(_lua, -1); colour[2] = b; } + lua_pop(_lua, 1); + + } + + // repack the colour data to the final destination form + osg::Vec4d colourToWrite = colour; + switch(image->getPixelFormat()) + { + case(GL_INTENSITY): colourToWrite[0] = colour[0]; break; + case(GL_LUMINANCE): colourToWrite[0] = colour[0]; break; + case(GL_ALPHA): colourToWrite[0] = colour[3]; break; + case(GL_LUMINANCE_ALPHA): + { + colourToWrite[0] = colour[0]; + colourToWrite[1] = colour[3]; + break; + } + case(GL_RGB): + case(GL_RGBA): + { + // nothing to do as data is already in the correct form + break; + } + case(GL_BGR): + case(GL_BGRA): + { + colourToWrite[0] = colour[2]; + colourToWrite[1] = colour[1]; + colourToWrite[2] = colour[0]; + colourToWrite[3] = colour[3]; + return 1; + } + } + + if (positionSet) + { + setImageColour(image, i,j,k, colourToWrite); + } + else + { + for(k=0; kr(); ++k) + { + for(j=0; jt(); ++j) + { + for(i=0; is(); ++i) + { + setImageColour(image, i,j,k, colourToWrite); + } + } + } + } + + return 0; +} + ////////////////////////////////////////////////////////////////////////////////////// // // Method calling support @@ -1377,6 +1841,23 @@ void LuaScriptEngine::initialize() lua_pushcclosure(_lua, setProperty, 1); lua_settable(_lua, -3); + lua_pushstring(_lua, "__tostring"); + lua_pushlightuserdata(_lua, this); + lua_pushcclosure(_lua, tostring, 1); + lua_settable(_lua, -3); + + lua_pop(_lua,1); + } + + // Set up the __newindex and __index methods for looking up implementations of Object properties + { + luaL_newmetatable(_lua, "LuaScriptEngine.Table"); + + lua_pushstring(_lua, "__tostring"); + lua_pushlightuserdata(_lua, this); + lua_pushcclosure(_lua, tostring, 1); + lua_settable(_lua, -3); + lua_pop(_lua,1); } @@ -2981,6 +3462,7 @@ bool LuaScriptEngine::getvec2(int pos) const { if (getfields(abs_pos, "x", "y", LUA_TNUMBER) || getfields(abs_pos, "s", "t", LUA_TNUMBER) || + getfields(abs_pos, "luminance", "alpha", LUA_TNUMBER) || getelements(abs_pos, 2, LUA_TNUMBER)) { return true; @@ -3194,6 +3676,7 @@ bool LuaScriptEngine::getValue(int pos, osg::BoundingSphered& value) const void LuaScriptEngine::pushValue(const osg::Vec2f& value) const { lua_newtable(_lua); + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); lua_pushstring(_lua, "x"); lua_pushnumber(_lua, value.x()); lua_settable(_lua, -3); lua_pushstring(_lua, "y"); lua_pushnumber(_lua, value.y()); lua_settable(_lua, -3); } @@ -3201,6 +3684,7 @@ void LuaScriptEngine::pushValue(const osg::Vec2f& value) const void LuaScriptEngine::pushValue(const osg::Vec3f& value) const { lua_newtable(_lua); + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); lua_pushstring(_lua, "x"); lua_pushnumber(_lua, value.x()); lua_settable(_lua, -3); lua_pushstring(_lua, "y"); lua_pushnumber(_lua, value.y()); lua_settable(_lua, -3); lua_pushstring(_lua, "z"); lua_pushnumber(_lua, value.z()); lua_settable(_lua, -3); @@ -3209,6 +3693,7 @@ void LuaScriptEngine::pushValue(const osg::Vec3f& value) const void LuaScriptEngine::pushValue(const osg::Vec4f& value) const { lua_newtable(_lua); + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); lua_pushstring(_lua, "x"); lua_pushnumber(_lua, value.x()); lua_settable(_lua, -3); lua_pushstring(_lua, "y"); lua_pushnumber(_lua, value.y()); lua_settable(_lua, -3); lua_pushstring(_lua, "z"); lua_pushnumber(_lua, value.z()); lua_settable(_lua, -3); @@ -3218,6 +3703,7 @@ void LuaScriptEngine::pushValue(const osg::Vec4f& value) const void LuaScriptEngine::pushValue(const osg::Matrixf& value) const { lua_newtable(_lua); + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); for(unsigned int r=0; r<4; ++r) { @@ -3231,6 +3717,7 @@ void LuaScriptEngine::pushValue(const osg::Matrixf& value) const void LuaScriptEngine::pushValue(const osg::Vec2d& value) const { lua_newtable(_lua); + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); lua_pushstring(_lua, "x"); lua_pushnumber(_lua, value.x()); lua_settable(_lua, -3); lua_pushstring(_lua, "y"); lua_pushnumber(_lua, value.y()); lua_settable(_lua, -3); } @@ -3238,6 +3725,7 @@ void LuaScriptEngine::pushValue(const osg::Vec2d& value) const void LuaScriptEngine::pushValue(const osg::Vec3d& value) const { lua_newtable(_lua); + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); lua_pushstring(_lua, "x"); lua_pushnumber(_lua, value.x()); lua_settable(_lua, -3); lua_pushstring(_lua, "y"); lua_pushnumber(_lua, value.y()); lua_settable(_lua, -3); lua_pushstring(_lua, "z"); lua_pushnumber(_lua, value.z()); lua_settable(_lua, -3); @@ -3246,6 +3734,7 @@ void LuaScriptEngine::pushValue(const osg::Vec3d& value) const void LuaScriptEngine::pushValue(const osg::Vec4d& value) const { lua_newtable(_lua); + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); lua_pushstring(_lua, "x"); lua_pushnumber(_lua, value.x()); lua_settable(_lua, -3); lua_pushstring(_lua, "y"); lua_pushnumber(_lua, value.y()); lua_settable(_lua, -3); lua_pushstring(_lua, "z"); lua_pushnumber(_lua, value.z()); lua_settable(_lua, -3); @@ -3255,6 +3744,7 @@ void LuaScriptEngine::pushValue(const osg::Vec4d& value) const void LuaScriptEngine::pushValue(const osg::Quat& value) const { lua_newtable(_lua); + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); lua_pushstring(_lua, "x"); lua_pushnumber(_lua, value.x()); lua_settable(_lua, -3); lua_pushstring(_lua, "y"); lua_pushnumber(_lua, value.y()); lua_settable(_lua, -3); lua_pushstring(_lua, "z"); lua_pushnumber(_lua, value.z()); lua_settable(_lua, -3); @@ -3264,6 +3754,7 @@ void LuaScriptEngine::pushValue(const osg::Quat& value) const void LuaScriptEngine::pushValue(const osg::Plane& value) const { lua_newtable(_lua); + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); lua_pushstring(_lua, "x"); lua_pushnumber(_lua, value.asVec4().x()); lua_settable(_lua, -3); lua_pushstring(_lua, "y"); lua_pushnumber(_lua, value.asVec4().y()); lua_settable(_lua, -3); lua_pushstring(_lua, "z"); lua_pushnumber(_lua, value.asVec4().z()); lua_settable(_lua, -3); @@ -3273,6 +3764,7 @@ void LuaScriptEngine::pushValue(const osg::Plane& value) const void LuaScriptEngine::pushValue(const osg::Matrixd& value) const { lua_newtable(_lua); + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); for(unsigned int r=0; r<4; ++r) { @@ -3286,6 +3778,7 @@ void LuaScriptEngine::pushValue(const osg::Matrixd& value) const void LuaScriptEngine::pushValue(const osg::BoundingBoxf& value) const { lua_newtable(_lua); + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); lua_pushstring(_lua, "xMin"); lua_pushnumber(_lua, value.xMin()); lua_settable(_lua, -3); lua_pushstring(_lua, "yMin"); lua_pushnumber(_lua, value.yMin()); lua_settable(_lua, -3); lua_pushstring(_lua, "zMin"); lua_pushnumber(_lua, value.zMin()); lua_settable(_lua, -3); @@ -3297,6 +3790,7 @@ void LuaScriptEngine::pushValue(const osg::BoundingBoxf& value) const void LuaScriptEngine::pushValue(const osg::BoundingBoxd& value) const { lua_newtable(_lua); + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); lua_pushstring(_lua, "xMin"); lua_pushnumber(_lua, value.xMin()); lua_settable(_lua, -3); lua_pushstring(_lua, "yMin"); lua_pushnumber(_lua, value.yMin()); lua_settable(_lua, -3); lua_pushstring(_lua, "zMin"); lua_pushnumber(_lua, value.zMin()); lua_settable(_lua, -3); @@ -3308,6 +3802,7 @@ void LuaScriptEngine::pushValue(const osg::BoundingBoxd& value) const void LuaScriptEngine::pushValue(const osg::BoundingSpheref& value) const { lua_newtable(_lua); + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); lua_pushstring(_lua, "x"); lua_pushnumber(_lua, value.center().x()); lua_settable(_lua, -3); lua_pushstring(_lua, "y"); lua_pushnumber(_lua, value.center().y()); lua_settable(_lua, -3); lua_pushstring(_lua, "z"); lua_pushnumber(_lua, value.center().z()); lua_settable(_lua, -3); @@ -3317,6 +3812,7 @@ void LuaScriptEngine::pushValue(const osg::BoundingSpheref& value) const void LuaScriptEngine::pushValue(const osg::BoundingSphered& value) const { lua_newtable(_lua); + lua_newtable(_lua); luaL_getmetatable(_lua, "LuaScriptEngine.Table"); lua_setmetatable(_lua, -2); lua_pushstring(_lua, "x"); lua_pushnumber(_lua, value.center().x()); lua_settable(_lua, -3); lua_pushstring(_lua, "y"); lua_pushnumber(_lua, value.center().y()); lua_settable(_lua, -3); lua_pushstring(_lua, "z"); lua_pushnumber(_lua, value.center().z()); lua_settable(_lua, -3); @@ -3639,7 +4135,6 @@ void LuaScriptEngine::pushObject(osg::Object* object) const osgDB::BaseSerializer* vs = _pi.getSerializer(object, "vector", type); if (vs) { - OSG_NOTICE<<"pushObject("<className()<<" Have vector"<(object)!=0) { - OSG_NOTICE<<"Have osg::Image need to implement Image methods"<(object)!=0) { - OSG_NOTICE<<"Have osg::StateSet need to implement stateset methods"<