| 1 | #include <osg/Billboard> |
|---|
| 2 | #include <osgDB/ObjectWrapper> |
|---|
| 3 | #include <osgDB/InputStream> |
|---|
| 4 | #include <osgDB/OutputStream> |
|---|
| 5 | |
|---|
| 6 | static bool checkPositionList( const osg::Billboard& node ) |
|---|
| 7 | { |
|---|
| 8 | return node.getPositionList().size()>0; |
|---|
| 9 | } |
|---|
| 10 | |
|---|
| 11 | static bool readPositionList( osgDB::InputStream& is, osg::Billboard& node ) |
|---|
| 12 | { |
|---|
| 13 | unsigned int size = is.readSize(); |
|---|
| 14 | is >> osgDB::BEGIN_BRACKET; |
|---|
| 15 | for ( unsigned int i=0; i<size; ++i ) |
|---|
| 16 | { |
|---|
| 17 | osg::Vec3d pos; is >> pos; |
|---|
| 18 | node.setPosition( i, pos ); |
|---|
| 19 | } |
|---|
| 20 | is >> osgDB::END_BRACKET; |
|---|
| 21 | return true; |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | static bool writePositionList( osgDB::OutputStream& os, const osg::Billboard& node ) |
|---|
| 25 | { |
|---|
| 26 | const osg::Billboard::PositionList& posList = node.getPositionList(); |
|---|
| 27 | os.writeSize(posList.size()); |
|---|
| 28 | os<< osgDB::BEGIN_BRACKET << std::endl; |
|---|
| 29 | for ( osg::Billboard::PositionList::const_iterator itr=posList.begin(); |
|---|
| 30 | itr!=posList.end(); ++itr ) |
|---|
| 31 | { |
|---|
| 32 | os << osg::Vec3d(*itr) << std::endl; |
|---|
| 33 | } |
|---|
| 34 | os << osgDB::END_BRACKET << std::endl; |
|---|
| 35 | return true; |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | REGISTER_OBJECT_WRAPPER( Billboard, |
|---|
| 39 | new osg::Billboard, |
|---|
| 40 | osg::Billboard, |
|---|
| 41 | "osg::Object osg::Node osg::Geode osg::Billboard" ) |
|---|
| 42 | { |
|---|
| 43 | BEGIN_ENUM_SERIALIZER( Mode, AXIAL_ROT ); |
|---|
| 44 | ADD_ENUM_VALUE( POINT_ROT_EYE ); |
|---|
| 45 | ADD_ENUM_VALUE( POINT_ROT_WORLD ); |
|---|
| 46 | ADD_ENUM_VALUE( AXIAL_ROT ); |
|---|
| 47 | END_ENUM_SERIALIZER(); |
|---|
| 48 | |
|---|
| 49 | ADD_VEC3_SERIALIZER( Axis, osg::Vec3f() ); |
|---|
| 50 | ADD_VEC3_SERIALIZER( Normal, osg::Vec3f() ); |
|---|
| 51 | ADD_USER_SERIALIZER( PositionList ); |
|---|
| 52 | } |
|---|