OBJFILELOADER - pygame

◇◆丶佛笑我妖孽 提交于 2019-12-02 14:23:14

You just have to pass the filename/path of the .obj file to the OBJ class:

obj = OBJ('suzzane.obj')

Also, the script was written in Python 2 and if you want to use it with Python 3, you have to update a few things.

Change this line,

raise ValueError, "mtl file doesn't start with newmtl stmt"

to:

raise ValueError("mtl file doesn't start with newmtl stmt")

And all the map iterators have to be turned into lists:

mtl[values[0]] = map(float, values[1:])
# Just call `list()`.
mtl[values[0]] = list(map(float, values[1:]))

Try generating wavefront(.obj) file and make sure to put the suzzane.obj and suzzane.mtl file on one directory with your code,

And instead of:

Sys.arg[0]

Use:

obj = OBJ('suzzane.obj')

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!