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

Revision 13041, 1.8 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/**********************************************************************
2 *
3 *    FILE:            Fog.cpp
4 *
5 *    DESCRIPTION:    Read/Write osg::Fog in binary format to disk.
6 *
7 *    CREATED BY:        Liang Aibin
8 *
9 *    HISTORY:        Created 17.06.2008
10 *
11 **********************************************************************/
12
13#include "Exception.h"
14#include "Fog.h"
15#include "Object.h"
16
17using namespace ive;
18
19void Fog::write(DataOutputStream* out){
20
21  // write Fog's identification
22  out->writeInt(IVEFOG);
23
24  // if the osg class is inherited by any other class we should also write this to file
25  osg::Object*  obj = dynamic_cast<osg::Object*>(this);
26  if(obj)
27    ((ive::Object*)(obj))->write(out);
28  else
29    out_THROW_EXCEPTION("Fog::write(): Could not cast this osg::Fog to an osg::Object.");
30
31  // write Fog's properties
32  out->writeInt(getMode());
33  out->writeFloat(getDensity());
34  out->writeFloat(getStart());
35  out->writeFloat(getEnd());
36  out->writeVec4(getColor());
37  out->writeInt(getFogCoordinateSource());
38}
39
40void Fog::read(DataInputStream* in){
41
42  // peek on Fog's identification
43  int id = in->peekInt();
44  if(id == IVEFOG)
45    {
46      // read Fog's identification
47      id = in->readInt();
48
49      // if the osg class is inherited by any other class we should also read this from file
50      osg::Object*  obj = dynamic_cast<osg::Object*>(this);
51      if(obj)
52        ((ive::Object*)(obj))->read(in);
53      else
54        in_THROW_EXCEPTION("Fog::read(): Could not cast this osg::Fog to an osg::Object.");
55
56      // Read Fog's properties
57      setMode(osg::Fog::Mode(in->readInt()));
58      setDensity(in->readFloat());
59      setStart(in->readFloat());
60      setEnd(in->readFloat());
61      setColor(in->readVec4());
62      setFogCoordinateSource(in->readInt());
63    }
64  else{
65    in_THROW_EXCEPTION("Fog::read(): Expected Fog identification.");
66  }
67}
Note: See TracBrowser for help on using the browser.