Flake8 compliance (except for unused variables)
This commit is contained in:
parent
52fdc65a5d
commit
c973f3a1da
3 changed files with 1086 additions and 693 deletions
|
@ -18,24 +18,27 @@
|
||||||
|
|
||||||
# Script copyright (c) Andreas Esau
|
# Script copyright (c) Andreas Esau
|
||||||
|
|
||||||
|
import bpy
|
||||||
|
from bpy.props import (StringProperty, BoolProperty, EnumProperty,
|
||||||
|
FloatProperty, IntProperty, CollectionProperty)
|
||||||
|
import os
|
||||||
|
from bpy.app.handlers import persistent
|
||||||
|
from mathutils import Matrix
|
||||||
|
|
||||||
bl_info = {
|
bl_info = {
|
||||||
"name": "Godot Export Manager",
|
"name": "Godot Export Manager",
|
||||||
"author": "Andreas Esau",
|
"author": "Andreas Esau",
|
||||||
"version": (1, 0),
|
"version": (1, 0),
|
||||||
"blender": (2, 7, 0),
|
"blender": (2, 7, 0),
|
||||||
"location": "Scene Properties > Godot Export Manager",
|
"location": "Scene Properties > Godot Export Manager",
|
||||||
"description": "Godot Export Manager uses the Better Collada Exporter to manage Export Groups and automatically export the objects groups to Collada Files.",
|
"description": "Godot Export Manager uses the Better Collada Exporter"
|
||||||
|
"to manage Export Groups and automatically export the objects groups"
|
||||||
|
"to Collada Files.",
|
||||||
"warning": "",
|
"warning": "",
|
||||||
"wiki_url": ("http://www.godotengine.org"),
|
"wiki_url": ("http://www.godotengine.org"),
|
||||||
"tracker_url": "",
|
"tracker_url": "",
|
||||||
"category": "Import-Export"}
|
"category": "Import-Export"}
|
||||||
|
|
||||||
import bpy
|
|
||||||
from bpy.props import StringProperty, BoolProperty, EnumProperty, FloatProperty, FloatVectorProperty, IntProperty, CollectionProperty, PointerProperty
|
|
||||||
import os
|
|
||||||
from bpy.app.handlers import persistent
|
|
||||||
from mathutils import Vector, Matrix
|
|
||||||
|
|
||||||
|
|
||||||
class godot_export_manager(bpy.types.Panel):
|
class godot_export_manager(bpy.types.Panel):
|
||||||
bl_label = "Godot Export Manager"
|
bl_label = "Godot Export Manager"
|
||||||
|
@ -45,8 +48,8 @@ class godot_export_manager(bpy.types.Panel):
|
||||||
|
|
||||||
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
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
|
""" Draw function for all ui elements """
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
split = self.layout.split()
|
split = self.layout.split()
|
||||||
scene = bpy.data.scenes[0]
|
scene = bpy.data.scenes[0]
|
||||||
|
@ -59,9 +62,13 @@ class godot_export_manager(bpy.types.Panel):
|
||||||
|
|
||||||
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()
|
||||||
|
@ -70,11 +77,15 @@ class godot_export_manager(bpy.types.Panel):
|
||||||
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:
|
||||||
|
@ -113,9 +124,10 @@ class godot_export_manager(bpy.types.Panel):
|
||||||
col.prop(group, "use_metadata")
|
col.prop(group, "use_metadata")
|
||||||
|
|
||||||
|
|
||||||
### Custom template_list look
|
|
||||||
class UI_List_Godot(bpy.types.UIList):
|
class UI_List_Godot(bpy.types.UIList):
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
|
""" Custom template_list look """
|
||||||
|
def draw_item(self, context, layout, data, item, icon, active_data,
|
||||||
|
active_propname, index):
|
||||||
ob = data
|
ob = data
|
||||||
slot = item
|
slot = item
|
||||||
col = layout.row(align=True)
|
col = layout.row(align=True)
|
||||||
|
@ -123,11 +135,14 @@ class UI_List_Godot(bpy.types.UIList):
|
||||||
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"
|
||||||
|
@ -141,20 +156,24 @@ class add_objects_to_group(bpy.types.Operator):
|
||||||
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):
|
||||||
if object.name not in scene.godot_export_groups[scene.godot_export_groups_index].nodes:
|
if object.name not in scene.godot_export_groups[
|
||||||
node = scene.godot_export_groups[scene.godot_export_groups_index].nodes.add()
|
scene.godot_export_groups_index].nodes:
|
||||||
|
node = scene.godot_export_groups[
|
||||||
|
scene.godot_export_groups_index].nodes.add()
|
||||||
node.name = object.name
|
node.name = object.name
|
||||||
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"
|
||||||
|
@ -172,21 +191,25 @@ class del_objects_from_group(bpy.types.Operator):
|
||||||
|
|
||||||
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"
|
||||||
|
@ -203,7 +226,8 @@ class select_group_objects(bpy.types.Operator):
|
||||||
if node.name in bpy.data.objects:
|
if node.name in bpy.data.objects:
|
||||||
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):
|
||||||
|
@ -217,9 +241,10 @@ class export_groups_autosave(bpy.types.Operator):
|
||||||
for i in range(len(scene.godot_export_groups)):
|
for i in range(len(scene.godot_export_groups)):
|
||||||
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):
|
||||||
|
@ -233,46 +258,49 @@ class export_all_groups(bpy.types.Operator):
|
||||||
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 is not 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 is not None:
|
||||||
for object in group.dupli_group.objects:
|
for object in group.dupli_group.objects:
|
||||||
if object.parent == None:
|
if object.parent is None:
|
||||||
object = self.copy_object_recursive(object, object, True)
|
object = self.copy_object_recursive(object, object, True)
|
||||||
matrix = Matrix(object.matrix_local)
|
matrix = Matrix(object.matrix_local)
|
||||||
object.matrix_local = Matrix()
|
object.matrix_local = Matrix()
|
||||||
|
@ -297,15 +325,16 @@ class export_group(bpy.types.Operator):
|
||||||
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
|
||||||
if os.path.exists(path) and group[self.idx].export_name != "":
|
# 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] * 20
|
||||||
|
|
||||||
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)
|
||||||
|
@ -319,17 +348,19 @@ class export_group(bpy.types.Operator):
|
||||||
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:
|
||||||
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":
|
||||||
context.scene.objects.active = bpy.data.objects[object.name]
|
context.scene.objects.active = bpy.data.objects[
|
||||||
|
object.name]
|
||||||
bpy.data.objects[object.name].select = True
|
bpy.data.objects[object.name].select = True
|
||||||
bpy.ops.object.duplicates_make_real()
|
bpy.ops.object.duplicates_make_real()
|
||||||
for object in context.selected_objects:
|
for object in context.selected_objects:
|
||||||
nodes_to_be_added.append(object)
|
nodes_to_be_added.append(object)
|
||||||
bpy.ops.object.parent_set(type="OBJECT", keep_transform=False)
|
bpy.ops.object.parent_set(type="OBJECT",
|
||||||
|
keep_transform=False)
|
||||||
|
|
||||||
for object in context.selected_objects:
|
for object in context.selected_objects:
|
||||||
object.select = False
|
object.select = False
|
||||||
|
@ -338,17 +369,35 @@ class export_group(bpy.types.Operator):
|
||||||
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,
|
||||||
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)
|
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)
|
||||||
|
|
||||||
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="")
|
||||||
|
@ -356,14 +405,16 @@ class export_group(bpy.types.Operator):
|
||||||
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
|
||||||
|
@ -375,6 +426,7 @@ class add_export_group(bpy.types.Operator):
|
||||||
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'}
|
||||||
|
|
||||||
|
|
||||||
|
@ -385,6 +437,7 @@ class del_export_group(bpy.types.Operator):
|
||||||
|
|
||||||
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):
|
||||||
|
@ -394,7 +447,8 @@ class del_export_group(bpy.types.Operator):
|
||||||
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):
|
||||||
|
@ -408,28 +462,74 @@ class godot_export_groups(bpy.types.PropertyGroup):
|
||||||
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",
|
||||||
apply_rot = BoolProperty(name="Apply Rotation", description="Apply Rotation before export.", default=False)
|
description="Apply Scale before export.",
|
||||||
apply_loc = BoolProperty(name="Apply Location", description="Apply Location before export.", default=False)
|
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_export_selected = BoolProperty(name="Selected Objects",
|
||||||
use_mesh_modifiers = BoolProperty(name="Apply Modifiers", description="Apply modifiers to mesh objects (on a copy!).", default=True)
|
description="Export only selected"
|
||||||
use_tangent_arrays = BoolProperty(name="Tangent Arrays", description="Export Tangent and Binormal arrays (for normalmapping).", default=False)
|
"objects (and visible in active layers "
|
||||||
use_triangles = BoolProperty(name="Triangulate", description="Export Triangles instead of Polygons.", default=False)
|
"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_copy_images = BoolProperty(name="Copy Images",
|
||||||
use_active_layers = BoolProperty(name="Active Layers", description="Export only objects on the active layers.", default=True)
|
description="Copy Images (create images/ "
|
||||||
use_anim = BoolProperty(name="Export Animation", description="Export keyframe animation", default=False)
|
"subfolder)", 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_active_layers = BoolProperty(name="Active Layers",
|
||||||
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)
|
description="Export only objects on the"
|
||||||
use_anim_optimize = BoolProperty(name="Optimize Keyframes", description="Remove double keyframes", default=True)
|
" 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_metadata = BoolProperty(name="Use Metadata", default=True,
|
||||||
use_include_particle_duplicates = BoolProperty(name="Include Particle Duplicates", default=True)
|
options={'HIDDEN'})
|
||||||
|
use_include_particle_duplicates = BoolProperty(
|
||||||
|
name="Include Particle Duplicates", default=True)
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
|
@ -446,7 +546,8 @@ def register():
|
||||||
bpy.utils.register_class(select_group_objects)
|
bpy.utils.register_class(select_group_objects)
|
||||||
bpy.utils.register_class(UI_List_Godot)
|
bpy.utils.register_class(UI_List_Godot)
|
||||||
|
|
||||||
bpy.types.Scene.godot_export_groups = CollectionProperty(type=godot_export_groups)
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,35 +18,30 @@
|
||||||
|
|
||||||
# <pep8-80 compliant>
|
# <pep8-80 compliant>
|
||||||
|
|
||||||
|
import bpy
|
||||||
|
from bpy.props import StringProperty, BoolProperty, FloatProperty, EnumProperty
|
||||||
|
|
||||||
|
from bpy_extras.io_utils import ExportHelper
|
||||||
bl_info = {
|
bl_info = {
|
||||||
"name": "Better Collada Exporter",
|
"name": "Better Collada Exporter",
|
||||||
"author": "Juan Linietsky",
|
"author": "Juan Linietsky",
|
||||||
"blender": (2, 5, 8),
|
"blender": (2, 5, 8),
|
||||||
"api": 38691,
|
"api": 38691,
|
||||||
"location": "File > Import-Export",
|
"location": "File > Import-Export",
|
||||||
"description": ("Export DAE Scenes, This plugin actually works better! otherwise contact me."),
|
"description": ("Export DAE Scenes, This plugin actually works better! "
|
||||||
|
"otherwise contact me."),
|
||||||
"warning": "",
|
"warning": "",
|
||||||
"wiki_url": ("http://www.godotengine.org"),
|
"wiki_url": ("http://www.godotengine.org"),
|
||||||
"tracker_url": "",
|
"tracker_url": "",
|
||||||
"support": 'OFFICIAL',
|
"support": 'OFFICIAL',
|
||||||
"category": "Import-Export"}
|
"category": "Import-Export"}
|
||||||
|
|
||||||
|
|
||||||
if "bpy" in locals():
|
if "bpy" in locals():
|
||||||
import imp
|
import imp
|
||||||
if "export_dae" in locals():
|
if "export_dae" in locals():
|
||||||
imp.reload(export_dae)
|
imp.reload(export_dae)
|
||||||
|
|
||||||
|
|
||||||
import bpy
|
|
||||||
from bpy.props import StringProperty, BoolProperty, FloatProperty, EnumProperty
|
|
||||||
|
|
||||||
from bpy_extras.io_utils import (ExportHelper,
|
|
||||||
path_reference_mode,
|
|
||||||
axis_conversion,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ExportDAE(bpy.types.Operator, ExportHelper):
|
class ExportDAE(bpy.types.Operator, ExportHelper):
|
||||||
'''Selection to DAE'''
|
'''Selection to DAE'''
|
||||||
bl_idname = "export_scene.dae"
|
bl_idname = "export_scene.dae"
|
||||||
|
@ -74,7 +69,8 @@ class ExportDAE(bpy.types.Operator, ExportHelper):
|
||||||
|
|
||||||
use_export_selected = BoolProperty(
|
use_export_selected = BoolProperty(
|
||||||
name="Selected Objects",
|
name="Selected Objects",
|
||||||
description="Export only selected objects (and visible in active layers if that applies).",
|
description="Export only selected objects (and visible in active "
|
||||||
|
"layers if that applies).",
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
use_mesh_modifiers = BoolProperty(
|
use_mesh_modifiers = BoolProperty(
|
||||||
|
@ -84,7 +80,8 @@ class ExportDAE(bpy.types.Operator, ExportHelper):
|
||||||
)
|
)
|
||||||
use_tangent_arrays = BoolProperty(
|
use_tangent_arrays = BoolProperty(
|
||||||
name="Tangent Arrays",
|
name="Tangent Arrays",
|
||||||
description="Export Tangent and Binormal arrays (for normalmapping).",
|
description="Export Tangent and Binormal arrays "
|
||||||
|
"(for normalmapping).",
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
use_triangles = BoolProperty(
|
use_triangles = BoolProperty(
|
||||||
|
@ -92,6 +89,7 @@ class ExportDAE(bpy.types.Operator, ExportHelper):
|
||||||
description="Export Triangles instead of Polygons.",
|
description="Export Triangles instead of Polygons.",
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
use_copy_images = BoolProperty(
|
use_copy_images = BoolProperty(
|
||||||
name="Copy Images",
|
name="Copy Images",
|
||||||
description="Copy Images (create images/ subfolder)",
|
description="Copy Images (create images/ subfolder)",
|
||||||
|
@ -109,12 +107,14 @@ class ExportDAE(bpy.types.Operator, ExportHelper):
|
||||||
)
|
)
|
||||||
use_anim_action_all = BoolProperty(
|
use_anim_action_all = BoolProperty(
|
||||||
name="All Actions",
|
name="All Actions",
|
||||||
description=("Export all actions for the first armature found in separate DAE files"),
|
description=("Export all actions for the first armature found "
|
||||||
|
"in separate DAE files"),
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
use_anim_skip_noexp = BoolProperty(
|
use_anim_skip_noexp = BoolProperty(
|
||||||
name="Skip (-noexp) Actions",
|
name="Skip (-noexp) Actions",
|
||||||
description="Skip exporting of actions whose name end in (-noexp). Useful to skip control animations.",
|
description="Skip exporting of actions whose name end in (-noexp)."
|
||||||
|
" Useful to skip control animations.",
|
||||||
default=True,
|
default=True,
|
||||||
)
|
)
|
||||||
use_anim_optimize = BoolProperty(
|
use_anim_optimize = BoolProperty(
|
||||||
|
@ -140,7 +140,8 @@ class ExportDAE(bpy.types.Operator, ExportHelper):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def check_extension(self):
|
def check_extension(self):
|
||||||
return True # return self.batch_mode == 'OFF'
|
# return self.batch_mode == 'OFF'
|
||||||
|
return True
|
||||||
|
|
||||||
def check(self, context):
|
def check(self, context):
|
||||||
return True
|
return True
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue