First pass of load files through an interface (to allow loading from memory, zip file etc). So instead of posix fopen/fread, using CommonFileIOInterface.

A fileIO plugin can override custom file IO operations. As a small test, load files from a zipfile in memory.
Default fileIO implementation is in examples/Utils/b3BulletDefaultFileIO.h
Affects URDF, SDF, MJCF, Wavefront OBJ, STL, DAE, images.
This commit is contained in:
erwincoumans
2018-10-08 21:27:08 -07:00
parent a1543714f1
commit dba239fe8d
49 changed files with 1211 additions and 322 deletions

View File

@@ -2,12 +2,15 @@
#include "../../ThirdPartyLibs/tinyxml2/tinyxml2.h"
#include "urdfStringSplit.h"
#include "urdfLexicalCast.h"
#include "UrdfFindMeshFile.h"
using namespace tinyxml2;
UrdfParser::UrdfParser()
UrdfParser::UrdfParser(CommonFileIOInterface* fileIO)
: m_parseSDF(false),
m_activeSdfModel(-1),
m_urdfScaling(1)
m_urdfScaling(1),
m_fileIO(fileIO)
{
m_urdf2Model.m_sourceFile = "IN_MEMORY_STRING"; // if loadUrdf() called later, source file name will be replaced with real
}
@@ -495,7 +498,7 @@ bool UrdfParser::parseGeometry(UrdfGeometry& geom, XMLElement* g, ErrorLogger* l
}
geom.m_meshFileName = fn;
bool success = findExistingMeshFile(
bool success = UrdfFindMeshFile(m_fileIO,
m_urdf2Model.m_sourceFile, fn, sourceFileLocation(shape),
&geom.m_meshFileName, &geom.m_meshFileType);
if (!success)