diff --git a/tools/export/blender25/godot_export_manager.py b/tools/export/blender25/godot_export_manager.py index 504fdb79348..293e0173e9c 100644 --- a/tools/export/blender25/godot_export_manager.py +++ b/tools/export/blender25/godot_export_manager.py @@ -55,13 +55,13 @@ class godot_export_manager(bpy.types.Panel): row = layout.row() col = row.column() - col.prop(scene,"godot_export_on_save",text="Export Groups on save") + col.prop(scene, "godot_export_on_save", text="Export Groups on save") row = layout.row() col = row.column(align=True) - op = col.operator("scene.godot_add_objects_to_group",text="Add selected objects to Group",icon="COPYDOWN") + op = col.operator("scene.godot_add_objects_to_group", text="Add selected objects to Group", icon="COPYDOWN") - op = col.operator("scene.godot_delete_objects_from_group",text="Delete selected objects from Group",icon="PASTEDOWN") + op = col.operator("scene.godot_delete_objects_from_group", text="Delete selected objects from Group", icon="PASTEDOWN") row = layout.row() col = row.column() @@ -70,20 +70,20 @@ class godot_export_manager(bpy.types.Panel): row = layout.row() col = row.column() - col.template_list("UI_List_Godot","dummy",scene, "godot_export_groups", scene, "godot_export_groups_index",rows=1,maxrows=10,type='DEFAULT') + col.template_list("UI_List_Godot", "dummy", scene, "godot_export_groups", scene, "godot_export_groups_index", rows=1, maxrows=10, type='DEFAULT') col = row.column(align=True) - col.operator("scene.godot_add_export_group",text="",icon="ZOOMIN") - col.operator("scene.godot_delete_export_group",text="",icon="ZOOMOUT") - col.operator("scene.godot_export_all_groups",text="",icon="EXPORT") + col.operator("scene.godot_add_export_group", text="", icon="ZOOMIN") + col.operator("scene.godot_delete_export_group", text="", icon="ZOOMOUT") + col.operator("scene.godot_export_all_groups", text="", icon="EXPORT") if len(scene.godot_export_groups) > 0: row = layout.row() col = row.column() group = scene.godot_export_groups[scene.godot_export_groups_index] - col.prop(group,"name",text="Group Name") - col.prop(group,"export_name",text="Export Name") - col.prop(group,"export_path",text="Export Filepath") + col.prop(group, "name", text="Group Name") + col.prop(group, "export_name", text="Export Name") + col.prop(group, "export_path", text="Export Filepath") row = layout.row() col = row.column() @@ -92,25 +92,25 @@ class godot_export_manager(bpy.types.Panel): col.label(text="Export Settings:") col = col.row(align=True) - col.prop(group,"apply_loc",toggle=True,icon="MAN_TRANS") - col.prop(group,"apply_rot",toggle=True,icon="MAN_ROT") - col.prop(group,"apply_scale",toggle=True,icon="MAN_SCALE") + col.prop(group, "apply_loc", toggle=True, icon="MAN_TRANS") + col.prop(group, "apply_rot", toggle=True, icon="MAN_ROT") + col.prop(group, "apply_scale", toggle=True, icon="MAN_SCALE") row = layout.row() col = row.column() - col.prop(group,"use_include_particle_duplicates") - col.prop(group,"use_mesh_modifiers") - col.prop(group,"use_tangent_arrays") - col.prop(group,"use_triangles") - col.prop(group,"use_copy_images") - col.prop(group,"use_active_layers") - col.prop(group,"use_anim") - col.prop(group,"use_anim_action_all") - col.prop(group,"use_anim_skip_noexp") - col.prop(group,"use_anim_optimize") - col.prop(group,"anim_optimize_precision") - col.prop(group,"use_metadata") + col.prop(group, "use_include_particle_duplicates") + col.prop(group, "use_mesh_modifiers") + col.prop(group, "use_tangent_arrays") + col.prop(group, "use_triangles") + col.prop(group, "use_copy_images") + col.prop(group, "use_active_layers") + col.prop(group, "use_anim") + col.prop(group, "use_anim_action_all") + col.prop(group, "use_anim_skip_noexp") + col.prop(group, "use_anim_optimize") + col.prop(group, "anim_optimize_precision") + col.prop(group, "use_metadata") ### Custom template_list look @@ -120,12 +120,12 @@ class UI_List_Godot(bpy.types.UIList): slot = item col = layout.row(align=True) - col.label(text=item.name,icon="GROUP") - col.prop(item,"active",text="") + col.label(text=item.name, icon="GROUP") + col.prop(item, "active", text="") - op = col.operator("scene.godot_select_group_objects",text="",emboss=False,icon="RESTRICT_SELECT_OFF") + op = col.operator("scene.godot_select_group_objects", text="", emboss=False, icon="RESTRICT_SELECT_OFF") op.idx = index - op = col.operator("scene.godot_export_group",text="",emboss=False,icon="EXPORT") + op = col.operator("scene.godot_export_group", text="", emboss=False, icon="EXPORT") op.idx = index class add_objects_to_group(bpy.types.Operator): @@ -135,12 +135,12 @@ class add_objects_to_group(bpy.types.Operator): undo = BoolProperty(default=True) - def execute(self,context): + def execute(self, context): scene = context.scene objects_str = "" if len(scene.godot_export_groups) > 0: - for i,object in enumerate(context.selected_objects): + for i, object in enumerate(context.selected_objects): if object.name not in scene.godot_export_groups[scene.godot_export_groups_index].nodes: node = scene.godot_export_groups[scene.godot_export_groups_index].nodes.add() node.name = object.name @@ -161,7 +161,7 @@ class del_objects_from_group(bpy.types.Operator): bl_label = "Delete Objects from Group" bl_description = "Delets the selected Objects from the active group below." - def execute(self,context): + def execute(self, context): scene = context.scene if len(scene.godot_export_groups) > 0: @@ -172,7 +172,7 @@ class del_objects_from_group(bpy.types.Operator): objects_str = "" j = 0 - for i,node in enumerate(scene.godot_export_groups[scene.godot_export_groups_index].nodes): + for i, node in enumerate(scene.godot_export_groups[scene.godot_export_groups_index].nodes): if node.name in selected_objects: scene.godot_export_groups[scene.godot_export_groups_index].nodes.remove(i) @@ -195,7 +195,7 @@ class select_group_objects(bpy.types.Operator): idx = IntProperty() - def execute(self,context): + def execute(self, context): scene = context.scene for object in context.scene.objects: object.select = False @@ -211,7 +211,7 @@ class export_groups_autosave(bpy.types.Operator): bl_label = "Export All Groups" bl_description = "Exports all groups to Collada." - def execute(self,context): + def execute(self, context): scene = context.scene if scene.godot_export_on_save: for i in range(len(scene.godot_export_groups)): @@ -227,11 +227,11 @@ class export_all_groups(bpy.types.Operator): bl_label = "Export All Groups" bl_description = "Exports all groups to Collada." - def execute(self,context): + def execute(self, context): scene = context.scene - for i in range(0,len(scene.godot_export_groups)): - bpy.ops.scene.godot_export_group(idx=i,export_all=True) + for i in range(0, len(scene.godot_export_groups)): + bpy.ops.scene.godot_export_group(idx=i, export_all=True) self.report({'INFO'}, "All Groups exported." ) return{'FINISHED'} @@ -245,7 +245,7 @@ class export_group(bpy.types.Operator): idx = IntProperty(default=0) export_all = BoolProperty(default=False) - def copy_object_recursive(self,ob,parent,single_user = True): + def copy_object_recursive(self, ob, parent, single_user = True): new_ob = bpy.data.objects[ob.name].copy() if single_user or ob.type=="ARMATURE": new_mesh_data = new_ob.data.copy() @@ -258,22 +258,22 @@ class export_group(bpy.types.Operator): new_ob.parent = None for child in ob.children: - self.copy_object_recursive(child,new_ob,single_user) + self.copy_object_recursive(child, new_ob, single_user) new_ob.select = True return new_ob - def delete_object(self,ob): + def delete_object(self, ob): if ob != None: for child in ob.children: self.delete_object(child) bpy.context.scene.objects.unlink(ob) bpy.data.objects.remove(ob) - def convert_group_to_node(self,group): + def convert_group_to_node(self, group): if group.dupli_group != None: for object in group.dupli_group.objects: if object.parent == None: - object = self.copy_object_recursive(object,object,True) + object = self.copy_object_recursive(object, object, True) matrix = Matrix(object.matrix_local) object.matrix_local = Matrix() object.matrix_local *= group.matrix_local @@ -281,7 +281,7 @@ class export_group(bpy.types.Operator): self.delete_object(group) - def execute(self,context): + def execute(self, context): scene = context.scene group = context.scene.godot_export_groups @@ -289,7 +289,7 @@ class export_group(bpy.types.Operator): if not group[self.idx].active and self.export_all: return{'FINISHED'} - for i,object in enumerate(group[self.idx].nodes): + for i, object in enumerate(group[self.idx].nodes): if object.name in bpy.data.objects: pass else: @@ -300,17 +300,17 @@ class export_group(bpy.types.Operator): if (path.find("//")==0 or path.find("\\\\")==0): #if relative, convert to absolute path = bpy.path.abspath(path) - path = path.replace("\\","/") + path = path.replace("\\", "/") ### if path exists and group export name is set the group will be exported if os.path.exists(path) and group[self.idx].export_name != "": - context.scene.layers = [True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True] + context.scene.layers = [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True] if group[self.idx].export_name.endswith(".dae"): - path = os.path.join(path,group[self.idx].export_name) + path = os.path.join(path, group[self.idx].export_name) else: - path = os.path.join(path,group[self.idx].export_name+".dae") + path = os.path.join(path, group[self.idx].export_name+".dae") hide_select = [] for object in context.scene.objects: @@ -322,7 +322,7 @@ class export_group(bpy.types.Operator): ### make particle duplicates, parent and select them nodes_to_be_added = [] if group[self.idx].use_include_particle_duplicates: - for i,object in enumerate(group[self.idx].nodes): + for i, object in enumerate(group[self.idx].nodes): if bpy.data.objects[object.name].type != "EMPTY": context.scene.objects.active = bpy.data.objects[object.name] bpy.data.objects[object.name].select = True @@ -339,7 +339,7 @@ class export_group(bpy.types.Operator): object.select = True ### select all other nodes from the group - for i,object in enumerate(group[self.idx].nodes): + for i, object in enumerate(group[self.idx].nodes): if bpy.data.objects[object.name].type == "EMPTY": self.convert_group_to_node(bpy.data.objects[object.name]) else: @@ -365,7 +365,7 @@ class add_export_group(bpy.types.Operator): bl_label = "Adds a new export Group" bl_description = "Creates a new Export Group with the selected Objects assigned to it." - def execute(self,context): + def execute(self, context): scene = context.scene item = scene.godot_export_groups.add() @@ -385,9 +385,9 @@ class del_export_group(bpy.types.Operator): def invoke(self, context, event): wm = context.window_manager - return wm.invoke_confirm(self,event) + return wm.invoke_confirm(self, event) - def execute(self,context): + def execute(self, context): scene = context.scene scene.godot_export_groups.remove(scene.godot_export_groups_index) @@ -406,30 +406,30 @@ class godot_export_groups(bpy.types.PropertyGroup): export_name = StringProperty(name="scene_name") nodes = CollectionProperty(type=godot_node_list) export_path = StringProperty(subtype="DIR_PATH") - active = BoolProperty(default=True,description="Export Group") + active = BoolProperty(default=True, description="Export Group") - object_types = EnumProperty(name="Object Types",options={'ENUM_FLAG'},items=(('EMPTY', "Empty", ""),('CAMERA', "Camera", ""),('LAMP', "Lamp", ""),('ARMATURE', "Armature", ""),('MESH', "Mesh", ""),('CURVE', "Curve", ""),),default={'EMPTY', 'CAMERA', 'LAMP', 'ARMATURE', 'MESH','CURVE'}) + object_types = EnumProperty(name="Object Types", options={'ENUM_FLAG'}, items=(('EMPTY', "Empty", ""), ('CAMERA', "Camera", ""), ('LAMP', "Lamp", ""), ('ARMATURE', "Armature", ""), ('MESH', "Mesh", ""), ('CURVE', "Curve", ""), ), default={'EMPTY', 'CAMERA', 'LAMP', 'ARMATURE', 'MESH', 'CURVE'}) - apply_scale = BoolProperty(name="Apply Scale",description="Apply Scale before export.",default=False) - apply_rot = BoolProperty(name="Apply Rotation",description="Apply Rotation before export.",default=False) - apply_loc = BoolProperty(name="Apply Location",description="Apply Location before export.",default=False) + apply_scale = BoolProperty(name="Apply Scale", description="Apply Scale before export.", default=False) + apply_rot = BoolProperty(name="Apply Rotation", description="Apply Rotation before export.", default=False) + apply_loc = BoolProperty(name="Apply Location", description="Apply Location before export.", default=False) - use_export_selected = BoolProperty(name="Selected Objects",description="Export only selected objects (and visible in active layers if that applies).",default=True) - use_mesh_modifiers = BoolProperty(name="Apply Modifiers",description="Apply modifiers to mesh objects (on a copy!).",default=True) - use_tangent_arrays = BoolProperty(name="Tangent Arrays",description="Export Tangent and Binormal arrays (for normalmapping).",default=False) - use_triangles = BoolProperty(name="Triangulate",description="Export Triangles instead of Polygons.",default=False) + use_export_selected = BoolProperty(name="Selected Objects", description="Export only selected objects (and visible in active layers if that applies).", default=True) + use_mesh_modifiers = BoolProperty(name="Apply Modifiers", description="Apply modifiers to mesh objects (on a copy!).", default=True) + use_tangent_arrays = BoolProperty(name="Tangent Arrays", description="Export Tangent and Binormal arrays (for normalmapping).", default=False) + use_triangles = BoolProperty(name="Triangulate", description="Export Triangles instead of Polygons.", default=False) - use_copy_images = BoolProperty(name="Copy Images",description="Copy Images (create images/ subfolder)",default=False) - use_active_layers = BoolProperty(name="Active Layers",description="Export only objects on the active layers.",default=True) - use_anim = BoolProperty(name="Export Animation",description="Export keyframe animation",default=False) - use_anim_action_all = BoolProperty(name="All Actions",description=("Export all actions for the first armature found in separate DAE files"),default=False) - use_anim_skip_noexp = BoolProperty(name="Skip (-noexp) Actions",description="Skip exporting of actions whose name end in (-noexp). Useful to skip control animations.",default=True) - use_anim_optimize = BoolProperty(name="Optimize Keyframes",description="Remove double keyframes",default=True) + use_copy_images = BoolProperty(name="Copy Images", description="Copy Images (create images/ subfolder)", default=False) + use_active_layers = BoolProperty(name="Active Layers", description="Export only objects on the active layers.", default=True) + use_anim = BoolProperty(name="Export Animation", description="Export keyframe animation", default=False) + use_anim_action_all = BoolProperty(name="All Actions", description=("Export all actions for the first armature found in separate DAE files"), default=False) + use_anim_skip_noexp = BoolProperty(name="Skip (-noexp) Actions", description="Skip exporting of actions whose name end in (-noexp). Useful to skip control animations.", default=True) + use_anim_optimize = BoolProperty(name="Optimize Keyframes", description="Remove double keyframes", default=True) - anim_optimize_precision = FloatProperty(name="Precision",description=("Tolerence for comparing double keyframes (higher for greater accuracy)"),min=1, max=16,soft_min=1, soft_max=16,default=6.0) + anim_optimize_precision = FloatProperty(name="Precision", description=("Tolerence for comparing double keyframes (higher for greater accuracy)"), min=1, max=16, soft_min=1, soft_max=16, default=6.0) - use_metadata = BoolProperty(name="Use Metadata",default=True,options={'HIDDEN'}) - use_include_particle_duplicates = BoolProperty(name="Include Particle Duplicates",default=True) + use_metadata = BoolProperty(name="Use Metadata", default=True, options={'HIDDEN'}) + use_include_particle_duplicates = BoolProperty(name="Include Particle Duplicates", default=True) def register(): @@ -447,7 +447,7 @@ def register(): bpy.utils.register_class(UI_List_Godot) bpy.types.Scene.godot_export_groups = CollectionProperty(type=godot_export_groups) - bpy.types.Scene.godot_export_groups_index = IntProperty(default=0,min=0) + bpy.types.Scene.godot_export_groups_index = IntProperty(default=0, min=0) def unregister(): diff --git a/tools/export/blender25/io_scene_dae/__init__.py b/tools/export/blender25/io_scene_dae/__init__.py index 89c1f009c2a..3bde01f2df0 100644 --- a/tools/export/blender25/io_scene_dae/__init__.py +++ b/tools/export/blender25/io_scene_dae/__init__.py @@ -69,7 +69,7 @@ class ExportDAE(bpy.types.Operator, ExportHelper): ('MESH', "Mesh", ""), ('CURVE', "Curve", ""), ), - default={'EMPTY', 'CAMERA', 'LAMP', 'ARMATURE', 'MESH','CURVE'}, + default={'EMPTY', 'CAMERA', 'LAMP', 'ARMATURE', 'MESH', 'CURVE'}, ) use_export_selected = BoolProperty( diff --git a/tools/export/blender25/io_scene_dae/export_dae.py b/tools/export/blender25/io_scene_dae/export_dae.py index 047c8a063d0..0b90a60eb82 100644 --- a/tools/export/blender25/io_scene_dae/export_dae.py +++ b/tools/export/blender25/io_scene_dae/export_dae.py @@ -66,7 +66,7 @@ CMP_EPSILON=0.0001 def snap_tup(tup): ret=() for x in tup: - ret+=( x-math.fmod(x,0.0001), ) + ret+=( x-math.fmod(x, 0.0001), ) return tup @@ -80,7 +80,7 @@ def strmtx(mtx): s+=" " return s -def numarr(a,mult=1.0): +def numarr(a, mult=1.0): s=" " for x in a: s+=" "+str(x*mult) @@ -88,7 +88,7 @@ def numarr(a,mult=1.0): return s -def numarr_alpha(a,mult=1.0): +def numarr_alpha(a, mult=1.0): s=" " for x in a: s+=" "+str(x*mult) @@ -108,12 +108,12 @@ def strarr(arr): class DaeExporter: - def validate_id(self,d): + def validate_id(self, d): if (d.find("id-")==0): return "z"+d return d - def new_id(self,t): + def new_id(self, t): self.last_id+=1 return "id-"+t+"-"+str(self.last_id) @@ -132,34 +132,34 @@ class DaeExporter: return True def get_tup(self): - tup = (self.vertex.x,self.vertex.y,self.vertex.z,self.normal.x,self.normal.y,self.normal.z) + tup = (self.vertex.x, self.vertex.y, self.vertex.z, self.normal.x, self.normal.y, self.normal.z) for t in self.uv: - tup = tup + (t.x,t.y) + tup = tup + (t.x, t.y) if (self.color!=None): - tup = tup + (self.color.x,self.color.y,self.color.z) + tup = tup + (self.color.x, self.color.y, self.color.z) if (self.tangent!=None): - tup = tup + (self.tangent.x,self.tangent.y,self.tangent.z) + tup = tup + (self.tangent.x, self.tangent.y, self.tangent.z) if (self.bitangent!=None): - tup = tup + (self.bitangent.x,self.bitangent.y,self.bitangent.z) + tup = tup + (self.bitangent.x, self.bitangent.y, self.bitangent.z) for t in self.bones: - tup = tup + (float(t),) + tup = tup + (float(t), ) for t in self.weights: - tup = tup + (float(t),) + tup = tup + (float(t), ) return tup def __init__(self): - self.vertex = Vector( (0.0,0.0,0.0) ) - self.normal = Vector( (0.0,0.0,0.0) ) + self.vertex = Vector( (0.0, 0.0, 0.0) ) + self.normal = Vector( (0.0, 0.0, 0.0) ) self.tangent = None self.bitangent = None self.color = None self.uv = [] - self.uv2 = Vector( (0.0,0.0) ) + self.uv2 = Vector( (0.0, 0.0) ) self.bones=[] self.weights=[] - def writel(self,section,indent,text): + def writel(self, section, indent, text): if (not (section in self.sections)): self.sections[section]=[] line="" @@ -168,7 +168,7 @@ class DaeExporter: line+=text self.sections[section].append(line) - def export_image(self,image): + def export_image(self, image): if (image in self.image_cache): return self.image_cache[image] @@ -188,12 +188,12 @@ class DaeExporter: dstfile=basedir+"/"+os.path.basename(imgpath) if (not os.path.isfile(dstfile)): - shutil.copy(imgpath,dstfile) + shutil.copy(imgpath, dstfile) imgpath="images/"+os.path.basename(imgpath) else: ### if file is not found save it as png file in the destination folder img_tmp_path = image.filepath - if img_tmp_path.endswith((".bmp",".rgb",".png",".jpeg",".jpg",".jp2",".tga",".cin",".dpx",".exr",".hdr",".tif")): + if img_tmp_path.endswith((".bmp", ".rgb", ".png", ".jpeg", ".jpg", ".jp2", ".tga", ".cin", ".dpx", ".exr", ".hdr", ".tif")): image.filepath = basedir+"/"+os.path.basename(img_tmp_path) else: image.filepath = basedir+"/"+image.name+".png" @@ -209,7 +209,7 @@ class DaeExporter: else: #export relative, always, no one wants absolute paths. try: - imgpath = os.path.relpath(imgpath,os.path.dirname(self.path)).replace("\\","/") # export unix compatible always + imgpath = os.path.relpath(imgpath, os.path.dirname(self.path)).replace("\\", "/") # export unix compatible always except: pass #fails sometimes, not sure why @@ -220,24 +220,24 @@ class DaeExporter: # if (not os.path.isfile(imgpath)): # print("NOT FILE?") -# if imgpath.endswith((".bmp",".rgb",".png",".jpeg",".jpg",".jp2",".tga",".cin",".dpx",".exr",".hdr",".tif")): +# if imgpath.endswith((".bmp", ".rgb", ".png", ".jpeg", ".jpg", ".jp2", ".tga", ".cin", ".dpx", ".exr", ".hdr", ".tif")): # imgpath="images/"+os.path.basename(imgpath) # else: # imgpath="images/"+image.name+".png" - self.writel(S_IMGS,1,'') - self.writel(S_IMGS,2,''+imgpath+'') - self.writel(S_IMGS,1,'') + self.writel(S_IMGS, 1, '') + self.writel(S_IMGS, 2, ''+imgpath+'') + self.writel(S_IMGS, 1, '') self.image_cache[image]=imgid return imgid - def export_material(self,material,double_sided_hint=True): + def export_material(self, material, double_sided_hint=True): if (material in self.material_cache): return self.material_cache[material] fxid = self.new_id("fx") - self.writel(S_FX,1,'') - self.writel(S_FX,2,'') + self.writel(S_FX, 1, '') + self.writel(S_FX, 2, '') #Find and fetch the textures and create sources sampler_table={} @@ -264,19 +264,19 @@ class DaeExporter: #surface surface_sid = self.new_id("fx_surf") - self.writel(S_FX,3,'') - self.writel(S_FX,4,'') - self.writel(S_FX,5,''+imgid+'') #this is sooo weird - self.writel(S_FX,5,'A8R8G8B8') - self.writel(S_FX,4,'') - self.writel(S_FX,3,'') + self.writel(S_FX, 3, '') + self.writel(S_FX, 4, '') + self.writel(S_FX, 5, ''+imgid+'') #this is sooo weird + self.writel(S_FX, 5, 'A8R8G8B8') + self.writel(S_FX, 4, '') + self.writel(S_FX, 3, '') #sampler, collada sure likes it difficult sampler_sid = self.new_id("fx_sampler") - self.writel(S_FX,3,'') - self.writel(S_FX,4,'') - self.writel(S_FX,5,''+surface_sid+'') - self.writel(S_FX,4,'') - self.writel(S_FX,3,'') + self.writel(S_FX, 3, '') + self.writel(S_FX, 4, '') + self.writel(S_FX, 5, ''+surface_sid+'') + self.writel(S_FX, 4, '') + self.writel(S_FX, 3, '') sampler_table[i]=sampler_sid if (ts.use_map_color_diffuse and diffuse_tex==None): @@ -288,90 +288,90 @@ class DaeExporter: if (ts.use_map_normal and normal_tex==None): normal_tex=sampler_sid - self.writel(S_FX,3,'') + self.writel(S_FX, 3, '') shtype="blinn" - self.writel(S_FX,4,'<'+shtype+'>') + self.writel(S_FX, 4, '<'+shtype+'>') #ambient? from where? - self.writel(S_FX,5,'') + self.writel(S_FX, 5, '') if (emission_tex!=None): - self.writel(S_FX,6,'') + self.writel(S_FX, 6, '') else: - self.writel(S_FX,6,''+numarr_alpha(material.diffuse_color,material.emit)+' ') # not totally right but good enough - self.writel(S_FX,5,'') + self.writel(S_FX, 6, ''+numarr_alpha(material.diffuse_color, material.emit)+' ') # not totally right but good enough + self.writel(S_FX, 5, '') - self.writel(S_FX,5,'') - self.writel(S_FX,6,''+numarr_alpha(self.scene.world.ambient_color,material.ambient)+' ') - self.writel(S_FX,5,'') + self.writel(S_FX, 5, '') + self.writel(S_FX, 6, ''+numarr_alpha(self.scene.world.ambient_color, material.ambient)+' ') + self.writel(S_FX, 5, '') - self.writel(S_FX,5,'') + self.writel(S_FX, 5, '') if (diffuse_tex!=None): - self.writel(S_FX,6,'') + self.writel(S_FX, 6, '') else: - self.writel(S_FX,6,''+numarr_alpha(material.diffuse_color,material.diffuse_intensity)+'') - self.writel(S_FX,5,'') + self.writel(S_FX, 6, ''+numarr_alpha(material.diffuse_color, material.diffuse_intensity)+'') + self.writel(S_FX, 5, '') - self.writel(S_FX,5,'') + self.writel(S_FX, 5, '') if (specular_tex!=None): - self.writel(S_FX,6,'') + self.writel(S_FX, 6, '') else: - self.writel(S_FX,6,''+numarr_alpha(material.specular_color,material.specular_intensity)+'') - self.writel(S_FX,5,'') + self.writel(S_FX, 6, ''+numarr_alpha(material.specular_color, material.specular_intensity)+'') + self.writel(S_FX, 5, '') - self.writel(S_FX,5,'') - self.writel(S_FX,6,''+str(material.specular_hardness)+'') - self.writel(S_FX,5,'') + self.writel(S_FX, 5, '') + self.writel(S_FX, 6, ''+str(material.specular_hardness)+'') + self.writel(S_FX, 5, '') - self.writel(S_FX,5,'') - self.writel(S_FX,6,''+numarr_alpha(material.mirror_color)+'') - self.writel(S_FX,5,'') + self.writel(S_FX, 5, '') + self.writel(S_FX, 6, ''+numarr_alpha(material.mirror_color)+'') + self.writel(S_FX, 5, '') if (material.use_transparency): - self.writel(S_FX,5,'') - self.writel(S_FX,6,''+str(material.alpha)+'') - self.writel(S_FX,5,'') + self.writel(S_FX, 5, '') + self.writel(S_FX, 6, ''+str(material.alpha)+'') + self.writel(S_FX, 5, '') - self.writel(S_FX,5,'') - self.writel(S_FX,6,''+str(material.specular_ior)+'') - self.writel(S_FX,5,'') + self.writel(S_FX, 5, '') + self.writel(S_FX, 6, ''+str(material.specular_ior)+'') + self.writel(S_FX, 5, '') - self.writel(S_FX,4,'') + self.writel(S_FX, 4, '') - self.writel(S_FX,4,'') - self.writel(S_FX,5,'') + self.writel(S_FX, 4, '') + self.writel(S_FX, 5, '') if (normal_tex): - self.writel(S_FX,6,'') - self.writel(S_FX,7,'') - self.writel(S_FX,6,'') + self.writel(S_FX, 6, '') + self.writel(S_FX, 7, '') + self.writel(S_FX, 6, '') - self.writel(S_FX,5,'') - self.writel(S_FX,5,'') - self.writel(S_FX,6,''+["0","1"][double_sided_hint]+"") - self.writel(S_FX,5,'') + self.writel(S_FX, 5, '') + self.writel(S_FX, 5, '') + self.writel(S_FX, 6, ''+["0", "1"][double_sided_hint]+"") + self.writel(S_FX, 5, '') if (material.use_shadeless): - self.writel(S_FX,5,'') - self.writel(S_FX,6,'1') - self.writel(S_FX,5,'') + self.writel(S_FX, 5, '') + self.writel(S_FX, 6, '1') + self.writel(S_FX, 5, '') - self.writel(S_FX,4,'') + self.writel(S_FX, 4, '') - self.writel(S_FX,3,'') - self.writel(S_FX,2,'') - self.writel(S_FX,1,'') + self.writel(S_FX, 3, '') + self.writel(S_FX, 2, '') + self.writel(S_FX, 1, '') # Also export blender material in all it's glory (if set as active) # Material matid = self.new_id("material") - self.writel(S_MATS,1,'') - self.writel(S_MATS,2,'') - self.writel(S_MATS,1,'') + self.writel(S_MATS, 1, '') + self.writel(S_MATS, 2, '') + self.writel(S_MATS, 1, '') self.material_cache[material]=matid return matid - def export_mesh(self,node,armature=None,skeyindex=-1,skel_source=None,custom_name=None): + def export_mesh(self, node, armature=None, skeyindex=-1, skel_source=None, custom_name=None): mesh = node.data if (node.data in self.mesh_cache): @@ -381,14 +381,14 @@ class DaeExporter: values=[] morph_targets=[] md=None - for k in range(0,len(mesh.shape_keys.key_blocks)): + for k in range(0, len(mesh.shape_keys.key_blocks)): shape = node.data.shape_keys.key_blocks[k] values+=[shape.value] #save value shape.value=0 mid = self.new_id("morph") - for k in range(0,len(mesh.shape_keys.key_blocks)): + for k in range(0, len(mesh.shape_keys.key_blocks)): shape = node.data.shape_keys.key_blocks[k] node.show_only_shape_key=True @@ -403,12 +403,12 @@ class DaeExporter: p = node.data v = node.to_mesh(bpy.context.scene, True, "RENDER") node.data = v -# self.export_node(node,il,shape.name) +# self.export_node(node, il, shape.name) node.data.update() if (armature and k==0): - md=self.export_mesh(node,armature,k,mid,shape.name) + md=self.export_mesh(node, armature, k, mid, shape.name) else: - md=self.export_mesh(node,None,k,None,shape.name) + md=self.export_mesh(node, None, k, None, shape.name) node.data = p node.data.update() @@ -421,14 +421,14 @@ class DaeExporter: node.show_only_shape_key=False node.active_shape_key_index = 0 - self.writel(S_MORPH,1,'') + self.writel(S_MORPH, 1, '') #if ("skin_id" in morph_targets[0]): - # self.writel(S_MORPH,2,'') + # self.writel(S_MORPH, 2, '') #else: - self.writel(S_MORPH,2,'') + self.writel(S_MORPH, 2, '') - self.writel(S_MORPH,3,'') - self.writel(S_MORPH,4,'') + self.writel(S_MORPH, 3, '') + self.writel(S_MORPH, 4, '') marr="" warr="" for i in range(len(morph_targets)): @@ -444,32 +444,32 @@ class DaeExporter: warr+=" 0" - self.writel(S_MORPH,5,marr) - self.writel(S_MORPH,4,'') - self.writel(S_MORPH,4,'') - self.writel(S_MORPH,5,'') - self.writel(S_MORPH,6,'') - self.writel(S_MORPH,5,'') - self.writel(S_MORPH,4,'') - self.writel(S_MORPH,3,'') + self.writel(S_MORPH, 5, marr) + self.writel(S_MORPH, 4, '') + self.writel(S_MORPH, 4, '') + self.writel(S_MORPH, 5, '') + self.writel(S_MORPH, 6, '') + self.writel(S_MORPH, 5, '') + self.writel(S_MORPH, 4, '') + self.writel(S_MORPH, 3, '') - self.writel(S_MORPH,3,'') - self.writel(S_MORPH,4,'') - self.writel(S_MORPH,5,warr) - self.writel(S_MORPH,4,'') - self.writel(S_MORPH,4,'') - self.writel(S_MORPH,5,'') - self.writel(S_MORPH,6,'') - self.writel(S_MORPH,5,'') - self.writel(S_MORPH,4,'') - self.writel(S_MORPH,3,'') + self.writel(S_MORPH, 3, '') + self.writel(S_MORPH, 4, '') + self.writel(S_MORPH, 5, warr) + self.writel(S_MORPH, 4, '') + self.writel(S_MORPH, 4, '') + self.writel(S_MORPH, 5, '') + self.writel(S_MORPH, 6, '') + self.writel(S_MORPH, 5, '') + self.writel(S_MORPH, 4, '') + self.writel(S_MORPH, 3, '') - self.writel(S_MORPH,3,'') - self.writel(S_MORPH,4,'') - self.writel(S_MORPH,4,'') - self.writel(S_MORPH,3,'') - self.writel(S_MORPH,2,'') - self.writel(S_MORPH,1,'') + self.writel(S_MORPH, 3, '') + self.writel(S_MORPH, 4, '') + self.writel(S_MORPH, 4, '') + self.writel(S_MORPH, 3, '') + self.writel(S_MORPH, 2, '') + self.writel(S_MORPH, 1, '') if (armature!=None): self.armature_for_morph[node]=armature @@ -493,7 +493,7 @@ class DaeExporter: if (custom_name!=None and custom_name!=""): name_to_use=custom_name - mesh=node.to_mesh(self.scene,apply_modifiers,"RENDER") #is this allright? + mesh=node.to_mesh(self.scene, apply_modifiers, "RENDER") #is this allright? triangulate=self.config["use_triangles"] if (triangulate): @@ -527,7 +527,7 @@ class DaeExporter: try: mesh.calc_tangents() except: - self.operator.report({'WARNING'},'CalcTangets failed for mesh "'+mesh.name+'", no tangets will be exported.') + self.operator.report({'WARNING'}, 'CalcTangets failed for mesh "'+mesh.name+'", no tangets will be exported.') #uv_layer_count=0 mesh.calc_normals_split() has_tangents=False @@ -551,7 +551,7 @@ class DaeExporter: mat= None if (mat!=None): - materials[f.material_index]=self.export_material( mat,mesh.show_double_sided ) + materials[f.material_index]=self.export_material( mat, mesh.show_double_sided ) else: materials[f.material_index]=None #weird, has no material? @@ -615,7 +615,7 @@ class DaeExporter: wsum+=vg.weight if (wsum==0.0): if not self.wrongvtx_report: - self.operator.report({'WARNING'},'Mesh for object "'+node.name+'" has unassigned weights. This may look wrong in exported model.') + self.operator.report({'WARNING'}, 'Mesh for object "'+node.name+'" has unassigned weights. This may look wrong in exported model.') self.wrongvtx_report=True #blender can have bones assigned that weight zero so they remain local @@ -639,74 +639,74 @@ class DaeExporter: indices.append(vi) meshid = self.new_id("mesh") - self.writel(S_GEOM,1,'') + self.writel(S_GEOM, 1, '') - self.writel(S_GEOM,2,'') + self.writel(S_GEOM, 2, '') # Vertex Array - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 3, '') float_values="" for v in vertices: float_values+=" "+str(v.vertex.x)+" "+str(v.vertex.y)+" "+str(v.vertex.z) - self.writel(S_GEOM,4,''+float_values+'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 4, ''+float_values+'') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 3, '') # Normal Array - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 3, '') float_values="" for v in vertices: float_values+=" "+str(v.normal.x)+" "+str(v.normal.y)+" "+str(v.normal.z) - self.writel(S_GEOM,4,''+float_values+'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 4, ''+float_values+'') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 3, '') if (has_tangents): - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 3, '') float_values="" for v in vertices: float_values+=" "+str(v.tangent.x)+" "+str(v.tangent.y)+" "+str(v.tangent.z) - self.writel(S_GEOM,4,''+float_values+'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 4, ''+float_values+'') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 3, '') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 3, '') float_values="" for v in vertices: float_values+=" "+str(v.bitangent.x)+" "+str(v.bitangent.y)+" "+str(v.bitangent.z) - self.writel(S_GEOM,4,''+float_values+'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 4, ''+float_values+'') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 3, '') # UV Arrays for uvi in range(uv_layer_count): - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 3, '') float_values="" for v in vertices: try: @@ -715,36 +715,36 @@ class DaeExporter: # I don't understand this weird multi-uv-layer API, but with this it seems to works float_values+=" 0 0 " - self.writel(S_GEOM,4,''+float_values+'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 4, ''+float_values+'') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 3, '') # Color Arrays if (has_colors): - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 3, '') float_values="" for v in vertices: float_values+=" "+str(v.color.x)+" "+str(v.color.y)+" "+str(v.color.z) - self.writel(S_GEOM,4,''+float_values+'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 4, ''+float_values+'') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 3, '') # Triangle Lists - self.writel(S_GEOM,3,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 3, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 3, '') prim_type="" if (triangulate): @@ -758,22 +758,22 @@ class DaeExporter: if (mat!=None): matref = self.new_id("trimat") - self.writel(S_GEOM,3,'<'+prim_type+' count="'+str(int(len(indices)))+'" material="'+matref+'">') # todo material - mat_assign.append( (mat,matref) ) + self.writel(S_GEOM, 3, '<'+prim_type+' count="'+str(int(len(indices)))+'" material="'+matref+'">') # todo material + mat_assign.append( (mat, matref) ) else: - self.writel(S_GEOM,3,'<'+prim_type+' count="'+str(int(len(indices)))+'">') # todo material + self.writel(S_GEOM, 3, '<'+prim_type+' count="'+str(int(len(indices)))+'">') # todo material - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') for uvi in range(uv_layer_count): - self.writel(S_GEOM,4,'') + self.writel(S_GEOM, 4, '') if (has_colors): - self.writel(S_GEOM,4,'') + self.writel(S_GEOM, 4, '') if (has_tangents): - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') if (triangulate): int_values="

