Hi, you dont need to clone the model for this purpose. Use the one loaded with different MatrixTransforms on top
osg::ref_ptr<osg::Node> Arbre = osgDB::readNodeFile("modeles/arbre.obj"); for(int i = 0 ; i < 5; i++) { osg::PositionAttitudeTransform* temp = new osg::PositionAttitudeTransform; temp->addChild(Abre.get()); temp->setPosition(myPos); this->addChild(temp.get()); } Also use osgconv to convert it into ive (osgconvert model.obj model.ive). It will load much faster Nick http://www.linkedin.com/in/tnick Sent from Izmit, 41, Turkey On Wed, Jan 20, 2010 at 3:32 PM, Guillaume Saby <luckybo...@hotmail.fr>wrote: > Hi, > > I'm actually in my second year for a diploma in IT. We curreently work on a > group project using OpenSceneGraph. > > We're making a turn by turn tactical game. On our map, we want to load some > trees. We have a .obj model (soon .osg) and use osgDB::ReadNodeFile to load > it, and put it in a PositionAttituteTransform with the good pos. > > The problem is that it took some time to load the model (around a > second)...I try to avoid it by copying the already loaded model, using the > clone function of osg::Node in a for loop, and puting the cloned node inside > a newly created PositionAttituteTransform ... > > But only one tree apears on the map. > If i use each time osgDB::ReadNodeFile in the loop, it works, i've got my > tree, but it took ~ 5 second for 5 trees.... > > Here's my code, maybe more clear than my english... > > > Code: > > //Loading of the model > osg::ref_ptr<osg::Node> Arbre = osgDB::readNodeFile("modeles/arbre.obj"); > > osg::ref_ptr<osg::PositionAttitudeTransform> temp; > > for(int i = 0 ; i < 5; i++) > { > temp = new osg::PositionAttitudeTransform; > > osg::Node* copy = dynamic_cast<osg::Node*>(Arbre->clone(osg::CopyOp())); > temp->addChild(copy); > temp->setPosition(myPos); > this->addChild(temp.get()); > } > > > > > "this" is my class which inherit from osg::Group. > > Did i use it wrong? Is it not possible to copy a node loaded byt > osg::ReadNodeFile? > > Thank you![/code] > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=22933#22933 > > > > > > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org