(verts, colors, indices, output_file)
| 25 | |
| 26 | |
| 27 | def write_ply(verts, colors, indices, output_file): |
| 28 | if colors is None: |
| 29 | colors = np.zeros_like(verts) |
| 30 | if indices is None: |
| 31 | indices = [] |
| 32 | |
| 33 | file = open(output_file, 'w') |
| 34 | file.write('ply\n') |
| 35 | file.write('format ascii 1.0\n') |
| 36 | file.write('element vertex {:d}\n'.format(len(verts))) |
| 37 | file.write('property float x\n') |
| 38 | file.write('property float y\n') |
| 39 | file.write('property float z\n') |
| 40 | file.write('property uchar red\n') |
| 41 | file.write('property uchar green\n') |
| 42 | file.write('property uchar blue\n') |
| 43 | file.write('element face {:d}\n'.format(len(indices))) |
| 44 | file.write('property list uchar uint vertex_indices\n') |
| 45 | file.write('end_header\n') |
| 46 | for vert, color in zip(verts, colors): |
| 47 | file.write("{:f} {:f} {:f} {:d} {:d} {:d}\n".format(vert[0], vert[1], vert[2] , int(color[0]*255), int(color[1]*255), int(color[2]*255))) |
| 48 | for ind in indices: |
| 49 | file.write('3 {:d} {:d} {:d}\n'.format(ind[0], ind[1], ind[2])) |
| 50 | file.close() |
| 51 | |
| 52 | |
| 53 | def create_cylinder_mesh(radius, p0, p1, stacks=10, slices=10): |
no outgoing calls
no test coverage detected