Merge pull request #17 from assimp/master

Update to upstream
pull/2600/head
RichardTea 2019-07-29 12:27:05 +01:00 committed by GitHub
commit 7b67b00a79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 54 additions and 45 deletions

View File

@ -34,15 +34,6 @@ namespace Assimp {
void ExportAssimp2Json(const char*, Assimp::IOSystem*, const aiScene*, const Assimp::ExportProperties*); void ExportAssimp2Json(const char*, Assimp::IOSystem*, const aiScene*, const Assimp::ExportProperties*);
Exporter::ExportFormatEntry Assimp2Json_desc = Assimp::Exporter::ExportFormatEntry(
"json",
"Plain JSON representation of the Assimp scene data structure",
"json",
&ExportAssimp2Json,
0u
);
// small utility class to simplify serializing the aiScene to Json // small utility class to simplify serializing the aiScene to Json
class JSONWriter { class JSONWriter {
public: public:

View File

@ -810,7 +810,7 @@ ADD_ASSIMP_IMPORTER( MMD
MMD/MMDVmdParser.h MMD/MMDVmdParser.h
) )
ADD_ASSIMP_EXPORTER( Assjson ADD_ASSIMP_EXPORTER( ASSJSON
Assjson/cencode.c Assjson/cencode.c
Assjson/cencode.h Assjson/cencode.h
Assjson/json_exporter.cpp Assjson/json_exporter.cpp

View File

@ -163,11 +163,11 @@ Exporter::ExportFormatEntry gExporters[] =
#endif #endif
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER #ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
Exporter::ExportFormatEntry( "assbin", "Assimp Binary", "assbin" , &ExportSceneAssbin, 0 ), Exporter::ExportFormatEntry( "assbin", "Assimp Binary File", "assbin" , &ExportSceneAssbin, 0 ),
#endif #endif
#ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER #ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER
Exporter::ExportFormatEntry( "assxml", "Assxml Document", "assxml" , &ExportSceneAssxml, 0 ), Exporter::ExportFormatEntry( "assxml", "Assimp XML Document", "assxml" , &ExportSceneAssxml, 0 ),
#endif #endif
#ifndef ASSIMP_BUILD_NO_X3D_EXPORTER #ifndef ASSIMP_BUILD_NO_X3D_EXPORTER
@ -183,8 +183,8 @@ Exporter::ExportFormatEntry gExporters[] =
Exporter::ExportFormatEntry( "3mf", "The 3MF-File-Format", "3mf", &ExportScene3MF, 0 ), Exporter::ExportFormatEntry( "3mf", "The 3MF-File-Format", "3mf", &ExportScene3MF, 0 ),
#endif #endif
#ifndef ASSIMP_BUILD_NO_Assjson_EXPORTER #ifndef ASSIMP_BUILD_NO_ASSJSON_EXPORTER
Exporter::ExportFormatEntry("json", "Plain JSON representation of the Assimp scene data structure", "json", &ExportAssimp2Json, 0) Exporter::ExportFormatEntry( "assjson", "Assimp JSON Document", "json", &ExportAssimp2Json, 0)
#endif #endif
}; };

View File

@ -1219,6 +1219,16 @@ void FBXExporter::WriteObjects ()
layer.AddChild(le); layer.AddChild(le);
layer.Dump(outstream, binary, indent); layer.Dump(outstream, binary, indent);
for(unsigned int lr = 1; lr < m->GetNumUVChannels(); ++ lr)
{
FBX::Node layerExtra("Layer", int32_t(1));
layerExtra.AddChild("Version", int32_t(100));
FBX::Node leExtra("LayerElement");
leExtra.AddChild("Type", "LayerElementUV");
leExtra.AddChild("TypedIndex", int32_t(lr));
layerExtra.AddChild(leExtra);
layerExtra.Dump(outstream, binary, indent);
}
// finish the node record // finish the node record
indent = 1; indent = 1;
n.End(outstream, binary, indent, true); n.End(outstream, binary, indent, true);

3
test/.gitignore vendored 100644
View File

@ -0,0 +1,3 @@
# Ignore Unit Test Output files
*_out.*

View File

@ -1,24 +0,0 @@
ply
format ascii 1.0
comment Created by Open Asset Import Library - http://assimp.sf.net (v4.1.993695325)
element vertex 8
property float x
property float y
property float z
element face 6
property list uchar int vertex_index
end_header
0 0 0
0 0 1
0 1 1
0 1 0
1 0 0
1 0 1
1 1 1
1 1 0
4 0 1 2 3
4 7 6 5 4
4 0 4 5 1
4 1 5 6 2
4 2 6 7 3
4 3 7 4 0

View File

@ -57,7 +57,7 @@ public:
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure);
Exporter exporter; Exporter exporter;
aiReturn res = exporter.Export(scene, "json", "./spider_test.json"); aiReturn res = exporter.Export(scene, "assjson", "./spider_test.json");
return aiReturn_SUCCESS == res; return aiReturn_SUCCESS == res;
} }
}; };

