#include "osg/Billboard" #include "osgDB/Registry" #include "osgDB/Input" #include "osgDB/Output" using namespace osg; using namespace osgDB; // forward declare functions to use later. bool Billboard_readLocalData(Object& obj, Input& fr); bool Billboard_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_BillboardProxy ( osgNew osg::Billboard, "Billboard", "Object Node Geode Billboard", &Billboard_readLocalData, &Billboard_writeLocalData ); bool Billboard_readLocalData(Object& obj, Input& fr) { bool iteratorAdvanced = false; Billboard& billboard = static_cast(obj); if (fr[0].matchWord("Mode")) { if (fr[1].matchWord("AXIAL_ROT")) { billboard.setMode(Billboard::AXIAL_ROT); fr+=2; iteratorAdvanced = true; } else if (fr[1].matchWord("POINT_ROT_EYE")) { billboard.setMode(Billboard::POINT_ROT_EYE); fr+=2; iteratorAdvanced = true; } else if (fr[1].matchWord("POINT_ROT_WORLD")) { billboard.setMode(Billboard::POINT_ROT_WORLD); fr+=2; iteratorAdvanced = true; } } if (fr[0].matchWord("Axis")) { float x,y,z; if (fr[1].getFloat(x) && fr[2].getFloat(y) && fr[3].getFloat(z)) { billboard.setAxis(Vec3(x,y,z)); fr+=4; iteratorAdvanced = true; } } // read the position data. bool matchFirst = false; if ((matchFirst=fr.matchSequence("Positions {")) || fr.matchSequence("Positions %i {")) { // set up coordinates. int entry = fr[0].getNoNestedBrackets(); Billboard::PositionList& positionList = billboard.getPositionList(); positionList.clear(); if (matchFirst) { fr += 2; } else { //positionList.(capacity); fr += 3; } Vec3 pos; while (!fr.eof() && fr[0].getNoNestedBrackets()>entry) { if (fr[0].getFloat(pos[0]) && fr[1].getFloat(pos[1]) && fr[2].getFloat(pos[2])) { fr += 3; positionList.push_back(pos); } else { ++fr; } } iteratorAdvanced = true; ++fr; } return iteratorAdvanced; } bool Billboard_writeLocalData(const Object& obj, Output& fw) { const Billboard& billboard = static_cast(obj); switch(billboard.getMode()) { case(Billboard::AXIAL_ROT): fw.indent() << "Mode AXIAL_ROT"<