root/OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osgSim/IO_Sector.cpp @ 13041

Revision 13041, 8.6 kB (checked in by robert, 2 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 <osgSim/Sector>
2#include <osg/io_utils>
3
4#include <iostream>
5#include <string>
6
7#include <osgDB/Registry>
8#include <osgDB/Input>
9#include <osgDB/Output>
10#include <osgDB/ParameterOutput>
11
12bool AzimSector_readLocalData(osg::Object &obj, osgDB::Input &fr);
13bool AzimSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
14
15REGISTER_DOTOSGWRAPPER(AzimSector_Proxy)
16(
17    new osgSim::AzimSector,
18    "AzimSector",
19    "Object AzimSector",
20    &AzimSector_readLocalData,
21    &AzimSector_writeLocalData,
22    osgDB::DotOsgWrapper::READ_AND_WRITE
23);
24
25bool AzimSector_readLocalData(osg::Object &obj, osgDB::Input &fr)
26{
27    bool iteratorAdvanced = false;
28    osgSim::AzimSector &sector = static_cast<osgSim::AzimSector &>(obj);
29
30    if (fr.matchSequence("azimuthRange %f %f %f"))
31    {
32        float minAzimuth;
33        float maxAzimuth;
34        float fadeRange;
35        fr[1].getFloat(minAzimuth);
36        fr[2].getFloat(maxAzimuth);
37        fr[3].getFloat(fadeRange);
38        fr += 4;
39        sector.setAzimuthRange(minAzimuth, maxAzimuth, fadeRange);
40        iteratorAdvanced = true;
41    }
42    return iteratorAdvanced;
43}
44
45bool AzimSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
46{
47    float minAzimuth, maxAzimuth, fadeAngle;
48
49    const osgSim::AzimSector &sector = static_cast<const osgSim::AzimSector &>(obj);
50    sector.getAzimuthRange(minAzimuth, maxAzimuth, fadeAngle);
51    fw.indent()<<"azimuthRange "<<minAzimuth<< " "<<maxAzimuth<< " "<<fadeAngle<<std::endl;
52    return true;
53}
54
55/******************************************************************/
56
57bool ElevationSector_readLocalData(osg::Object &obj, osgDB::Input &fr);
58bool ElevationSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
59
60REGISTER_DOTOSGWRAPPER(ElevationSector_Proxy)
61(
62    new osgSim::ElevationSector,
63    "ElevationSector",
64    "Object ElevationSector",
65    &ElevationSector_readLocalData,
66    &ElevationSector_writeLocalData,
67    osgDB::DotOsgWrapper::READ_AND_WRITE
68);
69
70bool ElevationSector_readLocalData(osg::Object &obj, osgDB::Input &fr)
71{
72    bool iteratorAdvanced = false;
73    osgSim::ElevationSector &sector = static_cast<osgSim::ElevationSector &>(obj);
74
75    if (fr.matchSequence("elevationRange %f %f %f"))
76    {
77        float minElevation;
78        float maxElevation;
79        float fadeAngle;
80
81        fr[1].getFloat(minElevation);
82        fr[2].getFloat(maxElevation);
83        fr[3].getFloat(fadeAngle);
84        fr += 4;
85        sector.setElevationRange(minElevation, maxElevation, fadeAngle);
86        iteratorAdvanced = true;
87    }
88    return iteratorAdvanced;
89}
90
91bool ElevationSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
92{
93
94    const osgSim::ElevationSector &sector = static_cast<const osgSim::ElevationSector &>(obj);
95
96    float minElevation = sector.getMinElevation();
97    float maxElevation = sector.getMaxElevation();
98    float fadeAngle = sector.getFadeAngle();
99    fw.indent()<<"elevationRange "<<minElevation<< " "<<maxElevation<< " "<<fadeAngle<<std::endl;
100
101    return true;
102}
103
104/******************************************************************/
105
106bool AzimElevationSector_readLocalData(osg::Object &obj, osgDB::Input &fr);
107bool AzimElevationSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
108
109REGISTER_DOTOSGWRAPPER(AzimElevationSector_Proxy)
110(
111    new osgSim::AzimElevationSector,
112    "AzimElevationSector",
113    "Object AzimElevationSector",
114    &AzimElevationSector_readLocalData,
115    &AzimElevationSector_writeLocalData,
116    osgDB::DotOsgWrapper::READ_AND_WRITE
117);
118
119bool AzimElevationSector_readLocalData(osg::Object &obj, osgDB::Input &fr)
120{
121    bool iteratorAdvanced = false;
122    osgSim::AzimElevationSector &sector = static_cast<osgSim::AzimElevationSector &>(obj);
123
124    if (fr.matchSequence("azimuthRange %f %f %f"))
125    {
126        float minAzimuth;
127        float maxAzimuth;
128        float fadeAngle;
129        fr[1].getFloat(minAzimuth);
130        fr[2].getFloat(maxAzimuth);
131        fr[3].getFloat(fadeAngle);
132        fr += 4;
133        sector.setAzimuthRange(minAzimuth, maxAzimuth, fadeAngle);
134        iteratorAdvanced = true;
135    }
136    if (fr.matchSequence("elevationRange %f %f %f"))
137    {
138        float minElevation;
139        float maxElevation;
140        float fadeAngle;
141
142        fr[1].getFloat(minElevation);
143        fr[2].getFloat(maxElevation);
144        fr[3].getFloat(fadeAngle);
145        fr += 4;
146        sector.setElevationRange(minElevation, maxElevation, fadeAngle);
147        iteratorAdvanced = true;
148    }
149    return iteratorAdvanced;
150}
151
152bool AzimElevationSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
153{
154
155    const osgSim::AzimElevationSector &sector = static_cast<const osgSim::AzimElevationSector &>(obj);
156
157    float minElevation = sector.getMinElevation();
158    float maxElevation = sector.getMaxElevation();
159    float fadeAngle = sector.getFadeAngle();
160    fw.indent()<<"elevationRange "<<minElevation<< " "<<maxElevation<< " "<<fadeAngle<<std::endl;
161
162    float minAzimuth, maxAzimuth;
163    sector.getAzimuthRange(minAzimuth, maxAzimuth, fadeAngle);
164    fw.indent()<<"azimuthRange "<<minAzimuth<< " "<<maxAzimuth<< " "<<fadeAngle<<std::endl;
165    return true;
166}
167
168/******************************************************************/
169
170bool ConeSector_readLocalData(osg::Object &obj, osgDB::Input &fr);
171bool ConeSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
172
173REGISTER_DOTOSGWRAPPER(ConeSector_Proxy)
174(
175    new osgSim::ConeSector,
176    "ConeSector",
177    "Object ConeSector",
178    &ConeSector_readLocalData,
179    &ConeSector_writeLocalData,
180    osgDB::DotOsgWrapper::READ_AND_WRITE
181);
182
183bool ConeSector_readLocalData(osg::Object &obj, osgDB::Input &fr)
184{
185    bool iteratorAdvanced = false;
186    osgSim::ConeSector &sector = static_cast<osgSim::ConeSector &>(obj);
187
188    if (fr.matchSequence("axis %f %f %f"))
189    {
190        float x, y, z;
191
192        fr[1].getFloat(x);
193        fr[2].getFloat(y);
194        fr[3].getFloat(z);
195        fr += 4;
196        sector.setAxis(osg::Vec3(x, y, z));
197        iteratorAdvanced = true;
198    }
199    if (fr.matchSequence("angle %f %f"))
200    {
201        float angle;
202        float fadeangle;
203        fr[1].getFloat(angle);
204        fr[2].getFloat(fadeangle);
205        fr += 3;
206        sector.setAngle(angle, fadeangle);
207        iteratorAdvanced = true;
208    }
209    return iteratorAdvanced;
210}
211
212bool ConeSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
213{
214    const osgSim::ConeSector &sector = static_cast<const osgSim::ConeSector &>(obj);
215
216    const osg::Vec3& axis = sector.getAxis();
217    fw.indent()<<"axis "<<axis<<std::endl;
218
219    float angle = sector.getAngle();
220    float fadeangle = sector.getFadeAngle();
221    fw.indent()<<"angle "<<angle<<" "<<fadeangle<<std::endl;
222    return true;
223}
224
225/******************************************************************/
226
227bool DirectionalSector_readLocalData(osg::Object &obj, osgDB::Input &fr);
228bool DirectionalSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
229
230REGISTER_DOTOSGWRAPPER(DirectionalSector_Proxy)
231(
232    new osgSim::DirectionalSector,
233    "DirectionalSector",
234    "Object DirectionalSector",
235    &DirectionalSector_readLocalData,
236    &DirectionalSector_writeLocalData,
237    osgDB::DotOsgWrapper::READ_AND_WRITE
238);
239
240bool DirectionalSector_readLocalData(osg::Object &obj, osgDB::Input &fr)
241{
242    bool iteratorAdvanced = false;
243    osgSim::DirectionalSector &sector = static_cast<osgSim::DirectionalSector &>(obj);
244
245    if (fr.matchSequence("direction %f %f %f"))
246    {
247        float x, y, z;
248
249        fr[1].getFloat(x);
250        fr[2].getFloat(y);
251        fr[3].getFloat(z);
252        fr += 4;
253        sector.setDirection(osg::Vec3(x, y, z));
254        iteratorAdvanced = true;
255    }
256    if (fr.matchSequence("angles %f %f %f %f"))
257    {
258        float horizangle;
259        float vertangle;
260        float rollangle;
261        float fadeangle;
262        fr[1].getFloat(horizangle);
263        fr[2].getFloat(vertangle);
264        fr[3].getFloat(rollangle);
265        fr[4].getFloat(fadeangle);
266        fr += 5;
267        sector.setHorizLobeAngle(horizangle);
268        sector.setVertLobeAngle(vertangle);
269        sector.setLobeRollAngle(rollangle);
270        sector.setFadeAngle(fadeangle);
271        iteratorAdvanced = true;
272    }
273    return iteratorAdvanced;
274}
275
276bool DirectionalSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
277{
278    const osgSim::DirectionalSector &sector = static_cast<const osgSim::DirectionalSector &>(obj);
279
280    const osg::Vec3& axis = sector.getDirection();
281    fw.indent()<<"direction "<<axis<<std::endl;
282
283    float horizangle = sector.getHorizLobeAngle();
284    float vertangle = sector.getVertLobeAngle();
285    float rollangle = sector.getLobeRollAngle();
286    float fadeangle = sector.getFadeAngle();
287    fw.indent()<<"angles "<<horizangle<<" "<<vertangle<<" "<<rollangle<<" "<<fadeangle<<std::endl;
288    return true;
289}
Note: See TracBrowser for help on using the browser.