[Bf-extensions-cvs] [0e175a9] fbx_io_development: Merge branch 'master' into fbx_io_development

Bastien Montagne noreply at git.blender.org
Mon Jul 21 21:16:32 CEST 2014


Commit: 0e175a9e2e670f8b44964816c7304634e96b77ab
Author: Bastien Montagne
Date:   Mon Jul 21 17:21:56 2014 +0200
Branches: fbx_io_development
https://developer.blender.org/rBA0e175a9e2e670f8b44964816c7304634e96b77ab

Merge branch 'master' into fbx_io_development

===================================================================



===================================================================

diff --cc io_scene_fbx/import_fbx.py
index 85b6da2,70af67b..179e51a
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@@ -1874,101 -1687,14 +1877,107 @@@ def load(operator, context, filepath=""
  
                  if blen_data.parent is None:
                      blen_data.matrix_basis = global_matrix * blen_data.matrix_basis
+ 
+             for (ob_arm, ob_me) in arm_parents:
+                 # Rigged meshes are in global space in FBX...
+                 ob_me.matrix_basis = global_matrix * ob_me.matrix_basis
+                 # And reverse-apply armature transform, so that it gets valid parented (local) position!
+                 ob_me.matrix_parent_inverse = ob_arm.matrix_basis.inverted()
      _(); del _
  
 +    # Animation!
 +    def _():
 +        fbx_tmpl_astack = fbx_template_get((b'AnimationStack', b'FbxAnimStack'))
 +        fbx_tmpl_alayer = fbx_template_get((b'AnimationLayer', b'FbxAnimLayer'))
 +        stacks = {}
 +
 +        # AnimationStacks.
 +        for as_uuid, fbx_asitem in fbx_table_nodes.items():
 +            fbx_asdata, _blen_data = fbx_asitem
 +            if fbx_asdata.id != b'AnimationStack' or fbx_asdata.props[2] != b'':
 +                continue
 +            stacks[as_uuid] = (fbx_asitem, {})
 +
 +        # AnimationLayers (mixing is completely ignored for now, each layer results in an independent set of actions).
 +        def get_astacks_from_alayer(al_uuid):
 +            for as_uuid, as_ctype in fbx_connection_map.get(al_uuid, ()):
 +                if as_ctype.props[0] != b'OO':
 +                    continue
 +                fbx_asdata, _bl_asdata = fbx_table_nodes.get(as_uuid, (None, None))
 +                if (fbx_asdata is None or fbx_asdata.id != b'AnimationStack' or
 +                    fbx_asdata.props[2] != b'' or as_uuid not in stacks):
 +                    continue
 +                yield as_uuid
 +        for al_uuid, fbx_alitem in fbx_table_nodes.items():
 +            fbx_aldata, _blen_data = fbx_alitem
 +            if fbx_aldata.id != b'AnimationLayer' or fbx_aldata.props[2] != b'':
 +                continue
 +            for as_uuid in get_astacks_from_alayer(al_uuid):
 +                _fbx_asitem, alayers = stacks[as_uuid]
 +                alayers[al_uuid] = (fbx_alitem, {}, {})  # objects and shapes.
 +
 +        # AnimationCurveNodes (also the ones linked to actual animated data!).
 +        curvenodes = {}
 +        for acn_uuid, fbx_acnitem in fbx_table_nodes.items():
 +            fbx_acndata, _blen_data = fbx_acnitem
 +            if fbx_acndata.id != b'AnimationCurveNode' or fbx_acndata.props[2] != b'':
 +                continue
 +            cnode = curvenodes[acn_uuid] = {}
 +            objs = []
 +            shps = []
 +            for n_uuid, n_ctype in fbx_connection_map.get(acn_uuid, ()):
 +                if n_ctype.props[0] != b'OP':
 +                    continue
 +                lnk_prop = n_ctype.props[3]
 +                if lnk_prop in {b'Lcl Translation', b'Lcl Rotation', b'Lcl Scaling'}:
 +                    ob = fbx_table_nodes[n_uuid][1]
 +                    if ob is None:
 +                        continue
 +                    objs.append((ob, lnk_prop))
 +                elif lnk_prop == b'DeformPercent':  # Shape keys.
 +                    keyblocks = blend_shape_channels.get(n_uuid)
 +                    if keyblocks is None:
 +                        continue
 +                    shps.append(keyblocks)
 +            for al_uuid, al_ctype in fbx_connection_map.get(acn_uuid, ()):
 +                if al_ctype.props[0] != b'OO':
 +                    continue
 +                fbx_aldata, _blen_aldata = fbx_alitem = fbx_table_nodes.get(al_uuid, (None, None))
 +                if fbx_aldata is None or fbx_aldata.id != b'AnimationLayer' or fbx_aldata.props[2] != b'':
 +                    continue
 +                for as_uuid in get_astacks_from_alayer(al_uuid):
 +                    _fbx_alitem, objects, shapes = stacks[as_uuid][1][al_uuid]
 +                    assert(_fbx_alitem == fbx_alitem)
 +                    for ob, ob_prop in objs:
 +                        # No need to keep curvenode FBX data here, contains nothing useful for us.
 +                        objects.setdefault(ob, {})[acn_uuid] = (cnode, ob_prop)
 +                    for keyblocks in shps:
 +                        shapes.setdefault(acn_uuid, []).append((keyblocks, cnode))
 +
 +        # AnimationCurves (real animation data).
 +        for ac_uuid, fbx_acitem in fbx_table_nodes.items():
 +            fbx_acdata, _blen_data = fbx_acitem
 +            if fbx_acdata.id != b'AnimationCurve' or fbx_acdata.props[2] != b'':
 +                continue
 +            for acn_uuid, acn_ctype in fbx_connection_map.get(ac_uuid, ()):
 +                if acn_ctype.props[0] != b'OP':
 +                    continue
 +                fbx_acndata, _bl_acndata = fbx_table_nodes.get(acn_uuid, (None, None))
 +                if (fbx_acndata is None or fbx_acndata.id != b'AnimationCurveNode' or
 +                    fbx_acndata.props[2] != b'' or acn_uuid not in curvenodes):
 +                    continue
 +                # Note this is an infamous simplification of the compound props stuff,
 +                # seems to be standard naming but we'll probably have to be smarter to handle more exotic files?
 +                channel = {b'd|X': 0, b'd|Y': 1, b'd|Z': 2, b'd|DeformPercent': 0}.get(acn_ctype.props[3], None)
 +                if channel is None:
 +                    continue
 +                curvenodes[acn_uuid][ac_uuid] = (fbx_acitem, channel)
 +
 +        # And now that we have sorted all this, apply animations!
 +        blen_read_animations(fbx_tmpl_astack, fbx_tmpl_alayer, stacks, scene, global_matrix)
 +
 +    _(); del _
 +
      def _():
          # link Material's to Geometry (via Model's)
          for fbx_uuid, fbx_item in fbx_table_nodes.items():



More information about the Bf-extensions-cvs mailing list