Hi, I looked through a lot of documentation on the OSG and did not find how to use correctly "draw instancing" in the OSG. I want to load the model tree in a format tree.3ds or tree.osg and draw more than 10,000 copies.
Please tell my classes for what I need to pay attention to the OSG to use "draw instancing" and draw a lot of trees. I tried to write this code: Code: static osg::Node *treeNode = NULL; treeNode = osgDB::readNodeFile("../../tree.3ds"); osg::Group *root = new osg::Group(); int k=100; // 10 000 for (int i=0, x=0; i<k; ++i, x+=40) for (int i=0, y=0; i<k; ++i, y+=40) { osg::MatrixTransform *tm = new osg::MatrixTransform; tm->setMatrix(osg::Matrix::translate(osg::Vec3f(x, y, 0))); tm->addChild(treeNode); root->addChild(tm); } osgViewer::Viewer viewer; viewer.setSceneData(root); viewer.setCameraManipulator(new osgGA::TrackballManipulator); viewer.realize(); printf("\nroot_num_childrens=%i\n", root->getNumChildren()); while(!viewer.done()) { viewer.frame(); } But this method is very bad. Because it is slow and takes a lot of memory. Thank you! Cheers, Oleg ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=27160#27160 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org