(If my problem does not fit with this sub forum, feel free to move it to the right one)
I would like to randomly deform an icosphere surface and animate it. So I will have a “moving surface” sush as a biological cell membrane (which I am trying to model).
I don’t know how to do it. I read som stuff about softbodies but I am not sure it can solve my problem.
One important thing, it’s I dont care about having a real physic simulations, only an “artisitc view” of a biological cell menbrane deformation.
So I tried something with shape keys. I wrote a small python script which create a shape keys every x frame and apply small random vertices translation.
The result is pretty nice but I have two problems with my script:
- this solution (one shape key for one frame) seems pretty heavy I think. I am a blender beginner so maybe shape keys are totally shaped to do this…
- after many frames, my original cell is totally deformed and it is worst with the time… this is because when I apply small random translation in my script, I apply it (I guess) on the previous shape key and I should apply this random translation on my original non deformed icosphere, but I didnt success to do it.
Here you have my code: (to run it, you have to create an icosphere called ‘cell’ before):
import bpy import random cell = bpy.data.objects['cell'] bpy.context.scene.objects.active = cell # Clear old shape key # Dont work: why ? if cell.data.shape_keys: for i, key in enumerate(cell.data.shape_keys.key_blocks): cell.active_shape_key_index = i bpy.ops.object.shape_key_remove() bpy.ops.object.shape_key_remove() # Create new shape key basis_key = cell.shape_key_add('basis') basis_key.keyframe_insert('value', frame=0) dt = 30 for i, t in enumerate(range(0, 1000, dt)): deform_key = cell.shape_key_add() cell.active_shape_key_index = i + 1 start_dyn = 0.8 end_dyn = 1.2 for basis_vertex, vertex in zip(basis_key.data, deform_key.data): vertex.co.x = basis_vertex.co.x * random.uniform(start_dyn, end_dyn) vertex.co.y = basis_vertex.co.y * random.uniform(start_dyn, end_dyn) vertex.co.z = basis_vertex.co.z * random.uniform(start_dyn, end_dyn) deform_key.value = random.uniform(0, 0.2) deform_key.keyframe_insert('value', frame=t) deform_key.value = random.uniform(0.8, 1) deform_key.keyframe_insert('value', frame=t + dt * 2) bpy.ops.object.shape_key_clear()
Thank you for your help !
PS: I am discovering Blender for few days now, and it is just awesome what you can do with !!!
PS2: I am a biologist, trying to make nice biological visualization