Faster OBJ loaderI'm submitting a tool for use in Pyweek 12+. Here it is:
Faster OBJ loader (74kb, tgz format)
This is something I started working on during Pyweek 10. It's intended to be an improvement of the well-known OpenGL OBJ loader tool at the pygame wiki. The main goal is to speed up game load time. I had some games where the time to load all the animation frames from OBJ files was on the order of 30 seconds, and this gets it down to less than 1 second.
This is accomplished by making the python OBJ objects picklable. The idea is that you, the game designer, will run the parsing code once and pickle the models. When you distribute the game, you only distribute the pickle files, and when the player runs the game, the models are unpickled and the player sees much faster load times.
To get this benefit, you need to use one of two derived classes: OBJ_array or OBJ_vbo, which use vertex arrays and vertex buffer objects instead of fixed function. It doesn't speed up the framerate during the game, but it does speed up the load time as intended.
The only file you need from the zip is fasterobj.py. The other files included are a stress test and an example OBJ file (and associated MTL file), so you can test the various options available to you. An example of how to use the code can be found in stress-test.py. Simply, though, something like this should work:
obj = cPickle.load(open("model.pkl", "rb"))
obj = OBJ_vbo('model.obj')
cPickle.dump(obj, open("model.pkl", "wb"), -1)
I haven't gotten a ton of feedback on this yet (I don't think anyone has actually tried it), so it could probably use some improvement. But I think it's ready to be used in a Pyweek game. Let me know if you run into any issues or have suggestions or questions!