# Path: psychoblend/util.py
# def escape_name(name):
#     name = name.replace("\\", "\\\\")
#     name = name.replace(" ", "\\ ")
#     name = name.replace("$", "\\$")
#     name = name.replace("[", "\\[")
#     name = name.replace("]", "\\]")
#     name = name.replace("{", "\\{")
#     name = name.replace("}", "\\}")
#     return name
# 
# def mat2str(m):
#     """ Converts a matrix into a single-line string of values.
#     """
#     s = ""
#     for j in range(4):
#         for i in range(4):
#             s += (" %f" % m[i][j])
#     return s[1:]
# 
# def needs_def_mb(ob):
#     """ Determines if the given object needs to be exported with
#         deformation motion blur or not.
#     """
#     anim = ob.animation_data
#     no_anim_data = anim == None or (anim.action == None and len(anim.nla_tracks) == 0 and len(anim.drivers) == 0)
# 
#     for mod in ob.modifiers:
#         if mod.type == 'SUBSURF':
#             pass
#         elif mod.type == 'MULTIRES':
#             pass
#         elif mod.type == 'MIRROR':
#             if mod.mirror_object == None:
#                 pass
#             else:
#                 return True
#         elif mod.type == 'BEVEL' and no_anim_data:
#             pass
#         elif mod.type == 'EDGE_SPLIT' and no_anim_data:
#             pass
#         elif mod.type == 'SOLIDIFY' and no_anim_data:
#             pass
#         elif mod.type == 'MASK' and no_anim_data:
#             pass
#         elif mod.type == 'REMESH' and no_anim_data:
#             pass
#         elif mod.type == 'TRIANGULATE' and no_anim_data:
#             pass
#         elif mod.type == 'WIREFRAME' and no_anim_data:
#             pass
#         else:
#             return True
# 
#     if ob.type == 'MESH':
#         if ob.data.shape_keys == None:
#             pass
#         else:
#             return True
# 
#     return False
# 
# def needs_xform_mb(ob):
#     """ Determines if the given object needs to be exported with
#         transformation motion blur or not.
#     """
#     if ob.animation_data != None:
#         return True
# 
#     if len(ob.constraints) > 0:
#         return True
# 
#     if ob.parent != None:
#         return needs_xform_mb(ob.parent)
# 
#     return False
# 
# class ExportCancelled(Exception):
#     """ Indicates that the render was cancelled in the middle of exporting
#         the scene file.
#     """
#     pass


import bpy
from .util import escape_name, mat2str, needs_def_mb, needs_xform_mb, ExportCancelled
                    if name not in self.assembly_names:
                        self.assembly_names.add(name)
                        self.objects += [Assembly(self.render_engine, ob.dupli_group.objects, ob.dupli_group.layers, name, ob.dupli_group.dupli_offset*-1)]
            elif ob.type == 'MESH':
                name = self.get_mesh(ob, group_prefix)
            elif ob.type == 'LAMP' and ob.data.type == 'POINT':
                name = self.get_sphere_lamp(ob, group_prefix)
            elif ob.type == 'LAMP' and ob.data.type == 'AREA':
                name = self.get_rect_lamp(ob, group_prefix)
            
            # Store instance
            if name != None:
                self.instances += [Instance(render_engine, ob, name)]

    def export(self, render_engine, w):
        if self.name == "":
            w.write("Assembly {\n")
        else:
            w.write("Assembly $%s {\n" % self.name)
        w.indent()

        for mat in self.materials:
            # Check if render is cancelled
            if render_engine.test_break():
                raise ExportCancelled()
            mat.export(render_engine, w)

        for ob in self.objects:
            # Check if render is cancelled
            if render_engine.test_break():

# Path: psychoblend/util.py
# def escape_name(name):
#     name = name.replace("\\", "\\\\")
#     name = name.replace(" ", "\\ ")
#     name = name.replace("$", "\\$")
#     name = name.replace("[", "\\[")
#     name = name.replace("]", "\\]")
#     name = name.replace("{", "\\{")
#     name = name.replace("}", "\\}")
#     return name
# 
# def mat2str(m):
#     """ Converts a matrix into a single-line string of values.
#     """
#     s = ""
#     for j in range(4):
#         for i in range(4):
#             s += (" %f" % m[i][j])
#     return s[1:]
# 
# def needs_def_mb(ob):
#     """ Determines if the given object needs to be exported with
#         deformation motion blur or not.
#     """
#     anim = ob.animation_data
#     no_anim_data = anim == None or (anim.action == None and len(anim.nla_tracks) == 0 and len(anim.drivers) == 0)
# 
#     for mod in ob.modifiers:
#         if mod.type == 'SUBSURF':
#             pass
#         elif mod.type == 'MULTIRES':
#             pass
#         elif mod.type == 'MIRROR':
#             if mod.mirror_object == None:
#                 pass
#             else:
#                 return True
#         elif mod.type == 'BEVEL' and no_anim_data:
#             pass
#         elif mod.type == 'EDGE_SPLIT' and no_anim_data:
#             pass
#         elif mod.type == 'SOLIDIFY' and no_anim_data:
#             pass
#         elif mod.type == 'MASK' and no_anim_data:
#             pass
#         elif mod.type == 'REMESH' and no_anim_data:
#             pass
#         elif mod.type == 'TRIANGULATE' and no_anim_data:
#             pass
#         elif mod.type == 'WIREFRAME' and no_anim_data:
#             pass
#         else:
#             return True
# 
#     if ob.type == 'MESH':
#         if ob.data.shape_keys == None:
#             pass
#         else:
#             return True
# 
#     return False
# 
# def needs_xform_mb(ob):
#     """ Determines if the given object needs to be exported with
#         transformation motion blur or not.
#     """
#     if ob.animation_data != None:
#         return True
# 
#     if len(ob.constraints) > 0:
#         return True
# 
#     if ob.parent != None:
#         return needs_xform_mb(ob.parent)
# 
#     return False
# 
# class ExportCancelled(Exception):
#     """ Indicates that the render was cancelled in the middle of exporting
#         the scene file.
#     """
#     pass


# Path: psychoblend/assembly.py
import bpy
from .util import escape_name, mat2str, needs_def_mb, needs_xform_mb, ExportCancelled

                    if name not in self.assembly_names:
                        self.assembly_names.add(name)
                        self.objects += [Assembly(self.render_engine, ob.dupli_group.objects, ob.dupli_group.layers, name, ob.dupli_group.dupli_offset*-1)]
            elif ob.type == 'MESH':
                name = self.get_mesh(ob, group_prefix)
            elif ob.type == 'LAMP' and ob.data.type == 'POINT':
                name = self.get_sphere_lamp(ob, group_prefix)
            elif ob.type == 'LAMP' and ob.data.type == 'AREA':
                name = self.get_rect_lamp(ob, group_prefix)
            
            # Store instance
            if name != None:
                self.instances += [Instance(render_engine, ob, name)]

    def export(self, render_engine, w):
        if self.name == "":
            w.write("Assembly {\n")
        else:
            w.write("Assembly $%s {\n" % self.name)
        w.indent()

        for mat in self.materials:
            # Check if render is cancelled
            if render_engine.test_break():
                raise ExportCancelled()
            mat.export(render_engine, w)

        for ob in self.objects:
            # Check if render is cancelled
            if render_engine.test_break():

                raise ExportCancelled()