| 1 | #include <osgSim/DOFTransform> |
|---|
| 2 | #include <osgDB/ObjectWrapper> |
|---|
| 3 | #include <osgDB/InputStream> |
|---|
| 4 | #include <osgDB/OutputStream> |
|---|
| 5 | |
|---|
| 6 | static bool checkPutMatrix( const osgSim::DOFTransform& dof ) |
|---|
| 7 | { return !dof.getPutMatrix().isIdentity(); } |
|---|
| 8 | |
|---|
| 9 | static bool readPutMatrix( osgDB::InputStream& is, osgSim::DOFTransform& dof ) |
|---|
| 10 | { |
|---|
| 11 | osg::Matrixf put; is >> put; |
|---|
| 12 | dof.setPutMatrix( put ); |
|---|
| 13 | dof.setInversePutMatrix( osg::Matrix::inverse(put) ); |
|---|
| 14 | return true; |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | static bool writePutMatrix( osgDB::OutputStream& os, const osgSim::DOFTransform& dof ) |
|---|
| 18 | { |
|---|
| 19 | osg::Matrixf put = dof.getPutMatrix(); |
|---|
| 20 | os << put << std::endl; |
|---|
| 21 | return true; |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | static bool checkLimitationFlags( const osgSim::DOFTransform& dof ) |
|---|
| 25 | { return dof.getLimitationFlags()>0; } |
|---|
| 26 | |
|---|
| 27 | static bool readLimitationFlags( osgDB::InputStream& is, osgSim::DOFTransform& dof ) |
|---|
| 28 | { |
|---|
| 29 | unsigned long flags; is >> flags; |
|---|
| 30 | dof.setLimitationFlags( flags );; |
|---|
| 31 | return true; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | static bool writeLimitationFlags( osgDB::OutputStream& os, const osgSim::DOFTransform& dof ) |
|---|
| 35 | { |
|---|
| 36 | os << dof.getLimitationFlags() << std::endl; |
|---|
| 37 | return true; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | REGISTER_OBJECT_WRAPPER( osgSim_DOFTransform, |
|---|
| 41 | new osgSim::DOFTransform, |
|---|
| 42 | osgSim::DOFTransform, |
|---|
| 43 | "osg::Object osg::Node osg::Group osg::Transform osgSim::DOFTransform" ) |
|---|
| 44 | { |
|---|
| 45 | ADD_VEC3_SERIALIZER( MinHPR, osg::Vec3() ); |
|---|
| 46 | ADD_VEC3_SERIALIZER( MaxHPR, osg::Vec3() ); |
|---|
| 47 | ADD_VEC3_SERIALIZER( CurrentHPR, osg::Vec3() ); |
|---|
| 48 | ADD_VEC3_SERIALIZER( IncrementHPR, osg::Vec3() ); |
|---|
| 49 | ADD_VEC3_SERIALIZER( MinTranslate, osg::Vec3() ); |
|---|
| 50 | ADD_VEC3_SERIALIZER( MaxTranslate, osg::Vec3() ); |
|---|
| 51 | ADD_VEC3_SERIALIZER( CurrentTranslate, osg::Vec3() ); |
|---|
| 52 | ADD_VEC3_SERIALIZER( IncrementTranslate, osg::Vec3() ); |
|---|
| 53 | ADD_VEC3_SERIALIZER( MinScale, osg::Vec3() ); |
|---|
| 54 | ADD_VEC3_SERIALIZER( MaxScale, osg::Vec3() ); |
|---|
| 55 | ADD_VEC3_SERIALIZER( CurrentScale, osg::Vec3() ); |
|---|
| 56 | ADD_VEC3_SERIALIZER( IncrementScale, osg::Vec3() ); |
|---|
| 57 | ADD_USER_SERIALIZER( PutMatrix ); |
|---|
| 58 | ADD_USER_SERIALIZER( LimitationFlags ); |
|---|
| 59 | ADD_BOOL_SERIALIZER( AnimationOn, false ); |
|---|
| 60 | |
|---|
| 61 | BEGIN_ENUM_SERIALIZER2( HPRMultOrder, osgSim::DOFTransform::MultOrder, PRH ); |
|---|
| 62 | ADD_ENUM_VALUE( PRH ); |
|---|
| 63 | ADD_ENUM_VALUE( PHR ); |
|---|
| 64 | ADD_ENUM_VALUE( HPR ); |
|---|
| 65 | ADD_ENUM_VALUE( HRP ); |
|---|
| 66 | ADD_ENUM_VALUE( RPH ); |
|---|
| 67 | ADD_ENUM_VALUE( RHP ); |
|---|
| 68 | END_ENUM_SERIALIZER(); |
|---|
| 69 | } |
|---|