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
|
#ifndef ASSIMP_BUILD_NO_ASSBIN_IMPORTER
|
||||||
# include "AssbinLoader.h"
|
# include "AssbinLoader.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||||
|
# include "glTFImporter.h"
|
||||||
|
#endif
|
||||||
#ifndef ASSIMP_BUILD_NO_C4D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_C4D_IMPORTER
|
||||||
# include "C4DImporter.h"
|
# include "C4DImporter.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -305,8 +307,10 @@ void GetImporterInstanceList(std::vector< BaseImporter* >& out)
|
||||||
#if ( !defined ASSIMP_BUILD_NO_ASSBIN_IMPORTER )
|
#if ( !defined ASSIMP_BUILD_NO_ASSBIN_IMPORTER )
|
||||||
out.push_back( new AssbinImporter() );
|
out.push_back( new AssbinImporter() );
|
||||||
#endif
|
#endif
|
||||||
|
#if ( !defined ASSIMP_BUILD_NO_GLTF_IMPORTER )
|
||||||
#ifndef ASSIMP_BUILD_NO_C4D_IMPORTER
|
out.push_back( new glTFImporter() );
|
||||||
|
#endif
|
||||||
|
#if ( !defined ASSIMP_BUILD_NO_C4D_IMPORTER )
|
||||||
out.push_back( new C4DImporter() );
|
out.push_back( new C4DImporter() );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,18 +51,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||||
"glTF Importer",
|
|
||||||
"",
|
static const aiImporterDesc desc = {
|
||||||
"",
|
"glTF Importer",
|
||||||
"",
|
"",
|
||||||
aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportCompressedFlavour,
|
"",
|
||||||
0,
|
"",
|
||||||
0,
|
aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportCompressedFlavour,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
"gltf"
|
0,
|
||||||
};
|
0,
|
||||||
|
"gltf"
|
||||||
|
};
|
||||||
|
|
||||||
glTFImporter::glTFImporter()
|
glTFImporter::glTFImporter()
|
||||||
: BaseImporter()
|
: BaseImporter()
|
||||||
|
@ -95,6 +97,15 @@ void glTFImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IO
|
||||||
|
|
||||||
// Allocate buffer and read file into it
|
// Allocate buffer and read file into it
|
||||||
TextFileToBuffer( stream.get(), m_buffer );
|
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