| 1 | #include <osgVolume/VolumeTile> |
|---|
| 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 VolumeTile_readLocalData(osg::Object &obj, osgDB::Input &fr); |
|---|
| 17 | bool VolumeTile_writeLocalData(const osg::Object &obj, osgDB::Output &fw); |
|---|
| 18 | |
|---|
| 19 | REGISTER_DOTOSGWRAPPER(VolumeTile_Proxy) |
|---|
| 20 | ( |
|---|
| 21 | new osgVolume::VolumeTile, |
|---|
| 22 | "VolumeTile", |
|---|
| 23 | "Object Node VolumeTile Group", |
|---|
| 24 | VolumeTile_readLocalData, |
|---|
| 25 | VolumeTile_writeLocalData |
|---|
| 26 | ); |
|---|
| 27 | |
|---|
| 28 | bool VolumeTile_readLocalData(osg::Object& obj, osgDB::Input &fr) |
|---|
| 29 | { |
|---|
| 30 | osgVolume::VolumeTile& volumeTile = static_cast<osgVolume::VolumeTile&>(obj); |
|---|
| 31 | |
|---|
| 32 | bool itrAdvanced = false; |
|---|
| 33 | |
|---|
| 34 | osg::ref_ptr<osg::Object> readObject = fr.readObjectOfType(osgDB::type_wrapper<osgVolume::Locator>()); |
|---|
| 35 | if (readObject.valid()) itrAdvanced = true; |
|---|
| 36 | |
|---|
| 37 | osgVolume::Locator* locator = dynamic_cast<osgVolume::Locator*>(readObject.get()); |
|---|
| 38 | if (locator) volumeTile.setLocator(locator); |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | readObject = fr.readObjectOfType(osgDB::type_wrapper<osgVolume::Layer>()); |
|---|
| 42 | if (readObject.valid()) itrAdvanced = true; |
|---|
| 43 | |
|---|
| 44 | osgVolume::Layer* readLayer = dynamic_cast<osgVolume::Layer*>(readObject.get()); |
|---|
| 45 | if (readLayer) volumeTile.setLayer(readLayer); |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | readObject = fr.readObjectOfType(osgDB::type_wrapper<osgVolume::VolumeTechnique>()); |
|---|
| 49 | if (readObject.valid()) |
|---|
| 50 | { |
|---|
| 51 | volumeTile.setVolumeTechnique(dynamic_cast<osgVolume::VolumeTechnique*>(readObject.get())); |
|---|
| 52 | itrAdvanced = true; |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | return itrAdvanced; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | bool VolumeTile_writeLocalData(const osg::Object& obj, osgDB::Output& fw) |
|---|
| 59 | { |
|---|
| 60 | const osgVolume::VolumeTile& volumeTile = static_cast<const osgVolume::VolumeTile&>(obj); |
|---|
| 61 | |
|---|
| 62 | int prec = fw.precision(); |
|---|
| 63 | fw.precision(15); |
|---|
| 64 | |
|---|
| 65 | if (volumeTile.getLocator()) |
|---|
| 66 | { |
|---|
| 67 | fw.writeObject(*volumeTile.getLocator()); |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | if (volumeTile.getLayer()) |
|---|
| 71 | { |
|---|
| 72 | fw.writeObject(*volumeTile.getLayer()); |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | if (volumeTile.getVolumeTechnique()) |
|---|
| 76 | { |
|---|
| 77 | fw.writeObject(*volumeTile.getVolumeTechnique()); |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | fw.precision(prec); |
|---|
| 81 | |
|---|
| 82 | return true; |
|---|
| 83 | } |
|---|