Revision: 8290 http://playerstage.svn.sourceforge.net/playerstage/?rev=8290&view=rev Author: hsujohnhsu Date: 2009-10-14 23:31:54 +0000 (Wed, 14 Oct 2009)
Log Message: ----------- patch to check absolute and relative paths for a mesh file. Modified Paths: -------------- code/gazebo/trunk/server/MeshLoader.cc Modified: code/gazebo/trunk/server/MeshLoader.cc =================================================================== --- code/gazebo/trunk/server/MeshLoader.cc 2009-10-13 22:19:28 UTC (rev 8289) +++ code/gazebo/trunk/server/MeshLoader.cc 2009-10-14 23:31:54 UTC (rev 8290) @@ -6,6 +6,7 @@ #include "Simulator.hh" #include "GazeboConfig.hh" +#include "GazeboMessage.hh" #include "MeshLoader.hh" using namespace gazebo; @@ -28,27 +29,47 @@ { struct stat st; std::string fullname; + bool found = false; - std::list<std::string> gazeboPaths; + std::string extension; - gazeboPaths = Simulator::Instance()->GetGazeboConfig()->GetGazeboPaths(); - - for (std::list<std::string>::iterator iter=gazeboPaths.begin(); - iter!=gazeboPaths.end(); ++iter) + fullname = std::string("./")+filename; + if (stat(fullname.c_str(), &st) == 0) { - fullname = (*iter)+"/Media/models/"+filename; - if (stat(fullname.c_str(), &st) == 0) + found = true; + } + else if ( stat(filename.c_str(), &st) == 0) + { + fullname = filename; + found = true; + } + else + { + std::list<std::string> gazeboPaths; + gazeboPaths = Simulator::Instance()->GetGazeboConfig()->GetGazeboPaths(); + for (std::list<std::string>::iterator iter=gazeboPaths.begin(); + iter!=gazeboPaths.end(); ++iter) { - std::string extension = fullname.substr(fullname.rfind(".")+1, - fullname.size()); - if (extension == "mesh") - this->LoadOgre(fullname); - else - this->ivcon.Load(fullname, this->vertices, this->indices); - break; + fullname = (*iter)+"/Media/models/"+filename; + if (stat(fullname.c_str(), &st) == 0) + { + found = true; + break; + } } } + if (found) + { + extension = fullname.substr(fullname.rfind(".")+1, fullname.size()); + + if (extension == "mesh") + this->LoadOgre(fullname); + else + this->ivcon.Load(fullname, this->vertices, this->indices); + } + else + gzerr(0) << "Unable to find file[" << filename << "]\n"; } //////////////////////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit