Added shape keys export
This commit is contained in:
parent
4ac71615ed
commit
a3a35702b4
@ -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>')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user