diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 8941d39e0..5189455c0 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -110,7 +110,7 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I mTextures.clear(); // parse the input file - ColladaParser parser( pFile); + ColladaParser parser( pIOHandler, pFile); if( !parser.mRootNode) throw new ImportErrorException( "Collada: File came out empty. Something is wrong here."); @@ -154,16 +154,6 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I // store all lights StoreSceneLights( pScene); - // if we know which camera is the primary camera, copy it to index 0 - if (0 == parser.mRootNode->mPrimaryCamera.length()) { - for (unsigned int i = 1; i < mCameras.size(); ++i) { - if (mCameras[i]->mName == parser.mRootNode->mPrimaryCamera) { - std::swap(mCameras[i],mCameras[0]); - break; - } - } - } - // store all cameras StoreSceneCameras( pScene); } diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index 5182abf88..d83d653b3 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -55,7 +55,7 @@ using namespace Assimp::Collada; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -ColladaParser::ColladaParser( const std::string& pFile) +ColladaParser::ColladaParser( IOSystem* pIOHandler, const std::string& pFile) : mFileName( pFile) { mRootNode = NULL; @@ -65,8 +65,14 @@ ColladaParser::ColladaParser( const std::string& pFile) // We assume the newest file format by default mFormat = FV_1_5_n; + // open the file + boost::scoped_ptr file( pIOHandler->Open( pFile)); + if( file.get() == NULL) + throw new ImportErrorException( "Failed to open file " + pFile + "."); + // generate a XML reader for it - mReader = irr::io::createIrrXMLReader( pFile.c_str()); + boost::scoped_ptr mIOWrapper( new CIrrXML_IOStreamReader( file.get())); + mReader = irr::io::createIrrXMLReader( mIOWrapper.get()); if( !mReader) ThrowException( "Collada: Unable to open file."); diff --git a/code/ColladaParser.h b/code/ColladaParser.h index e601c182c..c26360f41 100644 --- a/code/ColladaParser.h +++ b/code/ColladaParser.h @@ -62,7 +62,7 @@ class ColladaParser protected: /** Constructor from XML file */ - ColladaParser( const std::string& pFile); + ColladaParser( IOSystem* pIOHandler, const std::string& pFile); /** Destructor */ ~ColladaParser(); @@ -224,7 +224,7 @@ protected: /** Filename, for a verbose error message */ std::string mFileName; - /** XML reader */ + /** XML reader, member for everyday use */ irr::io::IrrXMLReader* mReader; /** All data arrays found in the file by ID. Might be referred to by actually diff --git a/code/IRRLoader.cpp b/code/IRRLoader.cpp index 74700b623..f3622badd 100644 --- a/code/IRRLoader.cpp +++ b/code/IRRLoader.cpp @@ -60,6 +60,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif using namespace Assimp; +using namespace irr; +using namespace irr::io; using namespace boost::math; diff --git a/code/IRRMeshLoader.cpp b/code/IRRMeshLoader.cpp index 40ae200cf..6dab0d319 100644 --- a/code/IRRMeshLoader.cpp +++ b/code/IRRMeshLoader.cpp @@ -48,6 +48,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fast_atof.h" using namespace Assimp; +using namespace irr; +using namespace irr::io; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer diff --git a/code/IRRShared.cpp b/code/IRRShared.cpp index 1dadb8f6e..bc09d0404 100644 --- a/code/IRRShared.cpp +++ b/code/IRRShared.cpp @@ -50,6 +50,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fast_atof.h" using namespace Assimp; +using namespace irr; +using namespace irr::io; // Transformation matrix to convert from Assimp to IRR space const aiMatrix4x4 Assimp::AI_TO_IRR_MATRIX = aiMatrix4x4 ( diff --git a/code/IRRShared.h b/code/IRRShared.h index 222b66533..04f8b3d36 100644 --- a/code/IRRShared.h +++ b/code/IRRShared.h @@ -77,7 +77,7 @@ protected: /** XML reader instance */ - IrrXMLReader* reader; + irr::io::IrrXMLReader* reader; // ------------------------------------------------------------------- /** Parse a material description from the XML diff --git a/code/irrXMLWrapper.h b/code/irrXMLWrapper.h index c74900a8d..6b6b60489 100644 --- a/code/irrXMLWrapper.h +++ b/code/irrXMLWrapper.h @@ -6,16 +6,15 @@ #include "./../contrib/irrXML/irrXML.h" #include "./../include/IOStream.h" -namespace Assimp { -using namespace irr; -using namespace irr::io; +namespace Assimp +{ // --------------------------------------------------------------------------------- /** @brief Utility class to make IrrXML work together with our custom IO system * * See the IrrXML docs for more details. */ -class CIrrXML_IOStreamReader +class CIrrXML_IOStreamReader : public irr::io::IFileReadCallBack { public: