Added Vector serialization and support in lua plugin top enable script users to set/get vector properties such as osg::Array, osg::PrimitiveSet and children lists.

This commit is contained in:
Robert Osfield
2014-02-24 10:19:48 +00:00
parent 6d68718fba
commit 4ef5d9eb5f
15 changed files with 1566 additions and 103 deletions

View File

@@ -6,12 +6,54 @@
namespace PrimitiveSetWrapper {
#define CUSTOM_BEGIN_ENUM_SERIALIZER(PROP, DEF) \
{ typedef osgDB::EnumSerializer<MyClass, MyClass::PROP, void> MySerializer; \
osg::ref_ptr<MySerializer> serializer = new MySerializer( \
#PROP, MyClass::DEF, &MyClass::get##PROP, &MyClass::set##PROP)
REGISTER_OBJECT_WRAPPER( PrimitiveSet,
0,
osg::PrimitiveSet,
"osg::Object osg::PrimitiveSet" )
{
ADD_INT_SERIALIZER( NumInstances, 0);
#if 1
{
typedef osgDB::EnumSerializer<MyClass, MyClass::Mode, void> MySerializer;
typedef osg::PrimitiveSet::Mode (osg::PrimitiveSet::*Getter)() const;
typedef void (osg::PrimitiveSet::*Setter)( osg::PrimitiveSet::Mode );
osg::ref_ptr<MySerializer> serializer = new MySerializer( "Mode", osg::PrimitiveSet::POINTS,
reinterpret_cast<Getter>(&osg::PrimitiveSet::getMode),
reinterpret_cast<Setter>(&osg::PrimitiveSet::setMode));
ADD_ENUM_VALUE( POINTS );
ADD_ENUM_VALUE( LINES );
ADD_ENUM_VALUE( LINE_STRIP );
ADD_ENUM_VALUE( LINE_LOOP );
ADD_ENUM_VALUE( TRIANGLES );
ADD_ENUM_VALUE( TRIANGLE_STRIP );
ADD_ENUM_VALUE( TRIANGLE_FAN );
ADD_ENUM_VALUE( QUADS );
ADD_ENUM_VALUE( QUAD_STRIP );
ADD_ENUM_VALUE( POLYGON );
ADD_ENUM_VALUE( LINES_ADJACENCY );
ADD_ENUM_VALUE( LINE_STRIP_ADJACENCY );
ADD_ENUM_VALUE( TRIANGLES_ADJACENCY );
ADD_ENUM_VALUE( TRIANGLE_STRIP_ADJACENCY );
ADD_ENUM_VALUE( PATCHES );
wrapper->addSerializer(serializer.get(), osgDB::BaseSerializer::RW_ENUM);
}
#else
ADD_GLENUM_SERIALIZER( Mode, GLenum, GL_NONE );
#endif
#if 0
BEGIN_ENUM_SERIALIZER_NO_SET( Type, PrimitiveType );
ADD_ENUM_VALUE( PrimitiveType );
ADD_ENUM_VALUE( DrawArraysPrimitiveType );
@@ -21,17 +63,14 @@ REGISTER_OBJECT_WRAPPER( PrimitiveSet,
ADD_ENUM_VALUE( DrawElementsUIntPrimitiveType );
END_ENUM_SERIALIZER();
ADD_INT_SERIALIZER( NumInstances, 0);
ADD_GLENUM_SERIALIZER( Mode, GLenum, GL_NONE );
ADD_UINT_SERIALIZER_NO_SET( TotalDataSize, 0);
ADD_UINT_SERIALIZER_NO_SET( NumPrimitives, 0);
ADD_UINT_SERIALIZER_NO_SET( NumIndices, 0);
wrapper->addSerializer(
new osgDB::PropByValSerializer< osg::PrimitiveSet, bool > ("supportsBufferObject", false, &osg::PrimitiveSet::supportsBufferObject, 0, osgDB::BaseSerializer::RW_BOOL )
);
#endif
}
}
@@ -49,6 +88,20 @@ REGISTER_OBJECT_WRAPPER( DrawArrays,
}
namespace DrawArrayLengthsWrapper {
REGISTER_OBJECT_WRAPPER( DrawArrayLengths,
new osg::DrawArrayLengths,
osg::DrawArrayLengths,
"osg::Object osg::PrimitiveSet osg::DrawArrayLengths" )
{
ADD_GLINT_SERIALIZER( First, 0);
ADD_ISAVECTOR_SERIALIZER( vector, osgDB::BaseSerializer::RW_INT, 4 );
}
}
#if 0
namespace DrawElementsWrapper {
struct ResizeDrawElements : public osgDB::MethodObject
@@ -74,7 +127,6 @@ struct ResizeDrawElements : public osgDB::MethodObject
}
};
REGISTER_OBJECT_WRAPPER( DrawElements,
0,
osg::DrawElements,
@@ -84,10 +136,16 @@ REGISTER_OBJECT_WRAPPER( DrawElements,
}
}
#endif
#define DRAW_ELEMENTS_WRAPPER( DRAWELEMENTS ) \
namespace Wrapper##DRAWELEMENTS { REGISTER_OBJECT_WRAPPER( DRAWELEMENTS, new osg::DRAWELEMENTS, osg::DRAWELEMENTS, "osg::Object osg::PrimitiveSet osg::DrawElements "#DRAWELEMENTS) {} }
#define DRAW_ELEMENTS_WRAPPER( DRAWELEMENTS, ELEMENTTYPE ) \
namespace Wrapper##DRAWELEMENTS { \
REGISTER_OBJECT_WRAPPER( DRAWELEMENTS, new osg::DRAWELEMENTS, osg::DRAWELEMENTS, "osg::Object osg::PrimitiveSet osg::"#DRAWELEMENTS) \
{ \
ADD_ISAVECTOR_SERIALIZER( vector, osgDB::BaseSerializer::ELEMENTTYPE, 4 ); \
} \
}
DRAW_ELEMENTS_WRAPPER( DrawElementsUByte )
DRAW_ELEMENTS_WRAPPER( DrawElementsUShort )
DRAW_ELEMENTS_WRAPPER( DrawElementsUInt )
DRAW_ELEMENTS_WRAPPER( DrawElementsUByte, RW_UCHAR )
DRAW_ELEMENTS_WRAPPER( DrawElementsUShort, RW_USHORT )
DRAW_ELEMENTS_WRAPPER( DrawElementsUInt, RW_UINT )