MCPcopy Create free account
hub / github.com/TencentARC/InstantMesh / loadobj

Function loadobj

src/utils/mesh_util.py:92–111  ·  view source on GitHub ↗
(meshfile)

Source from the content-addressed store, hash-verified

90
91
92def loadobj(meshfile):
93 v = []
94 f = []
95 meshfp = open(meshfile, 'r')
96 for line in meshfp.readlines():
97 data = line.strip().split(' ')
98 data = [da for da in data if len(da) > 0]
99 if len(data) != 4:
100 continue
101 if data[0] == 'v':
102 v.append([float(d) for d in data[1:]])
103 if data[0] == 'f':
104 data = [da.split('/')[0] for da in data]
105 f.append([int(d) for d in data[1:]])
106 meshfp.close()
107
108 # torch need int64
109 facenp_fx3 = np.array(f, dtype=np.int64) - 1
110 pointnp_px3 = np.array(v, dtype=np.float32)
111 return pointnp_px3, facenp_fx3
112
113
114def loadobjtex(meshfile):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected