root/OpenSceneGraph/trunk/src/osgWrappers/serializers/osgParticle/MultiSegmentPlacer.cpp @ 11020

Revision 11020, 1.3 kB (checked in by robert, 5 years ago)

From Wang Rui, added osgParticle serializers

Line 
1#include <osgParticle/MultiSegmentPlacer>
2#include <osgDB/ObjectWrapper>
3#include <osgDB/InputStream>
4#include <osgDB/OutputStream>
5
6static bool checkVertices( const osgParticle::MultiSegmentPlacer& placer )
7{
8    return placer.numVertices()>0;
9}
10
11static bool readVertices( osgDB::InputStream& is, osgParticle::MultiSegmentPlacer& placer )
12{
13    unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
14    for ( unsigned int i=0; i<size; ++i )
15    {
16        osg::Vec3d vec; is >> vec;
17        placer.addVertex( vec );
18    }
19    is >> osgDB::END_BRACKET;
20    return true;
21}
22
23static bool writeVertices( osgDB::OutputStream& os, const osgParticle::MultiSegmentPlacer& placer )
24{
25    unsigned int size = placer.numVertices();
26    os << size << osgDB::BEGIN_BRACKET << std::endl;
27    for ( unsigned int i=0; i<size; ++i )
28    {
29        os << osg::Vec3d(placer.getVertex(i));
30    }
31    os << std::endl;
32    os << osgDB::END_BRACKET << std::endl;
33    return true;
34}
35
36REGISTER_OBJECT_WRAPPER( osgParticleMultiSegmentPlacer,
37                         new osgParticle::MultiSegmentPlacer,
38                         osgParticle::MultiSegmentPlacer,
39                         "osg::Object osgParticle::Placer osgParticle::MultiSegmentPlacer" )
40{
41    ADD_USER_SERIALIZER( Vertices );  // _vx
42}
Note: See TracBrowser for help on using the browser.