+bool ShaderGeometry_readLocalData(Object& obj, Input& fr)
+{
+ bool iteratorAdvanced = false;
+
+ ShaderGeometry& geom = static_cast<ShaderGeometry&>(obj);
+
+ if ((fr[0].matchWord("geometry"))) {
+ ++fr;
+ iteratorAdvanced = true;
+ osg::Drawable* drawable = fr.readDrawable();
+ if (drawable) {
+ geom._geometry = drawable;
+ }
+ }
+ if ((fr.matchSequence("instances %i"))) {
+ int entry = fr[0].getNoNestedBrackets();
+ int capacity;
+ fr[1].getInt(capacity);
+ geom._trees.reserve(capacity);
+ fr += 3;
+ iteratorAdvanced = true;
+ // skip {
+ while (!fr.eof() && fr[0].getNoNestedBrackets() > entry) {
+ SGVec3f v;
+ int t;
+ float s;
+ if (fr[0].getFloat(v.x()) && fr[1].getFloat(v.y())
+ && fr[2].getFloat(v.z()) && fr[3].getInt(t) && fr[4].getFloat(s)) {
+ fr += 4;
+ //SGVec3f* v = new SGVec3f(v.x(), v.y(), v.z());
+ //TreeBin::Tree tree = new TreeBin::Tree(v, t, s);
+ geom._trees.push_back(TreeBin::Tree(v, t, s));
+ } else {
+ ++fr;
+ }
+ }
+ }
+ return iteratorAdvanced;
+}
+
+bool ShaderGeometry_writeLocalData(const Object& obj, Output& fw)
+{
+ const ShaderGeometry& geom = static_cast<const ShaderGeometry&>(obj);
+
+ fw.indent() << "geometry" << std::endl;
+ fw.writeObject(*geom._geometry);
+ fw.indent() << "instances " << geom._trees.size() << std::endl;
+ fw.indent() << "{" << std::endl;
+ fw.moveIn();
+ for (TreeBin::TreeList::const_iterator iter
+ = geom._trees.begin();
+ iter != geom._trees.end();
+ ++iter) {
+ fw.indent() << iter->position.x() << " " << iter->position.y() << " " << iter->position.z() << " "
+ << iter->texture_index << " " << iter->scale << std::endl;
+ }
+ fw.moveOut();
+ fw.indent() << "}" << std::endl;
+ return true;
+}
+
+osgDB::RegisterDotOsgWrapperProxy shaderGeometryProxy
+(
+ new ShaderGeometry,
+ "ShaderGeometry",
+ "Object Drawable ShaderGeometry",
+ &ShaderGeometry_readLocalData,
+ &ShaderGeometry_writeLocalData
+ );