root/OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osg/ShapeDrawable.cpp @ 13041

Revision 13041, 1.7 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 <osg/ShapeDrawable>
2#include <osg/Notify>
3#include <osg/io_utils>
4
5#include <osgDB/Registry>
6#include <osgDB/Input>
7#include <osgDB/Output>
8
9using namespace osg;
10using namespace osgDB;
11
12// forward declare functions to use later.
13bool ShapeDrawable_readLocalData(Object& obj, Input& fr);
14bool ShapeDrawable_writeLocalData(const Object& obj, Output& fw);
15
16REGISTER_DOTOSGWRAPPER(ShapeDrawable)
17(
18    new osg::ShapeDrawable,
19    "ShapeDrawable",
20    "Object Drawable ShapeDrawable",
21    &ShapeDrawable_readLocalData,
22    &ShapeDrawable_writeLocalData,
23    DotOsgWrapper::READ_AND_WRITE
24);
25
26bool ShapeDrawable_readLocalData(Object& obj, Input& fr)
27{
28    bool iteratorAdvanced = false;
29
30    ShapeDrawable& geom = static_cast<ShapeDrawable&>(obj);
31
32    if (fr.matchSequence("color %f %f %f %f"))
33    {
34        osg::Vec4 color;
35        fr[1].getFloat(color[0]);
36        fr[2].getFloat(color[1]);
37        fr[3].getFloat(color[2]);
38        fr[4].getFloat(color[3]);
39
40        geom.setColor(color);
41
42        fr+=5;
43        iteratorAdvanced = true;
44    }
45
46    ref_ptr<Object> readObject = fr.readObjectOfType(type_wrapper<TessellationHints>());
47    if (readObject.valid()) {
48        TessellationHints* hints = static_cast<TessellationHints*>(readObject.get());
49        geom.setTessellationHints(hints);
50        iteratorAdvanced = true;
51    }
52
53    return iteratorAdvanced;
54}
55
56bool ShapeDrawable_writeLocalData(const Object& obj, Output& fw)
57{
58    const ShapeDrawable& geom = static_cast<const ShapeDrawable&>(obj);
59
60    fw.indent() << "color " << geom.getColor() << std::endl;
61
62    const TessellationHints* hints = geom.getTessellationHints();
63    if (hints)
64        fw.writeObject(*hints);
65
66    return true;
67}
Note: See TracBrowser for help on using the browser.