| 1 | #include <osgVolume/Property> |
|---|
| 2 | |
|---|
| 3 | #include <iostream> |
|---|
| 4 | #include <string> |
|---|
| 5 | |
|---|
| 6 | #include <osg/Vec3> |
|---|
| 7 | #include <osg/Vec4> |
|---|
| 8 | #include <osg/io_utils> |
|---|
| 9 | |
|---|
| 10 | #include <osgDB/ReadFile> |
|---|
| 11 | #include <osgDB/Registry> |
|---|
| 12 | #include <osgDB/Input> |
|---|
| 13 | #include <osgDB/Output> |
|---|
| 14 | #include <osgDB/ParameterOutput> |
|---|
| 15 | |
|---|
| 16 | bool CompositeProperty_readLocalData(osg::Object &obj, osgDB::Input &fr); |
|---|
| 17 | bool CompositeProperty_writeLocalData(const osg::Object &obj, osgDB::Output &fw); |
|---|
| 18 | |
|---|
| 19 | REGISTER_DOTOSGWRAPPER(CompositeProperty_Proxy) |
|---|
| 20 | ( |
|---|
| 21 | new osgVolume::CompositeProperty, |
|---|
| 22 | "CompositeProperty", |
|---|
| 23 | "Object CompositeProperty", |
|---|
| 24 | CompositeProperty_readLocalData, |
|---|
| 25 | CompositeProperty_writeLocalData |
|---|
| 26 | ); |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | bool CompositeProperty_readLocalData(osg::Object& obj, osgDB::Input &fr) |
|---|
| 30 | { |
|---|
| 31 | osgVolume::CompositeProperty& cp = static_cast<osgVolume::CompositeProperty&>(obj); |
|---|
| 32 | |
|---|
| 33 | bool itrAdvanced = false; |
|---|
| 34 | |
|---|
| 35 | osg::ref_ptr<osg::Object> readObject; |
|---|
| 36 | do |
|---|
| 37 | { |
|---|
| 38 | readObject = fr.readObjectOfType(osgDB::type_wrapper<osgVolume::Property>()); |
|---|
| 39 | if (readObject.valid()) itrAdvanced = true; |
|---|
| 40 | |
|---|
| 41 | osgVolume::Property* property = dynamic_cast<osgVolume::Property*>(readObject.get()); |
|---|
| 42 | if (property) cp.addProperty(property); |
|---|
| 43 | |
|---|
| 44 | } while (readObject.valid()); |
|---|
| 45 | |
|---|
| 46 | return itrAdvanced; |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | bool CompositeProperty_writeLocalData(const osg::Object& obj, osgDB::Output& fw) |
|---|
| 50 | { |
|---|
| 51 | const osgVolume::CompositeProperty& cp = static_cast<const osgVolume::CompositeProperty&>(obj); |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | for(unsigned int i=0; i<cp.getNumProperties(); ++i) |
|---|
| 55 | { |
|---|
| 56 | fw.writeObject(*cp.getProperty(i)); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | return true; |
|---|
| 60 | } |
|---|