Change Terrain so that it subclassed from CoordinateSystemNode.
Implemented new update scheme of GeometryTechnique to avoid potential threading issues. Added Terrain support to .ive.
This commit is contained in:
@@ -101,6 +101,7 @@ SET(TARGET_SRC
|
||||
Stencil.cpp
|
||||
Switch.cpp
|
||||
SwitchLayer.cpp
|
||||
Terrain.cpp
|
||||
TerrainTile.cpp
|
||||
TexEnvCombine.cpp
|
||||
TexEnv.cpp
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
|
||||
#include "Text.h"
|
||||
|
||||
#include "Terrain.h"
|
||||
#include "TerrainTile.h"
|
||||
#include "Locator.h"
|
||||
#include "ImageLayer.h"
|
||||
@@ -1836,6 +1837,10 @@ osg::Node* DataInputStream::readNode()
|
||||
node = new osgTerrain::TerrainTile();
|
||||
((ive::TerrainTile*)(node.get()))->read(this);
|
||||
}
|
||||
else if(nodeTypeID== IVETERRAIN){
|
||||
node = new osgTerrain::Terrain();
|
||||
((ive::Terrain*)(node.get()))->read(this);
|
||||
}
|
||||
else if(nodeTypeID== IVEVOLUME){
|
||||
node = new osgVolume::Volume();
|
||||
((ive::Volume*)(node.get()))->read(this);
|
||||
|
||||
@@ -103,6 +103,7 @@
|
||||
|
||||
#include "Text.h"
|
||||
|
||||
#include "Terrain.h"
|
||||
#include "TerrainTile.h"
|
||||
#include "Locator.h"
|
||||
#include "ImageLayer.h"
|
||||
@@ -1333,9 +1334,6 @@ void DataOutputStream::writeNode(const osg::Node* node)
|
||||
else if(dynamic_cast<const osg::Switch*>(node)){
|
||||
((ive::Switch*)(node))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osg::CoordinateSystemNode*>(node)){
|
||||
((ive::CoordinateSystemNode*)(node))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osgSim::MultiSwitch*>(node)){
|
||||
((ive::MultiSwitch*)(node))->write(this);
|
||||
}
|
||||
@@ -1378,9 +1376,17 @@ void DataOutputStream::writeNode(const osg::Node* node)
|
||||
else if(dynamic_cast<const osgTerrain::TerrainTile*>(node)){
|
||||
((ive::TerrainTile*)(node))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osgTerrain::Terrain*>(node)){
|
||||
((ive::Terrain*)(node))->write(this);
|
||||
}
|
||||
else if(dynamic_cast<const osgVolume::Volume*>(node)){
|
||||
((ive::Volume*)(node))->write(this);
|
||||
}
|
||||
|
||||
else if(dynamic_cast<const osg::CoordinateSystemNode*>(node)){
|
||||
((ive::CoordinateSystemNode*)(node))->write(this);
|
||||
}
|
||||
|
||||
else if(dynamic_cast<const osgVolume::VolumeTile*>(node)){
|
||||
((ive::VolumeTile*)(node))->write(this);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace ive {
|
||||
#define IVEVALIDRANGE 0x0020000B
|
||||
#define IVENODATAVALUE 0x0020000C
|
||||
#define IVESWITCHLAYER 0x0020000D
|
||||
#define IVETERRAIN 0x0020000A
|
||||
#define IVETERRAIN 0x0020000E
|
||||
|
||||
// osgVolume classes
|
||||
#define IVEVOLUMETILE 0x00300001
|
||||
|
||||
63
src/osgPlugins/ive/Terrain.cpp
Normal file
63
src/osgPlugins/ive/Terrain.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Terrain.h"
|
||||
#include "TerrainTile.h"
|
||||
#include "CoordinateSystemNode.h"
|
||||
|
||||
#include <osgTerrain/GeometryTechnique>
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void Terrain::write(DataOutputStream* out)
|
||||
{
|
||||
// Write Terrain's identification.
|
||||
out->writeInt(IVETERRAIN);
|
||||
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(this);
|
||||
if(csn)
|
||||
((ive::CoordinateSystemNode*)(csn))->write(out);
|
||||
else
|
||||
out_THROW_EXCEPTION("Terrain::write(): Could not cast this osgTerrain::Terrain to an osg::CoordinateSystemNode.");
|
||||
|
||||
out->writeFloat(getSampleRatio());
|
||||
out->writeFloat(getVerticalScale());
|
||||
out->writeInt(getBlendingPolicy());
|
||||
|
||||
TerrainTile::writeTerrainTechnique(out, getTerrainTechniquePrototype());
|
||||
}
|
||||
|
||||
void Terrain::read(DataInputStream* in)
|
||||
{
|
||||
// Peek on Terrain's identification.
|
||||
int id = in->peekInt();
|
||||
if (id != IVETERRAIN) in_THROW_EXCEPTION("TerrainTile::read(): Expected Terrain identification.");
|
||||
|
||||
// Read Terrain's identification.
|
||||
id = in->readInt();
|
||||
|
||||
osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(this);
|
||||
if(csn)
|
||||
((ive::CoordinateSystemNode*)(csn))->read(in);
|
||||
else
|
||||
in_THROW_EXCEPTION("Terrain::read(): Could not cast this osgTerran::Terrain to an osg::CoordinateSystemNode.");
|
||||
|
||||
setSampleRatio(in->readFloat());
|
||||
setVerticalScale(in->readFloat());
|
||||
setBlendingPolicy(static_cast<osgTerrain::TerrainTile::BlendingPolicy>(in->readInt()));
|
||||
|
||||
setTerrainTechniquePrototype(TerrainTile::readTerrainTechnique(in));
|
||||
}
|
||||
|
||||
33
src/osgPlugins/ive/Terrain.h
Normal file
33
src/osgPlugins/ive/Terrain.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef IVE_TERRAIN
|
||||
#define IVE_TERRAIN 1
|
||||
|
||||
#include <osgTerrain/Terrain>
|
||||
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive
|
||||
{
|
||||
|
||||
class Terrain : public osgTerrain::Terrain, public ReadWrite
|
||||
{
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -153,7 +153,7 @@ osgTerrain::TerrainTechnique* TerrainTile::readTerrainTechnique(DataInputStream*
|
||||
{
|
||||
bool hasTechnique = in->readBool();
|
||||
if (!hasTechnique) return 0;
|
||||
|
||||
|
||||
int id = in->readInt();
|
||||
if (id==IVEGEOMETRYTECHNIQUE)
|
||||
{
|
||||
|
||||
@@ -27,8 +27,8 @@ public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
|
||||
void writeTerrainTechnique(DataOutputStream* out, osgTerrain::TerrainTechnique* technique);
|
||||
osgTerrain::TerrainTechnique* readTerrainTechnique(DataInputStream* out);
|
||||
static void writeTerrainTechnique(DataOutputStream* out, osgTerrain::TerrainTechnique* technique);
|
||||
static osgTerrain::TerrainTechnique* readTerrainTechnique(DataInputStream* out);
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user