Hi,
osgDB::ReaderWriter::ReadResult will keep a handle on the node.
At the end of your function (after return), the reference count of you
object (maintained by ReadResult) will drop to Zero => object destroyed.
I don't know what is the "official" way to avoid that, but one way or
another, you will have to keep a ref_count pointer on your node to keep it
alive.
Luc
Manolo Padron Martinez <[email protected]>
Envoyé par : [email protected]
29/04/2010 16:30
Veuillez répondre à
OpenSceneGraph Users <[email protected]>
A
[email protected]
cc
Objet
[osg-users] Loading an Osg model from memory
Hi:
We're trying to load an osg model from an stream. We got the code like
this
membuf sb((char *)Data, Size);
std::istream stream(&sb);
osgDB::ReaderWriter* reader =
osgDB::Registry::instance()->getReaderWriterForExtension("osg");
if(reader)
{
osgDB::ReaderWriter::ReadResult rr =
reader->readNode(stream,0);
if(rr.success())
{
osg::Node *new_model = new
osg::Node(*rr.getNode());
return new_model;
}
}
return NULL;
Its seems to load as it should. Rr is successfull but when I try to
add the node to a treenode I didn't saw it on screen. If I change the
code before for the code to load it from disk It works perfectly. Any
idea? There are a problem with the plugin of osg file when a stream is
used to read the node?
Regards from Canary Islands
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org