0

Mesh vertex animation

My prerequisites: Little to no experience with blender, advanced experience in python

Starting Point: Mesh M with n vertices and m faces as .obj file.

Next step : Change coordinates of the n vertices incrementally.

What I have : Python script that calculates the new vertex coordinates for X timesteps

What I need : How to apply the list of new vertex coordinates to the mesh in blender with the related timesteps (=frames). (Python API of blender?) Is there something like:

for timestep in range(0,len(timesteps)):
    newCoordinates = calculateCoordinates(mesh.vertices, timestep)
    mesh.co = newCoordinates
    mesh.Update()
# --> add keyframe to animation

What I tried:

  • PlugIn Animall seems to have that functionality, however, I was not able to get that to work for my problem
  • Keyframe animation is an older post from 2015. The aim appears to be similar, however none of the code snippets is working nor is leading to the desired results
BennyS
  • 1
  • 2
  • Have made the necessary (and very minor) edits to 2 of 3 answers to update them to 2.8. The other handler technique is similar to https://blender.stackexchange.com/questions/187361/updating-objects-parameters-using-python-creates-multiple-objects – batFINGER Aug 18 '20 at 09:23
  • https://blender.stackexchange.com/questions/74063/animating-z-surface-math-functions – batFINGER Aug 18 '20 at 09:35
  • Okay thanks a lot! Will check that tonight – BennyS Aug 18 '20 at 09:37
  • Thank you very much batfinger, it works now! Just one little additional question : Is it possible to "vectorize" the "for v in mesh.vertices"- loop in your first suggested answer? I do have N - matrices containing the vertex coordinates for N frames. I would just have to rewrite the vertice coordinates for each frame instead of for each vertex for each frame. Is it possible to improve its performance here? – BennyS Aug 19 '20 at 13:57
  • Related https://blender.stackexchange.com/questions/190165/quick-keyframe-frame-insertion-for-shape-keys-with-foreach-set-from-data/190227#190227 instead of animating the verts with keyframes make a shapekey for each. Example of using numpy for setting vert coords https://blender.stackexchange.com/a/180184/15543 (for a curve couldn't find a link for object quickly).. anyway same, ravel the numpy array. – batFINGER Aug 19 '20 at 17:14

0 Answers0