add unittest for textured meshes
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@1094 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
8
src/Unittests/TestFiles/square_material_texture.mtl
Normal file
8
src/Unittests/TestFiles/square_material_texture.mtl
Normal file
@@ -0,0 +1,8 @@
|
||||
newmtl Texture
|
||||
Ka 0.500 0.500 0.500
|
||||
Kd 0.500 0.500 0.500
|
||||
Ks 0.500 0.500 0.500
|
||||
Tr 1.000000
|
||||
illum 1
|
||||
Ns 0.000000
|
||||
map_Kd square_material_texture.jpg
|
||||
13
src/Unittests/TestFiles/square_material_texture.obj
Normal file
13
src/Unittests/TestFiles/square_material_texture.obj
Normal file
@@ -0,0 +1,13 @@
|
||||
mtllib square_material_texture.mtl
|
||||
|
||||
v 0.000000 2.000000 0.000000
|
||||
v 0.000000 0.000000 0.000000
|
||||
v 2.000000 0.000000 0.000000
|
||||
v 2.000000 2.000000 0.000000
|
||||
vt 0.000000 1.000000 0.000000
|
||||
vt 0.000000 0.000000 0.000000
|
||||
vt 1.000000 0.000000 0.000000
|
||||
vt 1.000000 1.000000 0.000000
|
||||
|
||||
usemtl Texture
|
||||
f 1/1 2/2 3/3 4/4
|
||||
@@ -214,6 +214,39 @@ TEST_F(OpenMeshReadWriteOBJ, LoadObjWithMaterial) {
|
||||
mesh_.release_face_colors();
|
||||
}
|
||||
|
||||
TEST_F(OpenMeshReadWriteOBJ, LoadObjWithTexture) {
|
||||
|
||||
mesh_.clear();
|
||||
|
||||
mesh_.request_face_colors();
|
||||
mesh_.request_face_texture_index();
|
||||
|
||||
OpenMesh::IO::Options options;
|
||||
options += OpenMesh::IO::Options::FaceTexCoord;
|
||||
|
||||
std::string file_name = "square_material_texture.obj";
|
||||
|
||||
bool ok = OpenMesh::IO::read_mesh(mesh_, file_name, options);
|
||||
|
||||
EXPECT_TRUE(ok) << file_name;
|
||||
|
||||
//check texture mapping for the mesh
|
||||
OpenMesh::MPropHandleT< std::map< int, std::string > > property;
|
||||
mesh_.get_property_handle(property, "TextureMapping");
|
||||
EXPECT_EQ(mesh_.property(property).size(), 1) << "More than one texture defined";
|
||||
std::map< int, std::string >::iterator tex = mesh_.property(property).find(1);
|
||||
EXPECT_TRUE(tex != mesh_.property(property).end()) << "Could not find texture with id 1";
|
||||
EXPECT_TRUE((mesh_.property(property)[1] == std::string("square_material_texture.jpg"))) << "Wrong texture name";
|
||||
|
||||
//check texture mapping per face
|
||||
OpenMesh::FaceHandle fh = mesh_.face_handle(mesh_.halfedge_handle(0));
|
||||
EXPECT_TRUE(fh.is_valid()) << "fh should be valid";
|
||||
EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(),fh),1) << "Face texture index is not set correctly";
|
||||
|
||||
mesh_.release_face_colors();
|
||||
mesh_.release_face_texture_index();
|
||||
}
|
||||
|
||||
/*
|
||||
* Just load a obj file of a cube with vertex colors defined directly after the vertex definitions
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user