|
Revision 13041, 2.2 kB
(checked in by robert, 14 months ago)
|
|
Ran script to remove trailing spaces and tabs
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | #include "Exception.h" |
|---|
| 15 | #include "Terrain.h" |
|---|
| 16 | #include "TerrainTile.h" |
|---|
| 17 | #include "CoordinateSystemNode.h" |
|---|
| 18 | |
|---|
| 19 | #include <osgTerrain/GeometryTechnique> |
|---|
| 20 | |
|---|
| 21 | using namespace ive; |
|---|
| 22 | |
|---|
| 23 | void Terrain::write(DataOutputStream* out) |
|---|
| 24 | { |
|---|
| 25 | |
|---|
| 26 | out->writeInt(IVETERRAIN); |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 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 | |
|---|
| 42 | void Terrain::read(DataInputStream* in) |
|---|
| 43 | { |
|---|
| 44 | |
|---|
| 45 | int id = in->peekInt(); |
|---|
| 46 | if (id != IVETERRAIN) in_THROW_EXCEPTION("TerrainTile::read(): Expected Terrain identification."); |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 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 | } |
|---|