Blender how get animated mesh bounding box

47 views Asked by At

I have this code:

bb = [mesh_object.matrix_world @ v.co for v in mesh_object.data.vertices]

# Convert world coordinates to screen space
screen_coords = [bpy_extras.object_utils.world_to_camera_view(bpy.context.scene, scene.camera, coord) for coord in bb]

# Find the top-left and bottom-right pixel coordinates
min_x = min(coord.x * bpy.context.scene.render.resolution_x for coord in screen_coords)
max_x = max(coord.x * bpy.context.scene.render.resolution_x for coord in screen_coords)
min_y = min((1.0 - coord.y) * bpy.context.scene.render.resolution_y for coord in screen_coords)
max_y = max((1.0 - coord.y) * bpy.context.scene.render.resolution_y for coord in screen_coords)`

It works perfectly for getting the 2d bounding box of an object. However, im trying to get an armature's body's bounding box, but the armature is animated. with this code i'm still getting the UNanimated version of the bounding box of the body. how to solve this problem?

I tried getting the bounding box, which works, but only gives me the coordinates of the unanimated object.

0

There are 0 answers