I have been using OSG for a number of years for a commercial product. Our product loads various models and earth views as the user requires them (for security monitoring – buildings and campuses mostly). I have a problem with 3.6.3/4 that wasn't there in 3.4.0.
I have an OpenFlight model (sample/demo model) that uses textures for terrain and on buildings. The first time I load it all is fine. However, if I load another model (or another graphics file – the application supports AutoCAD, raster, OSG Earth, and ArcGIS formats as well) then reload the model the terrain is black and the textures are corrupted if they are not black. This worked fine with 3.4.0 and 3.4.1 but does not work with 3.6.3 or 3.6.4. I have debugged into the code and it appears that the model and textures are always reloaded from the cache and I cannot override this (setting Options::CACHE_NONE doesn’t affect it - in 3.4.0 the model always loaded from files with Options set to CACHE_NONE). If I look at the model graph in memory (after the first load), the textures appear to be erased or over-written during the traversals in one of the classes called in ViewerBase::runOperations() (though it’s a little confusing to me at that point, it appears to be when GlobalObjectVisitor::compile() calls node.accept(*this)). During the traversals where the textures appear to be over-written, I noticed the context ID is always 0, so the textures appear to be reloaded, over-writing the original data in the process (though I could be quite confused as to what I am seeing and it may all be irrelevant to the issue). Below is a short snippet from my initialization and cleanup code between model loads. I load the model, add a clip node to peel down through the models vertically. I also add other nodes to hold embedded bitmaps (Billboards) representing security devices – cameras, doors, alarm points, etc. Those details are omitted from the code below. After the model is loaded I set up the graphics context and render the image to an offscreen window (which is then copied to a memory bitmap). The application is a Windows console app (with hidden window) that streams bitmap images to the client app via named pipe on the same machine (I know, it’s complicated, but it’s a complex environment, including live video windows). As I said, it has worked fine with previous versions of OSG (back to 3.0.1, if not earlier). This may be specific to Open Flight models, as I can load FBX models, OSG earth files, or the cessnafire.osg model and the textures appear correct. Any help would be appreciated. If the model would always be loaded from the file when Options::CACHE_NONE were set it would solve my problem. OSGLoadResult OpenSceneGraphBitmap::LoadModel(std::string fileName, osgDB:: Options* dbOptions) { CleanupModel(); if (m_Root == nullptr) m_Root = new osg::Group; // Init the main Root Node/Group // Load the Model from the model name osg::Group* model = dynamic_cast<osg::Group*>(osgDB::readNodeFile( fileName, dbOptions)); if (model != nullptr) { // Optimize the model osgUtil::Optimizer optimizer; optimizer.optimize(model); optimizer.reset(); // Create the clip node and add to scene osg::ComputeBoundsVisitor cbbv; model->accept(cbbv); osg::BoundingBox bb = cbbv.getBoundingBox(); osg::ref_ptr<osg::ClipPlane> clipPlane = new osg::ClipPlane; clipPlane->setClipPlane(0.0, 0.0, -1.0, bb.zMin() + (bb.zMax() - bb.zMin())); clipPlane->setClipPlaneNum(0); osg::ref_ptr<osg::ClipNode> clipNode = new osg::ClipNode; clipNode->setName("CLIP_NODE"); clipNode->addClipPlane(clipPlane.get()); clipNode->setCullingActive(false); model->setStateSet(clipNode->getStateSet()); m_Root->addChild(clipNode); m_Root->addChild(model); m_Root->setDataVariance(osg::Object::DYNAMIC); return OSGLoadResult::Sucess; } // since load failed, reset the wait event so the render thread resumes return OSGLoadResult::FileLoadError; } void OpenSceneGraphBitmap::CleanupModel() { RemoveViews(); if (m_Root != nullptr) // if root already exists (already loaded previous scene) remove children to clean up { m_Root->releaseGLObjects(); m_Root->removeChildren(0, m_Root->getNumChildren()); void* ptr = m_Root.release(); delete ptr; m_Root = nullptr; } } void OpenSceneGraphBitmap::RemoveViews() { if (m_nhiCompositeViewer != nullptr) { m_nhiCompositeViewer->setDone(true); delete m_nhiCompositeViewer; m_nhiCompositeViewer = nullptr; } } -- You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/6f68265d-b8d2-4f74-b55a-f119fc807d37%40googlegroups.com.
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org