コード例 #1
0
 def test_has_n_meshes(self):
     geoms = read_objfile(self.script_dir +
                          "/wavefronts/untitled_with_normals.obj")
     self.assertTrue(len(geoms.object_list) == 1)
     geoms = read_objfile(self.script_dir +
                          "/wavefronts/two_complete_meshes.obj")
     self.assertTrue(len(geoms.object_list) == 2)
コード例 #2
0
def arena_obj_to_transformation(objfile, object="Arena"):
    """Returns the 3x3 rotation matrix and 1x3 translation array for the "object" object in the objfile, using PCA."""
    verts = wavefront_reader.read_objfile(objfile)[object]['v']
    uverts = np.unique(verts, axis=0)
    floor_verts = uverts[uverts[:,1].argsort()][:4, :]
    pca = PCA(n_components=3).fit(floor_verts)
    rotmat, translation = pca.components_, pca.mean_
    return rotmat, translation
コード例 #3
0
ファイル: test_obj.py プロジェクト: SimLeek/wavefront_obj
 def testGetVBOTriangles(self):
     obj_file = read_objfile(self.script_dir + "/wavefronts/cube.obj")
     cube = obj_file['Cube.002']
     first_four = [1.0, -1.0, 1.0, 1.0, 0.249684, 0.666956,
                   -1.0, -1.0, 1.0, 1.0, 0.000802, 0.666956,
                   -1.0, -1.0, -1.0, 1.0, 0.000802, 0.335112,
                   1.0, 1.0, -0.999999, 1.0, 0.498618, 0.668223]
     self.assertListEqual(cube.get_vbo_data_triangles()[:24], first_four)
     pass
コード例 #4
0
 def test_writer_can_be_read_by_reader(self):
     fname = '/tmp/testobj{}.obj'.format(uuid4())
     self.writer.dump(fname)
     geoms = read_objfile(fname)
     self.assertTrue(self.objname in geoms)
     obj = geoms[self.objname]
     self.assertTrue(
         np.isclose(np.array(self.verts), np.array(obj['v'])).all())
     self.assertTrue(
         np.isclose(np.array(self.norms), np.array(obj['vn'])).all())
コード例 #5
0
 def test_has_no_texcoords(self):
     geoms = read_objfile(self.script_dir +
                          "/wavefronts/untitled_with_normals.obj")
     cube = geoms['Cube']
     self.assertTrue(len(cube.vertex_textures) == 0)
コード例 #6
0
 def testHasVertices(self):
     obj_file = read_objfile(self.script_dir + "/wavefronts/untitled.obj")
     cube = obj_file['Cube']
     self.assertTrue(len(cube.vertices) > 0)