" @@ -781,19 +781,19 @@ class DaeExporter: for i in p: int_values+=" "+str(i) int_values+="

" - self.writel(S_GEOM,4,int_values) + self.writel(S_GEOM, 4, int_values) else: for p in indices: int_values="

" for i in p: int_values+=" "+str(i) int_values+="

" - self.writel(S_GEOM,4,int_values) + self.writel(S_GEOM, 4, int_values) - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 3, '') - self.writel(S_GEOM,2,'
') - self.writel(S_GEOM,1,'
') + self.writel(S_GEOM, 2, '') + self.writel(S_GEOM, 1, '
') meshdata={} meshdata["id"]=meshid @@ -806,41 +806,41 @@ class DaeExporter: contid = self.new_id("controller") - self.writel(S_SKIN,1,'') + self.writel(S_SKIN, 1, '') if (skel_source!=None): - self.writel(S_SKIN,2,'') + self.writel(S_SKIN, 2, '') else: - self.writel(S_SKIN,2,'') + self.writel(S_SKIN, 2, '') - self.writel(S_SKIN,3,''+strmtx(node.matrix_world)+'') + self.writel(S_SKIN, 3, ''+strmtx(node.matrix_world)+'') #Joint Names - self.writel(S_SKIN,3,'') + self.writel(S_SKIN, 3, '') name_values="" for v in si["bone_names"]: name_values+=" "+v - self.writel(S_SKIN,4,''+name_values+'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,5,'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,3,'') + self.writel(S_SKIN, 4, ''+name_values+'') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 5, '') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 3, '') #Pose Matrices! - self.writel(S_SKIN,3,'') + self.writel(S_SKIN, 3, '') pose_values="" for v in si["bone_bind_poses"]: pose_values+=" "+strmtx(v) - self.writel(S_SKIN,4,''+pose_values+'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,5,'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,3,'') + self.writel(S_SKIN, 4, ''+pose_values+'') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 5, '') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 3, '') #Skin Weights! - self.writel(S_SKIN,3,'') + self.writel(S_SKIN, 3, '') skin_weights="" skin_weights_total=0 for v in vertices: @@ -848,21 +848,21 @@ class DaeExporter: for w in v.weights: skin_weights+=" "+str(w) - self.writel(S_SKIN,4,''+skin_weights+'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,5,'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,3,'') + self.writel(S_SKIN, 4, ''+skin_weights+'') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 5, '') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 3, '') - self.writel(S_SKIN,3,'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,3,'') - self.writel(S_SKIN,3,'') - self.writel(S_SKIN,4,'') - self.writel(S_SKIN,4,'') + self.writel(S_SKIN, 3, '') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 3, '') + self.writel(S_SKIN, 3, '') + self.writel(S_SKIN, 4, '') + self.writel(S_SKIN, 4, '') vcounts="" vs="" vcount=0 @@ -872,17 +872,17 @@ class DaeExporter: vs+=" "+str(b) vs+=" "+str(vcount) vcount+=1 - self.writel(S_SKIN,4,''+vcounts+'') - self.writel(S_SKIN,4,''+vs+'') - self.writel(S_SKIN,3,'') + self.writel(S_SKIN, 4, ''+vcounts+'') + self.writel(S_SKIN, 4, ''+vs+'') + self.writel(S_SKIN, 3, '') - self.writel(S_SKIN,2,'') - self.writel(S_SKIN,1,'') + self.writel(S_SKIN, 2, '') + self.writel(S_SKIN, 1, '') meshdata["skin_id"]=contid return meshdata - def export_mesh_node(self,node,il): + def export_mesh_node(self, node, il): if (node.data==None): return @@ -896,12 +896,12 @@ class DaeExporter: if (node.parent.type=="ARMATURE"): armature=node.parent if (armcount>1): - self.operator.report({'WARNING'},'Object "'+node.name+'" refers to more than one armature! This is unsupported.') + self.operator.report({'WARNING'}, 'Object "'+node.name+'" refers to more than one armature! This is unsupported.') if (armcount==0): - self.operator.report({'WARNING'},'Object "'+node.name+'" is child of an armature, but has no armature modifier.') + self.operator.report({'WARNING'}, 'Object "'+node.name+'" is child of an armature, but has no armature modifier.') if (armcount>0 and not armature): - self.operator.report({'WARNING'},'Object "'+node.name+'" has armature modifier, but is not a child of an armature. This is unsupported.') + self.operator.report({'WARNING'}, 'Object "'+node.name+'" has armature modifier, but is not a child of an armature. This is unsupported.') if (node.data.shape_keys!=None): sk = node.data.shape_keys @@ -916,50 +916,50 @@ class DaeExporter: #print("LINKING "+str(node)+" WITH "+str(t.id.name)) self.armature_for_morph[node]=self.scene.objects[t.id.name] - meshdata = self.export_mesh(node,armature) + meshdata = self.export_mesh(node, armature) close_controller=False if ("skin_id" in meshdata): close_controller=True - self.writel(S_NODES,il,'') + self.writel(S_NODES, il, '') for sn in self.skeleton_info[armature]["skeleton_nodes"]: - self.writel(S_NODES,il+1,'#'+sn+'') + self.writel(S_NODES, il+1, '#'+sn+'') elif ("morph_id" in meshdata): - self.writel(S_NODES,il,'') + self.writel(S_NODES, il, '') close_controller=True elif (armature==None): - self.writel(S_NODES,il,'') + self.writel(S_NODES, il, '') if (len(meshdata["material_assign"])>0): - self.writel(S_NODES,il+1,'') - self.writel(S_NODES,il+2,'') + self.writel(S_NODES, il+1, '') + self.writel(S_NODES, il+2, '') for m in meshdata["material_assign"]: - self.writel(S_NODES,il+3,'') + self.writel(S_NODES, il+3, '') - self.writel(S_NODES,il+2,'') - self.writel(S_NODES,il+1,'') + self.writel(S_NODES, il+2, '') + self.writel(S_NODES, il+1, '') if (close_controller): - self.writel(S_NODES,il,'') + self.writel(S_NODES, il, '') else: - self.writel(S_NODES,il,'') + self.writel(S_NODES, il, '') - def export_armature_bone(self,bone,il,si): + def export_armature_bone(self, bone, il, si): boneid = self.new_id("bone") boneidx = si["bone_count"] si["bone_count"]+=1 bonesid = si["id"]+"-"+str(boneidx) if (bone.name in self.used_bones): if (self.config["use_anim_action_all"]): - self.operator.report({'WARNING'},'Bone name "'+bone.name+'" used in more than one skeleton. Actions might export wrong.') + self.operator.report({'WARNING'}, 'Bone name "'+bone.name+'" used in more than one skeleton. Actions might export wrong.') else: self.used_bones.append(bone.name) si["bone_index"][bone.name]=boneidx si["bone_ids"][bone]=boneid si["bone_names"].append(bonesid) - self.writel(S_NODES,il,'') + self.writel(S_NODES, il, '') il+=1 xform = bone.matrix_local si["bone_bind_poses"].append((si["armature_xform"] * xform).inverted()) @@ -969,25 +969,25 @@ class DaeExporter: else: si["skeleton_nodes"].append(boneid) - self.writel(S_NODES,il,''+strmtx(xform)+'') + self.writel(S_NODES, il, ''+strmtx(xform)+'') for c in bone.children: - self.export_armature_bone(c,il,si) + self.export_armature_bone(c, il, si) il-=1 - self.writel(S_NODES,il,'') + self.writel(S_NODES, il, '') - def export_armature_node(self,node,il): + def export_armature_node(self, node, il): if (node.data==None): return self.skeletons.append(node) armature = node.data - self.skeleton_info[node]={ "bone_count":0, "id":self.new_id("skelbones"),"name":node.name, "bone_index":{},"bone_ids":{},"bone_names":[],"bone_bind_poses":[],"skeleton_nodes":[],"armature_xform":node.matrix_world } + self.skeleton_info[node]={ "bone_count":0, "id":self.new_id("skelbones"), "name":node.name, "bone_index":{}, "bone_ids":{}, "bone_names":[], "bone_bind_poses":[], "skeleton_nodes":[], "armature_xform":node.matrix_world } for b in armature.bones: if (b.parent!=None): continue - self.export_armature_bone(b,il,self.skeleton_info[node]) + self.export_armature_bone(b, il, self.skeleton_info[node]) if (node.pose): for b in node.pose.bones: @@ -995,86 +995,86 @@ class DaeExporter: if (x.type=='ACTION'): self.action_constraints.append(x.action) - def export_camera_node(self,node,il): + def export_camera_node(self, node, il): if (node.data==None): return camera=node.data camid=self.new_id("camera") - self.writel(S_CAMS,1,'') - self.writel(S_CAMS,2,'') - self.writel(S_CAMS,3,'') + self.writel(S_CAMS, 1, '') + self.writel(S_CAMS, 2, '') + self.writel(S_CAMS, 3, '') if (camera.type=="PERSP"): - self.writel(S_CAMS,4,'') - self.writel(S_CAMS,5,' '+str(math.degrees(camera.angle))+' ') # I think? - self.writel(S_CAMS,5,' '+str(self.scene.render.resolution_x / self.scene.render.resolution_y)+' ') - self.writel(S_CAMS,5,' '+str(camera.clip_start)+' ') - self.writel(S_CAMS,5,' '+str(camera.clip_end)+' ') - self.writel(S_CAMS,4,'') + self.writel(S_CAMS, 4, '') + self.writel(S_CAMS, 5, ' '+str(math.degrees(camera.angle))+' ') # I think? + self.writel(S_CAMS, 5, ' '+str(self.scene.render.resolution_x / self.scene.render.resolution_y)+' ') + self.writel(S_CAMS, 5, ' '+str(camera.clip_start)+' ') + self.writel(S_CAMS, 5, ' '+str(camera.clip_end)+' ') + self.writel(S_CAMS, 4, '') else: - self.writel(S_CAMS,4,'') - self.writel(S_CAMS,5,' '+str(camera.ortho_scale*0.5)+' ') # I think? - self.writel(S_CAMS,5,' '+str(self.scene.render.resolution_x / self.scene.render.resolution_y)+' ') - self.writel(S_CAMS,5,' '+str(camera.clip_start)+' ') - self.writel(S_CAMS,5,' '+str(camera.clip_end)+' ') - self.writel(S_CAMS,4,'') + self.writel(S_CAMS, 4, '') + self.writel(S_CAMS, 5, ' '+str(camera.ortho_scale*0.5)+' ') # I think? + self.writel(S_CAMS, 5, ' '+str(self.scene.render.resolution_x / self.scene.render.resolution_y)+' ') + self.writel(S_CAMS, 5, ' '+str(camera.clip_start)+' ') + self.writel(S_CAMS, 5, ' '+str(camera.clip_end)+' ') + self.writel(S_CAMS, 4, '') - self.writel(S_CAMS,3,'') - self.writel(S_CAMS,2,'') - self.writel(S_CAMS,1,'') + self.writel(S_CAMS, 3, '') + self.writel(S_CAMS, 2, '') + self.writel(S_CAMS, 1, '') - self.writel(S_NODES,il,'') + self.writel(S_NODES, il, '') - def export_lamp_node(self,node,il): + def export_lamp_node(self, node, il): if (node.data==None): return light=node.data lightid=self.new_id("light") - self.writel(S_LAMPS,1,'') - #self.writel(S_LAMPS,2,'') - self.writel(S_LAMPS,3,'') + self.writel(S_LAMPS, 1, '') + #self.writel(S_LAMPS, 2, '') + self.writel(S_LAMPS, 3, '') if (light.type=="POINT"): - self.writel(S_LAMPS,4,'') - self.writel(S_LAMPS,5,''+strarr(light.color)+'') + self.writel(S_LAMPS, 4, '') + self.writel(S_LAMPS, 5, ''+strarr(light.color)+'') att_by_distance = 2.0 / light.distance # convert to linear attenuation - self.writel(S_LAMPS,5,''+str(att_by_distance)+'') + self.writel(S_LAMPS, 5, ''+str(att_by_distance)+'') if (light.use_sphere): - self.writel(S_LAMPS,5,''+str(light.distance)+'') + self.writel(S_LAMPS, 5, ''+str(light.distance)+'') - self.writel(S_LAMPS,4,'') + self.writel(S_LAMPS, 4, '') elif (light.type=="SPOT"): - self.writel(S_LAMPS,4,'') - self.writel(S_LAMPS,5,''+strarr(light.color)+'') + self.writel(S_LAMPS, 4, '') + self.writel(S_LAMPS, 5, ''+strarr(light.color)+'') att_by_distance = 2.0 / light.distance # convert to linear attenuation - self.writel(S_LAMPS,5,''+str(att_by_distance)+'') - self.writel(S_LAMPS,5,''+str(math.degrees(light.spot_size/2))+'') - self.writel(S_LAMPS,4,'') + self.writel(S_LAMPS, 5, ''+str(att_by_distance)+'') + self.writel(S_LAMPS, 5, ''+str(math.degrees(light.spot_size/2))+'') + self.writel(S_LAMPS, 4, '') else: #write a sun lamp for everything else (not supported) - self.writel(S_LAMPS,4,'') - self.writel(S_LAMPS,5,''+strarr(light.color)+'') - self.writel(S_LAMPS,4,'') + self.writel(S_LAMPS, 4, '') + self.writel(S_LAMPS, 5, ''+strarr(light.color)+'') + self.writel(S_LAMPS, 4, '') - self.writel(S_LAMPS,3,'') - #self.writel(S_LAMPS,2,'') - self.writel(S_LAMPS,1,'') + self.writel(S_LAMPS, 3, '') + #self.writel(S_LAMPS, 2, '') + self.writel(S_LAMPS, 1, '') - self.writel(S_NODES,il,'') + self.writel(S_NODES, il, '') - def export_empty_node(self,node,il): - self.writel(S_NODES,4,'') - self.writel(S_NODES,5,'') - self.writel(S_NODES,6,''+node.empty_draw_type+'') - self.writel(S_NODES,5,'') - self.writel(S_NODES,4,'') + def export_empty_node(self, node, il): + self.writel(S_NODES, 4, '') + self.writel(S_NODES, 5, '') + self.writel(S_NODES, 6, ''+node.empty_draw_type+'') + self.writel(S_NODES, 5, '') + self.writel(S_NODES, 4, '') - def export_curve(self,curve): + def export_curve(self, curve): splineid = self.new_id("spline") - self.writel(S_GEOM,1,'') - self.writel(S_GEOM,2,'') + self.writel(S_GEOM, 1, '') + self.writel(S_GEOM, 2, '') points=[] interps=[] @@ -1115,122 +1115,122 @@ class DaeExporter: tilts.append(s.tilt) interps.append("LINEAR") - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 3, '') position_values="" for x in points: position_values+=" "+str(x) - self.writel(S_GEOM,4,''+position_values+'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 4, ''+position_values+'') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 3, '') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 3, '') intangent_values="" for x in handles_in: intangent_values+=" "+str(x) - self.writel(S_GEOM,4,''+intangent_values+'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 4, ''+intangent_values+'') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 3, '') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 3, '') outtangent_values="" for x in handles_out: outtangent_values+=" "+str(x) - self.writel(S_GEOM,4,''+outtangent_values+'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 4, ''+outtangent_values+'') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 3, '') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 3, '') interpolation_values="" for x in interps: interpolation_values+=" "+x - self.writel(S_GEOM,4,''+interpolation_values+'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 4, ''+interpolation_values+'') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 3, '') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 3, '') tilt_values="" for x in tilts: tilt_values+=" "+str(x) - self.writel(S_GEOM,4,''+tilt_values+'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,5,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 4, ''+tilt_values+'') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 5, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 3, '') - self.writel(S_GEOM,3,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,4,'') - self.writel(S_GEOM,3,'') + self.writel(S_GEOM, 3, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 4, '') + self.writel(S_GEOM, 3, '') - self.writel(S_GEOM,2,'') - self.writel(S_GEOM,1,'') + self.writel(S_GEOM, 2, '') + self.writel(S_GEOM, 1, '') return splineid - def export_curve_node(self,node,il): + def export_curve_node(self, node, il): if (node.data==None): return curveid = self.export_curve(node.data) - self.writel(S_NODES,il,'') - self.writel(S_NODES,il,'') + self.writel(S_NODES, il, '') + self.writel(S_NODES, il, '') - def export_node(self,node,il): + def export_node(self, node, il): if (not node in self.valid_nodes): return prev_node = bpy.context.scene.objects.active bpy.context.scene.objects.active = node - self.writel(S_NODES,il,'') + self.writel(S_NODES, il, '') il+=1 - self.writel(S_NODES,il,''+strmtx(node.matrix_local)+'') + self.writel(S_NODES, il, ''+strmtx(node.matrix_local)+'') #print("NODE TYPE: "+node.type+" NAME: "+node.name) if (node.type=="MESH"): - self.export_mesh_node(node,il) + self.export_mesh_node(node, il) elif (node.type=="CURVE"): - self.export_curve_node(node,il) + self.export_curve_node(node, il) elif (node.type=="ARMATURE"): - self.export_armature_node(node,il) + self.export_armature_node(node, il) elif (node.type=="CAMERA"): - self.export_camera_node(node,il) + self.export_camera_node(node, il) elif (node.type=="LAMP"): - self.export_lamp_node(node,il) + self.export_lamp_node(node, il) elif (node.type=="EMPTY"): - self.export_empty_node(node,il) + self.export_empty_node(node, il) for x in node.children: - self.export_node(x,il) + self.export_node(x, il) il-=1 - self.writel(S_NODES,il,'') + self.writel(S_NODES, il, '') bpy.context.scene.objects.active = prev_node #make previous node active again - def is_node_valid(self,node): + def is_node_valid(self, node): if (not node.type in self.config["object_types"]): return False @@ -1250,8 +1250,8 @@ class DaeExporter: return True def export_scene(self): - self.writel(S_NODES,0,'') - self.writel(S_NODES,1,'') + self.writel(S_NODES, 0, '') + self.writel(S_NODES, 1, '') # validate nodes for obj in self.scene.objects: @@ -1266,28 +1266,28 @@ class DaeExporter: for obj in self.scene.objects: if (obj in self.valid_nodes and obj.parent==None): - self.export_node(obj,2) + self.export_node(obj, 2) - self.writel(S_NODES,1,'') - self.writel(S_NODES,0,'') + self.writel(S_NODES, 1, '') + self.writel(S_NODES, 0, '') def export_asset(self): - self.writel(S_ASSET,0,'') + self.writel(S_ASSET, 0, '') # Why is this time stuff mandatory?, no one could care less... - self.writel(S_ASSET,1,'') - self.writel(S_ASSET,2,' Anonymous ') #Who made Collada, the FBI ? - self.writel(S_ASSET,2,' Collada Exporter for Blender 2.6+, by Juan Linietsky (juan@codenix.com) ') #Who made Collada, the FBI ? - self.writel(S_ASSET,1,'') - self.writel(S_ASSET,1,''+time.strftime("%Y-%m-%dT%H:%M:%SZ ")+'') - self.writel(S_ASSET,1,''+time.strftime("%Y-%m-%dT%H:%M:%SZ")+'') - self.writel(S_ASSET,1,'') - self.writel(S_ASSET,1,'Z_UP') - self.writel(S_ASSET,0,'') + self.writel(S_ASSET, 1, '') + self.writel(S_ASSET, 2, ' Anonymous ') #Who made Collada, the FBI ? + self.writel(S_ASSET, 2, ' Collada Exporter for Blender 2.6+, by Juan Linietsky (juan@codenix.com) ') #Who made Collada, the FBI ? + self.writel(S_ASSET, 1, '') + self.writel(S_ASSET, 1, ''+time.strftime("%Y-%m-%dT%H:%M:%SZ ")+'') + self.writel(S_ASSET, 1, ''+time.strftime("%Y-%m-%dT%H:%M:%SZ")+'') + self.writel(S_ASSET, 1, '') + self.writel(S_ASSET, 1, 'Z_UP') + self.writel(S_ASSET, 0, '') - def export_animation_transform_channel(self,target,keys,matrices=True): + def export_animation_transform_channel(self, target, keys, matrices=True): frame_total=len(keys) anim_id=self.new_id("anim") - self.writel(S_ANIM,1,'') + self.writel(S_ANIM, 1, '') source_frames = "" source_transforms = "" source_interps = "" @@ -1302,60 +1302,60 @@ class DaeExporter: source_interps +=" LINEAR" # Time Source - self.writel(S_ANIM,2,'') - self.writel(S_ANIM,3,''+source_frames+'') - self.writel(S_ANIM,3,'') - self.writel(S_ANIM,4,'') - self.writel(S_ANIM,5,'') - self.writel(S_ANIM,4,'') - self.writel(S_ANIM,3,'') - self.writel(S_ANIM,2,'') + self.writel(S_ANIM, 2, '') + self.writel(S_ANIM, 3, ''+source_frames+'') + self.writel(S_ANIM, 3, '') + self.writel(S_ANIM, 4, '') + self.writel(S_ANIM, 5, '') + self.writel(S_ANIM, 4, '') + self.writel(S_ANIM, 3, '') + self.writel(S_ANIM, 2, '') if (matrices): # Transform Source - self.writel(S_ANIM,2,'') - self.writel(S_ANIM,3,''+source_transforms+'') - self.writel(S_ANIM,3,'') - self.writel(S_ANIM,4,'') - self.writel(S_ANIM,5,'') - self.writel(S_ANIM,4,'') - self.writel(S_ANIM,3,'') - self.writel(S_ANIM,2,'') + self.writel(S_ANIM, 2, '') + self.writel(S_ANIM, 3, ''+source_transforms+'') + self.writel(S_ANIM, 3, '') + self.writel(S_ANIM, 4, '') + self.writel(S_ANIM, 5, '') + self.writel(S_ANIM, 4, '') + self.writel(S_ANIM, 3, '') + self.writel(S_ANIM, 2, '') else: # Value Source - self.writel(S_ANIM,2,'') - self.writel(S_ANIM,3,''+source_transforms+'') - self.writel(S_ANIM,3,'') - self.writel(S_ANIM,4,'') - self.writel(S_ANIM,5,'') - self.writel(S_ANIM,4,'') - self.writel(S_ANIM,3,'') - self.writel(S_ANIM,2,'') + self.writel(S_ANIM, 2, '') + self.writel(S_ANIM, 3, ''+source_transforms+'') + self.writel(S_ANIM, 3, '') + self.writel(S_ANIM, 4, '') + self.writel(S_ANIM, 5, '') + self.writel(S_ANIM, 4, '') + self.writel(S_ANIM, 3, '') + self.writel(S_ANIM, 2, '') # Interpolation Source - self.writel(S_ANIM,2,'') - self.writel(S_ANIM,3,''+source_interps+'') - self.writel(S_ANIM,3,'') - self.writel(S_ANIM,4,'') - self.writel(S_ANIM,5,'') - self.writel(S_ANIM,4,'') - self.writel(S_ANIM,3,'') - self.writel(S_ANIM,2,'') + self.writel(S_ANIM, 2, '') + self.writel(S_ANIM, 3, ''+source_interps+'') + self.writel(S_ANIM, 3, '') + self.writel(S_ANIM, 4, '') + self.writel(S_ANIM, 5, '') + self.writel(S_ANIM, 4, '') + self.writel(S_ANIM, 3, '') + self.writel(S_ANIM, 2, '') - self.writel(S_ANIM,2,'') - self.writel(S_ANIM,3,'') - self.writel(S_ANIM,3,'') - self.writel(S_ANIM,3,'') - self.writel(S_ANIM,2,'') + self.writel(S_ANIM, 2, '') + self.writel(S_ANIM, 3, '') + self.writel(S_ANIM, 3, '') + self.writel(S_ANIM, 3, '') + self.writel(S_ANIM, 2, '') if (matrices): - self.writel(S_ANIM,2,'') + self.writel(S_ANIM, 2, '') else: - self.writel(S_ANIM,2,'') - self.writel(S_ANIM,1,'') + self.writel(S_ANIM, 2, '') + self.writel(S_ANIM, 1, '') return [anim_id] - def export_animation(self,start,end,allowed=None): + def export_animation(self, start, end, allowed=None): # Blender -> Collada frames needs a little work # Collada starts from 0, blender usually from 1 # The last frame must be included also @@ -1375,7 +1375,7 @@ class DaeExporter: # This improves performance enormously #print("anim from: "+str(start)+" to "+str(end)+" allowed: "+str(allowed)) - for t in range(start,end+1): + for t in range(start, end+1): self.scene.frame_set(t) key = t * frame_len - frame_sub # print("Export Anim Frame "+str(t)+"/"+str(self.scene.frame_end+1)) @@ -1401,7 +1401,7 @@ class DaeExporter: if (not (name in blend_cache)): blend_cache[name]=[] - blend_cache[name].append( (key,node.data.shape_keys.key_blocks[i].value) ) + blend_cache[name].append( (key, node.data.shape_keys.key_blocks[i].value) ) if (node.type=="MESH" and node.parent and node.parent.type=="ARMATURE"): @@ -1417,7 +1417,7 @@ class DaeExporter: if (node.parent): mtx = node.parent.matrix_world.inverted() * mtx - xform_cache[name].append( (key,mtx) ) + xform_cache[name].append( (key, mtx) ) if (node.type=="ARMATURE"): #All bones exported for now @@ -1445,15 +1445,15 @@ class DaeExporter: if (not parent_invisible): mtx = parent_posebone.matrix.inverted() * mtx - xform_cache[bone_name].append( (key,mtx) ) + xform_cache[bone_name].append( (key, mtx) ) self.scene.frame_set(frame_orig) #export animation xml for nid in xform_cache: - tcn+=self.export_animation_transform_channel(nid,xform_cache[nid],True) + tcn+=self.export_animation_transform_channel(nid, xform_cache[nid], True) for nid in blend_cache: - tcn+=self.export_animation_transform_channel(nid,blend_cache[nid],False) + tcn+=self.export_animation_transform_channel(nid, blend_cache[nid], False) return tcn @@ -1464,9 +1464,9 @@ class DaeExporter: for bone in s.pose.bones: tmp_bone_mat.append(Matrix(bone.matrix_basis)) bone.matrix_basis = Matrix() - tmp_mat.append([Matrix(s.matrix_local),tmp_bone_mat]) + tmp_mat.append([Matrix(s.matrix_local), tmp_bone_mat]) - self.writel(S_ANIM,0,'') + self.writel(S_ANIM, 0, '') if (self.config["use_anim_action_all"] and len(self.skeletons)): cached_actions = {} @@ -1475,7 +1475,7 @@ class DaeExporter: if s.animation_data and s.animation_data.action: cached_actions[s] = s.animation_data.action.name - self.writel(S_ANIM_CLIPS,0,'') + self.writel(S_ANIM_CLIPS, 0, '') for x in bpy.data.actions[:]: if x.users==0 or x in self.action_constraints: @@ -1496,7 +1496,7 @@ class DaeExporter: bones.append(dp) allowed_skeletons=[] - for i,y in enumerate(self.skeletons): + for i, y in enumerate(self.skeletons): if (y.animation_data): for z in y.pose.bones: if (z.bone.name in bones): @@ -1505,87 +1505,87 @@ class DaeExporter: y.animation_data.action=x; y.matrix_local = tmp_mat[i][0] - for j,bone in enumerate(s.pose.bones): + for j, bone in enumerate(s.pose.bones): bone.matrix_basis = Matrix() # print("allowed skeletons "+str(allowed_skeletons)) # print(str(x)) - tcn = self.export_animation(int(x.frame_range[0]),int(x.frame_range[1]+0.5),allowed_skeletons) + tcn = self.export_animation(int(x.frame_range[0]), int(x.frame_range[1]+0.5), allowed_skeletons) framelen=(1.0/self.scene.render.fps) start = x.frame_range[0]*framelen end = x.frame_range[1]*framelen #print("Export anim: "+x.name) - self.writel(S_ANIM_CLIPS,1,'') + self.writel(S_ANIM_CLIPS, 1, '') for z in tcn: - self.writel(S_ANIM_CLIPS,2,'') - self.writel(S_ANIM_CLIPS,1,'') + self.writel(S_ANIM_CLIPS, 2, '') + self.writel(S_ANIM_CLIPS, 1, '') if (len(tcn)==0): - self.operator.report({'WARNING'},'Animation clip "'+x.name+'" contains no tracks.') + self.operator.report({'WARNING'}, 'Animation clip "'+x.name+'" contains no tracks.') - self.writel(S_ANIM_CLIPS,0,'') + self.writel(S_ANIM_CLIPS, 0, '') - for i,s in enumerate(self.skeletons): + for i, s in enumerate(self.skeletons): if (s.animation_data==None): continue if s in cached_actions: s.animation_data.action = bpy.data.actions[cached_actions[s]] else: s.animation_data.action = None - for j,bone in enumerate(s.pose.bones): + for j, bone in enumerate(s.pose.bones): bone.matrix_basis = tmp_mat[i][1][j] else: - self.export_animation(self.scene.frame_start,self.scene.frame_end) + self.export_animation(self.scene.frame_start, self.scene.frame_end) - self.writel(S_ANIM,0,'') + self.writel(S_ANIM, 0, '') def export(self): - self.writel(S_GEOM,0,'') - self.writel(S_CONT,0,'') - self.writel(S_CAMS,0,'') - self.writel(S_LAMPS,0,'') - self.writel(S_IMGS,0,'') - self.writel(S_MATS,0,'') - self.writel(S_FX,0,'') + self.writel(S_GEOM, 0, '') + self.writel(S_CONT, 0, '') + self.writel(S_CAMS, 0, '') + self.writel(S_LAMPS, 0, '') + self.writel(S_IMGS, 0, '') + self.writel(S_MATS, 0, '') + self.writel(S_FX, 0, '') self.skeletons=[] self.action_constraints=[] self.export_asset() self.export_scene() - self.writel(S_GEOM,0,'') + self.writel(S_GEOM, 0, '') #morphs always go before skin controllers if S_MORPH in self.sections: for l in self.sections[S_MORPH]: - self.writel(S_CONT,0,l) + self.writel(S_CONT, 0, l) del self.sections[S_MORPH] #morphs always go before skin controllers if S_SKIN in self.sections: for l in self.sections[S_SKIN]: - self.writel(S_CONT,0,l) + self.writel(S_CONT, 0, l) del self.sections[S_SKIN] - self.writel(S_CONT,0,'') - self.writel(S_CAMS,0,'') - self.writel(S_LAMPS,0,'') - self.writel(S_IMGS,0,'') - self.writel(S_MATS,0,'') - self.writel(S_FX,0,'') + self.writel(S_CONT, 0, '') + self.writel(S_CAMS, 0, '') + self.writel(S_LAMPS, 0, '') + self.writel(S_IMGS, 0, '') + self.writel(S_MATS, 0, '') + self.writel(S_FX, 0, '') if (self.config["use_anim"]): self.export_animations() try: - f = open(self.path,"wb") + f = open(self.path, "wb") except: return False - f.write(bytes('\n',"UTF-8")) - f.write(bytes('\n',"UTF-8")) + f.write(bytes('\n', "UTF-8")) + f.write(bytes('\n', "UTF-8")) s=[] for x in self.sections.keys(): @@ -1593,15 +1593,15 @@ class DaeExporter: s.sort() for x in s: for l in self.sections[x]: - f.write(bytes(l+"\n","UTF-8")) + f.write(bytes(l+"\n", "UTF-8")) - f.write(bytes('\n',"UTF-8")) - f.write(bytes('\t\n',"UTF-8")) - f.write(bytes('\n',"UTF-8")) - f.write(bytes('\n',"UTF-8")) + f.write(bytes('\n', "UTF-8")) + f.write(bytes('\t\n', "UTF-8")) + f.write(bytes('\n', "UTF-8")) + f.write(bytes('\n', "UTF-8")) return True - def __init__(self,path,kwargs,operator): + def __init__(self, path, kwargs, operator): self.operator=operator self.scene=bpy.context.scene self.last_id=0 @@ -1626,7 +1626,7 @@ def save(operator, context, **kwargs ): - exp = DaeExporter(filepath,kwargs,operator) + exp = DaeExporter(filepath, kwargs, operator) exp.export() return {'FINISHED'} # so the script wont run after we have batch exported.