Reputation: 21
I imported .dae file in python using pycollada package and edited its animation class and it worked as I want but when I wrote the object as a new .dae file using write() function the changes that I made didn't save and vscode formatter didn't recognize my created file as a xml file. how can I solve this problem or is there any other way to write a .dae file?
from collada import Collada
mesh= Collada('Shuffling.dae')
mesh1 = Collada('Hip Hop Dancing.dae')
mesh2= Collada('Shuffling.dae')
animation_ids=[]
for anim in mesh1.animations:
animation_ids.append(anim.id)
def timemaker(t):
times=[]
clocker=0
for i in range(t):
times.append(clocker)
clocker=round(clocker+0.033333,6)
return(times)
import numpy as np
for i in range(len(animation_ids)):
anim1=mesh1.animations[i]
anim2=mesh2.animations[i]
node1=anim1.sourceById
node2=anim2.sourceById
for i in range(len(animation_ids)):
anim1=mesh1.animations[i]
anim2=mesh2.animations[i]
node1=anim1.sourceById
node2=anim2.sourceById
for key in mesh1.animations[i].sourceById.keys():
if 'input' not in key:
mesh.animations[i].sourceById[key].data=np.concatenate((node1[key].data,node2[key].data),axis=0)
else:
mesh.animations[i].sourceById[key].data=timemaker(len(node1[key])+len(node2[key]))
mesh.save()
mesh.write('combined.dae')
Upvotes: 2
Views: 121