Merge pull request #390 from filnet/readref

replace more read*File() usage to readRef*File()
This commit is contained in:
OpenSceneGraph git repository 2017-11-29 08:09:01 +00:00 committed by GitHub
commit fc1d19b6e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 15 additions and 11 deletions

View File

@ -23,7 +23,7 @@ void OsgMainApp::loadModels(){
newModel = _vModelsToLoad[i]; newModel = _vModelsToLoad[i];
osg::notify(osg::ALWAYS)<<"Loading: "<<newModel.filename<<std::endl; osg::notify(osg::ALWAYS)<<"Loading: "<<newModel.filename<<std::endl;
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(newModel.filename); osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFile(newModel.filename);
if (loadedModel == 0) { if (loadedModel == 0) {
osg::notify(osg::ALWAYS)<<"Model not loaded"<<std::endl; osg::notify(osg::ALWAYS)<<"Model not loaded"<<std::endl;
} else { } else {

View File

@ -23,7 +23,7 @@ void OsgMainApp::loadModels(){
newModel = _vModelsToLoad[i]; newModel = _vModelsToLoad[i];
osg::notify(osg::ALWAYS)<<"Loading: "<<newModel.filename<<std::endl; osg::notify(osg::ALWAYS)<<"Loading: "<<newModel.filename<<std::endl;
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(newModel.filename); osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFile(newModel.filename);
if (loadedModel == 0) { if (loadedModel == 0) {
osg::notify(osg::ALWAYS)<<"Model not loaded"<<std::endl; osg::notify(osg::ALWAYS)<<"Model not loaded"<<std::endl;
} else { } else {

View File

@ -196,7 +196,11 @@ int main( int argc, char **argv )
newCameraProperty = true; newCameraProperty = true;
cp = new gsc::CameraProperty; cp = new gsc::CameraProperty;
osg::ref_ptr<osg::Node> node = fc->getInputFileName().empty() ? 0 : osgDB::readNodeFile(fc->getInputFileName()); osg::ref_ptr<osg::Node> node;
if (!fc->getInputFileName().empty())
{
osgDB::readRefNodeFile(fc->getInputFileName());
}
if (node.valid()) if (node.valid())
{ {
cp->setToModel(node.get()); cp->setToModel(node.get());
@ -522,7 +526,7 @@ int main( int argc, char **argv )
gsc::CaptureSettings* fc = itr->get(); gsc::CaptureSettings* fc = itr->get();
screenShot->_frameCapture = fc; screenShot->_frameCapture = fc;
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(fc->getInputFileName()); osg::ref_ptr<osg::Node> model = osgDB::readRefNodeFile(fc->getInputFileName());
if (!model) break; if (!model) break;
viewer.setSceneData(model.get()); viewer.setSceneData(model.get());

View File

@ -170,7 +170,7 @@ int main(int argc, char** argv)
} }
// load the data // load the data
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments); osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);
if (!loadedModel) if (!loadedModel)
{ {
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl; std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;

View File

@ -1193,7 +1193,7 @@ A -respondsToSelector: check has been used to provide compatibility with previou
// int number_of_files = [file_names count]; // int number_of_files = [file_names count];
// Exercise for the reader: Try loading all files in the array // Exercise for the reader: Try loading all files in the array
NSString* single_file = [file_names objectAtIndex:0]; NSString* single_file = [file_names objectAtIndex:0];
osg::ref_ptr<osg::Node> loaded_model = osgDB::readNodeFile([single_file fileSystemRepresentation]); osg::ref_ptr<osg::Node> loaded_model = osgDB::readRefNodeFile([single_file fileSystemRepresentation]);
if(!loaded_model) if(!loaded_model)
{ {
NSLog(@"File: %@ failed to load", single_file); NSLog(@"File: %@ failed to load", single_file);
@ -1212,7 +1212,7 @@ A -respondsToSelector: check has been used to provide compatibility with previou
return NO; return NO;
} }
NSString* file_path = [file_url path]; NSString* file_path = [file_url path];
osg::ref_ptr<osg::Node> loaded_model = osgDB::readNodeFile([file_path fileSystemRepresentation]); osg::ref_ptr<osg::Node> loaded_model = osgDB::readRefNodeFile([file_path fileSystemRepresentation]);
if(!loaded_model) if(!loaded_model)
{ {
NSLog(@"URL: %@ failed to load, %@", file_url, file_path); NSLog(@"URL: %@ failed to load, %@", file_url, file_path);

View File

@ -39,7 +39,7 @@ FOX_OSG_MDIView::FOX_OSG_MDIView(FXMDIClient *p, const FXString &name,
viewer->setKeyEventSetsDone(0); viewer->setKeyEventSetsDone(0);
// load the scene. // load the scene.
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile("cow.osgt"); osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFile("cow.osgt");
if (!loadedModel) if (!loadedModel)
{ {
return ; return ;

View File

@ -69,7 +69,7 @@ class ExampleOSGGTKDrawingArea : public OSGGTKDrawingArea {
if(gtk_dialog_run(GTK_DIALOG(of)) == GTK_RESPONSE_ACCEPT) { if(gtk_dialog_run(GTK_DIALOG(of)) == GTK_RESPONSE_ACCEPT) {
char* file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(of)); char* file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(of));
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(file); osg::ref_ptr<osg::Node> model = osgDB::readRefNodeFile(file);
if(model.valid()) { if(model.valid()) {
setSceneData(model.get()); setSceneData(model.get());
@ -170,7 +170,7 @@ int main(int argc, char** argv) {
if(da.createWidget(640, 480)) { if(da.createWidget(640, 480)) {
if(argc >= 2) { if(argc >= 2) {
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(argv[1]); osg::ref_ptr<osg::Node> model = osgDB::readRefNodeFile(argv[1]);
if(model.valid()) da.setSceneData(model.get()); if(model.valid()) da.setSceneData(model.get());
} }

View File

@ -337,7 +337,7 @@ private:
_root->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE); _root->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);
//load and attach scene model //load and attach scene model
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(osgDB::findDataFile("lz.osg")); osg::ref_ptr<osg::Node> model = osgDB::readRefNodeFile(osgDB::findDataFile("lz.osg"));
if (!model) { if (!model) {
osg::Geode* geode = new osg::Geode(); osg::Geode* geode = new osg::Geode();
osg::ShapeDrawable* drawable = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0,0,0), 1)); osg::ShapeDrawable* drawable = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0,0,0), 1));