2006/10/16, Jose Luis Hidalgo <[EMAIL PROTECTED]>:
I'm not sure, the problem appears inside a scripting environment, may
be is a exception, or a bad pointer... I will try to find out what it
is... Seems that osgIntrospection allows me to convert and
osgProducer::Viewer to a Referenced object and it opens a can of
worms... never mind, the problem could be anywhere else in the code.
How can I do something like this? :
osg::ref_ptr<osg::Group> group = new osg::Group();
osgIntrospection::Value v( group.get());
osg::ref_ptr<osg::Referenced> ref =
osgIntrospection::variant_cast<osg::Referenced*>(v)
is it correct? because I'm not able to use it, the variant_cast
throws an exception:type `PN3osg5GroupE' is declared but not defined
ok so about the variant_cast, there are some strange thing
1) under linux, use the -Wl,-E in the link line
2) under windows, i use visual studio 8.0 and the osgIntrospection::variant_cast call could not compile
the compilator give an obscure error, i use osgIntrospection::getInstance instead
I don'l like window sufficiently to look for the problem and find an explication
if you use the -Wl,-E option the exception is not throw.
see the example file joint with the mail
There are something wrong in osgUtil ...
compile line : g++ -W -Wall -Wl,-E osgintrospection_variant_cast.cpp -losgIntrospection -losg -losgDB
cheers
David Callu
#include <osg/ref_ptr> #include <osg/Group> #include <osgIntrospection/Reflection> #include <osgIntrospection/variant_cast> #include <osgIntrospection/Utility> #include <osgIntrospection/Type>
#include <osgDB/DynamicLibrary>
#include <iostream>
using namespace osgIntrospection;
// borrowed from osgDB...
std::string createLibraryNameForWrapper(const std::string& ext)
{
#if defined(WIN32)
// !! recheck evolving Cygwin DLL extension naming protocols !! NHV
#ifdef __CYGWIN__
return "cygosgwrapper_"+ext+".dll";
#elif defined(__MINGW32__)
return "libosgwrapper_"+ext+".dll";
#else
#ifdef _DEBUG
return "osgwrapper_"+ext+"d.dll";
#else
return "osgwrapper_"+ext+".dll";
#endif
#endif
#elif macintosh
return "osgwrapper_"+ext;
#elif defined(__hpux__)
// why don't we use PLUGIN_EXT from the makefiles here?
return "osgwrapper_"+ext+".sl";
#else
return "osgwrapper_"+ext+".so";
#endif
}
int main(int argc, char** argv)
{
// load the library of wrappers that reflect the
// classes defined in the 'osg' namespace. In the
// future this will be done automatically under
// certain circumstances (like deserialization).
osg::ref_ptr<osgDB::DynamicLibrary> osg_reflectors = osgDB::DynamicLibrary::loadLibrary(createLibraryNameForWrapper("osg"));
osg::ref_ptr<osgDB::DynamicLibrary> osgDB_reflectors = osgDB::DynamicLibrary::loadLibrary(createLibraryNameForWrapper("osgDB"));
osg::ref_ptr<osgDB::DynamicLibrary> osgFX_reflectors = osgDB::DynamicLibrary::loadLibrary(createLibraryNameForWrapper("osgFX"));
osg::ref_ptr<osgDB::DynamicLibrary> osgGA_reflectors = osgDB::DynamicLibrary::loadLibrary(createLibraryNameForWrapper("osgGA"));
osg::ref_ptr<osgDB::DynamicLibrary> osgParticle_reflectors = osgDB::DynamicLibrary::loadLibrary(createLibraryNameForWrapper("osgParticle"));
osg::ref_ptr<osgDB::DynamicLibrary> osgText_reflectors = osgDB::DynamicLibrary::loadLibrary(createLibraryNameForWrapper("osgText"));
osg::ref_ptr<osgDB::DynamicLibrary> osgSim_reflectors = osgDB::DynamicLibrary::loadLibrary(createLibraryNameForWrapper("osgSim"));
osg::ref_ptr<osgDB::DynamicLibrary> osgTerrain_reflectors = osgDB::DynamicLibrary::loadLibrary(createLibraryNameForWrapper("osgTerrain"));
try
{
osg::ref_ptr<osg::Group> group = new osg::Group();
std::cout << "osg::ref_ptr<osg::Group> group = " << group.get() << std::endl;
osgIntrospection::Value v(group.get());
osg::ref_ptr<osg::Referenced> ref(osgIntrospection::variant_cast<osg::Referenced*>(v));
std::cout << "osg::ref_ptr<osg::Referenced> ref = " << ref.get() << std::endl;
}
catch(const osgIntrospection::Exception &e)
{
std::cerr << e.what() << std::endl;
}
std::cout << "Now load the osgUtil wrapper" << std::endl;
osg::ref_ptr<osgDB::DynamicLibrary> osgUtil_reflectors = osgDB::DynamicLibrary::loadLibrary(createLibraryNameForWrapper("osgUtil"));
try
{
osg::ref_ptr<osg::Group> group = new osg::Group();
std::cout << "osg::ref_ptr<osg::Group> group = " << group.get() << std::endl;
osgIntrospection::Value v(group.get());
osg::ref_ptr<osg::Referenced> ref(osgIntrospection::variant_cast<osg::Referenced*>(v));
std::cout << "osg::ref_ptr<osg::Referenced> ref = " << ref.get() << std::endl
<< "if ref == 0 here, there are probably something wrong in osgUtil wrapper" << std::endl;
}
catch(const osgIntrospection::Exception &e)
{
std::cerr << e.what() << std::endl;
}
return 0;
}
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
