Hi Robert,

Once again, thank you for your time.

I continued to look into the scene export issues I was having, and here are some of my findings (against OSG 3.1.7 development release).

I attached an alternate implementation of osgDB::Registry::writeNodeImplementation(). The same changes would apply to other Registry member functions: writeShaderImplementation(), writeObjectImplementation(), writeImageImplementation(), writeHeightFieldImplementation(), and possibly read().

One of the major behavior changes is that once ERROR_IN_WRITING_FILE is encountered, no more attempts are made to write the file. It also prevents a possible ERROR_IN_WRITING_FILE status from propagating even though the real error seemed to be FILE_NOT_HANDED. The changes I made are based on my assumptions about how the plugins "should work", but I may have overlooked something. The point of the changes is to make it so the export behavior is the same, regardless of whether or not a plugin DLL was loaded in response to an export request.

Also, per our DLL search path discussion, the following DLL paths are searched when attempting to export a model to "osg.txt" (where txt is an unregistered extension that is not associated with any plugins):

1. Executable folder: [path to application binary]\osgPlugins-3.1.7\osgdb_txt.dll ... 2. Location of osgDB DLL: [path to osgDB DLL]\osgPlugins-3.1.7\osgdb_txt.dll ...
3. System 32 folder: C:\Windows\system32\osgPlugins-3.1.7\osgdb_txt.dll ...
4. System folder: C:\Windows\System\osgPlugins-3.1.7\osgdb_txt.dll ...
5. Windows folder: C:\Windows\osgPlugins-3.1.7\osgdb_txt.dll ...
6. Working directory: .\osgPlugins-3.1.7\osgdb_txt.dll ...
7. Folders specified in PATH env var: [PATH ...]\osgPlugins-3.1.7\osgdb_txt.dll ...

[Repeat list, but omit osgPlugins-* portion of that path]

I ended up loading all of the OSG plugin DLLs I plan to use manually and calling osgDB::Registry::instance ()->setLibraryFilePathList (std::string ()); early during application startup to prevent the traversal of the above search paths. I cannot speak for other platforms, but for Microsoft Windows environments, the default plugin DLL loading behavior does not seem suitable for production environments.

Regards,

Judson
ReaderWriter::WriteResult Registry::writeNodeImplementation(const Node& 
node,const std::string& fileName,const Options* options)
{
    // storage for a ReaderWriter result.
    ReaderWriter::WriteResult 
result(ReaderWriter::WriteResult::FILE_NOT_HANDLED);

    // now look for a plug-in to save the file.
    std::string libraryName = createLibraryNameForFile(fileName);
    (void) loadLibrary(libraryName);

    // attempt to write the file from ReaderWriter(s).
    AvailableReaderWriterIterator itr(_rwList, _pluginMutex);
    for(;itr.valid();++itr)
    {
        ReaderWriter::WriteResult rr = itr->writeNode(node,fileName,options);
        if (rr.success() || rr.error ())
        {
            // rr.status(): FILE_SAVED or ERROR_IN_WRITING_FILE
            result = rr;
            break;
        }

        // rr.status(): NOT_IMPLEMENTED or FILE_NOT_HANDLED
    }

    if (result.message().empty())
    {
        switch(result.status())
        {
            case(ReaderWriter::WriteResult::FILE_NOT_HANDLED):
                result.message() = "Warning: Write to \""+fileName+"\" not 
supported.";
                break;

            case(ReaderWriter::WriteResult::ERROR_IN_WRITING_FILE):
                result.message() = "Warning: Error in writing to 
\""+fileName+"\".";
                break;
        }
    }

    return result;
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to