Sorry for the late reply. The codes of CreateGeometryNode looks like this:
osg::ref_ptr<osg::MatrixTransform> CreateGeometryNode() {
std::vector<float> xyzs = RandomPoints(); ///< Create ramdon number of points
osg::Vec3Array vs = new osg::Vec3Array(xyzs.size()/3, (const osg::Vec3 *)(xyzs.data()));
osg::ref_ptr<osg::Geometry> geo = new osg::Geometry;
geo->setVertexArray(vs.get());
geo->setColorArray(osg::Vec3(0.5,0.5,0.5));
geo->setColorBinding(osg::Geometry::BIND_OVERALL);
geo->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, numpt));
geo->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
geo->getOrCreateStateSet()->setAttribute(new osg::Point(size), osg::StateAttribute::ON);
osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform;
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable(geo.get());
mt->addChild(geode);
return mt;
}
There's an old post from you which said that OSG will cache objects to improve performance, I wonder if this is the case and how I could change that behavior.
Thanks!