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:
60
src/osgPlugins/osg/CoordinateSystemNode.cpp
Normal file
60
src/osgPlugins/osg/CoordinateSystemNode.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "osg/CoordinateSystemNode"
|
||||
|
||||
#include "osgDB/Registry"
|
||||
#include "osgDB/Input"
|
||||
#include "osgDB/Output"
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
|
||||
// forward declare functions to use later.
|
||||
bool CoordinateSystemNode_readLocalData(Object& obj, Input& fr);
|
||||
bool CoordinateSystemNode_writeLocalData(const Object& obj, Output& fw);
|
||||
|
||||
// register the read and write functions with the osgDB::Registry.
|
||||
RegisterDotOsgWrapperProxy g_CoordinateSystemNodeProxy
|
||||
(
|
||||
new osg::CoordinateSystemNode,
|
||||
"CoordinateSystemNode",
|
||||
"Object Node CoordinateSystemNode Group",
|
||||
&CoordinateSystemNode_readLocalData,
|
||||
&CoordinateSystemNode_writeLocalData
|
||||
);
|
||||
|
||||
bool CoordinateSystemNode_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
CoordinateSystemNode& csn = static_cast<CoordinateSystemNode&>(obj);
|
||||
|
||||
if (fr.matchSequence("CoordinateSystem %s"))
|
||||
{
|
||||
const char* str = fr[1].getStr();
|
||||
if (str) csn.setCoordinateSystem(str);
|
||||
|
||||
iteratorAdvanced = true;
|
||||
fr+=2;
|
||||
}
|
||||
|
||||
static ref_ptr<EllipsoidModel> s_ellipsoidModel = new EllipsoidModel;
|
||||
|
||||
EllipsoidModel* em = static_cast<EllipsoidModel*>(fr.readObjectOfType(*s_ellipsoidModel));
|
||||
if (em) csn.setEllipsoidModel(em);
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
|
||||
bool CoordinateSystemNode_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const CoordinateSystemNode& csn = static_cast<const CoordinateSystemNode&>(obj);
|
||||
|
||||
fw.indent()<<"CoordinateSystem "<<fw.wrapString(csn.getCoordinateSystem())<<std::endl;
|
||||
|
||||
if (csn.getEllipsoidModel())
|
||||
{
|
||||
fw.writeObject(*csn.getEllipsoidModel());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user