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

Revision 13041, 2.2 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#include "Exception.h"
15#include "Terrain.h"
16#include "TerrainTile.h"
17#include "CoordinateSystemNode.h"
18
19#include <osgTerrain/GeometryTechnique>
20
21using namespace ive;
22
23void Terrain::write(DataOutputStream* out)
24{
25    // Write Terrain's identification.
26    out->writeInt(IVETERRAIN);
27
28    // If the osg class is inherited by any other class we should also write this to file.
29    osg::CoordinateSystemNode*  csn = dynamic_cast<osg::CoordinateSystemNode*>(this);
30    if(csn)
31        ((ive::CoordinateSystemNode*)(csn))->write(out);
32    else
33        out_THROW_EXCEPTION("Terrain::write(): Could not cast this osgTerrain::Terrain to an osg::CoordinateSystemNode.");
34
35    out->writeFloat(getSampleRatio());
36    out->writeFloat(getVerticalScale());
37    out->writeInt(getBlendingPolicy());
38
39    TerrainTile::writeTerrainTechnique(out, getTerrainTechniquePrototype());
40}
41
42void Terrain::read(DataInputStream* in)
43{
44    // Peek on Terrain's identification.
45    int id = in->peekInt();
46    if (id != IVETERRAIN) in_THROW_EXCEPTION("TerrainTile::read(): Expected Terrain identification.");
47
48    // Read Terrain's identification.
49    id = in->readInt();
50
51    osg::CoordinateSystemNode*  csn = dynamic_cast<osg::CoordinateSystemNode*>(this);
52    if(csn)
53        ((ive::CoordinateSystemNode*)(csn))->read(in);
54    else
55        in_THROW_EXCEPTION("Terrain::read(): Could not cast this osgTerran::Terrain to an osg::CoordinateSystemNode.");
56
57    setSampleRatio(in->readFloat());
58    setVerticalScale(in->readFloat());
59    setBlendingPolicy(static_cast<osgTerrain::TerrainTile::BlendingPolicy>(in->readInt()));
60
61    setTerrainTechniquePrototype(TerrainTile::readTerrainTechnique(in));
62}
Note: See TracBrowser for help on using the browser.