From 964110f315619e28c310781beddb8df7a1aa0ae3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 23 Feb 2006 20:37:19 +0000 Subject: [PATCH] Completed .osg support for ClusterCullingCallback. --- src/osgPlugins/osg/ClusterCullingCallback.cpp | 56 ++++++++++++++++--- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/src/osgPlugins/osg/ClusterCullingCallback.cpp b/src/osgPlugins/osg/ClusterCullingCallback.cpp index 85eb56ee3..b55583b24 100644 --- a/src/osgPlugins/osg/ClusterCullingCallback.cpp +++ b/src/osgPlugins/osg/ClusterCullingCallback.cpp @@ -1,6 +1,5 @@ -#include - #include +#include #include #include @@ -23,21 +22,60 @@ osgDB::RegisterDotOsgWrapperProxy ClusterCullingCallback_Proxy bool ClusterCullingCallback_readLocalData(osg::Object &obj, osgDB::Input &fr) { - ClusterCullingCallback& nc = dynamic_cast(obj); - if (!(&nc)) return false; + ClusterCullingCallback* ccc = dynamic_cast(&obj); + if (!ccc) return false; - bool itrAdvanced = false; + bool iteratorAdvanced = false; + osg::Vec3 vec; + if (fr[0].matchWord("controlPoint") && + fr[1].getFloat(vec[0]) && fr[2].getFloat(vec[1]) && fr[3].getFloat(vec[2])) + { + ccc->setControlPoint(vec); + fr += 4; + iteratorAdvanced = true; + } - return itrAdvanced; + if (fr[0].matchWord("normal") && + fr[1].getFloat(vec[0]) && fr[2].getFloat(vec[1]) && fr[3].getFloat(vec[2])) + { + ccc->setNormal(vec); + fr += 4; + iteratorAdvanced = true; + } + + float value; + if (fr[0].matchWord("radius") && fr[1].getFloat(value)) + { + ccc->setRadius(value); + fr += 2; + iteratorAdvanced = true; + } + + if (fr[0].matchWord("deviation") && fr[1].getFloat(value)) + { + ccc->setDeviation(value); + fr += 2; + iteratorAdvanced = true; + } + + return iteratorAdvanced; } bool ClusterCullingCallback_writeLocalData(const osg::Object &obj, osgDB::Output &fw) { - const ClusterCullingCallback* nc = dynamic_cast(&obj); - if (!nc) return false; + const ClusterCullingCallback* ccc = dynamic_cast(&obj); + if (!ccc) return false; - ClusterCullingCallback* nnc = (ClusterCullingCallback*) nc; + int prec = fw.precision(); + fw.precision(15); + + fw.indent() << "controlPoint " << ccc->getControlPoint() << std::endl; + fw.indent() << "normal " << ccc->getNormal() << std::endl; + fw.indent() << "radius " << ccc->getRadius() << std::endl; + fw.indent() << "deviation " << ccc->getDeviation() << std::endl; + + fw.precision(prec); return true; }