root/OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osgParticle/IO_SinkOperator.cpp @ 13041

Revision 13041, 2.6 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1
2#include <osgParticle/SinkOperator>
3
4#include <osgDB/Registry>
5#include <osgDB/Input>
6#include <osgDB/Output>
7
8#include <osg/Vec3>
9
10#include <iostream>
11
12bool  SinkOperator_readLocalData(osg::Object &obj, osgDB::Input &fr);
13bool  SinkOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
14
15REGISTER_DOTOSGWRAPPER(SinkOperator_Proxy)
16(
17    new osgParticle::SinkOperator,
18    "SinkOperator",
19    "Object Operator DomainOperator SinkOperator",
20    SinkOperator_readLocalData,
21    SinkOperator_writeLocalData
22);
23
24bool SinkOperator_readLocalData(osg::Object &obj, osgDB::Input &fr)
25{
26    osgParticle::SinkOperator &sp = static_cast<osgParticle::SinkOperator &>(obj);
27    bool itAdvanced = false;
28
29    if (fr[0].matchWord("sinkTarget")) {
30        const char *ptstr = fr[1].getStr();
31        if (ptstr) {
32            std::string str(ptstr);
33            if (str == "position")
34                sp.setSinkTarget(osgParticle::SinkOperator::SINK_POSITION);
35            else if (str == "velocity")
36                sp.setSinkTarget(osgParticle::SinkOperator::SINK_VELOCITY);
37            else if (str == "angular_velocity")
38                sp.setSinkTarget(osgParticle::SinkOperator::SINK_ANGULAR_VELOCITY);
39
40            fr += 2;
41            itAdvanced = true;
42        }
43    }
44
45    if (fr[0].matchWord("sinkStrategy")) {
46        const char *ptstr = fr[1].getStr();
47        if (ptstr) {
48            std::string str(ptstr);
49            if (str == "inside")
50                sp.setSinkStrategy(osgParticle::SinkOperator::SINK_INSIDE);
51            else if (str == "outside")
52                sp.setSinkStrategy(osgParticle::SinkOperator::SINK_OUTSIDE);
53
54            fr += 2;
55            itAdvanced = true;
56        }
57    }
58
59    return itAdvanced;
60}
61
62bool SinkOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
63{
64    const osgParticle::SinkOperator &sp = static_cast<const osgParticle::SinkOperator &>(obj);
65
66    fw.indent() << "sinkTarget ";
67    switch (sp.getSinkTarget())
68    {
69    case osgParticle::SinkOperator::SINK_POSITION:
70        fw << "position" << std::endl; break;
71    case osgParticle::SinkOperator::SINK_VELOCITY:
72        fw << "velocity" << std::endl; break;
73    case osgParticle::SinkOperator::SINK_ANGULAR_VELOCITY:
74        fw << "angular_velocity" << std::endl; break;
75    default:
76        fw << "undefined" << std::endl; break;
77    }
78
79    fw.indent() << "sinkStrategy ";
80    switch (sp.getSinkStrategy())
81    {
82    case osgParticle::SinkOperator::SINK_INSIDE:
83        fw << "inside" << std::endl; break;
84    case osgParticle::SinkOperator::SINK_OUTSIDE:
85        fw << "outside" << std::endl; break;
86    default:
87        fw << "undefined" << std::endl; break;
88    }
89
90    return true;
91}
Note: See TracBrowser for help on using the browser.