diff options
Diffstat (limited to 'tools/export')
-rw-r--r-- | tools/export/blender25/io_scene_dae/__init__.py | 4 | ||||
-rw-r--r-- | tools/export/blender25/io_scene_dae/export_dae.py | 48 |
2 files changed, 38 insertions, 14 deletions
diff --git a/tools/export/blender25/io_scene_dae/__init__.py b/tools/export/blender25/io_scene_dae/__init__.py index 39d8e94a53..fe8a383383 100644 --- a/tools/export/blender25/io_scene_dae/__init__.py +++ b/tools/export/blender25/io_scene_dae/__init__.py @@ -126,6 +126,10 @@ class ExportDAE(bpy.types.Operator, ExportHelper): default=True, options={'HIDDEN'}, ) + export_shapekeys = BoolProperty( + name="Export Shape Keys", + default=False, + ) @property def check_extension(self): diff --git a/tools/export/blender25/io_scene_dae/export_dae.py b/tools/export/blender25/io_scene_dae/export_dae.py index cd785fca40..38c5c3b723 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,22 @@ 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" and self.config["export_shapekeys"]: + for k in range(0,len(node.data.shape_keys.key_blocks)): + shape = node.data.shape_keys.key_blocks[k] + oldval = shape.value + 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() + shape.value = oldval il-=1 self.writel(S_NODES,il,'</node>') |