Remove trailing spaces

This commit is contained in:
Rémi Verschelde
2016-04-02 20:26:12 +02:00
parent 453eb675df
commit 5d1627c9b9
3 changed files with 121 additions and 121 deletions

View File

@@ -41,9 +41,9 @@ class godot_export_manager(bpy.types.Panel):
bl_space_type = 'PROPERTIES' bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW' bl_region_type = 'WINDOW'
bl_context = "scene" bl_context = "scene"
bpy.types.Scene.godot_export_on_save = BoolProperty(default=False) bpy.types.Scene.godot_export_on_save = BoolProperty(default=False)
### draw function for all ui elements ### draw function for all ui elements
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
@@ -51,56 +51,56 @@ class godot_export_manager(bpy.types.Panel):
scene = bpy.data.scenes[0] scene = bpy.data.scenes[0]
ob = context.object ob = context.object
scene = context.scene scene = context.scene
row = layout.row() row = layout.row()
col = row.column() 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() row = layout.row()
col = row.column(align=True) 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() row = layout.row()
col = row.column() col = row.column()
col.label(text="Export Groups:") col.label(text="Export Groups:")
row = layout.row() row = layout.row()
col = row.column() 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 = row.column(align=True)
col.operator("scene.godot_add_export_group",text="",icon="ZOOMIN") col.operator("scene.godot_add_export_group",text="",icon="ZOOMIN")
col.operator("scene.godot_delete_export_group",text="",icon="ZOOMOUT") col.operator("scene.godot_delete_export_group",text="",icon="ZOOMOUT")
col.operator("scene.godot_export_all_groups",text="",icon="EXPORT") col.operator("scene.godot_export_all_groups",text="",icon="EXPORT")
if len(scene.godot_export_groups) > 0: if len(scene.godot_export_groups) > 0:
row = layout.row() row = layout.row()
col = row.column() col = row.column()
group = scene.godot_export_groups[scene.godot_export_groups_index] group = scene.godot_export_groups[scene.godot_export_groups_index]
col.prop(group,"name",text="Group Name") col.prop(group,"name",text="Group Name")
col.prop(group,"export_name",text="Export Name") col.prop(group,"export_name",text="Export Name")
col.prop(group,"export_path",text="Export Filepath") col.prop(group,"export_path",text="Export Filepath")
row = layout.row() row = layout.row()
col = row.column() col = row.column()
row = layout.row() row = layout.row()
col = row.column() col = row.column()
col.label(text="Export Settings:") col.label(text="Export Settings:")
col = col.row(align=True) col = col.row(align=True)
col.prop(group,"apply_loc",toggle=True,icon="MAN_TRANS") col.prop(group,"apply_loc",toggle=True,icon="MAN_TRANS")
col.prop(group,"apply_rot",toggle=True,icon="MAN_ROT") col.prop(group,"apply_rot",toggle=True,icon="MAN_ROT")
col.prop(group,"apply_scale",toggle=True,icon="MAN_SCALE") col.prop(group,"apply_scale",toggle=True,icon="MAN_SCALE")
row = layout.row() row = layout.row()
col = row.column() col = row.column()
col.prop(group,"use_include_particle_duplicates") col.prop(group,"use_include_particle_duplicates")
col.prop(group,"use_mesh_modifiers") col.prop(group,"use_mesh_modifiers")
col.prop(group,"use_tangent_arrays") col.prop(group,"use_tangent_arrays")
@@ -120,25 +120,25 @@ class UI_List_Godot(bpy.types.UIList):
ob = data ob = data
slot = item slot = item
col = layout.row(align=True) col = layout.row(align=True)
col.label(text=item.name,icon="GROUP") col.label(text=item.name,icon="GROUP")
col.prop(item,"active",text="") 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.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 op.idx = index
class add_objects_to_group(bpy.types.Operator): class add_objects_to_group(bpy.types.Operator):
bl_idname = "scene.godot_add_objects_to_group" bl_idname = "scene.godot_add_objects_to_group"
bl_label = "Add Objects to Group" bl_label = "Add Objects to Group"
bl_description = "Adds the selected Objects to the active group below." bl_description = "Adds the selected Objects to the active group below."
undo = BoolProperty(default=True) undo = BoolProperty(default=True)
def execute(self,context): def execute(self,context):
scene = context.scene scene = context.scene
objects_str = "" objects_str = ""
if len(scene.godot_export_groups) > 0: if len(scene.godot_export_groups) > 0:
for i,object in enumerate(context.selected_objects): for i,object in enumerate(context.selected_objects):
@@ -148,57 +148,57 @@ class add_objects_to_group(bpy.types.Operator):
if i == 0: if i == 0:
objects_str += object.name objects_str += object.name
else: else:
objects_str += ", "+object.name objects_str += ", "+object.name
self.report({'INFO'}, objects_str + " added to group." ) self.report({'INFO'}, objects_str + " added to group." )
if self.undo: if self.undo:
bpy.ops.ed.undo_push(message="Objects added to group") bpy.ops.ed.undo_push(message="Objects added to group")
else: else:
self.report({'WARNING'}, "Create a group first." ) self.report({'WARNING'}, "Create a group first." )
return{'FINISHED'} return{'FINISHED'}
class del_objects_from_group(bpy.types.Operator): class del_objects_from_group(bpy.types.Operator):
bl_idname = "scene.godot_delete_objects_from_group" bl_idname = "scene.godot_delete_objects_from_group"
bl_label = "Delete Objects from Group" bl_label = "Delete Objects from Group"
bl_description = "Delets the selected Objects from the active group below." bl_description = "Delets the selected Objects from the active group below."
def execute(self,context): def execute(self,context):
scene = context.scene scene = context.scene
if len(scene.godot_export_groups) > 0: if len(scene.godot_export_groups) > 0:
selected_objects = [] selected_objects = []
for object in context.selected_objects: for object in context.selected_objects:
selected_objects.append(object.name) selected_objects.append(object.name)
objects_str = "" objects_str = ""
j = 0 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: if node.name in selected_objects:
scene.godot_export_groups[scene.godot_export_groups_index].nodes.remove(i) scene.godot_export_groups[scene.godot_export_groups_index].nodes.remove(i)
if j == 0: if j == 0:
objects_str += object.name objects_str += object.name
else: else:
objects_str += ", "+object.name objects_str += ", "+object.name
j+=1 j+=1
self.report({'INFO'}, objects_str + " deleted from group." ) self.report({'INFO'}, objects_str + " deleted from group." )
bpy.ops.ed.undo_push(message="Objects deleted from group") bpy.ops.ed.undo_push(message="Objects deleted from group")
else: else:
self.report({'WARNING'}, "There is no group to delete from." ) self.report({'WARNING'}, "There is no group to delete from." )
return{'FINISHED'} return{'FINISHED'}
class select_group_objects(bpy.types.Operator): class select_group_objects(bpy.types.Operator):
bl_idname = "scene.godot_select_group_objects" bl_idname = "scene.godot_select_group_objects"
bl_label = "Select Group Objects" bl_label = "Select Group Objects"
bl_description = "Will select all group Objects in the scene." bl_description = "Will select all group Objects in the scene."
idx = IntProperty() idx = IntProperty()
def execute(self,context): def execute(self,context):
scene = context.scene scene = context.scene
for object in context.scene.objects: for object in context.scene.objects:
@@ -208,12 +208,12 @@ class select_group_objects(bpy.types.Operator):
bpy.data.objects[node.name].select = True bpy.data.objects[node.name].select = True
context.scene.objects.active = bpy.data.objects[node.name] context.scene.objects.active = bpy.data.objects[node.name]
return{'FINISHED'} return{'FINISHED'}
class export_groups_autosave(bpy.types.Operator): class export_groups_autosave(bpy.types.Operator):
bl_idname = "scene.godot_export_groups_autosave" bl_idname = "scene.godot_export_groups_autosave"
bl_label = "Export All Groups" bl_label = "Export All Groups"
bl_description = "Exports all groups to Collada." bl_description = "Exports all groups to Collada."
def execute(self,context): def execute(self,context):
scene = context.scene scene = context.scene
if scene.godot_export_on_save: if scene.godot_export_on_save:
@@ -221,57 +221,57 @@ class export_groups_autosave(bpy.types.Operator):
if scene.godot_export_groups[i].active: if scene.godot_export_groups[i].active:
bpy.ops.scene.godot_export_group(idx=i) bpy.ops.scene.godot_export_group(idx=i)
self.report({'INFO'}, "All Groups exported." ) self.report({'INFO'}, "All Groups exported." )
bpy.ops.ed.undo_push(message="Export all Groups") bpy.ops.ed.undo_push(message="Export all Groups")
return{'FINISHED'} return{'FINISHED'}
class export_all_groups(bpy.types.Operator): class export_all_groups(bpy.types.Operator):
bl_idname = "scene.godot_export_all_groups" bl_idname = "scene.godot_export_all_groups"
bl_label = "Export All Groups" bl_label = "Export All Groups"
bl_description = "Exports all groups to Collada." bl_description = "Exports all groups to Collada."
def execute(self,context): def execute(self,context):
scene = context.scene scene = context.scene
for i in range(0,len(scene.godot_export_groups)): for i in range(0,len(scene.godot_export_groups)):
bpy.ops.scene.godot_export_group(idx=i,export_all=True) bpy.ops.scene.godot_export_group(idx=i,export_all=True)
self.report({'INFO'}, "All Groups exported." ) self.report({'INFO'}, "All Groups exported." )
return{'FINISHED'} return{'FINISHED'}
class export_group(bpy.types.Operator): class export_group(bpy.types.Operator):
bl_idname = "scene.godot_export_group" bl_idname = "scene.godot_export_group"
bl_label = "Export Group" bl_label = "Export Group"
bl_description = "Exports the active group to destination folder as Collada file." bl_description = "Exports the active group to destination folder as Collada file."
idx = IntProperty(default=0) idx = IntProperty(default=0)
export_all = BoolProperty(default=False) 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() new_ob = bpy.data.objects[ob.name].copy()
if single_user or ob.type=="ARMATURE": if single_user or ob.type=="ARMATURE":
new_mesh_data = new_ob.data.copy() new_mesh_data = new_ob.data.copy()
new_ob.data = new_mesh_data new_ob.data = new_mesh_data
bpy.context.scene.objects.link(new_ob) bpy.context.scene.objects.link(new_ob)
if ob != parent: if ob != parent:
new_ob.parent = parent new_ob.parent = parent
else: else:
new_ob.parent = None new_ob.parent = None
for child in ob.children: 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 new_ob.select = True
return new_ob return new_ob
def delete_object(self,ob): def delete_object(self,ob):
if ob != None: if ob != None:
for child in ob.children: for child in ob.children:
self.delete_object(child) self.delete_object(child)
bpy.context.scene.objects.unlink(ob) bpy.context.scene.objects.unlink(ob)
bpy.data.objects.remove(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: if group.dupli_group != None:
for object in group.dupli_group.objects: for object in group.dupli_group.objects:
@@ -281,48 +281,48 @@ class export_group(bpy.types.Operator):
object.matrix_local = Matrix() object.matrix_local = Matrix()
object.matrix_local *= group.matrix_local object.matrix_local *= group.matrix_local
object.matrix_local *= matrix object.matrix_local *= matrix
self.delete_object(group) self.delete_object(group)
def execute(self,context): def execute(self,context):
scene = context.scene scene = context.scene
group = context.scene.godot_export_groups group = context.scene.godot_export_groups
if not group[self.idx].active and self.export_all: if not group[self.idx].active and self.export_all:
return{'FINISHED'} 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: if object.name in bpy.data.objects:
pass pass
else: else:
group[self.idx].nodes.remove(i) group[self.idx].nodes.remove(i)
bpy.ops.ed.undo_push(message="Clear not existent Group Nodes.") bpy.ops.ed.undo_push(message="Clear not existent Group Nodes.")
path = group[self.idx].export_path path = group[self.idx].export_path
if (path.find("//")==0 or path.find("\\\\")==0): if (path.find("//")==0 or path.find("\\\\")==0):
#if relative, convert to absolute #if relative, convert to absolute
path = bpy.path.abspath(path) 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 path exists and group export name is set the group will be exported
if os.path.exists(path) and group[self.idx].export_name != "": 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"): 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: 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 = [] hide_select = []
for object in context.scene.objects: for object in context.scene.objects:
hide_select.append(object.hide_select) hide_select.append(object.hide_select)
object.hide_select = False object.hide_select = False
object.select = False object.select = False
context.scene.objects.active = None context.scene.objects.active = None
### make particle duplicates, parent and select them ### make particle duplicates, parent and select them
nodes_to_be_added = [] nodes_to_be_added = []
if group[self.idx].use_include_particle_duplicates: if group[self.idx].use_include_particle_duplicates:
@@ -341,79 +341,79 @@ class export_group(bpy.types.Operator):
context.scene.objects.active = None context.scene.objects.active = None
for object in nodes_to_be_added: for object in nodes_to_be_added:
object.select = True object.select = True
### select all other nodes from the group ### 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": if bpy.data.objects[object.name].type == "EMPTY":
self.convert_group_to_node(bpy.data.objects[object.name]) self.convert_group_to_node(bpy.data.objects[object.name])
else: else:
bpy.data.objects[object.name].select = True bpy.data.objects[object.name].select = True
bpy.ops.object.transform_apply(location=group[self.idx].apply_loc, rotation=group[self.idx].apply_rot, scale=group[self.idx].apply_scale) bpy.ops.object.transform_apply(location=group[self.idx].apply_loc, rotation=group[self.idx].apply_rot, scale=group[self.idx].apply_scale)
bpy.ops.export_scene.dae(check_existing=True, filepath=path, filter_glob="*.dae", object_types=group[self.idx].object_types, use_export_selected=group[self.idx].use_export_selected, use_mesh_modifiers=group[self.idx].use_mesh_modifiers, use_tangent_arrays=group[self.idx].use_tangent_arrays, use_triangles=group[self.idx].use_triangles, use_copy_images=group[self.idx].use_copy_images, use_active_layers=group[self.idx].use_active_layers, use_anim=group[self.idx].use_anim, use_anim_action_all=group[self.idx].use_anim_action_all, use_anim_skip_noexp=group[self.idx].use_anim_skip_noexp, use_anim_optimize=group[self.idx].use_anim_optimize, anim_optimize_precision=group[self.idx].anim_optimize_precision, use_metadata=group[self.idx].use_metadata) bpy.ops.export_scene.dae(check_existing=True, filepath=path, filter_glob="*.dae", object_types=group[self.idx].object_types, use_export_selected=group[self.idx].use_export_selected, use_mesh_modifiers=group[self.idx].use_mesh_modifiers, use_tangent_arrays=group[self.idx].use_tangent_arrays, use_triangles=group[self.idx].use_triangles, use_copy_images=group[self.idx].use_copy_images, use_active_layers=group[self.idx].use_active_layers, use_anim=group[self.idx].use_anim, use_anim_action_all=group[self.idx].use_anim_action_all, use_anim_skip_noexp=group[self.idx].use_anim_skip_noexp, use_anim_optimize=group[self.idx].use_anim_optimize, anim_optimize_precision=group[self.idx].anim_optimize_precision, use_metadata=group[self.idx].use_metadata)
self.report({'INFO'}, '"'+group[self.idx].name+'"' + " Group exported." ) self.report({'INFO'}, '"'+group[self.idx].name+'"' + " Group exported." )
msg = "Export Group "+group[self.idx].name msg = "Export Group "+group[self.idx].name
bpy.ops.ed.undo_push(message="") bpy.ops.ed.undo_push(message="")
bpy.ops.ed.undo() bpy.ops.ed.undo()
bpy.ops.ed.undo_push(message=msg) bpy.ops.ed.undo_push(message=msg)
else: else:
self.report({'INFO'}, "Define Export Name and Export Path." ) self.report({'INFO'}, "Define Export Name and Export Path." )
return{'FINISHED'} return{'FINISHED'}
class add_export_group(bpy.types.Operator): class add_export_group(bpy.types.Operator):
bl_idname = "scene.godot_add_export_group" bl_idname = "scene.godot_add_export_group"
bl_label = "Adds a new export Group" bl_label = "Adds a new export Group"
bl_description = "Creates a new Export Group with the selected Objects assigned to it." 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 scene = context.scene
item = scene.godot_export_groups.add() item = scene.godot_export_groups.add()
item.name = "New Group" item.name = "New Group"
for object in context.selected_objects: for object in context.selected_objects:
node = item.nodes.add() node = item.nodes.add()
node.name = object.name node.name = object.name
scene.godot_export_groups_index = len(scene.godot_export_groups)-1 scene.godot_export_groups_index = len(scene.godot_export_groups)-1
bpy.ops.ed.undo_push(message="Create New Export Group") bpy.ops.ed.undo_push(message="Create New Export Group")
return{'FINISHED'} return{'FINISHED'}
class del_export_group(bpy.types.Operator): class del_export_group(bpy.types.Operator):
bl_idname = "scene.godot_delete_export_group" bl_idname = "scene.godot_delete_export_group"
bl_label = "Delets the selected export Group" bl_label = "Delets the selected export Group"
bl_description = "Delets the active Export Group." bl_description = "Delets the active Export Group."
def invoke(self, context, event): def invoke(self, context, event):
wm = context.window_manager 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 = context.scene
scene.godot_export_groups.remove(scene.godot_export_groups_index) scene.godot_export_groups.remove(scene.godot_export_groups_index)
if scene.godot_export_groups_index > 0: if scene.godot_export_groups_index > 0:
scene.godot_export_groups_index -= 1 scene.godot_export_groups_index -= 1
bpy.ops.ed.undo_push(message="Delete Export Group") bpy.ops.ed.undo_push(message="Delete Export Group")
return{'FINISHED'} return{'FINISHED'}
class godot_node_list(bpy.types.PropertyGroup): class godot_node_list(bpy.types.PropertyGroup):
name = StringProperty() name = StringProperty()
class godot_export_groups(bpy.types.PropertyGroup): class godot_export_groups(bpy.types.PropertyGroup):
name = StringProperty(name="Group Name") name = StringProperty(name="Group Name")
export_name = StringProperty(name="scene_name") export_name = StringProperty(name="scene_name")
nodes = CollectionProperty(type=godot_node_list) nodes = CollectionProperty(type=godot_node_list)
export_path = StringProperty(subtype="DIR_PATH") 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_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_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_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_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_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_tangent_arrays = BoolProperty(name="Tangent Arrays",description="Export Tangent and Binormal arrays (for normalmapping).",default=False)
@@ -431,7 +431,7 @@ class godot_export_groups(bpy.types.PropertyGroup):
use_metadata = BoolProperty(name="Use Metadata",default=True,options={'HIDDEN'}) use_metadata = BoolProperty(name="Use Metadata",default=True,options={'HIDDEN'})
use_include_particle_duplicates = BoolProperty(name="Include Particle Duplicates",default=True) use_include_particle_duplicates = BoolProperty(name="Include Particle Duplicates",default=True)
def register(): def register():
bpy.utils.register_class(godot_export_manager) bpy.utils.register_class(godot_export_manager)
bpy.utils.register_class(godot_node_list) bpy.utils.register_class(godot_node_list)
bpy.utils.register_class(godot_export_groups) bpy.utils.register_class(godot_export_groups)
@@ -465,7 +465,7 @@ def unregister():
@persistent @persistent
def auto_export(dummy): def auto_export(dummy):
bpy.ops.scene.godot_export_groups_autosave() bpy.ops.scene.godot_export_groups_autosave()
bpy.app.handlers.save_post.append(auto_export) bpy.app.handlers.save_post.append(auto_export)
if __name__ == "__main__": if __name__ == "__main__":

View File

@@ -59,7 +59,7 @@ class ExportDAE(bpy.types.Operator, ExportHelper):
# List of operator properties, the attributes will be assigned # List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling. # to the class instance from the operator settings before calling.
object_types = EnumProperty( object_types = EnumProperty(
name="Object Types", name="Object Types",
options={'ENUM_FLAG'}, options={'ENUM_FLAG'},

View File

@@ -171,38 +171,38 @@ class DaeExporter:
def export_image(self,image): def export_image(self,image):
if (image in self.image_cache): if (image in self.image_cache):
return self.image_cache[image] return self.image_cache[image]
imgpath = image.filepath imgpath = image.filepath
if (imgpath.find("//")==0 or imgpath.find("\\\\")==0): if (imgpath.find("//")==0 or imgpath.find("\\\\")==0):
#if relative, convert to absolute #if relative, convert to absolute
imgpath = bpy.path.abspath(imgpath) imgpath = bpy.path.abspath(imgpath)
#path is absolute, now do something! #path is absolute, now do something!
if (self.config["use_copy_images"]): if (self.config["use_copy_images"]):
#copy image #copy image
basedir = os.path.dirname(self.path)+"/images" basedir = os.path.dirname(self.path)+"/images"
if (not os.path.isdir(basedir)): if (not os.path.isdir(basedir)):
os.makedirs(basedir) os.makedirs(basedir)
if os.path.isfile(imgpath): if os.path.isfile(imgpath):
dstfile=basedir+"/"+os.path.basename(imgpath) dstfile=basedir+"/"+os.path.basename(imgpath)
if (not os.path.isfile(dstfile)): if (not os.path.isfile(dstfile)):
shutil.copy(imgpath,dstfile) shutil.copy(imgpath,dstfile)
imgpath="images/"+os.path.basename(imgpath) imgpath="images/"+os.path.basename(imgpath)
else: else:
### if file is not found save it as png file in the destination folder ### if file is not found save it as png file in the destination folder
img_tmp_path = image.filepath 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) image.filepath = basedir+"/"+os.path.basename(img_tmp_path)
else: else:
image.filepath = basedir+"/"+image.name+".png" image.filepath = basedir+"/"+image.name+".png"
dstfile=basedir+"/"+os.path.basename(image.filepath) dstfile=basedir+"/"+os.path.basename(image.filepath)
if (not os.path.isfile(dstfile)): if (not os.path.isfile(dstfile)):
image.save() image.save()
imgpath="images/"+os.path.basename(image.filepath) imgpath="images/"+os.path.basename(image.filepath)
image.filepath = img_tmp_path image.filepath = img_tmp_path
@@ -211,15 +211,15 @@ class DaeExporter:
#export relative, always, no one wants absolute paths. #export relative, always, no one wants absolute paths.
try: 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: except:
pass #fails sometimes, not sure why pass #fails sometimes, not sure why
imgid = self.new_id("image") imgid = self.new_id("image")
print("FOR: "+imgpath) print("FOR: "+imgpath)
# if (not os.path.isfile(imgpath)): # if (not os.path.isfile(imgpath)):
# print("NOT FILE?") # 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")):
@@ -956,7 +956,7 @@ class DaeExporter:
self.writel(S_NODES,il,'<instance_controller url="#'+meshdata["morph_id"]+'">') self.writel(S_NODES,il,'<instance_controller url="#'+meshdata["morph_id"]+'">')
close_controller=True close_controller=True
elif (armature==None): elif (armature==None):
self.writel(S_NODES,il,'<instance_geometry url="#'+meshdata["id"]+'">') self.writel(S_NODES,il,'<instance_geometry url="#'+meshdata["id"]+'">')
if (len(meshdata["material_assign"])>0): if (len(meshdata["material_assign"])>0):
@@ -1520,7 +1520,7 @@ class DaeExporter:
tmp_bone_mat.append(Matrix(bone.matrix_basis)) tmp_bone_mat.append(Matrix(bone.matrix_basis))
bone.matrix_basis = Matrix() 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,'<library_animations>') self.writel(S_ANIM,0,'<library_animations>')
@@ -1561,11 +1561,11 @@ class DaeExporter:
if (not y in allowed_skeletons): if (not y in allowed_skeletons):
allowed_skeletons.append(y) allowed_skeletons.append(y)
y.animation_data.action=x; y.animation_data.action=x;
y.matrix_local = tmp_mat[i][0] 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() bone.matrix_basis = Matrix()
#print("allowed skeletons "+str(allowed_skeletons)) #print("allowed skeletons "+str(allowed_skeletons))
@@ -1600,9 +1600,9 @@ class DaeExporter:
else: 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,'</library_animations>') self.writel(S_ANIM,0,'</library_animations>')
def export(self): def export(self):
@@ -1684,7 +1684,7 @@ class DaeExporter:
self.valid_nodes=[] self.valid_nodes=[]
self.armature_for_morph={} self.armature_for_morph={}
self.used_bones=[] self.used_bones=[]
self.wrongvtx_report=False self.wrongvtx_report=False