glTF: add importer to registry and try to parse json.
parent
702ef1a513
commit
502d9f17b6
|
@ -170,7 +170,9 @@ corresponding preprocessor flag to selectively disable formats.
|
|||
#ifndef ASSIMP_BUILD_NO_ASSBIN_IMPORTER
|
||||
# include "AssbinLoader.h"
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
# include "glTFImporter.h"
|
||||
#endif
|
||||
#ifndef ASSIMP_BUILD_NO_C4D_IMPORTER
|
||||
# include "C4DImporter.h"
|
||||
#endif
|
||||
|
@ -305,8 +307,10 @@ void GetImporterInstanceList(std::vector< BaseImporter* >& out)
|
|||
#if ( !defined ASSIMP_BUILD_NO_ASSBIN_IMPORTER )
|
||||
out.push_back( new AssbinImporter() );
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_C4D_IMPORTER
|
||||
#if ( !defined ASSIMP_BUILD_NO_GLTF_IMPORTER )
|
||||
out.push_back( new glTFImporter() );
|
||||
#endif
|
||||
#if ( !defined ASSIMP_BUILD_NO_C4D_IMPORTER )
|
||||
out.push_back( new C4DImporter() );
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -51,18 +51,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
namespace Assimp {
|
||||
|
||||
static const aiImporterDesc desc = {
|
||||
"glTF Importer",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportCompressedFlavour,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"gltf"
|
||||
};
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
|
||||
static const aiImporterDesc desc = {
|
||||
"glTF Importer",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportCompressedFlavour,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"gltf"
|
||||
};
|
||||
|
||||
glTFImporter::glTFImporter()
|
||||
: BaseImporter()
|
||||
|
@ -95,6 +97,15 @@ void glTFImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IO
|
|||
|
||||
// Allocate buffer and read file into it
|
||||
TextFileToBuffer( stream.get(), m_buffer );
|
||||
|
||||
std::string data( &m_buffer[ 0 ] );
|
||||
picojson::value v;
|
||||
std::string err = picojson::parse( v, data );
|
||||
if (!err.empty()) {
|
||||
throw DeadlyImportError( "Error occurred: " + err + "." );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
|
||||
} // Namespace Assimp
|
||||
|
|
Loading…
Reference in New Issue