I've been playing with the Blender .map export script, using the function that exports every face of a mesh to a brush. However it's really buggy and the results are often deformed. I think I've come up with a solution.
Read this post on the Blender Artists forum.
Basically I think that if the vertices of the face were rounded off to whole numbers and were made into a 3D brush by connecting them to a new vertex (also whole numbers) with triangles instead of square faces then this should eliminate any deformation. This would allow meshes made in Blender to be exported to valid brushwork.
Sadly I'm not a python scripter, but hopefully someone on this forum is. Here's the function that needs modifying.
Any volunteers?
def write_face2brush(file, face):
'''
takes a face and writes it as a brush
each face is a cube/brush
'''
if PREF_GRID_SNAP.val: format_vec= '( %d %d %d ) '
else: format_vec= '( %.8f %.8f %.8f ) '
image_text= PREF_NULL_TEX.val
try: mode= face.mode
except: mode= 0
if mode & Mesh.FaceModes.INVISIBLE:
image_text= PREF_INVIS_TEX.val
else:
try: image= face.image
except: image= None
if image: image_text = sys.splitext(sys.basename(image.filename))[0]
# original verts as tuples for writing
orig_vco= [tuple(v.co) for v in face]
# new verts that give the face a thickness
dist= PREF_SCALE.val * PREF_FACE_THICK.val
new_vco= [round_vec(v.co - (v.no * dist)) for v in face]
#new_vco= [round_vec(v.co - (face.no * dist)) for v in face]
file.write('// brush from face\n{\n')
# front
for co in orig_vco[2::-1]:
file.write(format_vec % co )
file.write(image_text)
# Texture stuff ignored for now
file.write(PREF_DEF_TEX_OPTS.val)
for co in new_vco[:3]:
file.write(format_vec % co )
if mode & Mesh.FaceModes.TWOSIDE:
file.write(image_text)
else:
file.write(PREF_INVIS_TEX.val)
# Texture stuff ignored for now
file.write(PREF_DEF_TEX_OPTS.val)
# sides.
if len(orig_vco)==3: # Tri, it seemms tri brushes are supported.
index_pairs= ((0,1), (1,2), (2,0))
else:
index_pairs= ((0,1), (1,2), (2,3), (3,0))
for i1, i2 in index_pairs:
for co in orig_vco[i1], orig_vco[i2], new_vco[i2]:
file.write( format_vec % co )
file.write(PREF_INVIS_TEX.val)
file.write(PREF_DEF_TEX_OPTS.val)
file.write('}\n')