Animating fractured geometry until breakpoint.

I’m struggling to create a physics simulation which shatters the object that I am animating. The examples I find online, which are great, all seem to rely on the fractured geometry being dropped, or standing still and waiting for something to hit it.

What I need to do is explode the object which is running into a wall or a post.

I’m able to do this with the un-fractured geometry, however, when I fracture my object the RBD properties are not copied into the various pieces. It seems like I can proceed by going through piece by piece and activating RBD and then re-animating each piece along with turning on/off the animation parameter of the RBD.

For thousands of pieces this is really not efficient.

By relying on Gravity and using the Bullet Physics Constraints tool I’m able to get something that works great if you drop it. But not if you want to animate it first.

I’ve tried creating a null parent for all the pieces but either I’m doing it wrong or that is simply not the proper way to go about this sort of thing.

Can anyone offer guidance? Or know of an on-line demo? I’ve only found one which comes close as it smashes a car into a pole, however in that, the car is only dented and not fractured into many pieces, which is where my problem seems to arise.

I do not know of any simple Way to do this, yet. My question is: Is your animated Object just animated location? Or is there Rotation too? Or is it even a Rig?

I think in the Case of only Location: A simple script to copy, what you did copy manual, should work and should be simple to put together.

In case of Rotation: One just need to calculate some stuff, to let the broken Part move as they should. Not to hard either, but Mathwise just a bit over my comfort zone.

In Case of Rig: Even more complicated, i have to assume.

My script does not really help you with this issue… (And i did not work on for over 1 Year, since this Scripts functionality was supposed to find it’s way to Blender otherwise.)

If you have “only” Location animated - let me know. Maybe i can come up with a simple script.

When I posted the suggestion I thought your script handled this case but it only seems to handle the opposite of the request. (i.e. a non-fractured object in motion collides with a pre-fractured object, not pre-fractured shard collide with passive rigid body).

The problem seems to be that the Animate property of the constraint is only a boolean and not a value. It would be nice if it were an influence value that transferred the motion of the object into the rigid body over time. The only system that has that feature is the particle system, however.

What about a script that takes a set of fracture shards (or any rigid body set) and creates a vertex only mesh with each vertex location being derived from the shard origin. Then apply a particle system to that resulting mesh with Emit From Verts enabled and Random disabled. Remove all velocity and gravity influence. Set the count equal to the shard count. Set Render to use the group that the shard belong to. With Pick Random disabled the shards should each be deployed at their related vertex coordinate keeping the fracture shape intact.

At this point is might be possible to leverage the velocity from Other feature of the particle system? You could just animate the result mesh as normal. It is one of those things that I would not know it it worked until I built a little test script…

Well that did not work. :no:

I did come up with a simple test that at least shows that Rigid Bodies can inherit the velocity of a parent object.
In the attached BLEND I have a normal parent cube and a rigid body child cube. The child is parented to the parent. The parent is animated to produce motion.

For this to work, you need to cross-animate the Dynamic and Animated flags at the correct time. So the parent animates from frames 1 to frame 20. At frame 19 the Dynamic is off and the Animated is on. Then on frame 20 the two are switched, the Dynamic is on and the Animated is off. The child cube looses its hold on the parent and bounces off in the direction the parent was traveling.

@bashi: So if a script request was possible what if you added another checkbox line that allowed you to “time” when a parenting was broken? Then all selected objects would have their Dynamic and Animated flags toggled at a user specified time.

Attachments

27_animated_to_dynamic.blend (95.6 KB)

All right, I think I have a working proof of concept. I wrote a small script that allows you to toggle the Dynamic/Animated flags at a specific point in time.

The work flow would be this.

1.) Create an object to be a parent, this is the one you will animate and should not be a physics participant.
2.) Setup your fracture object.
3.) After fracture, all the shards are selected so use the Physics TAB in the Tool window to add them all as active rigid bodies.
4.) SHIFT-Select the parent object and parent all the shards to that parent using CTRL-P.
5.) Unselect the parent object so the script will not try to operate upon it. (keep all shards selected)
6.) Alter the script variable, toggle_frame, number so it matches the point in your timeline where the parent lets go and the physics takes over.
7.) Run the script with all the shards selected.
8.) Play your animation.

In my example scene I choose frame #19 to release parenting.


import bpy


for ob in bpy.context.selected_objects:
    rb = ob.rigid_body
    if rb != None:
        toggle_frame = 19 #change this number for your timeline.
        rb.enabled = False
        rb.keyframe_insert(data_path='enabled', frame=toggle_frame)
        rb.kinematic = True
        rb.keyframe_insert(data_path='kinematic', frame=toggle_frame)
        rb.enabled = True
        rb.keyframe_insert(data_path='enabled', frame=toggle_frame+1)
        rb.kinematic = False
        rb.keyframe_insert(data_path='kinematic', frame=toggle_frame+1)

Attachments


27_animated_to_dynamic.blend (249 KB)

Nice One Atom.

You made me think.

@@pumplerod: I’m not quite sure this Trick will work for You, since “the object which is running” leaves to much room :wink: How is your Object Animated?

@Atom
Your Solution has brought up two ideas: Having a “Thrower” Object. Which basically your script is. Secondly, have a Way to replace an unbroken Original Mesh by fractured Shards, and a Way to trigger it. This one is tricky, i think. There are different Ways to animate Objects… A nice trigger would be Collision. (Do we have no Collision detection somehow accessible in Python? I have not found one yet)

My “Issue” with my Bullet Constraints Script is: It’s very very badly Made. I have not looked at it since i first released it, neither updated it. Part of the Reason was (i can’t remember his Name, i know i could look it up. too lazy) The Guy that integrated Bullet in Viewport told me he wanted to integrate those Functions himself. So i felt like not doing much more with my Script. But since nothing in this regard has happened and i see there could be much done i think i might give it a go again. It’s just i would have to rewrite the complete Script. (It really is that bad).

Destruction still interests me very much - i find it somehow creative :wink:

PS: On a side Note: I do use an Octree in my script. The one i use can only work with Integer? (Blackout if Word is right. Not Float, only Numbers without Decimal place) So i have to convert float. You know any OcTree/KDTree for Python with Float?

PS: What i actually wanted to say: I’ll think about it. Maybe integrate your Solution hacky into my Script. Or Redo. I have to see.

Wow, all very interesting information. Luckily, I’m just animating the location in one axis at the moment, so a script solution applying the properties to each chunk might work. But I imagine this as something that would be very useful for more complex systems. Like animating a person and having part of their body shatter for example.

a quick tip for an easier setup: you can keyframe the ‘animated’ property for one object and use Ctrl+L > ‘Animation Data’ to link action, this way you don’t need to script it… will work fine if the loc+rot stuff is in the parent -or do U > ‘Object Animation’ later-

bashi there have been improvements to acivation system, still waiting for them to reach master
http://wiki.blender.org/index.php/User:Sergof/GSoC2013/Documentation