root/OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osgFX/IO_MultiTextureControl.cpp @ 13041

Revision 13041, 2.0 kB (checked in by robert, 3 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#include <osgFX/MultiTextureControl>
2
3#include <osgDB/Registry>
4#include <osgDB/Input>
5#include <osgDB/Output>
6
7bool MultiTextureControl_readLocalData(osg::Object &obj, osgDB::Input &fr);
8bool MultiTextureControl_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
9
10REGISTER_DOTOSGWRAPPER(MultiTextureControl_Proxy)
11(
12    new osgFX::MultiTextureControl,
13    "osgFX::MultiTextureControl",
14    "Object Node osgFX::MultiTextureControl Group",
15    MultiTextureControl_readLocalData,
16    MultiTextureControl_writeLocalData
17);
18
19bool MultiTextureControl_readLocalData(osg::Object &obj, osgDB::Input &fr)
20{
21    osgFX::MultiTextureControl &mtc = static_cast<osgFX::MultiTextureControl &>(obj);
22    bool iteratorAdvanced = false;
23
24    bool matchFirst = false;
25    if ((matchFirst=fr.matchSequence("TextureWeights {")) || fr.matchSequence("TextureWeights %i {"))
26    {
27
28        // set up coordinates.
29        int entry = fr[0].getNoNestedBrackets();
30        if (matchFirst)
31        {
32            fr += 2;
33        }
34        else
35        {
36            fr += 3;
37        }
38
39        float weight=0.0f;
40        unsigned int i=0;
41        while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
42        {
43            if (fr[0].getFloat(weight))
44            {
45                mtc.setTextureWeight(i,weight);
46                ++fr;
47                ++i;
48            }
49            else
50            {
51                ++fr;
52            }
53        }
54
55        iteratorAdvanced = true;
56        ++fr;
57
58    }
59
60    return iteratorAdvanced;
61}
62
63bool MultiTextureControl_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
64{
65    const osgFX::MultiTextureControl &mtc = static_cast<const osgFX::MultiTextureControl &>(obj);
66
67    fw.indent() << "TextureWeights "<<mtc.getNumTextureWeights()<<" {"<< std::endl;
68    fw.moveIn();
69
70    for(unsigned int i=0; i<mtc.getNumTextureWeights();++i)
71    {
72        fw.indent() << mtc.getTextureWeight(i)<<std::endl;
73    }
74    fw.moveOut();
75    fw.indent() << "}"<< std::endl;
76
77
78    return true;
79}
Note: See TracBrowser for help on using the browser.