I realize you're kinda asking for a scripting answer, but hopefully this will be of use.
First start out with a map (white is wall, black is no wall). This one is 16x16:
That's all it is. A 16x16 png file. Now go into blender, create a plane, TAB into edit mode, and add ringcuts in both directions equal to the size of the map minus one. Since my map is 16x16, I should add 15x15 ringcuts. The shortcut for that would be CTRL + R15. You'll end up with:
Press A to select everything, and then ALT + E to extrude each face individually. If a little window pops up, click on Individual Faces
. Press Esc to save the extrude, but keep the new faces in the same place as the old faces.
Keeping the new faces selected, press CTRL + G and click Assign to New Group
to assign these extruded faces to their own group. We'll be using this a bit later.
Still with these same faces selected, press CTRL + . to cause each face to scale around it's own center, and then press S and scale all the faces down ever so slightly. Seriously. Just barely.
One last step. You can come back into object mode with Tab, go to the modifiers panel (it looks like this: ) and add a new displacement modifier.
Click New
under Texture, then go to the texture panel (), click Open
, and browse to your map png.
IMPORTANT: Under Image Sampling, uncheck Interpolation
!
Finally, go back to the modifier panel, select the vertex group we created, and set the Midlevel
to 0. And viola!
You can change the image map and then refresh it in the texture panel, and it will instantly update the model.
Simply make the mesh invisible in your game, and have the walls sticking up through your floor. I'm sure there's a way to script this, I'm just not very proficient with blender scripting :)