提交 f58c4167 编写于 作者: C Chris

allow negative vertex indices for obj model format

上级 51f45e8b
......@@ -536,16 +536,29 @@ def parse_obj(fname):
uv_index = []
normal_index = []
# Precompute vert / normal / uv lists
# for negative index lookup
vertlen = len(vertices) + 1
normlen = len(normals) + 1
uvlen = len(uvs) + 1
for v in chunks[1:]:
vertex = parse_vertex(v)
if vertex['v']:
if vertex['v'] < 0:
vertex['v'] += vertlen
vertex_index.append(vertex['v'])
if vertex['t']:
if vertex['t'] < 0:
vertex['t'] += uvlen
uv_index.append(vertex['t'])
if vertex['n']:
if vertex['n'] < 0:
vertex['n'] += normlen
normal_index.append(vertex['n'])
faces.append({
d = {
'vertex':vertex_index,
'uv':uv_index,
'normal':normal_index,
......@@ -554,7 +567,8 @@ def parse_obj(fname):
'group':group,
'object':object,
'smooth':smooth,
})
}
faces.append(d)
# Group
if chunks[0] == "g" and len(chunks) == 2:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册