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

Revision 13041, 2.2 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1
2#include <osgParticle/FluidProgram>
3#include <osgParticle/Operator>
4
5#include <iostream>
6
7#include <osg/Vec3>
8#include <osg/io_utils>
9
10#include <osgDB/Registry>
11#include <osgDB/Input>
12#include <osgDB/Output>
13
14bool  FluidProgram_readLocalData(osg::Object &obj, osgDB::Input &fr);
15bool  FluidProgram_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
16
17REGISTER_DOTOSGWRAPPER(FluidProgram_Proxy)
18(
19    new osgParticle::FluidProgram,
20    "FluidProgram",
21    "Object Node ParticleProcessor osgParticle::Program FluidProgram",
22    FluidProgram_readLocalData,
23    FluidProgram_writeLocalData
24);
25
26bool FluidProgram_readLocalData(osg::Object &obj, osgDB::Input &fr)
27{
28    osgParticle::FluidProgram &myobj = static_cast<osgParticle::FluidProgram &>(obj);
29    bool itAdvanced = false;
30
31    osg::Vec3 vec;
32    float f;
33
34    if (fr[0].matchWord("acceleration")) {
35        if (fr[1].getFloat(vec.x()) && fr[2].getFloat(vec.y()) && fr[3].getFloat(vec.z())) {
36            myobj.setAcceleration(vec);
37            fr += 4;
38            itAdvanced = true;
39        }
40    }
41
42    if (fr[0].matchWord("viscosity")) {
43        if (fr[1].getFloat(f)) {
44            myobj.setFluidViscosity(f);
45            fr += 2;
46            itAdvanced = true;
47        }
48    }
49
50    if (fr[0].matchWord("density")) {
51        if (fr[1].getFloat(f)) {
52            myobj.setFluidDensity(f);
53            fr += 2;
54            itAdvanced = true;
55        }
56    }
57
58    if (fr[0].matchWord("wind")) {
59        if (fr[1].getFloat(vec.x()) && fr[2].getFloat(vec.y()) && fr[3].getFloat(vec.z())) {
60            myobj.setWind(vec);
61            fr += 4;
62            itAdvanced = true;
63        }
64    }
65
66    return itAdvanced;
67}
68
69bool FluidProgram_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
70{
71    const osgParticle::FluidProgram &myobj = static_cast<const osgParticle::FluidProgram &>(obj);
72
73    osg::Vec3 vec;
74    float f;
75
76    vec = myobj.getAcceleration();
77    fw.indent() << "acceleration " << vec << std::endl;
78
79    f = myobj.getFluidViscosity();
80    fw.indent() << "viscosity " << f << std::endl;
81
82    f = myobj.getFluidDensity();
83    fw.indent() << "density " << f << std::endl;
84
85    vec = myobj.getWind();
86    fw.indent() << "wind " << vec << std::endl;
87
88    return true;
89}
Note: See TracBrowser for help on using the browser.