View File

@ -71,3 +71,32 @@ TEST_F(ExporterTest, ProgressHandlerTest) {
TestProgressHandler *ph(new TestProgressHandler); TestProgressHandler *ph(new TestProgressHandler);
exporter.SetProgressHandler(ph); exporter.SetProgressHandler(ph);
} }
// Make sure all the registered exporters have useful descriptions
TEST_F(ExporterTest, ExporterIdTest) {
Exporter exporter;
size_t exportFormatCount = exporter.GetExportFormatCount();
EXPECT_NE(0u, exportFormatCount) << "No registered exporters";
typedef std::map<std::string, const aiExportFormatDesc*> ExportIdMap;
ExportIdMap exporterMap;
for (size_t i = 0; i < exportFormatCount; ++i)
{
// Check that the exporter description exists and makes sense
const aiExportFormatDesc* desc = exporter.GetExportFormatDescription(i);
ASSERT_NE(nullptr, desc) << "Missing aiExportFormatDesc at index " << i;
EXPECT_NE(nullptr, desc->id) << "Null exporter ID at index " << i;
EXPECT_STRNE("", desc->id) << "Empty exporter ID at index " << i;
EXPECT_NE(nullptr, desc->description) << "Null exporter description at index " << i;
EXPECT_STRNE("", desc->description) << "Empty exporter description at index " << i;
EXPECT_NE(nullptr, desc->fileExtension) << "Null exporter file extension at index " << i;
EXPECT_STRNE("", desc->fileExtension) << "Empty exporter file extension at index " << i;
// Check the ID is unique
std::string key(desc->id);
std::pair<ExportIdMap::iterator, bool> result = exporterMap.emplace(key, desc);
EXPECT_TRUE(result.second) << "Duplicate exported id: '" << key << "' " << desc->description << " *." << desc->fileExtension << " at index " << i;
}
const aiExportFormatDesc* desc = exporter.GetExportFormatDescription(exportFormatCount);
EXPECT_EQ(nullptr, desc) << "More exporters than claimed";
}

View File

@ -56,8 +56,8 @@ public:
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure ); const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure );
Exporter exporter; Exporter exporter;
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "assbin", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_test.assbin" ) ); EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "assbin", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_out.assbin" ) );
const aiScene *newScene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider_test.assbin", aiProcess_ValidateDataStructure ); const aiScene *newScene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider_out.assbin", aiProcess_ValidateDataStructure );
return newScene != nullptr; return newScene != nullptr;
} }

View File

@ -205,8 +205,8 @@ protected:
::Assimp::Exporter exporter; ::Assimp::Exporter exporter;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure ); const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene ); EXPECT_NE( nullptr, scene );
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_test.obj" ) ); EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_out.obj" ) );
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "objnomtl", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_nomtl_test.obj" ) ); EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "objnomtl", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_nomtl_out.obj" ) );
return true; return true;
} }
@ -263,7 +263,7 @@ TEST_F( utObjImportExport, issue809_vertex_color_Test ) {
#ifndef ASSIMP_BUILD_NO_EXPORT #ifndef ASSIMP_BUILD_NO_EXPORT
::Assimp::Exporter exporter; ::Assimp::Exporter exporter;
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/test.obj" ) ); EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/test_out.obj" ) );
#endif // ASSIMP_BUILD_NO_EXPORT #endif // ASSIMP_BUILD_NO_EXPORT
} }

View File

@ -71,7 +71,7 @@ public:
Exporter exporter; Exporter exporter;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube.ply", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube.ply", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene); EXPECT_NE(nullptr, scene);
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "ply", ASSIMP_TEST_MODELS_DIR "/PLY/cube_test.ply")); EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "ply", ASSIMP_TEST_MODELS_DIR "/PLY/cube_out.ply"));
return true; return true;
} }