__init__.py 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. # ##### BEGIN GPL LICENSE BLOCK #####
  2. #
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version 2
  6. # of the License, or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software Foundation,
  15. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. # ##### END GPL LICENSE BLOCK #####
  18. # <pep8-80 compliant>
  19. bl_info = {
  20. "name": "Khronos Collada format",
  21. "author": "Juan Linietsky",
  22. "blender": (2, 5, 8),
  23. "api": 38691,
  24. "location": "File > Import-Export",
  25. "description": ("Export DAE Scenes"),
  26. "warning": "",
  27. "wiki_url": ("None"),
  28. "tracker_url": "",
  29. "support": 'OFFICIAL',
  30. "category": "Import-Export"}
  31. if "bpy" in locals():
  32. import imp
  33. if "export_dae" in locals():
  34. imp.reload(export_dae)
  35. import bpy
  36. from bpy.props import StringProperty, BoolProperty, FloatProperty, EnumProperty
  37. from bpy_extras.io_utils import (ExportHelper,
  38. path_reference_mode,
  39. axis_conversion,
  40. )
  41. class ExportDAE(bpy.types.Operator, ExportHelper):
  42. '''Selection to DAE'''
  43. bl_idname = "export_scene.dae"
  44. bl_label = "Export DAE"
  45. bl_options = {'PRESET'}
  46. filename_ext = ".dae"
  47. filter_glob = StringProperty(default="*.dae", options={'HIDDEN'})
  48. # List of operator properties, the attributes will be assigned
  49. # to the class instance from the operator settings before calling.
  50. object_types = EnumProperty(
  51. name="Object Types",
  52. options={'ENUM_FLAG'},
  53. items=(('EMPTY', "Empty", ""),
  54. ('CAMERA', "Camera", ""),
  55. ('LAMP', "Lamp", ""),
  56. ('ARMATURE', "Armature", ""),
  57. ('MESH', "Mesh", ""),
  58. ('CURVE', "Curve", ""),
  59. ),
  60. default={'EMPTY', 'CAMERA', 'LAMP', 'ARMATURE', 'MESH','CURVE'},
  61. )
  62. use_export_selected = BoolProperty(
  63. name="Selected Objects",
  64. description="Export only selected objects (and visible in active layers if that applies).",
  65. default=False,
  66. )
  67. use_mesh_modifiers = BoolProperty(
  68. name="Apply Modifiers",
  69. description="Apply modifiers to mesh objects (on a copy!).",
  70. default=True,
  71. )
  72. use_copy_images = BoolProperty(
  73. name="Copy Images",
  74. description="Copy Images (create images/ subfolder)",
  75. default=False,
  76. )
  77. use_active_layers = BoolProperty(
  78. name="Active Layers",
  79. description="Export only objects on the active layers.",
  80. default=True,
  81. )
  82. use_exclude_ctrl_bones = BoolProperty(
  83. name="Exclude Control Bones",
  84. description="Exclude skeleton bones with names that begin with 'ctrl'.",
  85. default=True,
  86. )
  87. use_anim = BoolProperty(
  88. name="Export Animation",
  89. description="Export keyframe animation",
  90. default=False,
  91. )
  92. use_anim_action_all = BoolProperty(
  93. name="All Actions",
  94. description=("Export all actions for the first armature found in separate DAE files"),
  95. default=False,
  96. )
  97. use_anim_optimize = BoolProperty(
  98. name="Optimize Keyframes",
  99. description="Remove double keyframes",
  100. default=True,
  101. )
  102. anim_optimize_precision = FloatProperty(
  103. name="Precision",
  104. description=("Tolerence for comparing double keyframes "
  105. "(higher for greater accuracy)"),
  106. min=1, max=16,
  107. soft_min=1, soft_max=16,
  108. default=6.0,
  109. )
  110. use_metadata = BoolProperty(
  111. name="Use Metadata",
  112. default=True,
  113. options={'HIDDEN'},
  114. )
  115. @property
  116. def check_extension(self):
  117. return True#return self.batch_mode == 'OFF'
  118. def check(self, context):
  119. return True
  120. """
  121. isretur_def_change = super().check(context)
  122. return (is_xna_change or is_def_change)
  123. """
  124. def execute(self, context):
  125. if not self.filepath:
  126. raise Exception("filepath not set")
  127. """ global_matrix = Matrix()
  128. global_matrix[0][0] = \
  129. global_matrix[1][1] = \
  130. global_matrix[2][2] = self.global_scale
  131. """
  132. keywords = self.as_keywords(ignore=("axis_forward",
  133. "axis_up",
  134. "global_scale",
  135. "check_existing",
  136. "filter_glob",
  137. "xna_validate",
  138. ))
  139. from . import export_dae
  140. return export_dae.save(self, context, **keywords)
  141. def menu_func(self, context):
  142. self.layout.operator(ExportDAE.bl_idname, text="Khronos Collada (.dae)")
  143. def register():
  144. bpy.utils.register_module(__name__)
  145. bpy.types.INFO_MT_file_export.append(menu_func)
  146. def unregister():
  147. bpy.utils.unregister_module(__name__)
  148. bpy.types.INFO_MT_file_export.remove(menu_func)
  149. if __name__ == "__main__":
  150. register()