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

Revision 13041, 2.7 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:            LightPointNode.cpp
4 *
5 *    DESCRIPTION:    Read/Write osgSim::LightPointNode in binary format to disk.
6 *
7 *    CREATED BY:        Auto generated by iveGenerator.exe
8 *                    and later modified by Rune Schmidt Jensen.
9 *
10 *    HISTORY:        Created 14.9.2003
11 *
12 **********************************************************************/
13
14#include "Exception.h"
15#include "LightPointNode.h"
16#include "LightPoint.h"
17#include "Node.h"
18
19using namespace ive;
20
21void LightPointNode::write(DataOutputStream* out){
22    // Write LightPointNode's identification.
23    out->writeInt(IVELIGHTPOINTNODE);
24    // If the osgSim class is inherited by any other class we should also write this to file.
25    osg::Node*  node = dynamic_cast<osg::Node*>(this);
26    if(node){
27        ((ive::Node*)(node))->write(out);
28    }
29    else
30        out_THROW_EXCEPTION("LightPointNode::write(): Could not cast this osgSim::LightPointNode to an osg::Node.");
31
32    // Write LightPointNode's properties.
33    out->writeFloat(getMinPixelSize());
34    out->writeFloat(getMaxPixelSize());
35    out->writeFloat(getMaxVisibleDistance2());
36
37    if (out->getVersion() >= VERSION_0024)
38    {
39        out->writeBool(getPointSprite());
40    }
41
42    // Write out LightPoints.
43    unsigned int size = getNumLightPoints();
44    out->writeUInt(size);
45    for(unsigned int i=0; i<size; i++){
46        ((ive::LightPoint*)(&getLightPoint(i)))->write(out);
47    }
48}
49
50void LightPointNode::read(DataInputStream* in){
51    // Peek on LightPointNode's identification.
52    int id = in->peekInt();
53    if(id == IVELIGHTPOINTNODE){
54        // Read LightPointNode's identification.
55        id = in->readInt();
56        // If the osgSim class is inherited by any other class we should also read this from file.
57        osg::Node*  node = dynamic_cast<osg::Node*>(this);
58        if(node){
59            ((ive::Node*)(node))->read(in);
60        }
61        else
62            in_THROW_EXCEPTION("LightPointNode::read(): Could not cast this osgSim::LightPointNode to an osg::Object.");
63        // Read LightPointNode's properties
64        setMinPixelSize(in->readFloat());
65        setMaxPixelSize(in->readFloat());
66        setMaxVisibleDistance2(in->readFloat());
67
68        if (in->getVersion() >= VERSION_0024)
69        {
70            setPointSprite(in->readBool());
71        }
72
73        // Read in lightpoints.
74        unsigned int size = in->readUInt();
75        for(unsigned int i=0; i<size; i++ ){
76            osgSim::LightPoint lightPoint;
77            ((ive::LightPoint*)(&lightPoint))->read(in);
78            addLightPoint(lightPoint);
79        }
80    }
81    else{
82        in_THROW_EXCEPTION("LightPointNode::read(): Expected LightPointNode identification.");
83    }
84}
Note: See TracBrowser for help on using the browser.