diff options
author | Sergey Lapin <slapin@ossfans.org> | 2014-09-04 16:53:38 +0400 |
---|---|---|
committer | Sergey Lapin <slapin@ossfans.org> | 2014-09-17 20:20:19 +0400 |
commit | a3a35702b4fd8a3cf6873731d13eac288cf76fbc (patch) | |
tree | f9f636f9a2b88871c230b0c98a9b7d4574f17889 /tools/export/blender25/io_scene_dae | |
parent | 4ac71615ed30bb526946927beb391712bfba9f4d (diff) |
Added shape keys export
Diffstat (limited to 'tools/export/blender25/io_scene_dae')
-rw-r--r-- | tools/export/blender25/io_scene_dae/export_dae.py | 46 |
1 files changed, 32 insertions, 14 deletions
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,'<geometry id="'+meshid+'" name="'+mesh.name+'_'+shapename+'">') + else: + meshid = self.new_id("mesh") + self.writel(S_GEOM,1,'<geometry id="'+meshid+'" name="'+mesh.name+'">') - self.writel(S_GEOM,1,'<geometry id="'+meshid+'" name="'+mesh.name+'">') self.writel(S_GEOM,2,'<mesh>') @@ -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,'<instance_geometry url="#'+meshdata["id"]+'">') @@ -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,'<node id="'+self.validate_id(node.name)+'" name="'+node.name+'" type="NODE">') + if shapename != None: + self.writel(S_NODES,il,'<node id="'+self.validate_id(node.name + '_' + shapename)+'" name="'+node.name+'_'+shapename+'" type="NODE">') + else: + self.writel(S_NODES,il,'<node id="'+self.validate_id(node.name)+'" name="'+node.name+'" type="NODE">') il+=1 self.writel(S_NODES,il,'<matrix sid="transform">'+strmtx(node.matrix_local)+'</matrix>') 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,'</node>') |