blob: 076c73954a2214d0a7611a611084ac2844704761 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import numpy as np
import struct
def pull_vertices(filename):
f = open(filename)
vertex = []
for line in f:
if not line.strip().startswith('vertex'):
continue
vertex.append([float(s) for s in line.strip().split()[1:]])
f.close()
return np.array(vertex)
def pull_vertices_binary(filename):
f = open(filename)
f.read(80)
triangles = struct.unpack('<I', f.read(4))[0]
vertex = []
for i in range(triangles):
f.read(12)
for j in range(3):
vertex.append(struct.unpack('<fff', f.read(12)))
f.read(2)
f.close()
return np.array(vertex)
|