1
$\begingroup$

Followed a tutorial on Animation Nodes by Jacques Lucke on Youtube the other day and tried a very basic setup. This was my very first AN test.. As I would like to render it on a renderfarm, I have to get the animation up and running without the AN addon. This is the setup:

enter image description here

I found some info on the Set Keyframes Node, used it on my Object and after that clicked Bake to Keyframes. This worked well for all simple Loc/Rot/Scale transformations.

Problem is, the "simple" deformation of the Grid mesh that is caused by the Point Distance Falloff Node is being ignored. Is there a way of converting the deformation to Shape Keys? Or which "Custom" value could I use in the Set Keyframes Node?

$\endgroup$
3
  • 5
    $\begingroup$ you can't really bake mesh animations to shape keys. The best practice is to bake the mesh into an alembic file. Can you try that? $\endgroup$ Jan 16, 2018 at 12:50
  • $\begingroup$ thanks for your quick reply.. I am still pretty new to all this, so have to admit never heard of alembic before. but I just googled it and will do some more research to try and figure out how to "bake" my blender animation into an alembic file $\endgroup$
    – ho.s
    Jan 18, 2018 at 10:34
  • 1
    $\begingroup$ @JacquesLucke finally .. I revisited my project and tried your suggestion! It worked very well: All I had to do is export the file to .abc format and then import this file into a new project. All the shapes from the animation nodes animation where applied automatically to keyframes then. A Mesh Sequence Cache Modifier which piointed to the .abc file was applied to the Mesh automatically. So - your comment is the solution to my problem. Thanks again. $\endgroup$
    – ho.s
    Feb 28, 2018 at 13:32

1 Answer 1

0
$\begingroup$

You can convert your node or alembic animation into a shapekey for each frame then animate those shapekeys using this script below. You also should remove your mesh sequence modifier after running the script.

import bpy

ob = bpy.context
obAc = ob.active_object
    mesh_data = obAc.data

start_frame = bpy.context.scene.frame_start
end_frame = bpy.context.scene.frame_end

if not obAc.data.shape_keys:
    obAc.shape_key_add(name="Basis")

# Create shape keys for each frame
for frame in range(start_frame, end_frame + 1):
    bpy.context.scene.frame_set(frame)
    
    # Evaluate the mesh with modifiers
    depsgraph = bpy.context.evaluated_depsgraph_get()
    object_eval = obAc.evaluated_get(depsgraph)
    mesh_eval = object_eval.data
    
    # Create a new shape key and set its points based on the current frame
    shape_key = obAc.shape_key_add(name=str(frame))
    
    # Collect vertex positions for the current frame
    vertices = [vertex.co for vertex in mesh_eval.vertices]
    
    # Set shape key data
    shape_key.data.foreach_set('co', [c for v in vertices for c in v])
    
if obAc.data.shape_keys:
    shape_keys = obAc.data.shape_keys.key_blocks
    
    # Iterate through shape keys and set keyframes
    for frame in range(start_frame, end_frame + 1):
        ob.scene.frame_set(frame)
        
        for shape_key in shape_keys:
            if shape_key.name.isdigit(): 
                value = 1.0 if int(shape_key.name) == frame else 0.0
                shape_key.value = value
                shape_key.keyframe_insert(data_path='value', index=-1)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .