1 #include <osgFX/SpecularHighlights>
2 #include <osg/io_utils>
3 
4 #include <osgDB/Registry>
5 #include <osgDB/Input>
6 #include <osgDB/Output>
7 
8 bool SpecularHighlights_readLocalData(osg::Object &obj, osgDB::Input &fr);
9 bool SpecularHighlights_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
10 
11 REGISTER_DOTOSGWRAPPER(SpecularHighlights_Proxy)
12 (
13     new osgFX::SpecularHighlights,
14     "osgFX::SpecularHighlights",
15     "Object Node Group osgFX::Effect osgFX::SpecularHighlights",
16     SpecularHighlights_readLocalData,
17     SpecularHighlights_writeLocalData
18 );
19 
SpecularHighlights_readLocalData(osg::Object & obj,osgDB::Input & fr)20 bool SpecularHighlights_readLocalData(osg::Object &obj, osgDB::Input &fr)
21 {
22     osgFX::SpecularHighlights &myobj = static_cast<osgFX::SpecularHighlights &>(obj);
23     bool itAdvanced = false;
24 
25     if (fr[0].matchWord("lightNumber")) {
26         int n;
27         if (fr[1].getInt(n)) {
28             myobj.setLightNumber(n);
29             fr += 2;
30             itAdvanced = true;
31         }
32     }
33 
34     if (fr[0].matchWord("textureUnit")) {
35         int n;
36         if (fr[1].getInt(n)) {
37             myobj.setTextureUnit(n);
38             fr += 2;
39             itAdvanced = true;
40         }
41     }
42 
43     if (fr[0].matchWord("specularColor")) {
44         osg::Vec4 w;
45         if (fr[1].getFloat(w.x()) && fr[2].getFloat(w.y()) &&
46             fr[3].getFloat(w.z()) && fr[4].getFloat(w.w())) {
47             myobj.setSpecularColor(w);
48             fr += 5;
49             itAdvanced = true;
50         }
51     }
52 
53     if (fr[0].matchWord("specularExponent")) {
54         float f;
55         if (fr[1].getFloat(f)) {
56             myobj.setSpecularExponent(f);
57             fr += 2;
58             itAdvanced = true;
59         }
60     }
61 
62 
63     return itAdvanced;
64 }
65 
SpecularHighlights_writeLocalData(const osg::Object & obj,osgDB::Output & fw)66 bool SpecularHighlights_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
67 {
68     const osgFX::SpecularHighlights &myobj = static_cast<const osgFX::SpecularHighlights &>(obj);
69 
70     fw.indent() << "lightNumber " << myobj.getLightNumber() << "\n";
71     fw.indent() << "textureUnit " << myobj.getTextureUnit() << "\n";
72     fw.indent() << "specularColor " << myobj.getSpecularColor() << "\n";
73     fw.indent() << "specularExponent " << myobj.getSpecularExponent() << "\n";
74 
75     return true;
76 }
77