for index in zip(vertex_indices, uv_indices, normal_indices): vertex_index, uv_index, normal_index = index vertex = vertices[vertex_index - 1] uv = uvs[uv_index - 1] normal = normals[normal_index - 1] indexed_vertices.extend(vertex) indexed_uvs.extend(uv) indexed_normals.extend(normal) return indexed_vertices, indexed_uvs, indexed_normals @scene(model=scene.File(filter='Object files (*.obj)')) def obj(cfg, n=0.5, model=None): '''Load and display a cube object (generated with Blender)''' if model is None: model = op.join(op.dirname(__file__), 'data', 'model.obj') with open(model) as fp: vertices_data, uvs_data, normals_data = _load_model(fp) vertices = ngl.BufferVec3(data=vertices_data) texcoords = ngl.BufferVec2(data=uvs_data) normals = ngl.BufferVec3(data=normals_data) q = ngl.Geometry(vertices, texcoords, normals) m = ngl.Media(cfg.medias[0].filename)
for index in zip(vertex_indices, uv_indices, normal_indices): vertex_index, uv_index, normal_index = index vertex = vertices[vertex_index - 1] uv = uvs[uv_index - 1] normal = normals[normal_index - 1] indexed_vertices.extend(vertex) indexed_uvs.extend(uv) indexed_normals.extend(normal) return indexed_vertices, indexed_uvs, indexed_normals @scene(model=scene.File(filter="Object files (*.obj)")) def obj(cfg, n=0.5, model=None): """Load and display a cube object (generated with Blender)""" if model is None: model = op.join(op.dirname(__file__), "data", "model.obj") with open(model) as fp: vertices_data, uvs_data, normals_data = _load_model(fp) vertices = ngl.BufferVec3(data=vertices_data) texcoords = ngl.BufferVec2(data=uvs_data) normals = ngl.BufferVec3(data=normals_data) q = ngl.Geometry(vertices, texcoords, normals) m = ngl.Media(cfg.medias[0].filename)