Sun position: Fix T80379 - Custom startup breaks the add-on
[blender-addons.git] / io_scene_fbx / __init__.py
blobe5fa3284bbb041069f70f3a14a76335f1ca85182
1 # ##### BEGIN GPL LICENSE BLOCK #####
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.
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.
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.
17 # ##### END GPL LICENSE BLOCK #####
19 # <pep8 compliant>
21 bl_info = {
22 "name": "FBX format",
23 "author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
24 "version": (4, 21, 3),
25 "blender": (2, 90, 0),
26 "location": "File > Import-Export",
27 "description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
28 "warning": "",
29 "doc_url": "{BLENDER_MANUAL_URL}/addons/import_export/scene_fbx.html",
30 "support": 'OFFICIAL',
31 "category": "Import-Export",
35 if "bpy" in locals():
36 import importlib
37 if "import_fbx" in locals():
38 importlib.reload(import_fbx)
39 if "export_fbx_bin" in locals():
40 importlib.reload(export_fbx_bin)
41 if "export_fbx" in locals():
42 importlib.reload(export_fbx)
45 import bpy
46 from bpy.props import (
47 StringProperty,
48 BoolProperty,
49 FloatProperty,
50 EnumProperty,
51 CollectionProperty,
53 from bpy_extras.io_utils import (
54 ImportHelper,
55 ExportHelper,
56 orientation_helper,
57 path_reference_mode,
58 axis_conversion,
62 @orientation_helper(axis_forward='-Z', axis_up='Y')
63 class ImportFBX(bpy.types.Operator, ImportHelper):
64 """Load a FBX file"""
65 bl_idname = "import_scene.fbx"
66 bl_label = "Import FBX"
67 bl_options = {'UNDO', 'PRESET'}
69 directory: StringProperty()
71 filename_ext = ".fbx"
72 filter_glob: StringProperty(default="*.fbx", options={'HIDDEN'})
74 files: CollectionProperty(
75 name="File Path",
76 type=bpy.types.OperatorFileListElement,
79 ui_tab: EnumProperty(
80 items=(('MAIN', "Main", "Main basic settings"),
81 ('ARMATURE', "Armatures", "Armature-related settings"),
83 name="ui_tab",
84 description="Import options categories",
87 use_manual_orientation: BoolProperty(
88 name="Manual Orientation",
89 description="Specify orientation and scale, instead of using embedded data in FBX file",
90 default=False,
92 global_scale: FloatProperty(
93 name="Scale",
94 min=0.001, max=1000.0,
95 default=1.0,
97 bake_space_transform: BoolProperty(
98 name="Apply Transform",
99 description="Bake space transform into object data, avoids getting unwanted rotations to objects when "
100 "target space is not aligned with Blender's space "
101 "(WARNING! experimental option, use at own risks, known broken with armatures/animations)",
102 default=False,
105 use_custom_normals: BoolProperty(
106 name="Custom Normals",
107 description="Import custom normals, if available (otherwise Blender will recompute them)",
108 default=True,
111 use_image_search: BoolProperty(
112 name="Image Search",
113 description="Search subdirs for any associated images (WARNING: may be slow)",
114 default=True,
117 use_alpha_decals: BoolProperty(
118 name="Alpha Decals",
119 description="Treat materials with alpha as decals (no shadow casting)",
120 default=False,
122 decal_offset: FloatProperty(
123 name="Decal Offset",
124 description="Displace geometry of alpha meshes",
125 min=0.0, max=1.0,
126 default=0.0,
129 use_anim: BoolProperty(
130 name="Import Animation",
131 description="Import FBX animation",
132 default=True,
134 anim_offset: FloatProperty(
135 name="Animation Offset",
136 description="Offset to apply to animation during import, in frames",
137 default=1.0,
140 use_subsurf: BoolProperty(
141 name="Subdivision Data",
142 description="Import FBX subdivision information as subdivision surface modifiers",
143 default=False,
146 use_custom_props: BoolProperty(
147 name="Custom Properties",
148 description="Import user properties as custom properties",
149 default=True,
151 use_custom_props_enum_as_string: BoolProperty(
152 name="Import Enums As Strings",
153 description="Store enumeration values as strings",
154 default=True,
157 ignore_leaf_bones: BoolProperty(
158 name="Ignore Leaf Bones",
159 description="Ignore the last bone at the end of each chain (used to mark the length of the previous bone)",
160 default=False,
162 force_connect_children: BoolProperty(
163 name="Force Connect Children",
164 description="Force connection of children bones to their parent, even if their computed head/tail "
165 "positions do not match (can be useful with pure-joints-type armatures)",
166 default=False,
168 automatic_bone_orientation: BoolProperty(
169 name="Automatic Bone Orientation",
170 description="Try to align the major bone axis with the bone children",
171 default=False,
173 primary_bone_axis: EnumProperty(
174 name="Primary Bone Axis",
175 items=(('X', "X Axis", ""),
176 ('Y', "Y Axis", ""),
177 ('Z', "Z Axis", ""),
178 ('-X', "-X Axis", ""),
179 ('-Y', "-Y Axis", ""),
180 ('-Z', "-Z Axis", ""),
182 default='Y',
184 secondary_bone_axis: EnumProperty(
185 name="Secondary Bone Axis",
186 items=(('X', "X Axis", ""),
187 ('Y', "Y Axis", ""),
188 ('Z', "Z Axis", ""),
189 ('-X', "-X Axis", ""),
190 ('-Y', "-Y Axis", ""),
191 ('-Z', "-Z Axis", ""),
193 default='X',
196 use_prepost_rot: BoolProperty(
197 name="Use Pre/Post Rotation",
198 description="Use pre/post rotation from FBX transform (you may have to disable that in some cases)",
199 default=True,
202 def draw(self, context):
203 pass
205 def execute(self, context):
206 keywords = self.as_keywords(ignore=("filter_glob", "directory", "ui_tab", "filepath", "files"))
208 from . import import_fbx
209 import os
211 if self.files:
212 ret = {'CANCELLED'}
213 dirname = os.path.dirname(self.filepath)
214 for file in self.files:
215 path = os.path.join(dirname, file.name)
216 if import_fbx.load(self, context, filepath=path, **keywords) == {'FINISHED'}:
217 ret = {'FINISHED'}
218 return ret
219 else:
220 return import_fbx.load(self, context, filepath=self.filepath, **keywords)
223 class FBX_PT_import_include(bpy.types.Panel):
224 bl_space_type = 'FILE_BROWSER'
225 bl_region_type = 'TOOL_PROPS'
226 bl_label = "Include"
227 bl_parent_id = "FILE_PT_operator"
229 @classmethod
230 def poll(cls, context):
231 sfile = context.space_data
232 operator = sfile.active_operator
234 return operator.bl_idname == "IMPORT_SCENE_OT_fbx"
236 def draw(self, context):
237 layout = self.layout
238 layout.use_property_split = True
239 layout.use_property_decorate = False # No animation.
241 sfile = context.space_data
242 operator = sfile.active_operator
244 layout.prop(operator, "use_custom_normals")
245 layout.prop(operator, "use_subsurf")
246 layout.prop(operator, "use_custom_props")
247 sub = layout.row()
248 sub.enabled = operator.use_custom_props
249 sub.prop(operator, "use_custom_props_enum_as_string")
250 layout.prop(operator, "use_image_search")
253 class FBX_PT_import_transform(bpy.types.Panel):
254 bl_space_type = 'FILE_BROWSER'
255 bl_region_type = 'TOOL_PROPS'
256 bl_label = "Transform"
257 bl_parent_id = "FILE_PT_operator"
259 @classmethod
260 def poll(cls, context):
261 sfile = context.space_data
262 operator = sfile.active_operator
264 return operator.bl_idname == "IMPORT_SCENE_OT_fbx"
266 def draw(self, context):
267 layout = self.layout
268 layout.use_property_split = True
269 layout.use_property_decorate = False # No animation.
271 sfile = context.space_data
272 operator = sfile.active_operator
274 layout.prop(operator, "global_scale")
275 layout.prop(operator, "decal_offset")
276 row = layout.row()
277 row.prop(operator, "bake_space_transform")
278 row.label(text="", icon='ERROR')
279 layout.prop(operator, "use_prepost_rot")
282 class FBX_PT_import_transform_manual_orientation(bpy.types.Panel):
283 bl_space_type = 'FILE_BROWSER'
284 bl_region_type = 'TOOL_PROPS'
285 bl_label = "Manual Orientation"
286 bl_parent_id = "FBX_PT_import_transform"
288 @classmethod
289 def poll(cls, context):
290 sfile = context.space_data
291 operator = sfile.active_operator
293 return operator.bl_idname == "IMPORT_SCENE_OT_fbx"
295 def draw_header(self, context):
296 sfile = context.space_data
297 operator = sfile.active_operator
299 self.layout.prop(operator, "use_manual_orientation", text="")
301 def draw(self, context):
302 layout = self.layout
303 layout.use_property_split = True
304 layout.use_property_decorate = False # No animation.
306 sfile = context.space_data
307 operator = sfile.active_operator
309 layout.enabled = operator.use_manual_orientation
311 layout.prop(operator, "axis_forward")
312 layout.prop(operator, "axis_up")
315 class FBX_PT_import_animation(bpy.types.Panel):
316 bl_space_type = 'FILE_BROWSER'
317 bl_region_type = 'TOOL_PROPS'
318 bl_label = "Animation"
319 bl_parent_id = "FILE_PT_operator"
320 bl_options = {'DEFAULT_CLOSED'}
322 @classmethod
323 def poll(cls, context):
324 sfile = context.space_data
325 operator = sfile.active_operator
327 return operator.bl_idname == "IMPORT_SCENE_OT_fbx"
329 def draw_header(self, context):
330 sfile = context.space_data
331 operator = sfile.active_operator
333 self.layout.prop(operator, "use_anim", text="")
335 def draw(self, context):
336 layout = self.layout
337 layout.use_property_split = True
338 layout.use_property_decorate = False # No animation.
340 sfile = context.space_data
341 operator = sfile.active_operator
343 layout.enabled = operator.use_anim
345 layout.prop(operator, "anim_offset")
348 class FBX_PT_import_armature(bpy.types.Panel):
349 bl_space_type = 'FILE_BROWSER'
350 bl_region_type = 'TOOL_PROPS'
351 bl_label = "Armature"
352 bl_parent_id = "FILE_PT_operator"
353 bl_options = {'DEFAULT_CLOSED'}
355 @classmethod
356 def poll(cls, context):
357 sfile = context.space_data
358 operator = sfile.active_operator
360 return operator.bl_idname == "IMPORT_SCENE_OT_fbx"
362 def draw(self, context):
363 layout = self.layout
364 layout.use_property_split = True
365 layout.use_property_decorate = False # No animation.
367 sfile = context.space_data
368 operator = sfile.active_operator
370 layout.prop(operator, "ignore_leaf_bones")
371 layout.prop(operator, "force_connect_children"),
372 layout.prop(operator, "automatic_bone_orientation"),
373 sub = layout.column()
374 sub.enabled = not operator.automatic_bone_orientation
375 sub.prop(operator, "primary_bone_axis")
376 sub.prop(operator, "secondary_bone_axis")
379 @orientation_helper(axis_forward='-Z', axis_up='Y')
380 class ExportFBX(bpy.types.Operator, ExportHelper):
381 """Write a FBX file"""
382 bl_idname = "export_scene.fbx"
383 bl_label = "Export FBX"
384 bl_options = {'UNDO', 'PRESET'}
386 filename_ext = ".fbx"
387 filter_glob: StringProperty(default="*.fbx", options={'HIDDEN'})
389 # List of operator properties, the attributes will be assigned
390 # to the class instance from the operator settings before calling.
392 use_selection: BoolProperty(
393 name="Selected Objects",
394 description="Export selected and visible objects only",
395 default=False,
397 use_active_collection: BoolProperty(
398 name="Active Collection",
399 description="Export only objects from the active collection (and its children)",
400 default=False,
402 global_scale: FloatProperty(
403 name="Scale",
404 description="Scale all data (Some importers do not support scaled armatures!)",
405 min=0.001, max=1000.0,
406 soft_min=0.01, soft_max=1000.0,
407 default=1.0,
409 apply_unit_scale: BoolProperty(
410 name="Apply Unit",
411 description="Take into account current Blender units settings (if unset, raw Blender Units values are used as-is)",
412 default=True,
414 apply_scale_options: EnumProperty(
415 items=(('FBX_SCALE_NONE', "All Local",
416 "Apply custom scaling and units scaling to each object transformation, FBX scale remains at 1.0"),
417 ('FBX_SCALE_UNITS', "FBX Units Scale",
418 "Apply custom scaling to each object transformation, and units scaling to FBX scale"),
419 ('FBX_SCALE_CUSTOM', "FBX Custom Scale",
420 "Apply custom scaling to FBX scale, and units scaling to each object transformation"),
421 ('FBX_SCALE_ALL', "FBX All",
422 "Apply custom scaling and units scaling to FBX scale"),
424 name="Apply Scalings",
425 description="How to apply custom and units scalings in generated FBX file "
426 "(Blender uses FBX scale to detect units on import, "
427 "but many other applications do not handle the same way)",
429 bake_space_transform: BoolProperty(
430 name="Apply Transform",
431 description="Bake space transform into object data, avoids getting unwanted rotations to objects when "
432 "target space is not aligned with Blender's space "
433 "(WARNING! experimental option, use at own risks, known broken with armatures/animations)",
434 default=False,
437 object_types: EnumProperty(
438 name="Object Types",
439 options={'ENUM_FLAG'},
440 items=(('EMPTY', "Empty", ""),
441 ('CAMERA', "Camera", ""),
442 ('LIGHT', "Lamp", ""),
443 ('ARMATURE', "Armature", "WARNING: not supported in dupli/group instances"),
444 ('MESH', "Mesh", ""),
445 ('OTHER', "Other", "Other geometry types, like curve, metaball, etc. (converted to meshes)"),
447 description="Which kind of object to export",
448 default={'EMPTY', 'CAMERA', 'LIGHT', 'ARMATURE', 'MESH', 'OTHER'},
451 use_mesh_modifiers: BoolProperty(
452 name="Apply Modifiers",
453 description="Apply modifiers to mesh objects (except Armature ones) - "
454 "WARNING: prevents exporting shape keys",
455 default=True,
457 use_mesh_modifiers_render: BoolProperty(
458 name="Use Modifiers Render Setting",
459 description="Use render settings when applying modifiers to mesh objects (DISABLED in Blender 2.8)",
460 default=True,
462 mesh_smooth_type: EnumProperty(
463 name="Smoothing",
464 items=(('OFF', "Normals Only", "Export only normals instead of writing edge or face smoothing data"),
465 ('FACE', "Face", "Write face smoothing"),
466 ('EDGE', "Edge", "Write edge smoothing"),
468 description="Export smoothing information "
469 "(prefer 'Normals Only' option if your target importer understand split normals)",
470 default='OFF',
472 use_subsurf: BoolProperty(
473 name="Export Subdivision Surface",
474 description="Export the last Catmull-Rom subdivision modifier as FBX subdivision "
475 "(does not apply the modifier even if 'Apply Modifiers' is enabled)",
476 default=False,
478 use_mesh_edges: BoolProperty(
479 name="Loose Edges",
480 description="Export loose edges (as two-vertices polygons)",
481 default=False,
483 use_tspace: BoolProperty(
484 name="Tangent Space",
485 description="Add binormal and tangent vectors, together with normal they form the tangent space "
486 "(will only work correctly with tris/quads only meshes!)",
487 default=False,
489 use_custom_props: BoolProperty(
490 name="Custom Properties",
491 description="Export custom properties",
492 default=False,
494 add_leaf_bones: BoolProperty(
495 name="Add Leaf Bones",
496 description="Append a final bone to the end of each chain to specify last bone length "
497 "(use this when you intend to edit the armature from exported data)",
498 default=True # False for commit!
500 primary_bone_axis: EnumProperty(
501 name="Primary Bone Axis",
502 items=(('X', "X Axis", ""),
503 ('Y', "Y Axis", ""),
504 ('Z', "Z Axis", ""),
505 ('-X', "-X Axis", ""),
506 ('-Y', "-Y Axis", ""),
507 ('-Z', "-Z Axis", ""),
509 default='Y',
511 secondary_bone_axis: EnumProperty(
512 name="Secondary Bone Axis",
513 items=(('X', "X Axis", ""),
514 ('Y', "Y Axis", ""),
515 ('Z', "Z Axis", ""),
516 ('-X', "-X Axis", ""),
517 ('-Y', "-Y Axis", ""),
518 ('-Z', "-Z Axis", ""),
520 default='X',
522 use_armature_deform_only: BoolProperty(
523 name="Only Deform Bones",
524 description="Only write deforming bones (and non-deforming ones when they have deforming children)",
525 default=False,
527 armature_nodetype: EnumProperty(
528 name="Armature FBXNode Type",
529 items=(('NULL', "Null", "'Null' FBX node, similar to Blender's Empty (default)"),
530 ('ROOT', "Root", "'Root' FBX node, supposed to be the root of chains of bones..."),
531 ('LIMBNODE', "LimbNode", "'LimbNode' FBX node, a regular joint between two bones..."),
533 description="FBX type of node (object) used to represent Blender's armatures "
534 "(use Null one unless you experience issues with other app, other choices may no import back "
535 "perfectly in Blender...)",
536 default='NULL',
538 bake_anim: BoolProperty(
539 name="Baked Animation",
540 description="Export baked keyframe animation",
541 default=True,
543 bake_anim_use_all_bones: BoolProperty(
544 name="Key All Bones",
545 description="Force exporting at least one key of animation for all bones "
546 "(needed with some target applications, like UE4)",
547 default=True,
549 bake_anim_use_nla_strips: BoolProperty(
550 name="NLA Strips",
551 description="Export each non-muted NLA strip as a separated FBX's AnimStack, if any, "
552 "instead of global scene animation",
553 default=True,
555 bake_anim_use_all_actions: BoolProperty(
556 name="All Actions",
557 description="Export each action as a separated FBX's AnimStack, instead of global scene animation "
558 "(note that animated objects will get all actions compatible with them, "
559 "others will get no animation at all)",
560 default=True,
562 bake_anim_force_startend_keying: BoolProperty(
563 name="Force Start/End Keying",
564 description="Always add a keyframe at start and end of actions for animated channels",
565 default=True,
567 bake_anim_step: FloatProperty(
568 name="Sampling Rate",
569 description="How often to evaluate animated values (in frames)",
570 min=0.01, max=100.0,
571 soft_min=0.1, soft_max=10.0,
572 default=1.0,
574 bake_anim_simplify_factor: FloatProperty(
575 name="Simplify",
576 description="How much to simplify baked values (0.0 to disable, the higher the more simplified)",
577 min=0.0, max=100.0, # No simplification to up to 10% of current magnitude tolerance.
578 soft_min=0.0, soft_max=10.0,
579 default=1.0, # default: min slope: 0.005, max frame step: 10.
581 path_mode: path_reference_mode
582 embed_textures: BoolProperty(
583 name="Embed Textures",
584 description="Embed textures in FBX binary file (only for \"Copy\" path mode!)",
585 default=False,
587 batch_mode: EnumProperty(
588 name="Batch Mode",
589 items=(('OFF', "Off", "Active scene to file"),
590 ('SCENE', "Scene", "Each scene as a file"),
591 ('COLLECTION', "Collection",
592 "Each collection (data-block ones) as a file, does not include content of children collections"),
593 ('SCENE_COLLECTION', "Scene Collections",
594 "Each collection (including master, non-data-block ones) of each scene as a file, "
595 "including content from children collections"),
596 ('ACTIVE_SCENE_COLLECTION', "Active Scene Collections",
597 "Each collection (including master, non-data-block one) of the active scene as a file, "
598 "including content from children collections"),
601 use_batch_own_dir: BoolProperty(
602 name="Batch Own Dir",
603 description="Create a dir for each exported file",
604 default=True,
606 use_metadata: BoolProperty(
607 name="Use Metadata",
608 default=True,
609 options={'HIDDEN'},
612 def draw(self, context):
613 pass
615 @property
616 def check_extension(self):
617 return self.batch_mode == 'OFF'
619 def execute(self, context):
620 from mathutils import Matrix
621 if not self.filepath:
622 raise Exception("filepath not set")
624 global_matrix = (axis_conversion(to_forward=self.axis_forward,
625 to_up=self.axis_up,
626 ).to_4x4())
628 keywords = self.as_keywords(ignore=("check_existing",
629 "filter_glob",
630 "ui_tab",
633 keywords["global_matrix"] = global_matrix
635 from . import export_fbx_bin
636 return export_fbx_bin.save(self, context, **keywords)
639 class FBX_PT_export_main(bpy.types.Panel):
640 bl_space_type = 'FILE_BROWSER'
641 bl_region_type = 'TOOL_PROPS'
642 bl_label = ""
643 bl_parent_id = "FILE_PT_operator"
644 bl_options = {'HIDE_HEADER'}
646 @classmethod
647 def poll(cls, context):
648 sfile = context.space_data
649 operator = sfile.active_operator
651 return operator.bl_idname == "EXPORT_SCENE_OT_fbx"
653 def draw(self, context):
654 layout = self.layout
655 layout.use_property_split = True
656 layout.use_property_decorate = False # No animation.
658 sfile = context.space_data
659 operator = sfile.active_operator
661 row = layout.row(align=True)
662 row.prop(operator, "path_mode")
663 sub = row.row(align=True)
664 sub.enabled = (operator.path_mode == 'COPY')
665 sub.prop(operator, "embed_textures", text="", icon='PACKAGE' if operator.embed_textures else 'UGLYPACKAGE')
666 row = layout.row(align=True)
667 row.prop(operator, "batch_mode")
668 sub = row.row(align=True)
669 sub.prop(operator, "use_batch_own_dir", text="", icon='NEWFOLDER')
672 class FBX_PT_export_include(bpy.types.Panel):
673 bl_space_type = 'FILE_BROWSER'
674 bl_region_type = 'TOOL_PROPS'
675 bl_label = "Include"
676 bl_parent_id = "FILE_PT_operator"
678 @classmethod
679 def poll(cls, context):
680 sfile = context.space_data
681 operator = sfile.active_operator
683 return operator.bl_idname == "EXPORT_SCENE_OT_fbx"
685 def draw(self, context):
686 layout = self.layout
687 layout.use_property_split = True
688 layout.use_property_decorate = False # No animation.
690 sfile = context.space_data
691 operator = sfile.active_operator
693 sublayout = layout.column(heading="Limit to")
694 sublayout.enabled = (operator.batch_mode == 'OFF')
695 sublayout.prop(operator, "use_selection")
696 sublayout.prop(operator, "use_active_collection")
698 layout.column().prop(operator, "object_types")
699 layout.prop(operator, "use_custom_props")
702 class FBX_PT_export_transform(bpy.types.Panel):
703 bl_space_type = 'FILE_BROWSER'
704 bl_region_type = 'TOOL_PROPS'
705 bl_label = "Transform"
706 bl_parent_id = "FILE_PT_operator"
708 @classmethod
709 def poll(cls, context):
710 sfile = context.space_data
711 operator = sfile.active_operator
713 return operator.bl_idname == "EXPORT_SCENE_OT_fbx"
715 def draw(self, context):
716 layout = self.layout
717 layout.use_property_split = True
718 layout.use_property_decorate = False # No animation.
720 sfile = context.space_data
721 operator = sfile.active_operator
723 layout.prop(operator, "global_scale")
724 layout.prop(operator, "apply_scale_options")
726 layout.prop(operator, "axis_forward")
727 layout.prop(operator, "axis_up")
729 layout.prop(operator, "apply_unit_scale")
730 row = layout.row()
731 row.prop(operator, "bake_space_transform")
732 row.label(text="", icon='ERROR')
735 class FBX_PT_export_geometry(bpy.types.Panel):
736 bl_space_type = 'FILE_BROWSER'
737 bl_region_type = 'TOOL_PROPS'
738 bl_label = "Geometry"
739 bl_parent_id = "FILE_PT_operator"
740 bl_options = {'DEFAULT_CLOSED'}
742 @classmethod
743 def poll(cls, context):
744 sfile = context.space_data
745 operator = sfile.active_operator
747 return operator.bl_idname == "EXPORT_SCENE_OT_fbx"
749 def draw(self, context):
750 layout = self.layout
751 layout.use_property_split = True
752 layout.use_property_decorate = False # No animation.
754 sfile = context.space_data
755 operator = sfile.active_operator
757 layout.prop(operator, "mesh_smooth_type")
758 layout.prop(operator, "use_subsurf")
759 layout.prop(operator, "use_mesh_modifiers")
760 #sub = layout.row()
761 #sub.enabled = operator.use_mesh_modifiers and False # disabled in 2.8...
762 #sub.prop(operator, "use_mesh_modifiers_render")
763 layout.prop(operator, "use_mesh_edges")
764 sub = layout.row()
765 #~ sub.enabled = operator.mesh_smooth_type in {'OFF'}
766 sub.prop(operator, "use_tspace")
769 class FBX_PT_export_armature(bpy.types.Panel):
770 bl_space_type = 'FILE_BROWSER'
771 bl_region_type = 'TOOL_PROPS'
772 bl_label = "Armature"
773 bl_parent_id = "FILE_PT_operator"
774 bl_options = {'DEFAULT_CLOSED'}
776 @classmethod
777 def poll(cls, context):
778 sfile = context.space_data
779 operator = sfile.active_operator
781 return operator.bl_idname == "EXPORT_SCENE_OT_fbx"
783 def draw(self, context):
784 layout = self.layout
785 layout.use_property_split = True
786 layout.use_property_decorate = False # No animation.
788 sfile = context.space_data
789 operator = sfile.active_operator
791 layout.prop(operator, "primary_bone_axis")
792 layout.prop(operator, "secondary_bone_axis")
793 layout.prop(operator, "armature_nodetype")
794 layout.prop(operator, "use_armature_deform_only")
795 layout.prop(operator, "add_leaf_bones")
798 class FBX_PT_export_bake_animation(bpy.types.Panel):
799 bl_space_type = 'FILE_BROWSER'
800 bl_region_type = 'TOOL_PROPS'
801 bl_label = "Bake Animation"
802 bl_parent_id = "FILE_PT_operator"
803 bl_options = {'DEFAULT_CLOSED'}
805 @classmethod
806 def poll(cls, context):
807 sfile = context.space_data
808 operator = sfile.active_operator
810 return operator.bl_idname == "EXPORT_SCENE_OT_fbx"
812 def draw_header(self, context):
813 sfile = context.space_data
814 operator = sfile.active_operator
816 self.layout.prop(operator, "bake_anim", text="")
818 def draw(self, context):
819 layout = self.layout
820 layout.use_property_split = True
821 layout.use_property_decorate = False # No animation.
823 sfile = context.space_data
824 operator = sfile.active_operator
826 layout.enabled = operator.bake_anim
827 layout.prop(operator, "bake_anim_use_all_bones")
828 layout.prop(operator, "bake_anim_use_nla_strips")
829 layout.prop(operator, "bake_anim_use_all_actions")
830 layout.prop(operator, "bake_anim_force_startend_keying")
831 layout.prop(operator, "bake_anim_step")
832 layout.prop(operator, "bake_anim_simplify_factor")
835 def menu_func_import(self, context):
836 self.layout.operator(ImportFBX.bl_idname, text="FBX (.fbx)")
839 def menu_func_export(self, context):
840 self.layout.operator(ExportFBX.bl_idname, text="FBX (.fbx)")
843 classes = (
844 ImportFBX,
845 FBX_PT_import_include,
846 FBX_PT_import_transform,
847 FBX_PT_import_transform_manual_orientation,
848 FBX_PT_import_animation,
849 FBX_PT_import_armature,
850 ExportFBX,
851 FBX_PT_export_main,
852 FBX_PT_export_include,
853 FBX_PT_export_transform,
854 FBX_PT_export_geometry,
855 FBX_PT_export_armature,
856 FBX_PT_export_bake_animation,
860 def register():
861 for cls in classes:
862 bpy.utils.register_class(cls)
864 bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
865 bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
868 def unregister():
869 bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
870 bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
872 for cls in classes:
873 bpy.utils.unregister_class(cls)
876 if __name__ == "__main__":
877 register()