Explorar el Código

Add unit-test for PLY with UV coordinates

Alexandre Avenel hace 7 años
padre
commit
cd5881c9c0
Se han modificado 2 ficheros con 57 adiciones y 0 borrados
  1. 45 0
      test/models/PLY/cube_uv.ply
  2. 12 0
      test/unit/utPLYImportExport.cpp

+ 45 - 0
test/models/PLY/cube_uv.ply

@@ -0,0 +1,45 @@
+ply
+format ascii 1.0
+comment Created by Blender 2.77 (sub 0) - www.blender.org, source file: ''
+element vertex 24
+property float x
+property float y
+property float z
+property float nx
+property float ny
+property float nz
+property float s
+property float t
+element face 6
+property list uchar uint vertex_indices
+end_header
+1.000000 1.000000 -1.000000 0.000000 0.000000 -1.000000 0.000000 0.000000
+1.000000 -1.000000 -1.000000 0.000000 0.000000 -1.000000 1.000000 0.000000
+-1.000000 -1.000000 -1.000000 0.000000 0.000000 -1.000000 1.000000 1.000000
+-1.000000 1.000000 -1.000000 0.000000 0.000000 -1.000000 0.000000 1.000000
+1.000000 0.999999 1.000000 0.000000 -0.000000 1.000000 0.000000 0.000000
+-1.000000 1.000000 1.000000 0.000000 -0.000000 1.000000 1.000000 0.000000
+-1.000000 -1.000000 1.000000 0.000000 -0.000000 1.000000 1.000000 1.000000
+0.999999 -1.000001 1.000000 0.000000 -0.000000 1.000000 0.000000 1.000000
+1.000000 1.000000 -1.000000 1.000000 -0.000000 0.000000 0.000000 0.000000
+1.000000 0.999999 1.000000 1.000000 -0.000000 0.000000 1.000000 0.000000
+0.999999 -1.000001 1.000000 1.000000 -0.000000 0.000000 1.000000 1.000000
+1.000000 -1.000000 -1.000000 1.000000 -0.000000 0.000000 0.000000 1.000000
+1.000000 -1.000000 -1.000000 -0.000000 -1.000000 -0.000000 0.000000 0.000000
+0.999999 -1.000001 1.000000 -0.000000 -1.000000 -0.000000 1.000000 0.000000
+-1.000000 -1.000000 1.000000 -0.000000 -1.000000 -0.000000 1.000000 1.000000
+-1.000000 -1.000000 -1.000000 -0.000000 -1.000000 -0.000000 0.000000 1.000000
+-1.000000 -1.000000 -1.000000 -1.000000 0.000000 -0.000000 0.000000 0.000000
+-1.000000 -1.000000 1.000000 -1.000000 0.000000 -0.000000 1.000000 0.000000
+-1.000000 1.000000 1.000000 -1.000000 0.000000 -0.000000 1.000000 1.000000
+-1.000000 1.000000 -1.000000 -1.000000 0.000000 -0.000000 0.000000 1.000000
+1.000000 0.999999 1.000000 0.000000 1.000000 0.000000 0.000000 0.000000
+1.000000 1.000000 -1.000000 0.000000 1.000000 0.000000 1.000000 0.000000
+-1.000000 1.000000 -1.000000 0.000000 1.000000 0.000000 1.000000 1.000000
+-1.000000 1.000000 1.000000 0.000000 1.000000 0.000000 0.000000 1.000000
+4 0 1 2 3
+4 4 5 6 7
+4 8 9 10 11
+4 12 13 14 15
+4 16 17 18 19
+4 20 21 22 23

+ 12 - 0
test/unit/utPLYImportExport.cpp

@@ -99,6 +99,18 @@ TEST_F(utPLYImportExport, importerMultipleTest) {
     EXPECT_NE(nullptr, scene);
 }
 
+TEST_F(utPLYImportExport, importPLYwithUV) {
+    Assimp::Importer importer;
+    const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube_uv.ply", aiProcess_ValidateDataStructure);
+
+    EXPECT_NE(nullptr, scene);
+    EXPECT_NE(nullptr, scene->mMeshes[0]);
+    //This test model is using n-gons, so 6 faces instead of 12 tris
+    EXPECT_EQ(6u, scene->mMeshes[0]->mNumFaces);
+    EXPECT_EQ(aiPrimitiveType_POLYGON, scene->mMeshes[0]->mPrimitiveTypes);
+    EXPECT_EQ(true, scene->mMeshes[0]->HasTextureCoords(0));
+}
+
 TEST_F( utPLYImportExport, vertexColorTest ) {
     Assimp::Importer importer;
     const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/PLY/float-color.ply", aiProcess_ValidateDataStructure);