Browse Source

Unit test for Issue #1923: OBJ Exporter can't correctly export vertex colors

Korbinian Würl 7 years ago
parent
commit
9e484daa65
2 changed files with 48 additions and 0 deletions
  1. 30 0
      test/models/OBJ/cube_with_vertexcolors_uni.obj
  2. 18 0
      test/unit/utObjImportExport.cpp

+ 30 - 0
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

+ 18 - 0
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"