From 4e67b2c989418af5fa4b0ee023457612dacc6f1a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 1 May 2005 21:33:12 +0000 Subject: [PATCH] Moved Impostor from osg to osgSim .osg plugin --- src/osgPlugins/osgSim/IO_Impostor.cpp | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/osgPlugins/osgSim/IO_Impostor.cpp diff --git a/src/osgPlugins/osgSim/IO_Impostor.cpp b/src/osgPlugins/osgSim/IO_Impostor.cpp new file mode 100644 index 000000000..31501aad7 --- /dev/null +++ b/src/osgPlugins/osgSim/IO_Impostor.cpp @@ -0,0 +1,51 @@ +#include "osgSim/Impostor" + +#include "osgDB/Registry" +#include "osgDB/Input" +#include "osgDB/Output" + +using namespace osgSim; +using namespace osgDB; + +// forward declare functions to use later. +bool Impostor_readLocalData(osg::Object& obj, Input& fr); +bool Impostor_writeLocalData(const osg::Object& obj, Output& fw); + +// register the read and write functions with the osgDB::Registry. +RegisterDotOsgWrapperProxy g_ImpostorProxy +( + new osgSim::Impostor, + "Impostor", + "Object Node Impostor LOD Group", + &Impostor_readLocalData, + &Impostor_writeLocalData +); + +bool Impostor_readLocalData(osg::Object& obj, Input& fr) +{ + bool iteratorAdvanced = false; + + Impostor& impostor = static_cast(obj); + + if (fr.matchSequence("ImpostorThreshold %f")) + { + float threshold; + fr[1].getFloat(threshold); + impostor.setImpostorThreshold(threshold); + + iteratorAdvanced = true; + fr+=2; + } + + return iteratorAdvanced; +} + + +bool Impostor_writeLocalData(const osg::Object& obj, Output& fw) +{ + const Impostor& impostor = static_cast(obj); + + fw.indent() << "ImpostorThreshold "<< impostor.getImpostorThreshold() << std::endl; + + return true; +}