Added support for decoration of the osgTerrain::DataSet generated databases
with a CoordinateSystemNode which reflect the coordinate system of the database. Added support for reading and writing CoordianteSystemNode into the .osg and .ive formats.
This commit is contained in:
76
src/osgPlugins/ive/CoordinateSystemNode.cpp
Normal file
76
src/osgPlugins/ive/CoordinateSystemNode.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: CoordinateSystemNode.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::CoordinateSystemNode in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerator
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 9.4.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "CoordinateSystemNode.h"
|
||||
#include "EllipsoidModel.h"
|
||||
#include "Group.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void CoordinateSystemNode::write(DataOutputStream* out)
|
||||
{
|
||||
// Write CoordinateSystemNode's identification.
|
||||
out->writeInt(IVECOORDINATESYSTEMNODE);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::Group* group = dynamic_cast<osg::Group*>(this);
|
||||
if(group){
|
||||
((ive::Group*)(group))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("CoordinateSystemNode::write(): Could not cast this osg::CoordinateSystemNode to an osg::Group.");
|
||||
// Write CoordinateSystemNode's properties.
|
||||
|
||||
out->writeString(getCoordinateSystem());
|
||||
|
||||
out->writeBool(getEllipsoidModel()!=0);
|
||||
if(getEllipsoidModel())
|
||||
{
|
||||
((ive::EllipsoidModel*)(getEllipsoidModel()))->write(out);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CoordinateSystemNode::read(DataInputStream* in){
|
||||
// Peek on CoordinateSystemNode's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVECOORDINATESYSTEMNODE)
|
||||
{
|
||||
// Read CoordinateSystemNode's identification.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Group* group = dynamic_cast<osg::Group*>(this);
|
||||
if(group){
|
||||
((ive::Group*)(group))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("CoordinateSystemNode::read(): Could not cast this osg::CoordinateSystemNode to an osg::Group.");
|
||||
// Read CoordinateSystemNode's properties
|
||||
|
||||
// Read coord string
|
||||
setCoordinateSystem( in->readString());
|
||||
|
||||
bool readEllopsoidModel = in->readBool();
|
||||
if (readEllopsoidModel)
|
||||
{
|
||||
osg::EllipsoidModel* em = new osg::EllipsoidModel();
|
||||
((ive::EllipsoidModel*)(em))->read(in);
|
||||
setEllipsoidModel(em);
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("CoordinateSystemNode::read(): Expected CoordinateSystemNode identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/CoordinateSystemNode.h
Normal file
15
src/osgPlugins/ive/CoordinateSystemNode.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_COORDINATESYSTEMNODE
|
||||
#define IVE_COORDINATESYSTEMNODE 1
|
||||
|
||||
#include <osg/CoordinateSystemNode>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class CoordinateSystemNode : public osg::CoordinateSystemNode, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "Switch.h"
|
||||
#include "OccluderNode.h"
|
||||
#include "Impostor.h"
|
||||
#include "CoordinateSystemNode.h"
|
||||
|
||||
#include "LightPointNode.h"
|
||||
#include "MultiSwitch.h"
|
||||
@@ -826,6 +827,10 @@ osg::Node* DataInputStream::readNode()
|
||||
node = new osg::PagedLOD();
|
||||
((ive::PagedLOD*)(node))->read(this);
|
||||
}
|
||||
else if(nodeTypeID== IVECOORDINATESYSTEMNODE){
|
||||
node = new osg::CoordinateSystemNode();
|
||||
((ive::CoordinateSystemNode*)(node))->read(this);
|
||||
}
|
||||
else if(nodeTypeID== IVESWITCH){
|
||||
node = new osg::Switch();
|
||||
((ive::Switch*)(node))->read(this);
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "Switch.h"
|
||||
#include "OccluderNode.h"
|
||||
#include "Impostor.h"
|
||||
#include "CoordinateSystemNode.h"
|
||||
|
||||
#include "LightPointNode.h"
|
||||
#include "MultiSwitch.h"
|
||||
@@ -611,6 +612,9 @@ 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);
|
||||
}
|
||||
|
||||
62
src/osgPlugins/ive/EllipsoidModel.cpp
Normal file
62
src/osgPlugins/ive/EllipsoidModel.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* FILE: EllipsoidModel.cpp
|
||||
*
|
||||
* DESCRIPTION: Read/Write osg::EllipsoidModel in binary format to disk.
|
||||
*
|
||||
* CREATED BY: Auto generated by iveGenerator
|
||||
* and later modified by Rune Schmidt Jensen.
|
||||
*
|
||||
* HISTORY: Created 23.4.2003
|
||||
*
|
||||
* Copyright 2003 VR-C
|
||||
**********************************************************************/
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Object.h"
|
||||
#include "EllipsoidModel.h"
|
||||
#include "ConvexPlanarPolygon.h"
|
||||
|
||||
using namespace ive;
|
||||
|
||||
void EllipsoidModel::write(DataOutputStream* out){
|
||||
// Write EllipsoidModel's identification.
|
||||
out->writeInt(IVEELLIPSOIDMODEL);
|
||||
// If the osg class is inherited by any other class we should also write this to file.
|
||||
osg::Object* obj = dynamic_cast<osg::Object*>(this);
|
||||
if(obj){
|
||||
((ive::Object*)(obj))->write(out);
|
||||
}
|
||||
else
|
||||
throw Exception("EllipsoidModel::write(): Could not cast this osg::EllipsoidModel to an osg::Object.");
|
||||
// Write EllipsoidModel's properties.
|
||||
|
||||
out->writeDouble(getRadiusEquator());
|
||||
out->writeDouble(getRadiusPolar());
|
||||
|
||||
}
|
||||
|
||||
void EllipsoidModel::read(DataInputStream* in){
|
||||
// Peek on EllipsoidModel's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEELLIPSOIDMODEL){
|
||||
// Read EllipsoidModel's identification.
|
||||
id = in->readInt();
|
||||
// If the osg class is inherited by any other class we should also read this from file.
|
||||
osg::Object* obj = dynamic_cast<osg::Object*>(this);
|
||||
if(obj){
|
||||
((ive::Object*)(obj))->read(in);
|
||||
}
|
||||
else
|
||||
throw Exception("EllipsoidModel::read(): Could not cast this osg::EllipsoidModel to an osg::Object.");
|
||||
// Read EllipsoidModel's properties
|
||||
|
||||
setRadiusEquator(in->readDouble());
|
||||
setRadiusPolar(in->readDouble());
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("EllipsoidModel::read(): Expected EllipsoidModel identification.");
|
||||
}
|
||||
}
|
||||
15
src/osgPlugins/ive/EllipsoidModel.h
Normal file
15
src/osgPlugins/ive/EllipsoidModel.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef IVE_ELLIPSOIDMODEL
|
||||
#define IVE_ELLIPSOIDMODEL 1
|
||||
|
||||
#include <osg/CoordinateSystemNode>
|
||||
#include "ReadWrite.h"
|
||||
|
||||
namespace ive{
|
||||
class EllipsoidModel : public osg::EllipsoidModel, public ReadWrite {
|
||||
public:
|
||||
void write(DataOutputStream* out);
|
||||
void read(DataInputStream* in);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -9,6 +9,7 @@ CXXFILES =\
|
||||
BlendFunc.cpp\
|
||||
ConvexPlanarOccluder.cpp\
|
||||
ConvexPlanarPolygon.cpp\
|
||||
CoordinateSystemNode.cpp\
|
||||
ClusterCullingCallback.cpp\
|
||||
CullFace.cpp\
|
||||
DataInputStream.cpp\
|
||||
@@ -20,6 +21,7 @@ CXXFILES =\
|
||||
DrawElementsUShort.cpp\
|
||||
DrawElementsUInt.cpp\
|
||||
Drawable.cpp\
|
||||
EllipsoidModel.cpp\
|
||||
Exception.cpp\
|
||||
Geode.cpp\
|
||||
Geometry.cpp\
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace ive {
|
||||
#define IVECONVEXPLANARPOLYGON 0x00000020
|
||||
#define IVEPAGEDLOD 0x00000021
|
||||
#define IVEDOFTRANSFORM 0x00000022
|
||||
#define IVECOORDINATESYSTEMNODE 0x00000023
|
||||
#define IVEELLIPSOIDMODEL 0x00000024
|
||||
|
||||
// Node callbacks
|
||||
#define IVENODECALLBACK 0x00000050
|
||||
|
||||
Reference in New Issue
Block a user