From b5d00a145009fc66b07db05a419d9c672020fac2 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 2 Jun 2011 22:05:10 +0000 Subject: [PATCH] Added support for new osg::Object user objects. --- src/osgWrappers/serializers/osg/Object.cpp | 35 +++++++++++++++ .../serializers/osg/ValueObject.cpp | 45 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 src/osgWrappers/serializers/osg/ValueObject.cpp diff --git a/src/osgWrappers/serializers/osg/Object.cpp b/src/osgWrappers/serializers/osg/Object.cpp index 273222922..9a9973a5a 100644 --- a/src/osgWrappers/serializers/osg/Object.cpp +++ b/src/osgWrappers/serializers/osg/Object.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +#include static bool checkUserData( const osg::Object& obj ) { @@ -25,6 +27,34 @@ static bool writeUserData( osgDB::OutputStream& os, const osg::Object& obj ) return true; } +static bool checkUserObjects( const osg::Object& obj ) +{ + return obj.getNumUserObjects()>0; +} + +static bool readUserObjects( osgDB::InputStream& is, osg::Object& obj ) +{ + unsigned int size = is.readSize(); is >> osgDB::BEGIN_BRACKET; + for( unsigned int i=0; i> osgDB::END_BRACKET; + return true; +} + +static bool writeUserObjects( osgDB::OutputStream& os, const osg::Object& obj ) +{ + unsigned int numObjects = obj.getNumUserObjects(); + os.writeSize(numObjects); os << osgDB::BEGIN_BRACKET << std::endl; + for ( unsigned int i=0; i +#include +#include +#include +#include +#include + +#define WRAPVALUEOBJECT( TYPE, INHERITANCE_STRING, SERIALIZER_TYPE, DEFAULT) \ + namespace Wrap##TYPE \ + { \ + REGISTER_OBJECT_WRAPPER( TYPE, \ + new osg::TYPE, \ + osg::TYPE, \ + INHERITANCE_STRING ) \ + { \ + SERIALIZER_TYPE( Value, DEFAULT ); \ + } \ + } \ + + +WRAPVALUEOBJECT( BoolValueObject, "osg::Object osg::BoolValueObject", ADD_REF_BOOL_SERIALIZER, 0) +WRAPVALUEOBJECT( CharValueObject, "osg::Object osg::CharValueObject", ADD_REF_CHAR_SERIALIZER, 0) +WRAPVALUEOBJECT( UCharValueObject, "osg::Object osg::UCharValueObject", ADD_REF_UCHAR_SERIALIZER, 0u) +WRAPVALUEOBJECT( ShortValueObject, "osg::Object osg::ShortValueObject", ADD_REF_SHORT_SERIALIZER, 0) +WRAPVALUEOBJECT( UShortValueObject, "osg::Object osg::UShortValueObject", ADD_REF_USHORT_SERIALIZER, 0u) +WRAPVALUEOBJECT( IntValueObject, "osg::Object osg::IntValueObject", ADD_REF_INT_SERIALIZER, 0) +WRAPVALUEOBJECT( UIntValueObject, "osg::Object osg::UIntValueObject", ADD_REF_UINT_SERIALIZER, 0u) +WRAPVALUEOBJECT( FloatValueObject, "osg::Object osg::FloatValueObject", ADD_REF_FLOAT_SERIALIZER, 0.0f) +WRAPVALUEOBJECT( DoubleValueObject, "osg::Object osg::DoubleValueObject", ADD_REF_DOUBLE_SERIALIZER, 0.0) + +WRAPVALUEOBJECT( StringValueObject, "osg::Object osg::StringValueObject", ADD_STRING_SERIALIZER, std::string()) + +WRAPVALUEOBJECT( Vec2fValueObject, "osg::Object osg::Vec2fValueObject", ADD_VEC2F_SERIALIZER, osg::Vec2f()) +WRAPVALUEOBJECT( Vec3fValueObject, "osg::Object osg::Vec3fValueObject", ADD_VEC3F_SERIALIZER, osg::Vec3f()) +WRAPVALUEOBJECT( Vec4fValueObject, "osg::Object osg::Vec4fValueObject", ADD_VEC4F_SERIALIZER, osg::Vec4f()) + +WRAPVALUEOBJECT( Vec2dValueObject, "osg::Object osg::Vec2dValueObject", ADD_VEC2D_SERIALIZER, osg::Vec2d()) +WRAPVALUEOBJECT( Vec3dValueObject, "osg::Object osg::Vec3dValueObject", ADD_VEC3D_SERIALIZER, osg::Vec3d()) +WRAPVALUEOBJECT( Vec4dValueObject, "osg::Object osg::Vec4dValueObject", ADD_VEC4D_SERIALIZER, osg::Vec4d()) + +WRAPVALUEOBJECT( PlaneValueObject, "osg::Object osg::PlaneValueObject", ADD_PLANE_SERIALIZER, osg::Plane()) +WRAPVALUEOBJECT( QuatValueObject, "osg::Object osg::QuatValueObject", ADD_QUAT_SERIALIZER, osg::Quat()) + +WRAPVALUEOBJECT( MatrixfValueObject, "osg::Object osg::MatrixfValueObject", ADD_MATRIXF_SERIALIZER, osg::Matrixf()) +WRAPVALUEOBJECT( MatrixdValueObject, "osg::Object osg::MatrixdValueObject", ADD_MATRIXD_SERIALIZER, osg::Matrixd())