| 1 | |
|---|
| 2 | #include <osgParticle/DampingOperator> |
|---|
| 3 | |
|---|
| 4 | #include <osgDB/Registry> |
|---|
| 5 | #include <osgDB/Input> |
|---|
| 6 | #include <osgDB/Output> |
|---|
| 7 | |
|---|
| 8 | #include <osg/Vec3> |
|---|
| 9 | |
|---|
| 10 | #include <iostream> |
|---|
| 11 | |
|---|
| 12 | bool DampingOperator_readLocalData(osg::Object &obj, osgDB::Input &fr); |
|---|
| 13 | bool DampingOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw); |
|---|
| 14 | |
|---|
| 15 | REGISTER_DOTOSGWRAPPER(DampingOperator_Proxy) |
|---|
| 16 | ( |
|---|
| 17 | new osgParticle::DampingOperator, |
|---|
| 18 | "DampingOperator", |
|---|
| 19 | "Object Operator DampingOperator", |
|---|
| 20 | DampingOperator_readLocalData, |
|---|
| 21 | DampingOperator_writeLocalData |
|---|
| 22 | ); |
|---|
| 23 | |
|---|
| 24 | bool DampingOperator_readLocalData(osg::Object &obj, osgDB::Input &fr) |
|---|
| 25 | { |
|---|
| 26 | osgParticle::DampingOperator &dp = static_cast<osgParticle::DampingOperator &>(obj); |
|---|
| 27 | bool itAdvanced = false; |
|---|
| 28 | |
|---|
| 29 | osg::Vec3 a; |
|---|
| 30 | if (fr[0].matchWord("damping")) { |
|---|
| 31 | if (fr[1].getFloat(a.x()) && fr[2].getFloat(a.y()) && fr[3].getFloat(a.z())) { |
|---|
| 32 | dp.setDamping(a); |
|---|
| 33 | fr += 4; |
|---|
| 34 | itAdvanced = true; |
|---|
| 35 | } |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | float low = 0.0f, high = FLT_MAX; |
|---|
| 39 | if (fr[0].matchWord("cutoff")) { |
|---|
| 40 | if (fr[1].getFloat(low) && fr[2].getFloat(high)) { |
|---|
| 41 | dp.setCutoff(low, high); |
|---|
| 42 | fr += 3; |
|---|
| 43 | itAdvanced = true; |
|---|
| 44 | } |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | return itAdvanced; |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | bool DampingOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw) |
|---|
| 51 | { |
|---|
| 52 | const osgParticle::DampingOperator &dp = static_cast<const osgParticle::DampingOperator &>(obj); |
|---|
| 53 | osg::Vec3 a = dp.getDamping(); |
|---|
| 54 | fw.indent() << "damping " << a.x() << " " << a.y() << " " << a.z() << std::endl; |
|---|
| 55 | |
|---|
| 56 | float low = dp.getCutoffLow(), high = dp.getCutoffHigh(); |
|---|
| 57 | fw.indent() << "cutoff " << low << " " << high << std::endl; |
|---|
| 58 | return true; |
|---|
| 59 | } |
|---|