我正在尝试使用python open\u gl并创建一个创建对象类。Im获取错误ModuleNotFoundError:没有名为“block\u model”的模块。py';'block\u model不是一个包,我的代码给出了我无法修复的错误:
`
class Create:
def __init__(self, cube_x, cube_y, cube_z, file):
glBegin(GL_LINES)
model = importlib.import_module(file)
model.verticies()
model.edges()
verticies = model.verticies
edges = model.edges
for edge in edges:
for vertex in edge:
glVertex3fv(verticies[vertex])
glEnd()
c1_x = 0
c1_y = 0
c1_z = 0
print(camera)
cube1 = Create(c1_x, c1_y, c1_z, file="block_model.py")
`
这就是block\u模型。py看起来像:
verticies = (
(1, -1, -1),
(1, 1, -1),
(-1, 1, -1),
(-1, -1, -1),
(1, -1, 1),
(1, 1, 1),
(-1, -1, 1),
(-1, 1, 1)
)
edges = (
(0, 1),
(0, 3),
(0, 4),
(2, 1),
(2, 3),
(2, 7),
(6, 3),
(6, 4),
(6, 7),
(5, 1),
(5, 4),
(5, 7)
)
def verticies():
print("Returning verticies")
return verticies
def edges():
print("Returning edges")
return edges
谢谢:)
**编辑:*我有一个新问题,它现在说:对于边中的边:TypeError:“function”对象不可iterable。有人对此有办法吗?