root/OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osg/CompositeShape.cpp @ 13041

Revision 13041, 2.0 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1#include <osg/Shape>
2#include <osg/Notify>
3#include <osg/io_utils>
4
5#include <osgDB/Registry>
6#include <osgDB/Input>
7#include <osgDB/ParameterOutput>
8
9using namespace osg;
10using namespace osgDB;
11
12
13//////////////////////////////////////////////////////////////////////////////
14// forward declare functions to use later.
15bool CompositeShape_readLocalData(Object& obj, Input& fr);
16bool CompositeShape_writeLocalData(const Object& obj, Output& fw);
17
18//register the read and write functions with the osgDB::Registry.
19REGISTER_DOTOSGWRAPPER(CompositeShape)
20(
21    new osg::CompositeShape,
22    "CompositeShape",
23    "Object CompositeShape",
24    &CompositeShape_readLocalData,
25    &CompositeShape_writeLocalData,
26    DotOsgWrapper::READ_AND_WRITE
27);
28
29bool CompositeShape_readLocalData(Object& obj, Input& fr)
30{
31    bool iteratorAdvanced = false;
32
33    CompositeShape& composite = static_cast<CompositeShape&>(obj);
34
35    ref_ptr<Object> readObject;
36    if (fr[0].matchWord("Shape"))
37    {
38        readObject = fr.readObject();
39        if (readObject.valid())
40        {
41            osg::Shape* shape = dynamic_cast<osg::Shape*>(readObject.get());
42            if (shape) composite.setShape(shape);
43            else notify(WARN)<<"Warning:: "<<readObject->className()<<" loaded but cannot not be attached to Drawable."<<std::endl;
44            iteratorAdvanced = true;
45        }
46    }
47
48    while((readObject=fr.readObjectOfType(type_wrapper<osg::Shape>())).valid())
49    {
50        osg::Shape* shape = static_cast<osg::Shape*>(readObject.get());
51        composite.addChild(shape);
52        iteratorAdvanced = true;
53    }
54
55    return iteratorAdvanced;
56}
57
58bool CompositeShape_writeLocalData(const Object& obj, Output& fw)
59{
60    const CompositeShape& composite = static_cast<const CompositeShape&>(obj);
61
62    if (composite.getShape())
63    {
64        fw.indent() << "Shape ";
65        fw.writeObject(*composite.getShape());
66    }
67
68    for(unsigned int i=0;i<composite.getNumChildren();++i)
69    {
70        fw.writeObject(*composite.getChild(i));
71    }
72
73    return true;
74}
Note: See TracBrowser for help on using the browser.