Re: [osg-users] Usage of osg::Node clone methode.
Well i feel stupid... I finally found why it didn't work. During a debugging session, after having passed my five turn of loop, who work like a charm, i try to continue runing my program, and the five trees where here... It appears that the srand(time(0)) made inside the loop made only one tree apears when you don't step by step the program in the loop I just put the srand before my loop, and it work like a charm Sorry for the inconvenience Tanks again for your help. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=22976#22976 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Usage of osg::Node clone methode.
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_ptrosg::Node Arbre = osgDB::readNodeFile(modeles/arbre.obj); osg::ref_ptrosg::PositionAttitudeTransform temp; for(int i = 0 ; i 5; i++) { temp = new osg::PositionAttitudeTransform; osg::Node* copy = dynamic_castosg::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
Re: [osg-users] Usage of osg::Node clone methode.
Hi, you dont need to clone the model for this purpose. Use the one loaded with different MatrixTransforms on top osg::ref_ptrosg::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.frwrote: 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_ptrosg::Node Arbre = osgDB::readNodeFile(modeles/arbre.obj); osg::ref_ptrosg::PositionAttitudeTransform temp; for(int i = 0 ; i 5; i++) { temp = new osg::PositionAttitudeTransform; osg::Node* copy = dynamic_castosg::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
Re: [osg-users] Usage of osg::Node clone methode.
Hi, Well this doesn't work ^^... I tried, and only one tree appears, but if a do : for(int i = 0 ; i 5; i++) { osg::PositionAttitudeTransform* temp = new osg::PositionAttitudeTransform; temp-addChild(osgDB::readNodeFile(modeles/arbre.obj)); temp-setPosition(myPos); this-addChild(temp); } This work, i got all my trees But thanks for your help anyways. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=22949#22949 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Usage of osg::Node clone methode.
well, I can not see why it shouldnt work. Are you setting different positions in the loop ? Nick http://www.linkedin.com/in/tnick Sent from Izmit, 41, Turkey On Wed, Jan 20, 2010 at 7:02 PM, Guillaume Saby luckybo...@hotmail.frwrote: Hi, Well this doesn't work ^^... I tried, and only one tree appears, but if a do : for(int i = 0 ; i 5; i++) { osg::PositionAttitudeTransform* temp = new osg::PositionAttitudeTransform; temp-addChild(osgDB::readNodeFile(modeles/arbre.obj)); temp-setPosition(myPos); this-addChild(temp); } This work, i got all my trees But thanks for your help anyways. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=22949#22949 ___ 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