1
$\begingroup$

A am making a scientific animation of cell development in a plant stem, as though you could watch time-lapse through a microscope. The cells "grow" as Python data structures, and their progress gets drawn frame by frame into Blender. Now, I want to smooth the action by animating between frames, but since each frame is individually drawn, Blender does not know which cells are the "same" between frames. Is there a way to tell Blender that two objects in different frames are the "same"?

I'm fairly familiar with the API and can see how to add keyframes on objects, down to individual points. The cells do various things: enlarge, change shape, undergo mitosis, get pushed aside by underlying growth, and mature into wood. A brute-force idea is to animate opacity, so one frame fades out as the next fades in; but there must be a better way, with more control. How does Blender normally track that an animated object is the "same" across frames?

plant cell growth animation

$\endgroup$
1
$\begingroup$

It's not clear from the question your exact requirement because the link provided doesn't work.

Since you already know how to set keyframes using the Python Api here,animating between keyframes is only a matter of setting the correct interpolation at individual keyframes until next keyframe.

#Setting individual interpolation points

import bpy  
ob = bpy.data.objects['Cube']  

frame_num = 0 
bpy.context.scene.frame_set(frame_num)
ob.scale = (4,1,1)
ob.keyframe_insert(data_path="scale", index=-1) # "-1" sets values for all axis's
bpy.context.scene.frame_set(frame_num)
key = ob.animation_data.action.fcurves[0].keyframe_points[0]
key.interpolation = 'BEZIER'


frame_num = 10
bpy.context.scene.frame_set(frame_num)
ob.scale = (1,5,1)
ob.keyframe_insert(data_path="scale", index=-1) 
key = ob.animation_data.action.fcurves[0].keyframe_points[1]
key.interpolation = 'LINEAR'

#And so on ............

#Setting all interpolations at once

import bpy  

ob = bpy.data.objects['Cube']
scales = [(4,1,1),(1,5,1),(1,1,6),(1,1,1)]
frame_num = 0 

for scale in scales: 
   bpy.context.scene.frame_set(frame_num)
   ob.scale = scale
   ob.keyframe_insert(data_path="scale", index=-1) # "-1" sets values for all axis's

   
    for fcurve in ob.animation_data.action.fcurves:
        key = fcurve.keyframe_points[-1]
        key.interpolation = "BEZIER"
    frame_num += 10
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.