From a3a35702b4fd8a3cf6873731d13eac288cf76fbc Mon Sep 17 00:00:00 2001 From: Sergey Lapin Date: Thu, 4 Sep 2014 16:53:38 +0400 Subject: Added shape keys export --- tools/export/blender25/io_scene_dae/export_dae.py | 46 ++++++++++++++++------- 1 file changed, 32 insertions(+), 14 deletions(-) (limited to 'tools/export/blender25/io_scene_dae') diff --git a/tools/export/blender25/io_scene_dae/export_dae.py b/tools/export/blender25/io_scene_dae/export_dae.py index cd785fca40..a66bcbb5df 100644 --- a/tools/export/blender25/io_scene_dae/export_dae.py +++ b/tools/export/blender25/io_scene_dae/export_dae.py @@ -315,12 +315,12 @@ class DaeExporter: return matid - def export_mesh(self,node,armature=None): + def export_mesh(self,node,armature=None,shapename=None): - if (node.data in self.mesh_cache): + if (node.data in self.mesh_cache) and shapename==None: return self.mesh_cache[mesh] - if (len(node.modifiers) and self.config["use_mesh_modifiers"]): + if (len(node.modifiers) and self.config["use_mesh_modifiers"]) or shapename!=None: mesh=node.to_mesh(self.scene,True,"RENDER") #is this allright? else: mesh=node.data @@ -427,9 +427,13 @@ class DaeExporter: indices.append(idx) - meshid = self.new_id("mesh") + if shapename != None: + meshid = self.new_id("mesh_"+shapename) + self.writel(S_GEOM,1,'') + else: + meshid = self.new_id("mesh") + self.writel(S_GEOM,1,'') - self.writel(S_GEOM,1,'') self.writel(S_GEOM,2,'') @@ -604,7 +608,7 @@ class DaeExporter: return meshdata - def export_mesh_node(self,node,il): + def export_mesh_node(self,node,il,shapename=None): if (node.data==None): return @@ -614,8 +618,7 @@ class DaeExporter: if (node.parent.type=="ARMATURE"): armature=node.parent - - meshdata = self.export_mesh(node,armature) + meshdata = self.export_mesh(node,armature,shapename) if (armature==None): self.writel(S_NODES,il,'') @@ -903,18 +906,21 @@ class DaeExporter: - def export_node(self,node,il): - + def export_node(self,node,il,shapename=None): if (not self.is_node_valid(node)): return + bpy.context.scene.objects.active = node - self.writel(S_NODES,il,'') + if shapename != None: + self.writel(S_NODES,il,'') + else: + self.writel(S_NODES,il,'') il+=1 self.writel(S_NODES,il,''+strmtx(node.matrix_local)+'') print("NODE TYPE: "+node.type+" NAME: "+node.name) if (node.type=="MESH"): - self.export_mesh_node(node,il) + self.export_mesh_node(node,il,shapename) elif (node.type=="CURVE"): self.export_curve_node(node,il) elif (node.type=="ARMATURE"): @@ -925,8 +931,20 @@ class DaeExporter: self.export_lamp_node(node,il) self.valid_nodes.append(node) - for x in node.children: - self.export_node(x,il) + if shapename==None: + for x in node.children: + self.export_node(x,il) + if node.type=="MESH": + for k in range(0,len(node.data.shape_keys.key_blocks)): + shape = node.data.shape_keys.key_blocks[k] + shape.value = 1.0 + node.active_shape_key_index = k + p = node.data + v = node.to_mesh(bpy.context.scene, True, "RENDER") + node.data = v + self.export_node(node,il,shape.name) + node.data = p + node.data.update() il-=1 self.writel(S_NODES,il,'') -- cgit v1.2.3