Skip to content

Commit

Permalink
Fixed export timing for vertex animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Five-Damned-Dollarz committed Mar 25, 2021
1 parent 82bc2bd commit aef9eb0
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def from_armature(armature_object):

''' Vertex Animations '''

# TODO: Modify this so shape keys can be animated (by driver, etc.) and will scene.frame_set, then get direct vertex data instead of name-binding a shape key per frame
# TODO: Clean up loops that don't need to be separate, reduce duplication, etc.

# Then most trivially, you find min and max of each dimension, set scales to (maxes-mins), subtract mins from all points, then divide by scales.
# And the transform is set by doing the same subtract and divide to the origin
Expand Down Expand Up @@ -361,7 +361,7 @@ def from_armature(armature_object):
for keyframe_index, keyframe in enumerate(animation.keyframes):

time = keyframe.time * get_framerate()
subframe_time = keyframe.time - floor(keyframe.time)
subframe_time = time - floor(time)
bpy.context.scene.frame_set(time, subframe = subframe_time)

evaluated_object = mesh_object.evaluated_get(dependency_graph)
Expand Down Expand Up @@ -393,17 +393,13 @@ def from_armature(armature_object):
for keyframe_index, keyframe in enumerate(animation.keyframes):

time = keyframe.time * get_framerate()
subframe_time = keyframe.time - floor(keyframe.time)
subframe_time = time - floor(time)
bpy.context.scene.frame_set(time, subframe = subframe_time)

print(subframe_time)

evaluated_object = mesh_object.evaluated_get(dependency_graph)
vert_mesh = evaluated_object.to_mesh()

for vertex_index in node_vertices:
print(evaluated_object.data.vertices[vertex_index].co)

temp_loc = (vert_mesh.vertices[vertex_index].co @ mesh_object.matrix_world) @ node.bind_matrix.transposed().inverted() - node.bounds_min
temp_vert = Vector((temp_loc.x / scale.x, temp_loc.y / scale.y, temp_loc.z / scale.z))

Expand Down

0 comments on commit aef9eb0

Please sign in to comment.