| 1 | #include <osg/ClusterCullingCallback> |
|---|
| 2 | #include <osg/io_utils> |
|---|
| 3 | |
|---|
| 4 | #include <osgDB/Registry> |
|---|
| 5 | #include <osgDB/Input> |
|---|
| 6 | #include <osgDB/Output> |
|---|
| 7 | |
|---|
| 8 | using namespace osg; |
|---|
| 9 | using namespace osgDB; |
|---|
| 10 | |
|---|
| 11 | bool ClusterCullingCallback_readLocalData(osg::Object &obj, osgDB::Input &fr); |
|---|
| 12 | bool ClusterCullingCallback_writeLocalData(const osg::Object &obj, osgDB::Output &fw); |
|---|
| 13 | |
|---|
| 14 | REGISTER_DOTOSGWRAPPER(ClusterCullingCallback) |
|---|
| 15 | ( |
|---|
| 16 | new ClusterCullingCallback, |
|---|
| 17 | "ClusterCullingCallback", |
|---|
| 18 | "Object ClusterCullingCallback", |
|---|
| 19 | &ClusterCullingCallback_readLocalData, |
|---|
| 20 | &ClusterCullingCallback_writeLocalData |
|---|
| 21 | ); |
|---|
| 22 | |
|---|
| 23 | bool ClusterCullingCallback_readLocalData(osg::Object &obj, osgDB::Input &fr) |
|---|
| 24 | { |
|---|
| 25 | ClusterCullingCallback* ccc = dynamic_cast<ClusterCullingCallback*>(&obj); |
|---|
| 26 | if (!ccc) return false; |
|---|
| 27 | |
|---|
| 28 | bool iteratorAdvanced = false; |
|---|
| 29 | |
|---|
| 30 | osg::Vec3 vec; |
|---|
| 31 | if (fr[0].matchWord("controlPoint") && |
|---|
| 32 | fr[1].getFloat(vec[0]) && fr[2].getFloat(vec[1]) && fr[3].getFloat(vec[2])) |
|---|
| 33 | { |
|---|
| 34 | ccc->setControlPoint(vec); |
|---|
| 35 | fr += 4; |
|---|
| 36 | iteratorAdvanced = true; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | if (fr[0].matchWord("normal") && |
|---|
| 40 | fr[1].getFloat(vec[0]) && fr[2].getFloat(vec[1]) && fr[3].getFloat(vec[2])) |
|---|
| 41 | { |
|---|
| 42 | ccc->setNormal(vec); |
|---|
| 43 | fr += 4; |
|---|
| 44 | iteratorAdvanced = true; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | float value; |
|---|
| 48 | if (fr[0].matchWord("radius") && fr[1].getFloat(value)) |
|---|
| 49 | { |
|---|
| 50 | ccc->setRadius(value); |
|---|
| 51 | fr += 2; |
|---|
| 52 | iteratorAdvanced = true; |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | if (fr[0].matchWord("deviation") && fr[1].getFloat(value)) |
|---|
| 56 | { |
|---|
| 57 | ccc->setDeviation(value); |
|---|
| 58 | fr += 2; |
|---|
| 59 | iteratorAdvanced = true; |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | return iteratorAdvanced; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | bool ClusterCullingCallback_writeLocalData(const osg::Object &obj, osgDB::Output &fw) |
|---|
| 66 | { |
|---|
| 67 | const ClusterCullingCallback* ccc = dynamic_cast<const ClusterCullingCallback*>(&obj); |
|---|
| 68 | if (!ccc) return false; |
|---|
| 69 | |
|---|
| 70 | int prec = fw.precision(); |
|---|
| 71 | fw.precision(15); |
|---|
| 72 | |
|---|
| 73 | fw.indent() << "controlPoint " << ccc->getControlPoint() << std::endl; |
|---|
| 74 | fw.indent() << "normal " << ccc->getNormal() << std::endl; |
|---|
| 75 | fw.indent() << "radius " << ccc->getRadius() << std::endl; |
|---|
| 76 | fw.indent() << "deviation " << ccc->getDeviation() << std::endl; |
|---|
| 77 | |
|---|
| 78 | fw.precision(prec); |
|---|
| 79 | |
|---|
| 80 | return true; |
|---|
| 81 | } |
|---|