| 68 | |
| 69 | |
| 70 | def save_hair_strands(path,strands): |
| 71 | segments = [strands[i].shape[0] for i in range(len(strands))] |
| 72 | hair_count=len(segments) |
| 73 | point_count=sum(segments) |
| 74 | points = np.concatenate(strands,0) |
| 75 | |
| 76 | with open(path, 'wb')as f: |
| 77 | f.write(struct.pack('I', hair_count)) |
| 78 | f.write(struct.pack('I', point_count)) |
| 79 | for num_every_strand in segments: |
| 80 | f.write(struct.pack('H', num_every_strand )) |
| 81 | |
| 82 | for vec in points: |
| 83 | f.write(struct.pack('f', vec[0])) |
| 84 | f.write(struct.pack('f', vec[1])) |
| 85 | f.write(struct.pack('f', vec[2])) |
| 86 | f.close() |
| 87 | |
| 88 | |
| 89 | def get_strands(points): |