root/OpenSceneGraph/trunk/src/osgPlugins/ive/LightPoint.cpp @ 13041

Revision 13041, 4.3 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/**********************************************************************
2 *
3 *    FILE:            LightPoint.cpp
4 *
5 *    DESCRIPTION:    Read/Write osgSim::LightPoint in binary format to disk.
6 *
7 *    CREATED BY:        Auto generated by iveGenerator
8 *                    and later modified by Rune Schmidt Jensen.
9 *
10 *    HISTORY:        Created 5.9.2003
11 *
12 **********************************************************************/
13
14#include "Exception.h"
15#include "LightPoint.h"
16#include "BlinkSequence.h"
17#include "AzimElevationSector.h"
18#include "ElevationSector.h"
19#include "AzimSector.h"
20#include "ConeSector.h"
21#include "DirectionalSector.h"
22
23using namespace ive;
24
25void LightPoint::write(DataOutputStream* out){
26    // Write LightPoint's identification.
27    out->writeInt(IVELIGHTPOINT);
28
29    // Write LightPoint's properties.
30    out->writeBool(_on);
31    out->writeVec3(_position);
32    out->writeVec4(_color);
33    out->writeFloat(_intensity);
34    out->writeFloat(_radius);
35
36    // Write out osgSim::sector.
37    out->writeBool(_sector.valid());
38    if(_sector.valid()){
39        if(dynamic_cast<osgSim::AzimElevationSector*>(_sector.get())){
40            ((ive::AzimElevationSector*)(_sector.get()))->write(out);
41        }
42        else if(dynamic_cast<osgSim::ElevationSector*>(_sector.get())){
43            ((ive::ElevationSector*)(_sector.get()))->write(out);
44        }
45        else if(dynamic_cast<osgSim::AzimSector*>(_sector.get())){
46            ((ive::AzimSector*)(_sector.get()))->write(out);
47        }
48        else if(dynamic_cast<osgSim::ConeSector*>(_sector.get())){
49            ((ive::ConeSector*)(_sector.get()))->write(out);
50        }
51        else if(dynamic_cast<osgSim::DirectionalSector*>(_sector.get())){
52            ((ive::DirectionalSector*)(_sector.get()))->write(out);
53        }
54        else
55            out_THROW_EXCEPTION("Unknown sector in LightPoint::write()");
56    }
57
58    // Write out osgSim::BlinkSequence.
59    out->writeBool(_blinkSequence.valid());
60    if(_blinkSequence.valid()){
61        ((ive::BlinkSequence*)(_blinkSequence.get()))->write(out);
62    }
63
64    // Write out blendingMode.
65    out->writeInt(_blendingMode);
66}
67
68void LightPoint::read(DataInputStream* in){
69    // Peek on LightPoint's identification.
70    int id = in->peekInt();
71    if(id == IVELIGHTPOINT){
72        // Read LightPoint's identification.
73        id = in->readInt();
74
75        // Read LightPoint's properties
76        _on = in->readBool();
77        _position = in->readVec3();
78        _color = in->readVec4();
79        _intensity = in->readFloat();
80        _radius = in->readFloat();
81
82        // read in osgSim::sector.
83        if(in->readBool()){
84            osgSim::Sector* sector;
85            int attributeID = in->peekInt();
86            if(attributeID == IVEAZIMELEVATIONSECTOR){
87                sector = new osgSim::AzimElevationSector();
88                ((ive::AzimElevationSector*)(sector))->read(in);
89                _sector = sector;
90            }
91            else if(attributeID == IVEELEVATIONSECTOR){
92                sector = new osgSim::ElevationSector();
93                ((ive::ElevationSector*)(sector))->read(in);
94                _sector = sector;
95            }
96            else if(attributeID == IVEAZIMSECTOR){
97                sector = new osgSim::AzimSector();
98                ((ive::AzimSector*)(sector))->read(in);
99                _sector = sector;
100            }
101            else if(attributeID == IVECONESECTOR){
102                sector = new osgSim::ConeSector();
103                ((ive::ConeSector*)(sector))->read(in);
104                _sector = sector;
105            }
106            else if(attributeID == IVEDIRECTIONALSECTOR){
107                sector = new osgSim::DirectionalSector();
108                ((ive::DirectionalSector*)(sector))->read(in);
109                _sector = sector;
110            }
111            else
112                in_THROW_EXCEPTION("Unknown sector in LightPoint::read()");
113        }
114
115        // Read in osgSim::BlinkSequence.
116        if(in->readBool()){
117            osgSim::BlinkSequence* blinkSequence = new osgSim::BlinkSequence();
118            ((ive::BlinkSequence*)(blinkSequence))->read(in);
119            _blinkSequence = blinkSequence;
120        }
121
122        // Read in blendingMode.
123        _blendingMode = (osgSim::LightPoint::BlendingMode)in->readInt();
124    }
125    else{
126        in_THROW_EXCEPTION("LightPoint::read(): Expected LightPoint identification.");
127    }
128}
Note: See TracBrowser for help on using the browser.