Hi Lucie,

I think this is a simple C++ issue.

First you create _model which is a pointer on a node.
Then you make a new node and set _model to store its adress.
Next, you load a new node and set _model to store it again. So the first
thing is, you don't need to do "_model = new osg::Node();"

So now _model is a pointer to a memory area where model1.osg is loaded.
Let's assume that you make something like view->setSceneData(_model).

Now, the view root node, which is also a pointeur, contain the same adress
than _model, where model1.osg is loaded.

Last, when you load a new model and set _model to store this new adress, you
are not modifying the viewer root node.

You should do a viewer->setSceneData(osgDB::readNodeFile("model2.osg")); or
maybe a group->replaceChild(_model,osgDB::readNodeFile("model2.osg"));

Don't hesitate to take a piece of paper to draw some memory allocation and
pointers to understand what is really done.

I hope this will help you.

Regards,
    Vincent.


2010/12/10 lucie lemonnier <lucielemonn...@hotmail.fr>

> Hi,
>
> I want to change the 3D model dynamically at the runtime.
> I have inatialize my node  at :
> _model = new osg::Node();
> _model = osgDB::readNodeFile("model1.osg");
>
> and when I do a particular action, I would like that the 3D model changes,
> I write this :
> _model = osgDB::readNodeFile("model2.osg");
> But it doesn't work!
> Would you have an idea?
>
> Thank you!
>
> Cheers,
> lucie
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=34707#34707
>
>
>
>
>
> _______________________________________________
> 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

Reply via email to