Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-10-05 08:51:43 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-05 08:51:43 +0400
commit75e5f56ef262e35a4992a7493ac19a47af3a5635 (patch)
tree056000a4a6f8dd6d19e368d6a88fc87aea197d6f /io_scene_fbx
parenta570a2761ca2a8d01a0c9304a8a70264b759581e (diff)
shape key support for FBX
Diffstat (limited to 'io_scene_fbx')
-rw-r--r--io_scene_fbx/export_fbx.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/io_scene_fbx/export_fbx.py b/io_scene_fbx/export_fbx.py
index ef87b2e6..3e6a2a99 100644
--- a/io_scene_fbx/export_fbx.py
+++ b/io_scene_fbx/export_fbx.py
@@ -1320,6 +1320,7 @@ def save_single(operator, scene, filepath="",
do_materials = bool(my_mesh.blenMaterials)
do_textures = bool(my_mesh.blenTextures)
do_uvs = bool(me.uv_textures)
+ do_shapekeys = bool(my_mesh.blenObject.data.shape_keys and len(my_mesh.blenObject.data.vertices) == len(me.vertices))
fw('\n\tModel: "Model::%s", "Mesh" {' % my_mesh.fbxName)
fw('\n\t\tVersion: 232') # newline is added in write_object_props
@@ -1332,6 +1333,10 @@ def save_single(operator, scene, filepath="",
poseMatrix = write_object_props(my_mesh.blenObject, None, my_mesh.parRelMatrix())[3]
pose_items.append((my_mesh.fbxName, poseMatrix))
+ if do_shapekeys:
+ for kb in my_mesh.blenObject.data.shape_keys.key_blocks[1:]:
+ fw('\n\t\t\tProperty: "%s", "Number", "AN",0' % kb.name)
+
fw('\n\t\t}')
fw('\n\t\tMultiLayer: 0'
@@ -1774,6 +1779,67 @@ def save_single(operator, scene, filepath="",
fw('\n\t\t\t\tTypedIndex: %i' % i)
fw('\n\t\t\t}')
fw('\n\t\t}')
+
+ if do_shapekeys:
+ key_blocks = my_mesh.blenObject.data.shape_keys.key_blocks[:]
+ for kb in key_blocks[1:]:
+
+ fw('\n\t\tShape: "%s" {' % kb.name)
+ fw('\n\t\t\tIndexes: ')
+
+ basis_verts = key_blocks[0].data
+ range_verts = []
+ delta_verts = []
+ i = -1
+ for j, kv in enumerate(kb.data):
+ delta = kv.co - basis_verts[j].co
+ if delta.length > 0.000001:
+ if i == -1:
+ fw('%d' % j)
+ else:
+ if i == 7:
+ fw('\n\t\t\t')
+ i = 0
+ fw(',%d' % j)
+ delta_verts.append(delta[:])
+ i += 1
+
+ fw('\n\t\t\tVertices: ')
+ i = -1
+ for dv in delta_verts:
+ if i == -1:
+ fw("%g,%g,%g" % dv)
+ else:
+ if i == 4:
+ fw('\n\t\t\t')
+ i = 0
+ fw(",%g,%g,%g" % dv)
+ i += 1
+
+ # all zero, why? - campbell
+ fw('\n\t\t\tNormals: ')
+ for j in range(len(delta_verts)):
+ if i == -1:
+ fw("0,0,0")
+ else:
+ if i == 4:
+ fw('\n\t\t\t')
+ i = 0
+ fw(",0,0,0")
+ i += 1
+ fw('\n\t\t}')
+
+ for v in me_vertices:
+ if i == -1:
+ fw('%.6f,%.6f,%.6f' % v.co[:])
+ i = 0
+ else:
+ if i == 7:
+ fw('\n\t\t')
+ i = 0
+ fw(',%.6f,%.6f,%.6f' % v.co[:])
+ i += 1
+
fw('\n\t}')
def write_group(name):