From 9e484daa65dc7993d39e89fa612f91b59f43bc2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Korbinian=20W=C3=BCrl?= Date: Mon, 30 Apr 2018 15:51:48 +0200 Subject: [PATCH] Unit test for Issue #1923: OBJ Exporter can't correctly export vertex colors --- .../models/OBJ/cube_with_vertexcolors_uni.obj | 30 +++++++++++++++++++ test/unit/utObjImportExport.cpp | 18 +++++++++++ 2 files changed, 48 insertions(+) create mode 100644 test/models/OBJ/cube_with_vertexcolors_uni.obj diff --git a/test/models/OBJ/cube_with_vertexcolors_uni.obj b/test/models/OBJ/cube_with_vertexcolors_uni.obj new file mode 100644 index 000000000..c698b9489 --- /dev/null +++ b/test/models/OBJ/cube_with_vertexcolors_uni.obj @@ -0,0 +1,30 @@ +g cube + +v 0.0 0.0 0.0 0.0 0.0 0.0 +v 0.0 0.0 1.0 1.0 0.6 0.3 +v 0.0 1.0 0.0 0.0 0.0 0.0 +v 0.0 1.0 1.0 0.3 0.6 1.0 +v 1.0 0.0 0.0 0.0 0.0 0.0 +v 1.0 0.0 1.0 1.0 0.6 0.3 +v 1.0 1.0 0.0 0.0 0.0 0.0 +v 1.0 1.0 1.0 0.3 0.6 1.0 + +vn 0.0 0.0 1.0 +vn 0.0 0.0 -1.0 +vn 0.0 1.0 0.0 +vn 0.0 -1.0 0.0 +vn 1.0 0.0 0.0 +vn -1.0 0.0 0.0 + +f 1//2 7//2 5//2 +f 1//2 3//2 7//2 +f 1//6 4//6 3//6 +f 1//6 2//6 4//6 +f 3//3 8//3 7//3 +f 3//3 4//3 8//3 +f 5//5 7//5 8//5 +f 5//5 8//5 6//5 +f 1//4 5//4 6//4 +f 1//4 6//4 2//4 +f 2//1 6//1 8//1 +f 2//1 8//1 4//1 \ No newline at end of file diff --git a/test/unit/utObjImportExport.cpp b/test/unit/utObjImportExport.cpp index 8aec9c443..e879c350e 100644 --- a/test/unit/utObjImportExport.cpp +++ b/test/unit/utObjImportExport.cpp @@ -267,6 +267,24 @@ TEST_F( utObjImportExport, issue809_vertex_color_Test ) { #endif // ASSIMP_BUILD_NO_EXPORT } +TEST_F( utObjImportExport, issue1923_vertex_color_Test ) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/cube_with_vertexcolors_uni.obj", aiProcess_ValidateDataStructure ); + EXPECT_NE( nullptr, scene ); + +#ifndef ASSIMP_BUILD_NO_EXPORT + ::Assimp::Exporter exporter; + const aiExportDataBlob* blob = exporter.ExportToBlob( scene, "obj"); + EXPECT_NE( nullptr, blob ); + + const aiScene *sceneReImport = importer.ReadFileFromMemory( blob->data, blob->size, aiProcess_ValidateDataStructure ); + EXPECT_NE( nullptr, scene ); + + SceneDiffer differ; + EXPECT_TRUE( differ.isEqual( scene, sceneReImport ) ); +#endif // ASSIMP_BUILD_NO_EXPORT +} + TEST_F( utObjImportExport, issue1453_segfault ) { static const std::string ObjModel = "v 0.0 0.0 0.0\n"