| 1 | |
|---|
| 2 | #include <osgParticle/RadialShooter> |
|---|
| 3 | #include <osgParticle/range> |
|---|
| 4 | |
|---|
| 5 | #include <osgDB/Registry> |
|---|
| 6 | #include <osgDB/Input> |
|---|
| 7 | #include <osgDB/Output> |
|---|
| 8 | |
|---|
| 9 | bool RadialShooter_readLocalData(osg::Object &obj, osgDB::Input &fr); |
|---|
| 10 | bool RadialShooter_writeLocalData(const osg::Object &obj, osgDB::Output &fw); |
|---|
| 11 | |
|---|
| 12 | REGISTER_DOTOSGWRAPPER(RadialShooter_Proxy) |
|---|
| 13 | ( |
|---|
| 14 | new osgParticle::RadialShooter, |
|---|
| 15 | "RadialShooter", |
|---|
| 16 | "Object Shooter RadialShooter", |
|---|
| 17 | RadialShooter_readLocalData, |
|---|
| 18 | RadialShooter_writeLocalData |
|---|
| 19 | ); |
|---|
| 20 | |
|---|
| 21 | bool RadialShooter_readLocalData(osg::Object &obj, osgDB::Input &fr) |
|---|
| 22 | { |
|---|
| 23 | osgParticle::RadialShooter &myobj = static_cast<osgParticle::RadialShooter &>(obj); |
|---|
| 24 | bool itAdvanced = false; |
|---|
| 25 | |
|---|
| 26 | osgParticle::rangef r; |
|---|
| 27 | |
|---|
| 28 | if (fr[0].matchWord("thetaRange")) { |
|---|
| 29 | if (fr[1].getFloat(r.minimum) && fr[2].getFloat(r.maximum)) { |
|---|
| 30 | myobj.setThetaRange(r); |
|---|
| 31 | fr += 3; |
|---|
| 32 | itAdvanced = true; |
|---|
| 33 | } |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | if (fr[0].matchWord("phiRange")) { |
|---|
| 37 | if (fr[1].getFloat(r.minimum) && fr[2].getFloat(r.maximum)) { |
|---|
| 38 | myobj.setPhiRange(r); |
|---|
| 39 | fr += 3; |
|---|
| 40 | itAdvanced = true; |
|---|
| 41 | } |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | if (fr[0].matchWord("initialSpeedRange")) { |
|---|
| 45 | if (fr[1].getFloat(r.minimum) && fr[2].getFloat(r.maximum)) { |
|---|
| 46 | myobj.setInitialSpeedRange(r); |
|---|
| 47 | fr += 3; |
|---|
| 48 | itAdvanced = true; |
|---|
| 49 | } |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | if (fr[0].matchWord("initialRotationalSpeedRange")) { |
|---|
| 53 | osg::Vec3 r1; |
|---|
| 54 | osg::Vec3 r2; |
|---|
| 55 | if (fr[1].getFloat(r1.x()) && fr[2].getFloat(r1.y()) && fr[3].getFloat(r1.z()) && \ |
|---|
| 56 | fr[4].getFloat(r2.x()) && fr[5].getFloat(r2.y()) && fr[6].getFloat(r2.z())) { |
|---|
| 57 | myobj.setInitialRotationalSpeedRange(r1,r2); |
|---|
| 58 | fr += 7; |
|---|
| 59 | itAdvanced = true; |
|---|
| 60 | } |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | return itAdvanced; |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | bool RadialShooter_writeLocalData(const osg::Object &obj, osgDB::Output &fw) |
|---|
| 67 | { |
|---|
| 68 | const osgParticle::RadialShooter &myobj = static_cast<const osgParticle::RadialShooter &>(obj); |
|---|
| 69 | osgParticle::rangef r; |
|---|
| 70 | |
|---|
| 71 | r = myobj.getThetaRange(); |
|---|
| 72 | fw.indent() << "thetaRange " << r.minimum << " " << r.maximum << std::endl; |
|---|
| 73 | r = myobj.getPhiRange(); |
|---|
| 74 | fw.indent() << "phiRange " << r.minimum << " " << r.maximum << std::endl; |
|---|
| 75 | r = myobj.getInitialSpeedRange(); |
|---|
| 76 | fw.indent() << "initialSpeedRange " << r.minimum << " " << r.maximum << std::endl; |
|---|
| 77 | |
|---|
| 78 | osgParticle::rangev3 rv = myobj.getInitialRotationalSpeedRange(); |
|---|
| 79 | osg::Vec3 v1 = rv.minimum; |
|---|
| 80 | osg::Vec3 v2 = rv.maximum; |
|---|
| 81 | fw.indent() << "initialRotationalSpeedRange "; |
|---|
| 82 | fw << v1.x() << " " << v1.y() << " " << v1.z() << " "; |
|---|
| 83 | fw << v2.x() << " " << v2.y() << " " << v2.z() << std::endl; |
|---|
| 84 | |
|---|
| 85 | return true; |
|---|
| 86 | } |
|---|