root/OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osg/Cylinder.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#include <osg/Shape>
2#include <osg/Notify>
3#include <osg/io_utils>
4
5#include <osgDB/Registry>
6#include <osgDB/Input>
7#include <osgDB/ParameterOutput>
8
9using namespace osg;
10using namespace osgDB;
11
12
13//////////////////////////////////////////////////////////////////////////////
14// forward declare functions to use later.
15bool Cylinder_readLocalData(Object& obj, Input& fr);
16bool Cylinder_writeLocalData(const Object& obj, Output& fw);
17
18//register the read and write functions with the osgDB::Registry.
19REGISTER_DOTOSGWRAPPER(Cylinder)
20(
21    new osg::Cylinder,
22    "Cylinder",
23    "Object Cylinder",
24    &Cylinder_readLocalData,
25    &Cylinder_writeLocalData,
26    DotOsgWrapper::READ_AND_WRITE
27);
28
29bool Cylinder_readLocalData(Object& obj, Input& fr)
30{
31    bool iteratorAdvanced = false;
32
33    Cylinder& cylinder = static_cast<Cylinder&>(obj);
34
35    if (fr.matchSequence("Center %f %f %f"))
36    {
37        osg::Vec3 center;
38        fr[1].getFloat(center.x());
39        fr[2].getFloat(center.y());
40        fr[3].getFloat(center.z());
41        cylinder.setCenter(center);
42        fr+=4;
43        iteratorAdvanced = true;
44    }
45
46    if (fr.matchSequence("Radius %f"))
47    {
48        float radius;
49        fr[1].getFloat(radius);
50        cylinder.setRadius(radius);
51        fr+=2;
52        iteratorAdvanced = true;
53    }
54
55    if (fr.matchSequence("Height %f"))
56    {
57        float height;
58        fr[1].getFloat(height);
59        cylinder.setHeight(height);
60        fr+=2;
61        iteratorAdvanced = true;
62    }
63
64    if (fr.matchSequence("Rotation %f %f %f %f"))
65    {
66        osg::Quat rotation;
67        fr[1].getFloat(rotation.x());
68        fr[2].getFloat(rotation.y());
69        fr[3].getFloat(rotation.z());
70        fr[4].getFloat(rotation.w());
71        cylinder.setRotation(rotation);
72        fr+=5;
73        iteratorAdvanced = true;
74    }
75
76    return iteratorAdvanced;
77}
78
79bool Cylinder_writeLocalData(const Object& obj, Output& fw)
80{
81    const Cylinder& cylinder = static_cast<const Cylinder&>(obj);
82
83    fw.indent()<<"Center "<<cylinder.getCenter()<<std::endl;
84    fw.indent()<<"Radius "<<cylinder.getRadius()<<std::endl;
85    fw.indent()<<"Height "<<cylinder.getHeight()<<std::endl;
86    fw.indent()<<"Rotation "<<cylinder.getRotation()<<std::endl;
87
88    return true;
89}
Note: See TracBrowser for help on using the browser.