root/OpenSceneGraph/trunk/src/osgWrappers/serializers/osg/PolygonMode.cpp @ 13041

Revision 13041, 1.7 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1#include <osg/PolygonMode>
2#include <osgDB/ObjectWrapper>
3#include <osgDB/InputStream>
4#include <osgDB/OutputStream>
5
6BEGIN_USER_TABLE( Mode, osg::PolygonMode );
7    ADD_USER_VALUE( POINT );
8    ADD_USER_VALUE( LINE );
9    ADD_USER_VALUE( FILL );
10END_USER_TABLE()
11
12USER_READ_FUNC( Mode, readModeValue )
13USER_WRITE_FUNC( Mode, writeModeValue )
14
15// _modeFront, _modeBack
16static bool checkMode( const osg::PolygonMode& attr )
17{
18    return true;
19}
20
21static bool readMode( osgDB::InputStream& is, osg::PolygonMode& attr )
22{
23    bool frontAndBack;
24    is >> osgDB::PROPERTY("UseFrontAndBack") >> frontAndBack;
25    is >> osgDB::PROPERTY("Front"); int value1 = readModeValue(is);
26    is >> osgDB::PROPERTY("Back"); int value2 = readModeValue(is);
27
28    if ( frontAndBack )
29        attr.setMode( osg::PolygonMode::FRONT_AND_BACK, (osg::PolygonMode::Mode)value1 );
30    else
31    {
32        attr.setMode(osg::PolygonMode::FRONT, (osg::PolygonMode::Mode)value1);
33        attr.setMode(osg::PolygonMode::BACK, (osg::PolygonMode::Mode)value2);
34    }
35    return true;
36}
37
38static bool writeMode( osgDB::OutputStream& os, const osg::PolygonMode& attr )
39{
40    os << osgDB::PROPERTY("UseFrontAndBack") << attr.getFrontAndBack() << std::endl;
41
42    os << osgDB::PROPERTY("Front");
43    writeModeValue( os, (int)attr.getMode(osg::PolygonMode::FRONT) );
44    os << std::endl;
45
46    os << osgDB::PROPERTY("Back");
47    writeModeValue( os, (int)attr.getMode(osg::PolygonMode::BACK) );
48    os << std::endl;
49    return true;
50}
51
52REGISTER_OBJECT_WRAPPER( PolygonMode,
53                         new osg::PolygonMode,
54                         osg::PolygonMode,
55                         "osg::Object osg::StateAttribute osg::PolygonMode" )
56{
57    ADD_USER_SERIALIZER( Mode );  // _modeFront, _modeBack
58}
Note: See TracBrowser for help on using the browser.