Skip to content
Snippets Groups Projects
export_fbx.py 116 KiB
Newer Older
  • Learn to ignore specific revisions
  •         for data in data_seq:  # scene or group
                newname = prefix + bpy.path.clean_name(data.name)
    
    
                    new_fbxpath = fbxpath + newname + os.sep
                    # path may already exist
                    # TODO - might exist but be a file. unlikely but should probably account for it.
    
                    if not os.path.exists(new_fbxpath):
                        os.makedirs(new_fbxpath)
    
                filepath = new_fbxpath + newname + '.fbx'
    
                print('\nBatch exporting %s as...\n\t%r' % (data, filepath))
    
                # XXX don't know what to do with this, probably do the same? (Arystan)
                if batch_mode == 'GROUP':  # group
                    # group, so objects update properly, add a dummy scene.
                    scene = bpy.data.scenes.new(name="FBX_Temp")
                    scene.layers = [True] * 20
    
    Campbell Barton's avatar
    Campbell Barton committed
                    # bpy.data.scenes.active = scene # XXX, cant switch
    
                    for ob_base in data.objects:
                        scene.objects.link(ob_base)
    
                    scene.update()
                else:
                    scene = data
    
                    # TODO - BUMMER! Armatures not in the group wont animate the mesh
    
                # else:  # scene
                #     data_seq.active = data
    
                # Call self with modified args
                # Dont pass batch options since we already usedt them
                kwargs_batch = kwargs.copy()
    
                kwargs_batch["context_objects"] = data.objects
    
                save_single(operator, scene, filepath, **kwargs_batch)
    
                if batch_mode == 'GROUP':
                    # remove temp group scene
                    bpy.data.scenes.remove(scene)
    
            # no active scene changing!
            # bpy.data.scenes.active = orig_sce
    
            return {'FINISHED'}  # so the script wont run after we have batch exported.
    
    
    # APPLICATION REQUIREMENTS
    # Please update the lists for UDK, Unity, XNA etc. on the following web page:
    #   http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Import-Export/UnifiedFBX
    
    # XNA FBX Requirements (JCB 29 July 2011)
    # - Armature must be parented to the scene
    # - Armature must be a 'Limb' never a 'null'.  This is in several places.
    # - First bone must be parented to the armature.
    # - Rotation must be completely disabled including
    #       always returning the original matrix in In object_tx().
    #       It is the animation that gets distorted during rotation!
    # - Lone edges cause intermittent errors in the XNA content pipeline!
    #       I have added a warning message and excluded them.
    # - Bind pose must be included with the 'MESH'
    # Typical settings for XNA export
    #   No Cameras, No Lamps, No Edges, No face smoothing, No Default_Take, Armature as bone, Disable rotation
    
    
    # NOTE TO Campbell -
    
    #   Can any or all of the following notes be removed because some have been here for a long time? (JCB 27 July 2011)
    
    # NOTES (all line numbers correspond to original export_fbx.py (under release/scripts)
    # - get rid of bpy.path.clean_name somehow
    # + get rid of BPyObject_getObjectArmature, move it in RNA?
    # - implement all BPyMesh_* used here with RNA
    # - getDerivedObjects is not fully replicated with .dupli* funcs
    # - don't know what those colbits are, do we need them? they're said to be deprecated in DNA_object_types.h: 1886-1893
    # - no hq normals: 1900-1901