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

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

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1
2#include <osgParticle/ParticleProcessor>
3#include <osgParticle/ParticleSystem>
4
5#include <iostream>
6
7#include <osg/ref_ptr>
8
9#include <osgDB/Registry>
10#include <osgDB/Input>
11#include <osgDB/Output>
12
13extern bool  read_particle(osgDB::Input &fr, osgParticle::Particle &P);
14extern void  write_particle(const osgParticle::Particle &P, osgDB::Output &fw);
15
16bool  ParticleProcessor_readLocalData(osg::Object &obj, osgDB::Input &fr);
17bool  ParticleProcessor_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
18
19REGISTER_DOTOSGWRAPPER(ParticleProcessor_Proxy)
20(
21    0,
22    "ParticleProcessor",
23    "Object Node ParticleProcessor",
24    ParticleProcessor_readLocalData,
25    ParticleProcessor_writeLocalData
26);
27
28bool ParticleProcessor_readLocalData(osg::Object &obj, osgDB::Input &fr)
29{
30    osgParticle::ParticleProcessor &myobj = static_cast<osgParticle::ParticleProcessor &>(obj);
31    bool itAdvanced = false;
32
33    osg::ref_ptr<osgParticle::ParticleSystem> ps_proto = new osgParticle::ParticleSystem;
34
35    osgParticle::ParticleSystem *ps = static_cast<osgParticle::ParticleSystem *>(fr.readObjectOfType(*ps_proto));
36    if (ps) {
37        myobj.setParticleSystem(ps);
38        itAdvanced = true;
39    }
40
41    if (fr[0].matchWord("enabled")) {
42        if (fr[1].matchWord("TRUE")) {
43            myobj.setEnabled(true);
44            fr += 2;
45            itAdvanced = true;
46        } else if (fr[1].matchWord("FALSE")) {
47            myobj.setEnabled(false);
48            fr += 2;
49            itAdvanced = true;
50        }
51    }
52
53    if (fr[0].matchWord("referenceFrame")) {
54        if (fr[1].matchWord("RELATIVE_TO_ABSOLUTE") || fr[1].matchWord("ABSOLUTE")) {
55            myobj.setReferenceFrame(osgParticle::ParticleProcessor::ABSOLUTE_RF);
56            fr += 2;
57            itAdvanced = true;
58        }
59        if (fr[1].matchWord("RELATIVE_TO_PARENTS") || fr[1].matchWord("RELATIVE")) {
60            myobj.setReferenceFrame(osgParticle::ParticleProcessor::RELATIVE_RF);
61            fr += 2;
62            itAdvanced = true;
63        }
64    }
65
66    if (fr[0].matchWord("endless")) {
67        if (fr[1].matchWord("TRUE")) {
68            myobj.setEndless(true);
69            fr += 2;
70            itAdvanced = true;
71        } else if (fr[1].matchWord("FALSE")) {
72            myobj.setEndless(false);
73            fr += 2;
74            itAdvanced = true;
75        }
76    }
77
78    if (fr[0].matchWord("lifeTime")) {
79        float lt;
80        if (fr[1].getFloat(lt)) {
81            myobj.setLifeTime(lt);
82            fr += 2;
83            itAdvanced = true;
84        }
85    }
86
87    if (fr[0].matchWord("startTime")) {
88        float st;
89        if (fr[1].getFloat(st)) {
90            myobj.setStartTime(st);
91            fr += 2;
92            itAdvanced = true;
93        }
94    }
95
96    if (fr[0].matchWord("currentTime")) {
97        float ct;
98        if (fr[1].getFloat(ct)) {
99            myobj.setCurrentTime(ct);
100            fr += 2;
101            itAdvanced = true;
102        }
103    }
104
105    if (fr[0].matchWord("resetTime")) {
106        float ct;
107        if (fr[1].getFloat(ct)) {
108            myobj.setResetTime(ct);
109            fr += 2;
110            itAdvanced = true;
111        }
112    }
113
114    return itAdvanced;
115}
116
117bool ParticleProcessor_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
118{
119    const osgParticle::ParticleProcessor &myobj = static_cast<const osgParticle::ParticleProcessor &>(obj);
120
121    if (myobj.getParticleSystem()) fw.writeObject(*myobj.getParticleSystem());
122
123    fw.indent() << "enabled ";
124    if (myobj.isEnabled())
125        fw << "TRUE" << std::endl;
126    else
127        fw << "FALSE" << std::endl;
128
129    fw.indent() << "referenceFrame ";
130    switch (myobj.getReferenceFrame())
131    {
132    case osgParticle::ParticleProcessor::ABSOLUTE_RF:
133        fw << "ABSOLUTE" << std::endl;
134        break;
135    case osgParticle::ParticleProcessor::RELATIVE_RF:
136    default:
137        fw << "RELATIVE" << std::endl;
138    }
139
140    fw.indent() << "endless ";
141    if (myobj.isEndless())
142        fw << "TRUE" << std::endl;
143    else
144        fw << "FALSE" << std::endl;
145
146    fw.indent() << "lifeTime " << myobj.getLifeTime() << std::endl;
147    fw.indent() << "startTime " << myobj.getStartTime() << std::endl;
148    fw.indent() << "currentTime " << myobj.getCurrentTime() << std::endl;
149    fw.indent() << "resetTime " << myobj.getResetTime() << std::endl;
150
151    return true;
152}
Note: See TracBrowser for help on using the browser.