| 1 | |
|---|
| 2 | #include <osgParticle/FluidFrictionOperator> |
|---|
| 3 | |
|---|
| 4 | #include <osg/io_utils> |
|---|
| 5 | |
|---|
| 6 | #include <osgDB/Registry> |
|---|
| 7 | #include <osgDB/Input> |
|---|
| 8 | #include <osgDB/Output> |
|---|
| 9 | |
|---|
| 10 | #include <iostream> |
|---|
| 11 | |
|---|
| 12 | bool FluidFrictionOperator_readLocalData(osg::Object &obj, osgDB::Input &fr); |
|---|
| 13 | bool FluidFrictionOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw); |
|---|
| 14 | |
|---|
| 15 | REGISTER_DOTOSGWRAPPER(FluidFrictionOperator_Proxy) |
|---|
| 16 | ( |
|---|
| 17 | new osgParticle::FluidFrictionOperator, |
|---|
| 18 | "FluidFrictionOperator", |
|---|
| 19 | "Object Operator FluidFrictionOperator", |
|---|
| 20 | FluidFrictionOperator_readLocalData, |
|---|
| 21 | FluidFrictionOperator_writeLocalData |
|---|
| 22 | ); |
|---|
| 23 | |
|---|
| 24 | bool FluidFrictionOperator_readLocalData(osg::Object &obj, osgDB::Input &fr) |
|---|
| 25 | { |
|---|
| 26 | osgParticle::FluidFrictionOperator &aop = static_cast<osgParticle::FluidFrictionOperator &>(obj); |
|---|
| 27 | bool itAdvanced = false; |
|---|
| 28 | |
|---|
| 29 | float f; |
|---|
| 30 | osg::Vec3 w; |
|---|
| 31 | |
|---|
| 32 | if (fr[0].matchWord("fluidDensity")) { |
|---|
| 33 | if (fr[1].getFloat(f)) { |
|---|
| 34 | aop.setFluidDensity(f); |
|---|
| 35 | fr += 2; |
|---|
| 36 | itAdvanced = true; |
|---|
| 37 | } |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | if (fr[0].matchWord("fluidViscosity")) { |
|---|
| 41 | if (fr[1].getFloat(f)) { |
|---|
| 42 | aop.setFluidViscosity(f); |
|---|
| 43 | fr += 2; |
|---|
| 44 | itAdvanced = true; |
|---|
| 45 | } |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | if (fr[0].matchWord("overrideRadius")) { |
|---|
| 49 | if (fr[1].getFloat(f)) { |
|---|
| 50 | aop.setOverrideRadius(f); |
|---|
| 51 | fr += 2; |
|---|
| 52 | itAdvanced = true; |
|---|
| 53 | } |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | if (fr[0].matchWord("wind")) { |
|---|
| 57 | if (fr[1].getFloat(w.x()) && fr[2].getFloat(w.y()) && fr[3].getFloat(w.z())) { |
|---|
| 58 | aop.setWind(w); |
|---|
| 59 | fr += 4; |
|---|
| 60 | itAdvanced = true; |
|---|
| 61 | } |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | return itAdvanced; |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | bool FluidFrictionOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw) |
|---|
| 68 | { |
|---|
| 69 | const osgParticle::FluidFrictionOperator &aop = static_cast<const osgParticle::FluidFrictionOperator &>(obj); |
|---|
| 70 | fw.indent() << "fluidDensity " << aop.getFluidDensity() << std::endl; |
|---|
| 71 | fw.indent() << "fluidViscosity " << aop.getFluidViscosity() << std::endl; |
|---|
| 72 | fw.indent() << "overrideRadius " << aop.getOverrideRadius() << std::endl; |
|---|
| 73 | |
|---|
| 74 | osg::Vec3 w = aop.getWind(); |
|---|
| 75 | fw.indent() << "wind " << w << std::endl; |
|---|
| 76 | return true; |
|---|
| 77 | } |
|---|